AI Skill Hub 强烈推荐:Claude代码缓存修复工具 是一款优质的AI工具。AI 综合评分 8.2 分,在同类工具中表现稳健。如果你正在寻找可靠的AI工具解决方案,这是一个值得深入了解的选择。
针对Claude Code提示词缓存回归问题的开源修复方案,可降低API成本20倍。通过API代理机制优化缓存策略,适合使用Claude Code进行开发的工程师和企业降低成本。
Claude代码缓存修复工具 是一款基于 JavaScript 开发的开源工具,专注于 缓存优化、成本控制、Claude API 等核心功能。作为 GitHub 开源项目,它拥有活跃的社区支持和持续的版本迭代,代码完全透明可审计,支持本地部署以保护数据隐私。无论是个人使用还是集成到企业工作流,都能提供稳定可靠的解决方案。
针对Claude Code提示词缓存回归问题的开源修复方案,可降低API成本20倍。通过API代理机制优化缓存策略,适合使用Claude Code进行开发的工程师和企业降低成本。
Claude代码缓存修复工具 是一款基于 JavaScript 开发的开源工具,专注于 缓存优化、成本控制、Claude API 等核心功能。作为 GitHub 开源项目,它拥有活跃的社区支持和持续的版本迭代,代码完全透明可审计,支持本地部署以保护数据隐私。无论是个人使用还是集成到企业工作流,都能提供稳定可靠的解决方案。
# 方式一:npm 全局安装 npm install -g claude-code-cache-fix # 方式二:npx 直接运行(无需安装) npx claude-code-cache-fix --help # 方式三:项目依赖安装 npm install claude-code-cache-fix # 方式四:从源码运行 git clone https://github.com/cnighswonger/claude-code-cache-fix cd claude-code-cache-fix npm install npm start
# 命令行使用
claude-code-cache-fix --help
# 基本用法
claude-code-cache-fix [options] <input>
# Node.js 代码中使用
const claude_code_cache_fix = require('claude-code-cache-fix');
const result = await claude_code_cache_fix.run(options);
console.log(result);
# claude-code-cache-fix 配置说明 # 查看配置选项 claude-code-cache-fix --config-example > config.yml # 常见配置项 # output_dir: ./output # log_level: info # workers: 4 # 环境变量(覆盖配置文件) export CLAUDE_CODE_CACHE_FIX_CONFIG="/path/to/config.yml"
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.
npm install -g claude-code-cache-fix
A multi-arch (amd64, arm64) container image is published to GitHub Container Registry on every release tag.
```bash docker run -d --name cache-fix-proxy \ --restart=always \ -p 9801:9801 \ ghcr.io/cnighswonger/claude-code-cache-fix:latest
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.
```bash
If you're on a Node.js-based CC version (v2.1.112 or earlier), the preload interceptor works without a proxy:
npm install -g claude-code-cache-fix
NODE_OPTIONS="--import claude-code-cache-fix" claude
Note: The preload does NOT work on CC v2.1.113+ (Bun binary). Use the proxy above.
See docs/preload-setup.md for wrapper scripts, shell aliases, Windows instructions, and VS Code preload-mode integration.
All proxy settings are controlled via environment variables. Set them before starting the proxy server.
| Variable | Default | Description |
|---|---|---|
CACHE_FIX_PROXY_PORT | 9801 | Listen port |
CACHE_FIX_PROXY_BIND | 127.0.0.1 | Bind address |
CACHE_FIX_PROXY_UPSTREAM | https://api.anthropic.com | Upstream URL. Change to chain another proxy (e.g. http://localhost:8080) |
CACHE_FIX_FORWARD_PROXY | unset | Set to on for forward-proxy mode (HTTP CONNECT + selective MITM of the upstream host) so the client points HTTPS_PROXY at the proxy instead of ANTHROPIC_BASE_URL, keeping Remote Control enabled. See [Forward-proxy mode](#forward-proxy-mode-keeps-remote-control-working). |
CACHE_FIX_CA_DIR | ~/.claude/cache-fix-ca | Directory for the forward-proxy CA/leaf cert (generated once on first start). The client trusts ca.pem via NODE_EXTRA_CA_CERTS. |
CACHE_FIX_PROXY_TIMEOUT | 600000 | Request timeout in milliseconds |
CACHE_FIX_EXTENSIONS_DIR | proxy/extensions/ | Directory for extension .mjs files |
CACHE_FIX_EXTENSIONS_CONFIG | proxy/extensions.json | Extension configuration file |
CACHE_FIX_DEBUG | 0 | Enable debug logging |
CACHE_FIX_HOT_RELOAD | unset | Set to on to enable in-process extension hot-reload. Off by default as of v4.0.0 — see [Upgrading from v3.x](#upgrading-from-v3x) for details and the supervisor restart flow. |
CACHE_FIX_READ_DEDUPE | unset | Set to 1 to dedupe repeat Read tool results that re-appear unchanged across turns. Keeps the first occurrence intact; replaces later byte-identical ones (keyed on file_path + content + offset + limit) with a stable pointer line. Default-off; opt in per session to validate before broader rollout. See [extension impact guide](docs/extension-impact-guide.md). |
CACHE_FIX_ADVISOR_PLAN | unset | Plan override for tools/tier-advisor.mjs — one of max-5x, max-20x, pro. Bypasses heuristic plan detection. See [Tier advisor](docs/tier-advisor.md). |
CACHE_FIX_ADVISOR_UPGRADE_THRESHOLD | 80 | Projected-Q7d percent that triggers an UPGRADE recommendation from tier-advisor. |
CACHE_FIX_ADVISOR_DOWNGRADE_THRESHOLD | 20 | Projected-Q7d percent that triggers a DOWNGRADE recommendation from tier-advisor (paired with the DOWNGRADE_WEEKS consecutive-weeks gate). |
CACHE_FIX_ADVISOR_DOWNGRADE_WEEKS | 2 | Consecutive completed weeks under the downgrade threshold required before tier-advisor recommends downgrade. Single-week dips never trigger; single-week spikes DO trigger upgrade (cost-of-being-throttled asymmetry). |
The proxy honors the following environment variables when forwarding to api.anthropic.com. Behind Zscaler / Netskope / Forcepoint / Bluecoat / corporate squid, set these in the proxy's environment.
| Variable | Effect |
|---|---|
HTTPS_PROXY / HTTP_PROXY (and lowercase variants) | Routes upstream requests through the corporate HTTP CONNECT proxy. |
NO_PROXY | Comma-separated host list to bypass the proxy. Supports * and .suffix.example.com. |
CACHE_FIX_PROXY_CA_FILE | Path to a PEM file with one or more extra CA certificates (for SSL-inspecting proxies). |
NODE_EXTRA_CA_CERTS | Standard Node mechanism — also honored. |
CACHE_FIX_PROXY_REJECT_UNAUTHORIZED=0 | **Insecure escape hatch.** Disables TLS verification. Use only as a last resort while you wait for IT to provide the corp CA bundle. |
Example (Windows PowerShell):
$env:HTTPS_PROXY = 'http://proxy.corp.example:8080'
$env:NO_PROXY = 'localhost,127.0.0.1,.corp.example'
$env:CACHE_FIX_PROXY_CA_FILE = 'C:\corp\zscaler-root.pem'
node "$(npm root -g)\claude-code-cache-fix\proxy\server.mjs"
Stderr will print [upstream] using proxy http://proxy.corp.example:8080 ... on first request when the agent is wired correctly. With no proxy/CA env vars set, behavior is unchanged from earlier versions (Node default agent, system trust store).
The proxy fixes what it can fix at the request layer. A handful of CC client-side env vars and ~/.claude/settings.json knobs solve adjacent problems the proxy can't reach — silent model swaps on CC update, ambiguous model fallback, schema-strip side effects. Surfacing these here as a recommendation; users decide their own config.
These findings come from @fgrosswig's binary analysis of CC v2.1.91. Methodology is public PowerShell + ASCII string extraction; he shared the resulting punch list privately as a courtesy.
The model IDs below are illustrative — replace with your preferred main and small-fast models. The point is that pinning something explicit beats relying on CC's defaults.
{
"env": {
"CLAUDE_CODE_DISABLE_LEGACY_MODEL_REMAP": "1",
"ANTHROPIC_MODEL": "claude-opus-4-7",
"ANTHROPIC_SMALL_FAST_MODEL": "claude-haiku-4-5-20251001"
}
}
CLAUDE_CODE_DISABLE_LEGACY_MODEL_REMAP=1 — single most impactful flag. CC has a legacy code path that silently remaps your pinned model to a different one after certain version updates. Setting this to 1 disables the remap; the model you pin is the model you get. (If you don't pin, CC's defaults apply as usual.)
ANTHROPIC_MODEL — pins the primary model. Keeping this explicit means the cache prefix hash stays stable across CC version bumps that would otherwise swap your default. Adjust to whichever model you actually want.
ANTHROPIC_SMALL_FAST_MODEL — pins the side-channel "fast" model CC uses for short auxiliary calls (e.g., title generation, classification). Without an explicit pin, this can silently fall back to a different family on update.
v4.0.0 flips CACHE_FIX_THINKING_SANITIZE from default-off to default-on. The v1 omitted-text drop will run on every request body passing through the embedded proxy. If your host depends on the prior no-sanitization behavior (e.g., your downstream code expects empty thinking blocks to survive the proxy round-trip), preserve it by either:
CACHE_FIX_THINKING_SANITIZE=off in your host's environment, ORprocess.env.CACHE_FIX_THINKING_SANITIZE = "off" in your code at any point before request handling — the mode is read per-request via modeFromEnv(), not cached at module load.The flip is backed by 7 days of prod dogfood (37 sessions, zero cannot be modified 400s, cache hit-rate aggregate 94.66% vs 92.44% baseline). See PR #201 for the validation data and #63147 for upstream context.
Picking up a new extension or a code change to an existing one in v4.0.0 requires a supervisor-level proxy restart. There are two upgrade flows depending on whether you also want to opt back into hot-reload.
The VS Code extension (v0.5.0) supports both proxy and preload modes:
Proxy mode (recommended): 1. Start the proxy (see above) 2. In VS Code command palette: Claude Code Cache Fix: Enable Proxy Mode 3. Restart any active Claude Code session
Preload mode (CC ≤v2.1.112): 1. npm install -g claude-code-cache-fix 2. Download the VSIX from GitHub Releases 3. Install: code --install-extension claude-code-cache-fix-0.5.0.vsix 4. Command palette: Claude Code Cache Fix: Enable
For manual VS Code wrapper setup (without the VSIX), see docs/preload-setup.md.
实用的成本优化工具,针对Claude API缓存问题提供直接解决方案。代码质量良好,社区关注度适中,适合有Claude API成本压力的开发者。
该工具使用 NOASSERTION 协议,商用场景请仔细阅读协议条款,必要时咨询法律意见。
AI Skill Hub 为第三方内容聚合平台,本页面信息基于公开数据整理,不对工具功能和质量作任何法律背书。
建议在沙箱或测试环境中充分验证后,再部署至生产环境,并做好必要的安全评估。
📄 NOASSERTION — 请查阅原始协议条款了解具体使用限制。
总体来看,Claude代码缓存修复工具 是一款质量优秀的AI工具,在同类工具中具备一定竞争力。AI Skill Hub 将持续追踪其更新动态,建议收藏备用,结合自身场景选择合适时机引入使用。
| 原始名称 | claude-code-cache-fix |
| 原始描述 | 开源AI工具:Fixes prompt cache regression in Claude Code that causes up to 20x cost increase。⭐270 · JavaScript |
| Topics | 缓存优化成本控制Claude API代理工具 |
| GitHub | https://github.com/cnighswonger/claude-code-cache-fix |
| License | NOASSERTION |
| 语言 | JavaScript |
收录时间:2026-06-04 · 更新时间:2026-06-05 · License:NOASSERTION · AI Skill Hub 不对第三方内容的准确性作法律背书。