Agent skill · research science · sickn33

prompt-caching

Caching strategies for LLM prompts including Anthropic prompt

Why this skill is useful

Provides specific caching strategies and code examples for LLM prompt and response caching that the AI wouldn't reliably generate on its own.

What it needs

Requires redis installed locally. About 6k tokens when loaded. Last updated 2026-08-07. 44,571 stars on the source repository.

What this skill does

Prompt Caching Caching strategies for LLM prompts including Anthropic prompt caching, response caching, and CAG (Cache Augmented Generation) Capabilities prompt-cache response-cache kv-cache cag-patterns cache-invalidation Prerequisites Knowledge: Caching fundamentals, LLM API usage, Hash functions Skillsrecommended: context-window-management Scope Doesnotcover: CDN caching, Database query caching, Static asset caching Boundaries: Focus is LLM-specific caching, Covers prompt and response caching Ecosystem Primarytools Anthropic Prompt Caching - Native prompt caching in Claude API Redis - In-memory cache for responses (ioredis on servers; @upstash/redis over HTTP on serverless, see upstash-redis) OpenAI Caching - Automatic caching in OpenAI API Patterns Anthropic Prompt Caching Use Claude's native prompt caching for repeated prefixes When to use: Using Claude API with stable system prompts or context import Anthropic from '@anthropic-ai/sdk'; const client = new Anthropic(); // Cache the stable parts of your prompt async function queryWithCaching(userQuery: string) { const response = await client.messages.create({ model: "claude-sonnet-4-20250514", maxtokens: 1024, system: [ { type: "text", text: LONGSYSTEMPROMPT, // Your detailed instructions cachecontrol: { type: "ephemeral" } // Cache this! }, { type: "text", text: KNOWLEDGEBASE, // Large static context cachecontrol: { type: "ephemeral" } } ], messages: [ { role: "user", content: userQuery } // Dynamic part ] }); // Check cache usage console.log(Cache read: ${response.usage.cachereadinputtokens}); console.log(Cache write: ${response.usage.cachecreationinputtokens}); return response; } // Cost savings: 90% reduction on cached tokens // Latency savings: Up to 2x faster Response Caching Cache full LLM responses for identical or similar queries When to use: Same queries asked repeatedly import { createHash } from 'crypto'; import Redis from 'ioredis'; const redis = new Redis(process.env.REDISURL); // Serverless/edge al …

How to use it

Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:

@skills sickn33/prompt-caching

View the source on GitHub

Browse the @skills marketplace