Skip to content

Claude Code Cache Optimization Proxy

claude-code-cache-fix is a small third-party open-source tool that helps Claude Code save credit. It sits like a "middleman" between your computer and the upstream, tidying up each request and adding the correct cache markers so the upstream is more likely to hit the cache, which means spending less credit. It won't make the AI smarter — it just makes your credit last longer.

Third-party tool notice

claude-code-cache-fix is not maintained by Tianshu, and requests pass through a local proxy. Review its source code and dependencies yourself before installing.

Who it's for

  • ✅ Heavy Claude Code users who care about credit
  • ✅ People who often --resume long sessions and run a bunch of MCP / Skills
  • ✅ People willing to touch the command line a little
  • ❌ Users who don't want to touch a terminal at all and just want it to work out of the box (you can skip it for now)

Windows users should use WSL

We don't recommend using this tool in native Windows CMD / PowerShell. Windows users should set up the whole stack — Node.js, Claude Code, Tianshu, and this tool — inside a WSL Linux environment, to avoid mismatched paths / environment variables / ports.

Minimal verification flow

On Linux / macOS / WSL, first verify the proxy works (with upstream pointing to Tianshu):

bash
npm install -g claude-code-cache-fix
CACHE_FIX_PROXY_UPSTREAM=https://tian-shu.org cache-fix-proxy server

If you use the direct route, change CACHE_FIX_PROXY_UPSTREAM to https://api.tian-shu.org.

Point Claude Code at the local proxy

After the proxy starts, change ANTHROPIC_BASE_URL in Claude Code's settings.json to the local proxy address, keeping ANTHROPIC_AUTH_TOKEN as your Tianshu token:

json
{
  "env": {
    "ANTHROPIC_BASE_URL": "http://127.0.0.1:9801",
    "ANTHROPIC_AUTH_TOKEN": "xxx",
    "CLAUDE_CODE_ATTRIBUTION_HEADER": "0",
    "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1",
    "CLAUDE_CODE_DISABLE_TERMINAL_TITLE": "1"
  }
}

Open another terminal to check the proxy's health:

bash
curl http://127.0.0.1:9801/health

Once it returns {"status":"ok"} and running claude again replies normally, the proxy and Tianshu are connected.

Long-term use

Starting the proxy manually is only good for quick verification. For long-term use, set the proxy up as a background service (systemd / launchd, etc.) so you don't have to start it manually before each Claude Code session.

Let AI help you configure it

This tool involves a local proxy, environment variables and a background service, which are easy to get wrong by hand. You can send your system environment, the Tianshu endpoint, and the tool's GitHub project link to an AI and have it generate the commands for your machine. Be sure to point upstream at https://tian-shu.org and use your Tianshu token.

It can't solve every credit problem

This tool only optimizes issues related to local request structure and caching. The model's own price, long-context consumption, choosing the wrong model, frequent large file reads, and the like still need to be addressed separately.