Skip to content

Cache it, share it or package it

Pick prompt caching, a shared prompt module or a Skill for reused content by how often it repeats, who maintains it and where it is used, and diagnose a cache that misses or a shared prompt that has drifted.

Scenario

An insurer runs nine Claude features. Each one starts with the same 3,000-word claims-handling guide, copied into its prompt. Finance asks why input costs are so high. Compliance asks why two features still quote last year's excess rules.

One team proposes caching. Another proposes a Skill. Both are reuse, but they solve different problems: one is about paying for the same bytes again, the other about who keeps the content right and where it is needed.

Explanation

Three mechanisms, three questions: how often does it repeat, who maintains it, where is it used?

Prompt caching answers the same bytes, sent again soon. It lowers the cost and latency of reading a repeated prefix; it changes neither the output nor who maintains the content.

  • The prefix is cached in order: tools, then system, then messages. A hit needs an exact match up to the breakpoint.
  • Put cache_control on the last block that is identical across requests; per-request content goes after it. Up to 4 breakpoints let parts that change at different rates cache separately.
  • Changing tool definitions invalidates everything; editing the system prompt invalidates the system and message caches.
  • Below a minimum length, which varies by model, nothing is cached and no error is returned: both cache fields in usage stay 0.
  • The cache lives 5 minutes by default, refreshed each time it is read. A 1-hour duration costs more to write and suits users who pause between turns.
  • On the Claude API, caches are isolated per workspace.

A shared prompt module answers many features, one owner. Common blocks (a policy summary, a house style, an output schema) live in one versioned source that each feature's prompt is assembled from, with consistent XML tag names. A fix ships once instead of being copied nine times. Copies drift; a module doesn't. Keep the shared, stable module at the start of the prompt so it also forms a cacheable prefix; each change to it costs one cache write per deploy.

A Skill answers a lot of expertise, needed only sometimes, in several places. A Skill is a folder of instructions, scripts and reference files, loaded in stages:

  • Its name and description (about 100 tokens) are always loaded; Claude matches requests against the description, so it must say what the Skill does and when to use it.
  • The body of SKILL.md loads only when the Skill is triggered.
  • Other files load when read; scripts run, and only their output enters the context.

Custom Skills don't sync across products: on the Claude API they are shared across a workspace, on claude.ai each user uploads their own, and in Claude Code they live in personal or project folders or plugins. On the API, Skills run without network access.

The mechanisms combine. A Skill's metadata sits in the system prompt, which you can cache; a module can be the cached prefix.

Worked example

The insurer's architect sorts the reuse:

Content Repeats Maintained by Used in Choice
Claims-handling guide, needed by every feature Every request Compliance, one owner 9 features Shared module, placed first so it is also the cached prefix
The chat assistant's instructions and tools, sent each turn Every turn, seconds apart The chat team 1 feature Caching, breakpoint at the end of the static part
Reserve-calculation procedure with a validation script and rate tables A few requests a day Actuarial team API feature and analysts in Claude Code Skill, so its body and tables load only when needed

The excess-rule drift ends because the two stale features now pull the guide from the module. The input bill drops because the guide is read from cache instead of being processed fresh on every request.