cnighswonger/claude-code-cache-fix
Fixes prompt cache regression in Claude Code that causes up to 20x cost increase on resumed sessions
What it solves
claude-code-cache-fix is a cache optimization proxy designed for Claude Code. It addresses prompt cache bugs that lead to excessive quota consumption and unstable request prefixes, which can cause frequent cache misses and increased costs.
How it works
The tool operates as a local HTTP proxy that sits between Claude Code and the Anthropic API. It applies a pipeline of composable extensions to every /v1/messages request to stabilize the prompt and optimize caching. It supports two modes of operation:
- Reverse-proxy mode: The user points
ANTHROPIC_BASE_URLto the proxy. - Forward-proxy mode: The proxy acts as an
HTTPS_PROXYand uses a locally generated CA certificate to MITM only the upstream host (api.anthropic.com), allowing features like Remote Control to remain active.
Who it’s for
Developers using Claude Code who want to reduce their API quota burn, improve cache hit rates, and monitor cache telemetry.
Highlights
- Cache Stabilization: Includes extensions to remove unstable fingerprints, stabilize tool/MCP definition ordering, and normalize message identity fields.
- Thinking-Desync Mitigation: Automatically drops empty thinking blocks to prevent
400errors (thinking-desync). - Observability: Extracts cache statistics from response headers and logs them to local JSON files.
- Flexible Deployment: Can be run as a standalone Node.js process, a managed system service (systemd/launchd), or via Docker.
- Performance: Demonstrated a cache hit rate increase from 82.3% to 95.5% in A/B testing.