prompt-caching
Skill0 starsChanged 16 days agoMITView on GitHub
Use when writing or reviewing code that calls an LLM API repeatedly with a large shared prefix, such as a system prompt, tool schema, long reference document, or a subagent dispatch template sent to many workers in one session, and repeat latency or per-call token cost matters. Also use when someone reports a prompt-cache miss, wants to cut agent-loop token spend, or is about to draft several similar subagent briefs in the same run.
4 other projects use a version of this.
Adopted by
Most recently taken up by
- cestercian/claude-playbook-skillstheir own version, first seen Nov 15, 2026
- xfstudio/skillstheir own version, first seen Oct 13, 2026
- Tgoldi/claude-skillstheir own version, first seen Oct 13, 2026
- ai4brands-design/claude-skillstheir own version, first seen Mar 22, 2026
Other versions4 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 4
- xfstudio/skills★ 9same name
- ai4brands-design/claude-skills★ 2same name
- cestercian/claude-playbook-skills★ 1same name
- Tgoldi/claude-skills★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository23 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- agent-orchestrationSkill
- ask-for-approvalSkill
- claim-verification-loopSkill
- code-councilSkill
- code-reviewSkill
- context-as-imagesSkill
- grillingSkill
- grow-test-coverageSkill
- investigateSkill
- loop-until-verifiedSkill
- plan-and-buildSkill
- proofreadSkill
- review-allSkill
- review-before-mergeSkill
- review-panelSkill
- to-questionnaireSkill
- track-review-findingsSkill
- trim-contextSkill
- unslopSkill
- verify-findingsSkill
- whatnowSkill
- wizardSkill
The file
We split this skill into the rules it gives an agent
1 rule. 0 are common, 0 are distinctive, and 1 is very specific to this project.
0
Common
Most of the 4 edited versions we read keep these.
0
Distinctive
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 49
Verify from usage numbers, not a feeling: cache_creation_input_tokens (write), then cache_read_input_tokens (hit).
“Common” is measured: kept by at least 6 in 10 of the 4 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Prompt caching
Overview
Some LLM APIs cache a block of prompt tokens so a later call skips reprocessing it: a hit costs a fraction of a normal input token and returns faster. This only works when the same token sequence opens the request each time, so put unchanging content first and per-call content last.
When to use
Several calls in a session share a long fixed prefix (system prompt, tool definitions, a reference document, a subagent-brief template reused across dispatches), and someone is cutting cost or latency on that loop.
Skip it for a one-off call, a prefix that changes every call (nothing shared to cache), or before the call is proven to work: get correctness and a cost/pass-rate baseline first, then add caching.
The pattern
- Identify the stable prefix: whatever is byte-identical call to call (system prompt, tool schemas, shared document, subagent template).
- Order the request stable-first: fixed content, then whatever changes this call (task specifics, current files, this turn's message) last. One differing byte before the cache point breaks the hit for everything after it.
- Mark the boundary: on Claude's API, top-level
cache_control: {"type": "ephemeral"}for automatic mode, or the same field on one content block for explicit control (up to 4 breakpoints). - Confirm the prefix clears the minimum size (table below); below it, caching silently does not apply.
- Pick a lifetime: 5 minutes (default, refreshed per hit) for a tight loop like seconds-apart subagent dispatches, or 1 hour (2x write cost) for slower work.
- Verify from usage numbers, not a feeling:
cache_creation_input_tokens(write), thencache_read_input_tokens(hit). Stop condition: later calls show a read count near the prefix size. Stuck at 0 means the prefix is not byte-identical; find the diff before calling it done.
Quick reference
| Model family | Minimum cacheable prefix |
| Sonnet | 1,024 tokens |
| Opus / Haiku 4.5 | 4,096 tokens |
| Lifetime | Write cost | Read cost |
| 5 min (default) | 1.25x base input | 0.1x base input |
| 1 hour | 2x base input | 0.1x base input |
Breakpoints: 4 explicit, or 1 in automatic mode.
Common mistakes
- Volatile content (timestamps, request IDs, non-deterministic ordering) before the boundary: silently kills every later hit, not just that call.
- Expecting a benefit below the minimum token count: a short system prompt never caches, wherever the marker sits.
- Optimizing placement before the call works: get a baseline pass rate and cost-per-task first (a pricier model that finishes in fewer turns can still cost less overall).
- Judging hits by feel instead of reading the usage fields above.
Source
- Repo: anthropics/claude-cookbooks, commit a4b0d89061bc65769fea7947c080b3b11d938515
- License: MIT (wording adapted, attribution given per license terms)
- Files read:
misc/prompt_caching.ipynb,cost_optimization/cost_optimization.ipynb(markdown cells only) - Adapted: generalized the notebooks'
cache_controlplacement and pricing into a "stable first, volatile last" pattern for any repeated-prefix call, including subagent dispatch.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

