Prompt Caching

作者 davila78da17d671b6f无许可证32K 个星标收录于 2026年10月8日更新于 2026年10月8日仓库今天更新

Caching strategies for LLM prompts including Anthropic prompt caching, response caching, and CAG (Cache Augmented Generation) Use when: prompt caching, cache prompt, response cache, cag, cache augmented.

仅含说明AI & Agents
AI 生成的概览

关于 LLM 提示缓存策略的指导,包括 Anthropic 提示缓存、响应缓存和 CAG。

功能
该技能提供缓存 LLM 提示和响应的说明与模式。它涵盖针对重复前缀的 Anthropic 原生提示缓存、针对相同或相似查询的完整响应缓存,以及将文档预缓存在提示中而非检索的缓存增强生成(CAG)。它还列出了反模式以及缓存失效和前缀变更等关键问题。
适用场景
当您需要通过缓存降低 LLM 成本或延迟时使用此技能,例如实现提示前缀缓存、响应缓存或 CAG 模式。它也适用于排查缓存未命中、失效或提示结构问题。
运行要求
无需脚本或特殊工具;这是一个仅包含说明的技能。它假定您熟悉 LLM API 和缓存概念。

Prompt Caching

You're a caching specialist who has reduced LLM costs by 90% through strategic caching. You've implemented systems that cache at multiple levels: prompt prefixes, full responses, and semantic similarity matches.

You understand that LLM caching is different from traditional caching—prompts have prefixes that can be cached, responses vary with temperature, and semantic similarity often matters more than exact match.

Your core principles:

  1. Cache at the right level—prefix, response, or both
  2. K

Capabilities

  • prompt-cache
  • response-cache
  • kv-cache
  • cag-patterns
  • cache-invalidation

Patterns

Anthropic Prompt Caching

Use Claude's native prompt caching for repeated prefixes

Response Caching

Cache full LLM responses for identical or similar queries

Cache Augmented Generation (CAG)

Pre-cache documents in prompt instead of RAG retrieval

Anti-Patterns

❌ Caching with High Temperature

❌ No Cache Invalidation

❌ Caching Everything

⚠️ Sharp Edges

IssueSeveritySolution
Cache miss causes latency spike with additional overheadhigh// Optimize for cache misses, not just hits
Cached responses become incorrect over timehigh// Implement proper cache invalidation
Prompt caching doesn't work due to prefix changesmedium// Structure prompts for optimal caching

Related Skills

Works well with: context-window-management, rag-implementation, conversation-memory

来源与署名

来源:davila7/claude-code-templates位于cli-tool/components/skills/ai-research/prompt-caching提交8da17d6

许可证: 无许可证

内容归原作者所有。SourceWeft 从公开仓库中收录这些内容。

举报或申请下架