prompt-caching

Implements Anthropic prompt caching, response caching, and Cache Augmented Generation patterns for LLM applications.

Updated Apr 5, 2026
One-click install
npx skills add https://github.com/RobinMillford/GopherNotebook --skill prompt-caching-robinmillford
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: prompt-caching
Source: https://github.com/RobinMillford/GopherNotebook/tree/main/.claude/skills/prompt-caching
Command: npx skills add https://github.com/RobinMillford/GopherNotebook --skill prompt-caching-robinmillford

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @anthropic-ai/sdk, ioredis.

What problem does it solve? LLM applications repeatedly send identical system prompts and context, wasting tokens, increasing latency, and inflating API costs. This Skill provides concrete caching patterns to eliminate redundant token processing and serve repeated queries faster. ## Core Features & Use Cases - Anthropic Prompt Caching: Apply cache_control markers to stable system prompts and knowledge bases for up to 90% cost reduction on cached tokens. - Response Caching: Cache full LLM responses in Redis using exact-match hashing or semantic similarity, with temperature-aware rules. - Cache Augmented Generation (CAG): Pre-cache stable document corpora directly in the prompt as an alternative to RAG when the corpus fits in context. - Use Case: A support chatbot sends the same 50K-token documentation with every request. By marking it with cache_control, each subsequent call reads from cache instead of reprocessing, cutting cost and latency dramatically. ## Quick Start Ask the AI to add Anthropic prompt caching to your Claude API calls so the static system prompt and knowledge base are cached across requests.

Frequently Asked Questions about prompt-caching

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I use Anthropic prompt caching with the Claude API?

Add cache_control with type ephemeral to stable system prompt blocks in your messages.create call. Claude caches the marked prefix, and subsequent requests with the identical prefix read from cache, reducing cached token costs by up to 90%.

When should I use CAG instead of RAG?

Use Cache Augmented Generation when your document corpus is stable, fits within the context window (under roughly 100K tokens), and latency is critical. Use RAG when the corpus is large, updates frequently, or queries target specific documents.

Why is my Anthropic prompt cache not hitting?

Prompt caching requires an exact prefix match. Dynamic content like timestamps inside cached blocks, reordered components, or any change to the prefix invalidates the cache. Move dynamic content into user messages and keep cached blocks static.

Should I cache LLM responses with high temperature?

No. Responses generated with temperature above 0.5 are non-deterministic, so caching them serves inconsistent results. Only cache low-temperature responses and include model and temperature in the cache key.

How do I invalidate stale cached LLM responses?

Use versioned cache keys to invalidate all entries at once, content-hash validation to detect source changes, or event-based invalidation tied to source updates. Always set a TTL appropriate to your data freshness requirements.