Prompt Caching

davila7/claude-code-templates/cli-tool/components/skills/ai-research/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 從公開儲存庫中收錄這些內容。

檢舉或申請下架