prompt-cache-boundaries
Skill0 starsChanged 39 days agoMITView on GitHub
Use when Claude API agents repeatedly rewrite shared context, first requests miss the prompt cache, or high cache-hit rates coexist with rising per-task cost.
In this repository66 other files it gives its agents.
- AGENTS.mdAGENTS.md
- postgres-locking-joinsSkill
- ai-bug-patternsSkill
- compressed-ndjson-boundariesSkill
- http-resume-integritySkill
- linux-io-latency-triageSkill
- macos-disk-space-recoverySkill
- minimal-sufficient-evidenceSkill
- modularize-large-filesSkill
- patch-reproducer-validitySkill
- proton-drive-selective-backupSkill
- transactional-outbox-deliverySkill
- conventional-commitsSkill
- git-advanced-mergingSkill
- git-bisect-forensicsSkill
- git-data-recoverySkill
- git-hooksSkill
- git-rerereSkill
- git-reset-mechanicsSkill
- git-revisions-syntaxSkill
- git-rewriting-historySkill
- git-submodulesSkill
- git-worktreesSkill
- github-ssh-keysSkill
- npm-publish-ci-pitfallsSkill
- sapling-stacked-pr-workflowSkill
- go-concurrency-patternsSkill
- go-data-idiomsSkill
- go-error-handlingSkill
- go-interfaces-embeddingSkill
- go-pprof-profilingSkill
- marketing-funnel-diagnosisSkill
- marketing-geo-experimentsSkill
- marketing-incrementalitySkill
- marketing-positioning-testsSkill
- python-descriptors-mroSkill
- python-logging-cookbookSkill
- python-scaling-regression-testsSkill
- python-unicode-gotchasSkill
- rust-compile-time-invariantsSkill
- rust-deterministic-concurrency-testsSkill
- rust-error-identity-boundariesSkill
- rust-regex-search-contractsSkill
- rust-runtime-bug-classesSkill
- rust-tokio-actor-deliverySkill
- rust-tokio-cancellation-safetySkill
- sales-discovery-qualificationSkill
- sales-mutual-action-plansSkill
- sales-pipeline-forecast-calibrationSkill
- sales-value-negotiationSkill
- ai-triage-evaluationSkill
- container-image-patchingSkill
- dependency-artifact-integritySkill
- dnssec-sentinel-diagnosticsSkill
- iam-policy-change-replaySkill
- rbvm-applicabilitySkill
- rbvm-asset-evidenceSkill
- rbvm-guarded-remediationSkill
- rbvm-priority-decisionsSkill
- rbvm-risk-exceptionsSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 2 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
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 23
Verify the chosen model/platform's minimum cacheable length, isolation scope, TTL, and breakpoint limits.
- Distinctive: line 40
Run offline counterexamples from repository root:
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Audit Prompt Cache Boundaries
A stable template need not produce a stable provider-bound prefix. A matching prefix is not an observed cache hit; a hit is not evidence of lower task cost or preserved task quality.
Separate the evidence
| Question | Evidence |
| What changed? | Final request structure, ordered tools, system blocks, history, model, and prompt-affecting settings |
| What was reused? | Actual response usage.cache_read_input_tokens, not a local hash |
| Did optimization help? | Comparable completed tasks: total usage, latency, failures, and independently checked outcomes |
Repair the boundary
- Inspect authorized synthetic requests after harness/SDK transformations. Record model, platform, workspace, feature configuration, and breakpoint positions. Keep prompt bodies, credentials, and customer data out of telemetry.
- Claude prefixes follow
tools → system → messages. Keep tool order and schema serialization deterministic. Changed tool definitions invalidate later prefixes; hashing only the system prompt misses this. Do not erase required instructions or tools merely to make requests match. - Separate stable instructions from changing repository/date/context blocks, preserving their roles, content, and ordering. Mark the last stable block with
"cache_control": {"type": "ephemeral"}. A marker after volatile content writes that volatile prefix; lookback cannot recover a shorter entry that was never written. Automatic caching alone does not fix that layout. - Verify the chosen model/platform's minimum cacheable length, isolation scope, TTL, and breakpoint limits. Concurrent readers cannot use a new entry before its writer's response starts. A local byte comparison establishes neither token eligibility nor cache availability.
[shared policy + cwd/date]◀cache differs between jobs. [shared policy]◀cache [cwd/date] exposes a reusable boundary without deleting context. Changing an earlier tool description still breaks that prefix. Reordering/splitting content needs task-quality checks; preserved concatenated text alone is insufficient.
Diagnose without inventing certainty
For authorized Claude API calls, opt into diagnostics each turn and chain the previous response ID. This feature is not available on Bedrock or Google Cloud. Read diagnostics alongside usage:
| Result | Interpretation |
diagnostics: null | Ambiguous without opt-in and prior-ID context; never independently proves a hit |
cache_miss_reason: null | Comparison pending |
previous_message_not_found / unavailable | No usable comparison |
*_changed | First divergence only; an earlier prefix may still hit |
Compare write/read/uncached/output tokens and calls per completed task, not only hit percentage. Keep model/effort and task mix comparable; any intentional changes need separate quality evaluation. Vendor savings do not transfer automatically.
Run offline counterexamples from repository root:
python3 skills/engineering/prompt-cache-boundaries/fixture.pyPrimary sources and validation limits.
Pitfalls
- Treating a null diagnostic or local fingerprint as a hit, or a first-call miss as proof of a broken boundary.
- Sharing private context beyond its authorized audience to improve reuse.
- Claiming savings or quality parity from serialization tests; they exercise neither inference nor billing.
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.

