No description
  • Python 86.8%
  • Shell 9.6%
  • PowerShell 3.6%
Find a file
Arxchibobo 60a7a5228c chore: AI metadata cleanup + markdown formatting
Bulk formatting normalization - emphasis style, line spacing, AI signature removal.
Companion to main repo d4b657a workspace cleanup.
2026-06-01 12:37:52 +08:00
node chore: AI metadata cleanup + markdown formatting 2026-06-01 12:37:52 +08:00
patches chore: AI metadata cleanup + markdown formatting 2026-06-01 12:37:52 +08:00
results Initial commit 2026-03-31 16:48:31 -04:00
tracker Remove personal/local artifacts and add ignore rules 2026-03-31 16:51:51 -04:00
.gitignore docs: complete 1.1 1.2 1.3 onboarding and smoke flow 2026-03-31 19:09:12 -04:00
install-mac.sh fix: use apply-patches.py in mac installer, document cold-cache behavior 2026-03-31 20:22:27 -04:00
install-windows.ps1 fix: restore and harden claude-patched installers across os 2026-03-31 19:28:56 -04:00
install.sh fix: restore and harden claude-patched installers across os 2026-03-31 19:28:56 -04:00
patch.py Initial commit 2026-03-31 16:48:31 -04:00
PROJECT_SCOPE.md docs: complete 1.1 1.2 1.3 onboarding and smoke flow 2026-03-31 19:09:12 -04:00
README.md fix: use apply-patches.py in mac installer, document cold-cache behavior 2026-03-31 20:22:27 -04:00
smoke_check.sh docs: complete 1.1 1.2 1.3 onboarding and smoke flow 2026-03-31 19:09:12 -04:00
test_cache.py Initial commit 2026-03-31 16:48:31 -04:00
usage_audit.py Initial commit 2026-03-31 16:48:31 -04:00

Claude Code Cache Fix

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.

Quick Start

Linux

./install.sh

macOS

./install-mac.sh

Windows (PowerShell)

powershell -ExecutionPolicy Bypass -File .\install-windows.ps1

Both 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-transcript

Windows (PowerShell):

Get-Command claude-patched -All
python .\test_cache.py claude-patched --timeout 240 --debug-transcript

First Run: Cold Cache Note

The 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%.

Smoke Check (installer + test + summary)

Run:

./smoke_check.sh --timeout 240

What it does:

  • runs installer (install.sh by 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 240

Usage Audit (real sessions)

To audit recent session cache efficiency:

python3 usage_audit.py --top 10 --window 8

Healthy sessions usually show high read ratio in the recent window.

What the Patches Do

Three patches are applied to cli.js:

  1. db8 attachment filter — persists deferred_tools_delta and mcp_instructions_delta attachments in the session JSONL so the cache prefix is reconstructed correctly on resume.
  2. Fingerprint meta skip — ensures the first-message hash used in the attribution header ignores injected meta messages, keeping the cache key stable across turns.
  3. Force 1h cache TTL — bypasses the subscription/feature-flag check so all cache markers use 1-hour TTL instead of the default 5 minutes.

Notes

  • Requires node, npm, and python3.
  • Requires Claude auth (ANTHROPIC_API_KEY or Claude local auth setup).
  • A currently running old claude-patched process will not auto-update; start a new session after patching.
  • Stock claude is never modified. To undo, just stop using claude-patched.