prompt-caching
Skill756 starsChanged 5 months agoMITView on GitHub
Cache the parts of the prompt that don't change so a long-running loop stops paying full price on every turn. Use when the system prompt, tool defs, or reference docs are stable across many turns.
3 other projects use a version of this.
Adopted by
Most recently taken up by
- cobusgreyling/agent-skillstheir own version, first seen May 19, 2026
- ai4brands-design/claude-skillstheir own version, first seen Mar 22, 2026
- xfstudio/skillstheir own version, first seen Jan 22, 2026
Other versions3 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 3
- cobusgreyling/agent-skills★ 18same name
- xfstudio/skills★ 9same name
- ai4brands-design/claude-skills★ 2same 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 repository55 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .claude/CLAUDE.mdCLAUDE.md
- a11y-passSkill
- active-memory-reminderSkill
- adversarial-verifySkill
- authz-checkSkill
- bisect-regressionSkill
- broken-window-checkSkill
- changelog-from-diffSkill
- clean-commitsSkill
- context-budgetSkill
- contract-testSkill
- coverage-gapsSkill
- decision-recordSkill
- dependency-auditSkill
- design-systemSkill
- eval-harnessSkill
- evaluator-calibrationSkill
- feature-list-jsonSkill
- flaky-hunterSkill
- harness-strippingSkill
- hitl-escalateSkill
- init-script-contractSkill
- input-validationSkill
- kill-dead-codeSkill
- loading-empty-error-statesSkill
- migration-writerSkill
- model-routingSkill
- owasp-reviewSkill
- pdf-ingestionSkill
- planner-spec-expandSkill
- pr-from-diffSkill
- progress-reading-protocolSkill
- readme-auditSkill
- read-the-traceSkill
- rebase-safelySkill
- reduce-nestingSkill
- revert-surgicalSkill
- schema-diffSkill
- secret-scanSkill
- self-eval-biasSkill
- shift-notesSkill
- simplifySkill
- spec-firstSkill
- sprint-contractSkill
- sql-reviewSkill
- structured-outputSkill
- subagent-fanoutSkill
- suggest-next-featuresSkill
- systematic-debuggingSkill
- tool-restraintSkill
- using-loopkitSkill
- verification-before-completionSkill
- write-failing-test-firstSkill
- my-new-skillSkill
The file
We split this skill into the rules it gives an agent
2 rules. 0 are common, 2 are distinctive, and 0 are very specific to this project.
0
Common
Most of the 3 edited versions we read keep these.
2
Distinctive
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 9
Every turn of a Plan→Act→Verify loop resends the same system prompt, the same tool definitions, and (usually) the same reference docs.
- Distinctive: line 36
If cost isn't dropping, log the cache-hit metric.
“Common” is measured: kept by at least 6 in 10 of the 3 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
Every turn of a Plan→Act→Verify loop resends the same system prompt, the same tool definitions, and (usually) the same reference docs. Without cache breakpoints you pay full input price on all of it, every turn. With them, cached reads cost ~10% of the write.
Where to put breakpoints
Cache from the top of the prompt down. The cache is prefix-matched — a break in the middle invalidates everything after it.
- System prompt — mark the end of it as a breakpoint if it's >1024 tokens (Sonnet/Opus) or >2048 (Haiku).
- Tool definitions — cache immediately after, if the tool set is stable across the loop.
- Large stable docs — repo map, style guide, spec — before any turn-specific user text.
- User message stem — only if the same preamble repeats every turn.
Everything past the last breakpoint is billed fresh every turn. That's fine — that's where the changing content goes.
TTL choice
- 5-minute cache (default) — for tight loops where turns are seconds apart. Free to write.
- 1-hour cache — for slow loops (human in the loop, background jobs). Write cost is higher; break-even is ~2 hits.
Pick 5m unless you know turns are minutes apart.
Staleness rules — cache invalidation is silent
- Any byte change above the breakpoint invalidates the cache from that point.
- Reordering tools or messages counts as change.
- Trailing whitespace counts as change.
- A different model version counts as change.
If cost isn't dropping, log the cache-hit metric. Do not assume.
When NOT to cache
- Prompt <1024 tokens — below the minimum block size, no savings.
- One-shot calls — no reuse, cache write is wasted.
- Highly dynamic system prompt (per-user templating) — cache misses will exceed hits.
Red flags
- Cost graph flat after adding breakpoints — you're invalidating on every turn. Diff two consecutive requests byte-for-byte above the breakpoint.
- Breakpoint after user message — pointless; the user message changes every turn.
- Four+ breakpoints — max is four; extras are ignored silently.
- Caching a prompt that gets edited mid-session — one edit above the cut wipes all downstream savings.
The math
Cache write ≈ 1.25× normal input. Cache read ≈ 0.1× normal input. So a stable 20K-token prefix hit N times: N=1 costs more than no-cache; N=2 breaks even; N=10 costs ~15% of no-cache. Long loops win big; short chats lose.
Cache is the single biggest cost lever on a long-running agent. Set it once at the start of the loop, verify hits, forget it.
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.

