prompt-caching
Skill by sickn33
Prompt caching gives developers caching patterns for LLM applications. It covers Anthropic prompt caching, response caching with Redis, and Cache Augmented Generation (CAG). It is aimed at developers building apps on the Claude API.
Install prompt-caching
Built from the published package, never by AI.
git clone --depth 1 https://github.com/sickn33/agentic-awesome-skills /tmp/agentic-awesome-skills && mkdir -p ~/.claude/skills && cp -r /tmp/agentic-awesome-skills/skills/prompt-caching ~/.claude/skills/prompt-cachingRun in your terminal. Claude Code loads skills from ~/.claude/skills automatically.
git clone --depth 1 https://github.com/sickn33/agentic-awesome-skills /tmp/agentic-awesome-skills && mkdir -p ~/.gemini/antigravity-cli/skills && cp -r /tmp/agentic-awesome-skills/skills/prompt-caching ~/.gemini/antigravity-cli/skills/prompt-cachingAntigravity CLI loads skills from ~/.gemini/antigravity-cli/skills, or .agents/skills for one project.
Skills can run scripts on your machine. Some need an API key: check the README.
About
Prompt caching is an agent skill that describes caching strategies for LLM prompts. It covers Anthropic prompt caching using cache_control blocks, response caching with exact-match and semantic-similarity lookups backed by Redis, and Cache Augmented Generation (CAG), which places a stable document set directly in the prompt instead of using retrieval. It also lists cache invalidation approaches and common pitfalls.
The examples are TypeScript code that use the Anthropic SDK, ioredis or @upstash/redis, and the claude-sonnet-4-20250514 model. The skill notes that Anthropic caching needs an exact prefix match, so dynamic content such as timestamps should stay out of cached blocks. It is aimed at developers building LLM applications who want to reduce repeated prompt cost or latency. CDN, database query and static asset caching are out of scope.
Written from the project's SKILL.md and checked against it.
What it can do
- Anthropic prompt cachingCaches stable system prompt and knowledge base blocks using cache_control with the ephemeral type.
- Response cachingStores full LLM responses in Redis, keyed by a SHA-256 hash of the prompt, with a one hour default TTL.
- Semantic response cachingLooks up similar prompts by embedding similarity against a threshold of 0.95.
- Cache Augmented GenerationPre-loads a document corpus into the prompt instead of using retrieval, for stable document sets.
- Cache invalidationCovers version-based, content-hash and event-based invalidation of cached responses.
- Prompt prefix structuringShows how to order static and dynamic prompt content so cache hits are not broken.
What you need
- Anthropic API access for Claude
- Node.js and the @anthropic-ai/sdk package
- Redis, via ioredis or @upstash/redis
- Embedding function for semantic caching
Try asking
- Show me how to add Anthropic prompt caching to my Claude system prompt.
- Help me set up response caching with Redis for repeated LLM queries.
- When should I use CAG instead of RAG for my document set?
Good to know
- Anthropic caching requires an exact prefix match, so dynamic content breaks hits.
- A cache miss can add latency, and the skill warns it may be slower than no caching.
- The CAG decision table suggests corpus sizes under 100K tokens.
- Does not cover CDN, database query or static asset caching.
Security check
ANo download-and-run commands, hidden instructions or signs of sending keys out were found.
Checked automatically: skills/prompt-caching/SKILL.md. This looks for known risky patterns and is not a full audit. How grades work
Inside the skill
-
SKILL.md15 KB
Alternatives to prompt-caching
All alternatives →Aligns a Qwen Code feature with a Codex or Claude Code reference agent. It runs both under the same scenario, captures HTTP and terminal traces, and compares them until behavior matches.
Searches, views, creates, updates, and deletes the user's Google Contacts from an AI assistant. It is for people who want to manage their address book through conversation. A one-time Google connect is required before it returns data.
Guides an AI assistant on error handling choices. It covers when to use Result, Option, ? propagation, unwrap, expect and panic, plus anyhow and thiserror.
Caveman is an agent skill that makes an AI assistant reply in a terse style. It cuts filler and keeps technical facts, code, commands and errors exact. It is built for users who want shorter, cheaper replies.
docs-sync audits or updates English SDK documentation against the requested implementation scope. It is for maintainers who want docs to match main branch features, configuration options, and defaults.
Guides an AI assistant through setting up and running monorepos with pnpm workspaces, Turborepo and Nx. Aimed at developers who need faster builds, shared code and managed dependencies across multiple packages.
Compare with agent-reproduce-align, google_contacts or m06-error-handling
prompt-caching: common questions
What does CAG mean in this skill?
CAG stands for Cache Augmented Generation. The skill describes pre-caching documents in the prompt instead of using RAG retrieval, for stable corpora that fit in the context window.
Does this skill require Redis?
The response caching examples use Redis through ioredis on servers or @upstash/redis on serverless. The source lists Redis as the primary tool for response caching.
Why might my prompt cache not hit?
The source says Anthropic caching needs an exact prefix match. Timestamps, dynamic content in the prefix, or a different message order can cause misses.
How do I install prompt-caching?
Run the command above to copy the skill into ~/.claude/skills/. Claude Code picks it up automatically.
Is prompt-caching free?
The code is published under the MIT licence. The service it connects to may have its own pricing.
Is prompt-caching safe to use?
It scores 89 of 100. Grades: maintenance A, licence A, quality A. Security check: grade A, no risky patterns found in the files checked. Review the code before you install. How grades work.
What are alternatives to prompt-caching?
Similar skills: agent-reproduce-align, google_contacts, m06-error-handling, caveman.
