環境変数
CLAUDE_CODE_PROMPT_CACHE_TTL
対話、-p、SDKターン、およびそれらと連動して実行されるヘルパーを含むメイン会話のプロンプトキャッシュ有効期間を設定します。5分または1時間のみを受け付けます。
使い方・用途
- メイン会話のキャッシュを長時間維持したい場合に「1h」を設定する
- APIの課金を抑えたい場合や、キャッシュヒット率を優先する場合に「5m」を設定する
- FORCE_PROMPT_CACHING_5Mが優先されるため、そちらが優先度順位の最上位であることを理解する
英語原文(公式ドキュメントより)
Set 5m or 1h, the only values Claude Code accepts, to choose the prompt cache TTL for the main conversation: your interactive, -p, and SDK turns, plus the helpers that run inline with them. Takes precedence over the promptCacheTtl setting and over ENABLE_PROMPT_CACHING_1H, and FORCE_PROMPT_CACHING_5M overrides it. The API bills 1-hour cache writes at a higher rate. Requires Claude Code v2.1.242 or later