能力标签
🛠
AI工具

Claude代码缓存修复工具

基于 JavaScript · 开源免费,本地部署,数据完全自主可控
英文名:claude-code-cache-fix
⭐ 270 Stars 🍴 20 Forks 💻 JavaScript 📄 NOASSERTION 🏷 AI 8.2分
8.2AI 综合评分
缓存优化成本控制Claude API代理工具
✦ AI Skill Hub 推荐

AI Skill Hub 强烈推荐:Claude代码缓存修复工具 是一款优质的AI工具。AI 综合评分 8.2 分,在同类工具中表现稳健。如果你正在寻找可靠的AI工具解决方案,这是一个值得深入了解的选择。

📚 深度解析

Claude代码缓存修复工具 是一款基于 JavaScript 的开源工具,在 GitHub 上收获 0k+ Star,是缓存优化、成本控制、Claude API、代理工具领域中的优质开源项目。开源工具的最大优势在于代码完全透明,你可以审计每一行代码的安全性,也可以根据自身需求进行二次开发和定制。

**为什么要使用开源工具而非商业 SaaS?**
对于个人开发者和有隐私需求的用户,本地部署的开源工具意味着数据不离本机,不受第三方服务商的数据政策约束。同时,开源工具通常没有使用次数限制和月度费用,一次安装即可长期使用,对于高频使用场景的总拥有成本(TCO)远低于订阅制商业工具。

**安装与环境准备**
Claude代码缓存修复工具 依赖 JavaScript 运行环境。建议通过 pyenv(Python)或 nvm(Node.js)管理 JavaScript 版本,避免全局环境污染。对于新手用户,推荐先创建虚拟环境(python -m venv venv && source venv/bin/activate),再安装依赖,这样即使出现问题也可以随时删除虚拟环境重新开始,不影响系统稳定性。

**社区与维护**
GitHub Issue 和 Discussion 是获取帮助的最快渠道。在提问前建议先检查 Closed Issues(已关闭的问题),大多数常见问题都已有解答。遇到 Bug 时,提供 pip list 的输出、完整错误堆栈和最小可复现示例,能显著提高开发者响应速度。AI Skill Hub 将持续追踪 Claude代码缓存修复工具 的版本更新,及时通知重要功能变化。

📋 工具概览

针对Claude Code提示词缓存回归问题的开源修复方案,可降低API成本20倍。通过API代理机制优化缓存策略,适合使用Claude Code进行开发的工程师和企业降低成本。

Claude代码缓存修复工具 是一款基于 JavaScript 开发的开源工具,专注于 缓存优化、成本控制、Claude API 等核心功能。作为 GitHub 开源项目,它拥有活跃的社区支持和持续的版本迭代,代码完全透明可审计,支持本地部署以保护数据隐私。无论是个人使用还是集成到企业工作流,都能提供稳定可靠的解决方案。

GitHub Stars
⭐ 270
开发语言
JavaScript
支持平台
Windows / macOS / Linux
维护状态
轻量级项目,按需更新
开源协议
NOASSERTION
AI 综合评分
8.2 分
工具类型
AI工具
Forks
20

📖 中文文档

以下内容由 AI Skill Hub 根据项目信息自动整理,如需查看完整原始文档请访问底部「原始来源」。

针对Claude Code提示词缓存回归问题的开源修复方案,可降低API成本20倍。通过API代理机制优化缓存策略,适合使用Claude Code进行开发的工程师和企业降低成本。

Claude代码缓存修复工具 是一款基于 JavaScript 开发的开源工具,专注于 缓存优化、成本控制、Claude API 等核心功能。作为 GitHub 开源项目,它拥有活跃的社区支持和持续的版本迭代,代码完全透明可审计,支持本地部署以保护数据隐私。无论是个人使用还是集成到企业工作流,都能提供稳定可靠的解决方案。

📌 核心特色
  • 开源免费,支持本地部署,数据完全自主可控
  • 活跃的 GitHub 开源社区,持续迭代更新
  • 提供详细文档和使用示例,新手友好
  • 支持自定义配置,灵活适配不同使用环境
  • 可作为基础组件集成进现有技术栈或进行二次开发
🎯 主要使用场景
  • 本地部署运行,保护数据隐私,满足合规要求
  • 自定义集成到现有系统,扩展技术栈能力
  • 作为开源基础组件进行商业化二次开发
以下安装命令基于项目开发语言和类型自动生成,实际以官方 README 为准。
安装命令
# 方式一: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
📋 安装步骤说明
  1. 访问 GitHub 仓库页面
  2. 按照 README 文档完成依赖安装
  3. 根据系统环境完成初始化配置
  4. 参考官方示例或文档开始使用
  5. 遇到问题可在 GitHub Issues 中查找解答
以下用法示例由 AI Skill Hub 整理,涵盖最常见的使用场景。
常用命令 / 代码示例
# 命令行使用
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"
📑 README 深度解析 真实文档 完整度 57/100 查看 GitHub 原文 →
以下内容由系统直接从 GitHub README 解析整理,保留代码块、表格与列表结构。

claude-code-cache-fix

npm Node.js License: MIT GitHub stars

English | 中文 | 한국어 | 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.

v3.0.3 — Local HTTP proxy with 7 hot-reloadable extensions. A/B tested 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=1 reduces 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).

Install

npm install -g claude-code-cache-fix

Docker

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

Setup

mkdir -p ~/.claude/hooks
cp "$(npm root -g)/claude-code-cache-fix/tools/quota-statusline.sh" ~/.claude/hooks/
chmod +x ~/.claude/hooks/quota-statusline.sh

Add to ~/.claude/settings.json:

{
  "statusLine": {
    "type": "command",
    "command": "~/.claude/hooks/quota-statusline.sh"
  }
}

Quick Start: Preload (CC v2.1.112 and earlier)

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.

Proxy configuration

All proxy settings are controlled via environment variables. Set them before starting the proxy server.

VariableDefaultDescription
CACHE_FIX_PROXY_PORT9801Listen port
CACHE_FIX_PROXY_BIND127.0.0.1Bind address
CACHE_FIX_PROXY_UPSTREAMhttps://api.anthropic.comUpstream URL. Change to chain another proxy (e.g. http://localhost:8080)
CACHE_FIX_PROXY_TIMEOUT600000Request timeout in milliseconds
CACHE_FIX_EXTENSIONS_DIRproxy/extensions/Directory for extension .mjs files
CACHE_FIX_EXTENSIONS_CONFIGproxy/extensions.jsonExtension configuration file
CACHE_FIX_DEBUG0Enable debug logging

Corporate environments (proxies, custom CAs)

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.

VariableEffect
HTTPS_PROXY / HTTP_PROXY (and lowercase variants)Routes upstream requests through the corporate HTTP CONNECT proxy.
NO_PROXYComma-separated host list to bypass the proxy. Supports * and .suffix.example.com.
CACHE_FIX_PROXY_CA_FILEPath to a PEM file with one or more extra CA certificates (for SSL-inspecting proxies).
NODE_EXTRA_CA_CERTSStandard 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).

Suggested `~/.claude/settings.json` env block

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.

System prompt rewrite (preload mode, optional)

The interceptor can rewrite Claude Code's # Output efficiency system-prompt section. Disabled by default. Enable with CACHE_FIX_OUTPUT_EFFICIENCY_REPLACEMENT. See docs/output-efficiency-prompts.md for the three known prompt variants and usage instructions.

Canonical filename rule — must mirror proxy/extensions/cache-telemetry.mjs

Image-guard pipeline (v3.3.0)

A conditional pipeline that mirrors Anthropic's actual rules. Strictly opt-in via a single env var:

export CACHE_FIX_IMAGE_GUARD=1

When enabled, the proxy runs:

PassTriggerAction
**Pass 0** (legacy)CACHE_FIX_IMAGE_KEEP_LAST=N setStrip tool_result images from user messages older than N most recent
**Pass 3**CACHE_FIX_IMAGE_PRESERVE_DETAIL=1 AND image long edge > model native capLanczos resize via sharp to native cap (2576 px for Opus 4.7, 1568 px otherwise), preserve aspect ratio and media type
**Pass 1**image long edge > active rejection capStrip and replace with forensic placeholder. Active cap = MAX_DIM if set, else 2000 px (when count > 20) or 8000 px (count ≤ 20)
**Pass 2**request body exceeds CACHE_FIX_IMAGE_REQUEST_SIZE_MAX (default 30 MB)Drop oldest images until under budget
**Count cap**surviving image count > CACHE_FIX_IMAGE_COUNT_MAX (default 100)Drop oldest images down to the cap

Execution order: Pass 0 → Pass 3 → Pass 1 → Pass 2 → count cap. Each pass is independent — Pass 1 never resizes; Pass 3 never strips.

Optional sharp dependency

Pass 3 requires sharp for Lanczos resize. It's declared as an optional peer dependency — install separately if you want Pass 3:

npm install sharp

If sharp is missing, Pass 3 skips cleanly (telemetry records library_missing: true); Pass 1 + Pass 2 + the count cap still run.

Precedence matrix

Env var combinationBehavior
Nothing setNo image processing (back-compat default; the extension short-circuits).
KEEP_LAST=N onlyExisting v3.2.1: count cap on tool_result images in user messages, runs first. No pipeline.
MAX_DIM=N onlyExisting v3.2.1: hard size cap, strip-only. No pipeline.
KEEP_LAST=N + MAX_DIM=NExisting v3.2.1 composition: KEEP_LAST runs first (drops count), then MAX_DIM runs on survivors (caps size). No pipeline, no Pass 2, no Pass 3.
IMAGE_GUARD=1New pipeline: Pass 1 (conditional cap) + Pass 2 (request-size guard) + image-count cap.
IMAGE_GUARD=1 + MAX_DIM=NMAX_DIM overrides Pass 1's conditional cap (acts as the cap value); Pass 2 still runs.
IMAGE_GUARD=1 + PRESERVE_DETAIL=1Adds Pass 3 (Lanczos resize via sharp). When sharp unavailable, falls back to strip behavior.
IMAGE_GUARD=1 + KEEP_LAST=NKEEP_LAST runs first as count cap (Pass 0); pipeline runs on remainder.
IMAGE_GUARD=1 + KEEP_LAST=N + MAX_DIM=NThree-way: KEEP_LAST runs first; pipeline runs on remainder, but MAX_DIM overrides Pass 1's conditional cap; Pass 2 still runs.
PRESERVE_DETAIL=1 without IMAGE_GUARD=1Logs warning, treats as no-op. PRESERVE_DETAIL is meaningless without the pipeline running.

Tunables

Env varDefaultPurpose
CACHE_FIX_IMAGE_GUARDunsetTop-level pipeline gate (=1 enables).
CACHE_FIX_IMAGE_PRESERVE_DETAILunsetEnable Pass 3 Lanczos resize via sharp.
CACHE_FIX_IMAGE_REQUEST_SIZE_MAX31457280 (30 MB)Pass 2 byte budget. 2 MB headroom from Anthropic's 32 MB ceiling.
CACHE_FIX_IMAGE_COUNT_MAX100Hard image-count cap. Set to 600 for legacy Claude 1/2.x/Instant if needed.

Explicit no-op (extension passes through unchanged)

export CACHE_FIX_THINKING_DISPLAY=disabled ```

The extension is default-on as of v3.6.1. The cache-prefix test measured 0% absolute drop in steady-state cache_read ratio when injection is active on Opus 4.7 (5 sequential claude -p calls per window, baseline vs injected — both windows held 1.000 cache_read ratio from call 2 onward). Adding thinking.display to the request body changes the bytes Anthropic hashes, but Anthropic's cache layer accepts and indexes the injected-prefix the same way it does any other prefix. Users who want the older "no injection" behavior (e.g. to avoid any request-body mutation at all) explicitly set CACHE_FIX_THINKING_DISPLAY=disabled.

Scoping rules baked into the extension:

  • Model-gated. Only fires on requests whose model matches /^claude-opus-4-7/ — covers claude-opus-4-7 and claude-opus-4-7-1m. Sonnet 4.7 needs separate verification (the API default-flip may differ); future versions (4.8+) require an explicit cache-fix bump rather than auto-applying unverified behavior.
  • User opt-out preserved. If the request already has thinking.display set (either "summarized" or "omitted"), the extension never overwrites. Explicit user choice always wins.
  • Thinking-active types only. The extension fires on thinking.type{ "enabled", "adaptive" } — the two active modes that produce thinking blocks on Opus 4.7. Other values ("disabled", future modes) are skipped. Conservative: if Anthropic ships a new thinking type with different display semantics, we'd rather miss the fix than auto-apply incorrect behavior.
Env varDefaultPurpose
CACHE_FIX_THINKING_DISPLAYsummarized (built-in)One of summarized / omitted / disabled. summarized restores thinking summaries (default). omitted force-suppresses thinking blocks. disabled opts the extension out entirely.

VS Code Extension

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.

🎯 aiskill88 AI 点评 A 级 2026-06-04

实用的成本优化工具,针对Claude API缓存问题提供直接解决方案。代码质量良好,社区关注度适中,适合有Claude API成本压力的开发者。

⚡ 核心功能

👥 适合人群

AI 技术爱好者研究人员和学生开发者和工程师技术创业者

🎯 使用场景

  • 本地部署运行,保护数据隐私,满足合规要求
  • 自定义集成到现有系统,扩展技术栈能力
  • 作为开源基础组件进行商业化二次开发

⚖️ 优点与不足

✅ 优点
  • +完全开源免费,无授权费用
  • +本地部署,数据完全自主可控
  • +开发者社区支持,遇问题可查可问
⚠️ 不足
  • 安装和初始配置可能需要一定技术基础
  • 功能完整性通常不如成熟商业产品
  • 技术支持主要依赖开源社区,响应速度不稳定
⚠️ 使用须知

该工具使用 NOASSERTION 协议,商用场景请仔细阅读协议条款,必要时咨询法律意见。

AI Skill Hub 为第三方内容聚合平台,本页面信息基于公开数据整理,不对工具功能和质量作任何法律背书。

建议在沙箱或测试环境中充分验证后,再部署至生产环境,并做好必要的安全评估。

📄 License 说明

📄 NOASSERTION — 请查阅原始协议条款了解具体使用限制。

🔗 相关工具推荐

🧩 你可能还需要
基于当前 Skill 的能力图谱,自动补全的工具组合

❓ 常见问题 FAQ

通过修复Claude Code的缓存机制,使提示词缓存正常工作,避免重复计费。
💡 AI Skill Hub 点评

总体来看,Claude代码缓存修复工具 是一款质量优秀的AI工具,在同类工具中具备一定竞争力。AI Skill Hub 将持续追踪其更新动态,建议收藏备用,结合自身场景选择合适时机引入使用。

📚 深入学习 Claude代码缓存修复工具
查看分步骤安装教程和完整使用指南,快速上手这款工具
🌐 原始信息
原始名称 claude-code-cache-fix
Topics 缓存优化成本控制Claude API代理工具
GitHub https://github.com/cnighswonger/claude-code-cache-fix
License NOASSERTION
语言 JavaScript
🔗 原始来源
🐙 GitHub 仓库  https://github.com/cnighswonger/claude-code-cache-fix 🌐 官方网站  https://github.com/cnighswonger/claude-code-cache-fix

收录时间:2026-06-04 · 更新时间:2026-06-04 · License:NOASSERTION · AI Skill Hub 不对第三方内容的准确性作法律背书。