softspark/ai-toolkit/prompt-caching-patterns
Claude Code and agent skill by softspark/ai-toolkit
- community
Checking that the SKILL.md file is still in the repository.
Anthropic API prompt caching: TTL, breakpoints, stacking, invalidation, hit rate. Triggers: prompt caching, cache_control, cache breakpoint, cache TTL, hit rate.
Install
npx vskill@latest install softspark/ai-toolkit/prompt-caching-patternsSKILL.md
The same SKILL.md was published earlier as softspark/ai-toolkit/prompt-caching-patterns.
Prompt Caching Patterns
Cache repeated prefixes when reuse offsets write costs. Cache eligibility and pricing depend on the model and platform; a short system prompt is not cached merely because it repeats.
Claude API cache reference (2026-11-18)
| Model | Minimum eligible prefix | Cache read / base input price | |
|---|---|---|---|
| Claude Opus 5.5 | 512 tokens | 5% | |
| Claude Fable 5.2 | 512 tokens | 2.5% | |
| Claude Sonnet 5.5 | 512 tokens | 5% | |
| Claude Haiku 5.5 | 512 tokens | 10% |
For the Claude API, a five-minute write costs 1.25 times base input and a one-hour write costs 2 times base input. Recheck current pricing before budgeting; provider-specific billing and model availability can differ.
Prefix design
Cache order is tools → system → messages, regardless of the order of request keys. An explicit breakpoint includes the marked block and everything before it. Keep dynamic material after the stable prefix.
There are at most four breakpoints. Top-level automatic cache_control moves a breakpoint to the last eligible block and consumes one slot. Explicit markers give control over a static prefix.
Explicit caching example
The caller supplies the approved model, text and output limit. Marking a prefix below its model's minimum silently produces no cache entry.
Use {"type": "ephemeral", "ttl": "1h"} for an approved one-hour write. When mixing TTLs, put longer-lived breakpoints before shorter-lived ones. Do not send paid heartbeat requests simply to keep an unused prefix warm.
Invalidation
Changing tools invalidates subsequent system and message prefixes; changing the system invalidates subsequent messages. Changing effective top-level effort can invalidate messages and, on some models, earlier blocks. Explicitly setting the model's default effort is equivalent to omitting it. A supported per-message effort update preserves the existing prefix. Check cache usage after switching models.
A static string passed as system alone does not enable caching: configure cache_control at the request or content-block level. Keep tool definitions, document serialization and stable instructions deterministic.
Measuring reuse
Include writes when calculating the fraction of input served from cache.
Record write/read counts and actual costs across cold and warm requests. Choose a target from observed reuse; a single universal hit-rate threshold is misleading. Both cache counters remaining zero can indicate an ineligible prefix.
When not to cache
Skip cache writes when no prefix will be reused before expiry or when measured cost exceeds uncached requests. Do not pad prompts with irrelevant content merely to reach a minimum. A one-hour TTL may fit intermittent reuse better than five minutes, within the approved cost policy.
Sources and related skills
Reviewed 2026-11-18.
Use model-routing-patterns for route evaluation and llm-ops-engineer for application operations.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingapp/skills/prompt-caching-patterns/SKILL.md
Popularity
- Repository stars
- 181
- Repository forks
- 21
- Repository npm downloads, 7 days
- 1,045
- 7-day trend score
- 43
Stars and forks are for the whole GitHub repository, not this skill alone. Downloads are for the repository's npm package. Refreshed 28 Apr 2026, 7 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/softspark/ai-toolkit/prompt-caching-patterns)