Claude Code Cache TTL Diagnostic
April 17, 2026 · View on GitHub
Is your Claude Code cache broken? Quick diagnostic for the silent TTL change that increased costs 20-32%
Claude Code Cache TTL Diagnostic
Your Claude Code token costs may have silently increased 20-32%.
In March 2026, the prompt cache TTL was reduced from 1 hour to 5 minutes (#46829). This means pausing for more than 5 minutes causes a full cache miss — and you pay for every token again.
Quick Check: Is Your Cache Working?
Run this in your terminal during a Claude Code session:
# Check your current cache hit rate
claude /cost
Look at the cache_read vs cache_creation ratio:
cache_read>>cache_creation= cache is workingcache_read≈ 0 = cache is broken, you're paying full price
3 Things That Break Your Cache
1. Pausing more than 5 minutes
Cache expires after 5 minutes of inactivity. Coffee break = full cache rebuild.
Fix: If you need to think, keep the session alive with a quick /cost check.
2. Any file change triggers git status change
Claude Code includes git status in the system prompt. Edit a file → git status changes → cache breaks.
Fix: export CLAUDE_CODE_DISABLE_GIT_INSTRUCTIONS=1 before starting claude. (Trade-off: no git context)
3. Starting a new session
Every new session starts with zero cache. The initial prompt (~6,500 tokens) is always uncached.
Fix: Don't restart sessions unnecessarily. Use /compact instead of starting fresh.
Hook: Auto-detect cache problems
Add this to your settings.json to warn when cache efficiency drops:
{
"hooks": {
"PostToolUse": [{
"matcher": { "event": "PostToolUse" },
"hooks": [{
"type": "command",
"command": "INPUT=$(cat); TOKENS=$(echo \"$INPUT\" | jq -r '.session_tokens // empty' 2>/dev/null); [ -z \"$TOKENS\" ] && exit 0; echo \"$(date +%H:%M:%S) $TOKENS\" >> /tmp/cc-token-session-$(date +%Y%m%d).log; exit 0"
}]
}]
}
}
Want the full picture?
- Token Checkup — Free 5-question diagnostic
- Token Book — 10 chapters, 800h of data, copy-paste templates (¥2,500)
- cc-safe-setup — 664 hooks for Claude Code safety
Diagnose your cache instantly: Cache Health Checker — paste your /cost output, get diagnosis in seconds.
By yurukusa — 800+ hours of autonomous Claude Code operation
Opus 4.7 became the default model on April 16. Token consumption is up to 4x higher, and the safety classifier broke (#49618) — 20+ data loss incidents in 3 days.
One-command fix: npx cc-safe-setup --opus47
- Opus 4.7 Survival Guide
- Emergency Defense Kit (Gist)
- Token Book — full optimization guide with Opus 4.7 chapter (~$17)