prompt-caching
Skill by henryalouf
Explains caching strategies for LLM prompts, including Anthropic prompt caching, response caching with Redis, and Cache Augmented Generation. 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/henryalouf/ruflow /tmp/ruflow && mkdir -p ~/.claude/skills && cp -r /tmp/ruflow/.agents/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/henryalouf/ruflow /tmp/ruflow && mkdir -p ~/.gemini/antigravity-cli/skills && cp -r /tmp/ruflow/.agents/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
This skill gives an assistant guidance and code patterns for caching in LLM applications. It covers Anthropic native prompt caching for stable system prompts and knowledge base text, exact-match and semantic response caching using Redis, and Cache Augmented Generation, which places a stable document set directly in the prompt instead of using retrieval.
It also lists common failure modes: cache misses adding latency, stale responses from long TTLs, and prefix changes such as timestamps breaking Anthropic cache hits. It includes a CAG versus RAG decision table. The source is licensed Apache 2.0 and is aimed at developers working with LLM APIs who already know caching basics.
Written from the project's SKILL.md and checked against it.
What it can do
- prompt-cacheCaches stable system prompts and context with Anthropic's native prompt caching.
- response-cacheStores full LLM responses in Redis under a SHA-256 hash of the prompt, with a one hour default TTL.
- Semantic response cachingReturns a cached response when an embedding similarity score is above 0.95.
- cag-patternsPre-loads a stable document set into the prompt instead of running retrieval.
- cache-invalidationDescribes version-based, content-hash and event-based cache invalidation.
What you need
- Anthropic API access (Claude API)
- Redis, used in the response caching examples
- Knowledge of LLM API usage and caching basics
Try asking
- Show me how to add Anthropic prompt caching to my Claude API calls.
- Write a Redis response cache with a one hour TTL for my LLM queries.
- Help me decide between CAG and RAG for my document corpus.
Good to know
- Does not cover CDN caching, database query caching or static asset caching.
- Anthropic prompt caching requires an exact prefix match.
- Response caching examples only cache low-temperature requests (temperature 0.5 or lower).
Security check
ANo download-and-run commands, hidden instructions or signs of sending keys out were found.
Checked automatically: .agents/skills/prompt-caching/SKILL.md. This looks for known risky patterns and is not a full audit. How grades work
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
Does this cover CDN or static asset caching?
No. The source says it excludes CDN caching, database query caching and static asset caching, and focuses on LLM prompt and response caching.
Why might Anthropic prompt caching not hit?
The source says Anthropic caching requires an exact prefix match, so timestamps or other dynamic content in the cached prefix cause misses.
When is CAG better than RAG?
The source's decision table favors CAG when the corpus is under about 100K tokens, updates are infrequent, and latency is critical.
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 70 of 100. Grades: maintenance B, licence A, quality B. 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.
