prompt-caching
Prompt caching for Claude API to reduce latency by up to 85% and costs by up to 90%. Activate for cache_control, ephemeral caching, cache breakpoints, and performance optimization.
npx skills add majiayu000/claude-skill-registry --skill prompt-caching-lobbi-docs-claude --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
# Prompt Caching Skill Leverage Anthropic's prompt caching to dramatically reduce latency and costs for repeated prompts. ## When to Use This Skill - RAG systems with large static documents - Multi-turn conversations with long instructions - Code analysis with large codebase context - Batch processing with shared prefixes - Document analysis and summarization ## Core Concepts ### Cache Control Placement ```python import anthropic client = anthropic.Anthropic() response = client.messages.create( model="claude-sonnet-4-20250514", max_tokens=1024, system=[ { "type": "text", "text": "You are a helpful assistant with access to a large knowledge base...", "cache_control": {"type": "ephemeral"} # Cache this content } ], messages=[{"role": "user", "content": "What is...?"}] ) ``` ### Cache Hierarchy Cache breakpoints are checked in this order: 1. **Tools** - Tool definitions cached first 2. **System** - System prompts cached second 3. **Messages** - Conversation history cached last ### TTL Options | TTL | Write Cost | Read Cost | Use Case | |-----|-----------|-----------|----------| | 5 minutes (default) | 1.25x base | 0.1x base | Interactive sessions | | 1 hour | 2.0x base | 0.1x base | B
- When to Use This Skill
- Core Concepts
- Cache Control Placement
- Cache Hierarchy
- TTL Options
- Cache Requirements
- Implementation Patterns
- Pattern 1: Single Breakpoint (Recommended)
- Pattern 2: Multi-Turn Conversation
- Pattern 3: RAG with Multiple Breakpoints
- Pattern 4: Batch Processing with 1-Hour TTL
- Performance Monitoring
- Check Cache Usage
- Cost Calculation
What does the prompt-caching skill do?
Prompt caching for Claude API to reduce latency by up to 85% and costs by up to 90%. Activate for cache_control, ephemeral caching, cache breakpoints, and performance optimization.
How do I install it?
Run `npx skills add majiayu000/claude-skill-registry --skill prompt-caching-lobbi-docs-claude --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From majiayu000/claude-skill-registry, a repository with 534 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.
