なぜ設定するのか
休憩を挟んでもキャッシュが残り、再開時の読み直しコストが下がります。
1時間キャッシュは書き込み単価が5分より高くなります(API 従量課金の場合)。v2.1.242 以降。
設定方法
~/.claude/settings.jsonを開く(なければ作る)- スニペットを JSON の中に統合する。既存の設定は消さず、キーを足す形で入れる
- Claude Code を起動し直す
- 既定値
- 未設定(リクエストごとの既定)
- 書く場所
~/.claude/settings.json- 型
- string, one of:
- 置ける場所
- Any file
指定できる値
"5m"the cache holds for five minutes"1h"the cache holds for an hour
公式ドキュメントの説明
Choose how long the prompt cache holds the main conversation. This key applies to your interactive, -p, and Agent SDK turns, together with the helpers Claude Code runs inline with them. The one-hour lifetime keeps the cache warm across longer breaks, and the API bills each cache write at a higher rate than at the five-minute lifetime. Requires Claude Code v2.1.242 or later.