Sponsored byOutsenseAI that finds your next clients
SponsorGROUOutbound, LinkedIn content and leads for B2B teamsSponsorOutsenseAI that finds your next clientsAd+Your tool hereSeen by people installing AI tools@Weekly picksThe best new tools, one email a week

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.

  • Score 89
  • 51k stars
  • MIT
  • Updated
Works withClaude CodeClaude apps Antigravity CLI

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-caching

Run in your terminal. Claude Code loads skills from ~/.claude/skills automatically.

Step-by-step: install prompt-caching in Claude Code

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

A

No 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 →

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.

prompt-caching Install

Add to stack

Loading.