Tue 27 Oct 2026 EN ES
Guides

Keep Claude Code sessions cheap: a cache-miss checklist

Treat cache-key changes, compaction, and beta switches as expensive operations, then verify hit rate after the warm turn.

Illustration: Keep Claude Code sessions cheap: a cache-miss checklist

Your session has been warm, then the bill jumps. Opus 4.7 metering indicated Q5h quota consumption running at roughly 2.4 times the Opus 4.6 rate for similar visible token counts. Claude Code 2.1.260 exposed a probable prompt-cache miss reason in /cost and the status line. That label is a triage tool; savings still depend on the next request.

The cause label narrows the search

A miss can come from a changed model, a new tool definition, a beta flag, or a context rebuild. The /cost cause field gives you the first clue. If the cause points to a setting you changed, fix the setting. If it points to a rebuild you expected, note the cost and move on. Use it to pick the next input to inspect. A context rebuild is the expected cost of a big change; a surprise rebuild is the one to chase.

Prefix changes are the expensive part

A prompt cache only helps when the beginning of the request stays the same. The prefix includes the model, system prompt, tools, and beta values the client sends. Change one of those and the cached prefix can become stale. An edit early in the request is the one to watch. Batch changes: put a new tool, model, or beta before the session warms, or at a point where a one-time rebuild is affordable. During a long task, keep the prefix stable.

Turning on Remote Control in a warm Claude Code session triggers a one-time prompt-cache rebuild because the feature adds an anthropic-beta value to the cache key. Claude Code 2.1.196 and newer disable Remote Control, /schedule, and claude.ai MCP connectors when ANTHROPIC_BASE_URL points to a non-Anthropic endpoint. If you run a proxy, test that path before relying on remote features in a long session. A proxy can be a useful test bench, but it can also alter the request.

Compaction is a budget decision

Compaction rewrites context, and a rewritten context can break the prefix that made the session cheap. Claude Code 2.1.260 moved auto-compact to trigger just before the 1M-token ceiling for Opus and Fable sessions, while /ultrareview was given a maximum wait of 45 minutes instead of 30.

Force compaction early and you may pay a rebuild to save tokens you had not yet needed. Wait until the ceiling and the tool handles overflow, but the task still has to survive a compressed context. The ceiling is a safety valve, not a target. A compressed context may keep the task moving, or it may drop the detail the next step needs. For long work, compact at a task boundary, not in the middle of a delicate refactor. Treat the longer /ultrareview wait as a cost item. Budget for it. Write down the token count before and after, so the rebuild cost is visible.

The checklist turns the bill into a debug question

The list below is the part you keep. Each item is a one-minute check. Run the items in the order the failure modes appear: cause, prefix, beta switch, compaction, verification. Use the list to make the next warm turn cheaper. The current bill is history.

  • Check /cost for the miss cause and note whether it follows a setting change.
  • Freeze model, system prompt, tools, and beta flags until the warm turn is verified.
  • Avoid enabling remote control mid-session unless you can afford a rebuild.
  • Let auto-compact run near the ceiling instead of forcing it early.
  • Verify hit rate after the warm turn before starting the next long task.

The claude-code-cache-fix v3.0.0 A/B baseline on Claude Code v2.1.117 reported a 95.5% first-warm-turn cache hit rate through the proxy compared with 82.3% direct. That comparison is not a promise for your setup. The warm turn is the number to watch. Record the hit rate, the cause label, and the setting you changed, so the next spike is easier to attribute. If the warm turn still misses, use the cause label to find the next input to freeze.

Advertisement