by cnighswonger
Fixes prompt cache regression in Claude Code that causes up to 20x cost increase on resumed sessions
# Add to your Claude Code skills
git clone https://github.com/cnighswonger/claude-code-cache-fixGuides for using cli tools skills like claude-code-cache-fix.
Last scanned: 6/4/2026
{
"issues": [],
"status": "PASSED",
"scannedAt": "2026-06-04T08:21:12.124Z",
"npmAuditRan": true,
"pipAuditRan": true
}claude-code-cache-fix is an open-source cli tools skill for AI coding assistants such as Claude Code, Codex CLI, and ChatGPT, built by cnighswonger. Fixes prompt cache regression in Claude Code that causes up to 20x cost increase on resumed sessions. It has 425 GitHub stars.
Yes. claude-code-cache-fix passed SkillsLLM's automated security scan — a dependency vulnerability audit plus prompt-injection heuristics — with no high-severity issues. You can read the full report in the Security Report section on this page.
Clone the repository with "git clone https://github.com/cnighswonger/claude-code-cache-fix" and add it to your Claude Code skills directory (see the Installation section above).
claude-code-cache-fix is primarily written in JavaScript. It is open-source under cnighswonger on GitHub, so you can review or fork the full source.
Yes. SkillsLLM lists many other CLI Tools skills you can browse and compare side by side. Open the CLI Tools category from the badge at the top of this page, or use the Related Skills and comparison links further down to weigh claude-code-cache-fix against similar tools.
No comments yet. Be the first to share your thoughts!
Top skills in this category by stars
⚠️ Third-Party Software Notice
This skill is third-party open-source software developed and hosted independently on GitHub. SkillsLLM is an informational directory and does not control or maintain the underlying repository.
Any security checks, ratings, or warnings displayed by SkillsLLM are automated and limited in scope. They do not constitute a security certification or guarantee that the software is safe, error-free, or free from malicious code, vulnerabilities, compromised dependencies, or prompt-injection risks.
Review the source code, permissions, dependencies, and configuration before installing or running any third-party skill. Use is at your own risk. To the maximum extent permitted by applicable law, SkillsLLM is not liable for losses arising from third-party software.
English | 中文 | 한국어 | Français | Português
Cache optimization proxy for Claude Code. Fixes prompt cache bugs that cause excessive quota burn, stabilizes the request prefix, and monitors for silent regressions. Works with all CC versions including the v2.1.113+ Bun binary.
This README documents current main; release availability is noted per feature.
A local proxy sits between Claude Code and Anthropic. Before you read further, here is exactly what that means — the full treatment is in Security model.
127.0.0.1 by default.~/.claude/, never sent anywhere. Two opt-in features do perform their own
egress, both off unless you enable them: OAuth refresh
(CACHE_FIX_OAUTH_REFRESH=on) posts to Anthropic's token endpoint, and
forward-proxy download acceleration re-issues release downloads to
downloads.claude.ai / storage.googleapis.com.POST /v1/messages. That capability is the cache
repair — there is no version of this that works without it.proxy/extensions/, readable in isolation.Forward-proxy mode (--remote-control) additionally terminates TLS for
api.anthropic.com using a locally-generated CA, which your client must trust.
Everything else is blind-tunnelled. That mode is opt-in and off by default.
Install or test it if: resumed or long-running sessions show repeated
cache_creation_input_tokens spikes; your cache-read ratio is low or unstable;
you see unexpected TTL 5m downgrades, thinking-desync 400s, or image-retry
storms; or one of the non-cache surfaces documented below applies.
You can skip it if: your sessions already hold a stable high cache-read ratio; you rarely resume long sessions; you are not under quota pressure; or you would rather not place a local proxy in the API path. All four are good reasons not to install this.
If you are not sure which applies, measure it — you do not need this project installed to find out.
Claude Code already records per-request cache accounting in its own session transcripts, so you can measure your cache health right now, before installing anything.
# Replace <session-uuid>, or use a glob to pick your most recent session.
jq -r 'select(.message.usage.cache_read_input_tokens != null) |
"\(.requestId)\t\(.message.usage.cache_read_input_tokens) \(.message.usage.cache_creation_input_tokens)"' \
~/.claude/projects/*/<session-uuid>.jsonl |
sort -u -k1,1 | cut -f2 |
awk '{n++; r+=$1; c+=$2}
END {if (n==0) print "no usage rows found — check the session path";
else printf "requests=%d cache_read=%d creation=%d read-ratio=%.0f%%\n", n, r, c, 100*r/(r+c)}'
sort -u -k1,1 counts each API call once — Claude Code writes multiple
transcript rows per request, and not always the same number of times per
request (ArkNill's analysis).
Summing raw rows weights each call by its own duplicate count. Two independent
sweeps of the local transcripts on one machine (2026-08-02) agreed on the shape:
short sessions are where this bites — over half of sessions under 20 requests
shifted by a point or more without the dedup, worst case 41 points, while
long sessions were almost all sub-point (3 of ~37). Short sessions are exactly
what a first-time reader will run this against.
Reading the result:
creation spiking on every
--resume — that is the problem this project exists to fix.v4.0.0 — Local HTTP proxy with a pipeline of cost-impact and observability extensions. Two long-standing defaults flipped:
thinking-block-sanitizev1 is on by default (mitigates the thinking-desync400wedge — #63147) and in-process extension hot-reload is opt-in (CACHE_FIX_HOT_RELOAD=on). A/B baseline (v3.0.0 on v2.1.117): 95.5% cache hit rate through proxy vs 82.3% direct on first warm turn. Full release notes →
Opus 4.7 advisory: Metered data shows 4.7 burns Q5h quota at ~2.4x the rate of 4.6 for equivalent visible token counts (independently confirmed by @ArkNill). Two factors: a new tokenizer (up to 35% more tokens, documented) and adaptive thinking overhead (~105%, not documented in usage response). The Q5h impact compounds into Q7d — the weekly quota ceiling that most heavy users will hit first. Workaround:
CLAUDE_CODE_DISABLE_ADAPTIVE_THINKING=1reduces burn by ~3.3x but may reduce quality on complex tasks. See Discussion #25 (initial observation) and Discussion #42 (controlled A/B data + Q7d analysis).
The proxy works with any CC version — Node.js or Bun binary. It sits between Claude Code and the Anthropic API, applying cache fixes as composable extensions.
# Install
npm install -g claude-code-cache-fix
# Start the proxy (runs on localhost:9801)
node "$(npm root -g)/claude-code-cache-fix/proxy/server.mjs" &
# Launch Claude Code through it
ANTHROPIC_BASE_URL=http://127.0.0.1:9801 claude
That's it. The proxy applies its default extension pipeline automatically. No wrapper scripts, no NODE_OPTIONS, no preload.
The quick-start above is reverse-proxy mode: you point ANTHROPIC_BASE_URL at the proxy. That is simple, but on Claude Code >= 2.1.196 a non-Anthropic ANTHROPIC_BASE_URL disables Remote Control (/remote-control), /schedule, and claude.ai MCP connectors (CC treats any custom base URL like a Bedrock/Vertex gateway). If you rely on those features, use forward-proxy mode instead.
In forward-proxy mode the proxy sits in front of the real api.anthropic.com as an HTTPS_PROXY. Claude Code's base URL stays api.anthropic.com, so Remote Control keeps working, while the proxy still sees and transforms /v1/messages.
# Start the proxy in forward-proxy mode
CACHE_FIX_FORWARD_PROXY=on node "$(npm root -g)/claude-code-cache-fix/proxy/server.mjs" &
# It prints the two env vars to wire the client, e.g.:
# export HTTPS_PROXY=http://127.0.0.1:9801
# export NODE_EXTRA_CA_CERTS=~/.claude/cache-fix-ca/ca.pem
# Launch Claude Code through it (leave ANTHROPIC_BASE_URL UNSET)
HTTPS_PROXY=http://127.0.0.1:9801 \
NODE_EXTRA_CA_CERTS=~/.claude/cache-fix-ca/ca.pem \
claude
Or let the launcher do both steps for you with --remote-control:
# Spawns the proxy with CACHE_FIX_FORWARD_PROXY=on and wires the client
# (HTTPS_PROXY + the MITM CA, ANTHROPIC_BASE_URL left unset) automatically.
cache-fix-proxy --remote-control
The --remote-control flag is the one-command equivalent of the manual wiring above: it starts the proxy in forward-proxy mode, waits for the CA, and launches claude pointed at HTTPS_PROXY with NODE_EXTRA_CA_CERTS set (and adds 127.0.0.1,localhost,::1 to NO_PROXY so local services — e.g. HTTP/SSE-transport MCP servers on localhost — bypass the proxy rather than being routed at it; any existing NO_PROXY is preserved). Without the flag the launcher stays in reverse-proxy mode (sets ANTHROPIC_BASE_URL), unchanged. Two things worth knowing: Remote Control does a trusted-device enrollment on first connect that can need a few /remote-control retries (a Claude Code step that runs upstream, not a proxy failure); and enabling RC on an already-warm session costs a single prompt-cache rebuild (RC adds an anthropic-beta the cache keys on), so if you want RC, launching with --remote-control from the start avoids that one-time flip. cache-fix-proxy --help documents both.
If you wire forward-proxy mode manually (setting
HTTPS_PROXYyourself instead of using--remote-control), setNO_PROXY=127.0.0.1,localhost,::1as well, or local HTTP-transport MCP servers and other localhost services will be routed at the cache-fix proxy and fail. stdio-transport MCP servers are unaffected (they use pipes, not the network).
How it works: the p