Patch + test toolkit for the known Claude Code cache issues:
- resume cache regression (
deferred_tools_delta/mcp_instructions_delta) - sentinel replacement behavior (
cch=00000)
This repo keeps stock claude untouched and gives you a separate claude-patched command.
./install.sh./install-mac.shpowershell -ExecutionPolicy Bypass -File .\install-windows.ps1Both Linux and macOS installers use patches/apply-patches.py which has regex and semantic search fallbacks for reliable patching across different minified code versions.
Then open a new terminal and verify.
Linux/macOS:
type -a claude-patched
python3 test_cache.py claude-patched --timeout 240 --debug-transcriptWindows (PowerShell):
Get-Command claude-patched -All
python .\test_cache.py claude-patched --timeout 240 --debug-transcriptThe first test_cache.py run after patching may report resume cache as "broken".
This is expected. The old 5-minute TTL cache entries from before the patch need to
expire before the new 1-hour TTL entries take effect. Run the test a second time
and it should report "healthy" with a read ratio of ~65-70%.
Run:
./smoke_check.sh --timeout 240What it does:
- runs installer (
install.shby default) - runs
test_cache.py - saves full output under
results/ - prints a short PASS/FAIL block you can paste into a post
For macOS, use:
./smoke_check.sh --installer ./install-mac.sh --timeout 240To audit recent session cache efficiency:
python3 usage_audit.py --top 10 --window 8Healthy sessions usually show high read ratio in the recent window.
Three patches are applied to cli.js:
- db8 attachment filter — persists
deferred_tools_deltaandmcp_instructions_deltaattachments in the session JSONL so the cache prefix is reconstructed correctly on resume. - Fingerprint meta skip — ensures the first-message hash used in the attribution header ignores injected meta messages, keeping the cache key stable across turns.
- Force 1h cache TTL — bypasses the subscription/feature-flag check so all cache markers use 1-hour TTL instead of the default 5 minutes.
- Requires
node,npm, andpython3. - Requires Claude auth (
ANTHROPIC_API_KEYor Claude local auth setup). - A currently running old
claude-patchedprocess will not auto-update; start a new session after patching. - Stock
claudeis never modified. To undo, just stop usingclaude-patched.