Get the most from CoreCode
Caching and billing
Every turn, Claude Code resends the system prompt, the tool definitions and the whole conversation. When that hits the prompt cache it is billed as a cache read, at 2.5–10% of the normal input price, 5% on Opus 5.5 and Sonnet 5.5. So the cache hit rate largely decides what you spend. Ways to save beyond caching are in Spending less on Claude Code.
CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS set, every tool call is preceded by an extra check request that almost never hits the cache; it shows as Non-stream in the usage logs. It can be more than half of your spend. See The cost of auto mode.How caching is billed
Anthropic's prompt cache matches by prefix: a request reads the cache only if its beginning is identical to content cached before. A request's input is billed in three parts:
| Part | Meaning | Relative to the input price |
|---|---|---|
| Cache read | The part identical to a cached prefix | 0.05× on Opus 5.5 and Sonnet 5.5; 0.1× on Haiku 5.5; 0.025× on Fable 5.1 |
| Cache write | The part newly written to the cache. Five-minute and one-hour entries are priced differently | About 1.25× for five minutes, 2× for one hour |
| Input | The part that is not cached, usually a few tokens in Claude Code | 1× |
Unit prices are on the Pricing page. In a normal Claude Code session each turn writes only the few hundred to few thousand new tokens, and the remaining hundreds of thousands are cache reads. Once the prefix changes, the whole context is written again at the write price, often hundreds of thousands of tokens at once.
What CoreCode does
- Native pass-through:
/v1/messagesis not translated.cache_controlmarkers andanthropic-betaheaders reach Anthropic unchanged, so the one-hour cache works too. - Session affinity: one Claude Code session (by session ID and model) stays on one upstream account, so the cache is not lost to an account switch; the binding is restored after a service restart.
- Official pricing terms: input, output, cache reads, and five-minute and one-hour cache writes are billed separately, and every record is in the Usage Logs.
When the cache breaks depends on what the client sends. The cases below are Claude Code's own behavior and are the same through any relay or directly with Anthropic.
The cost of auto mode
Claude Code's auto permission mode decides by itself whether an action may run instead of asking you each time. Each checked action still needs a judgement. From v2.1.278, when requests go through a gateway or proxy, Claude Code first asks the server to review actions inside the normal model requests, with no extra request. CoreCode passes those requests and the review results through unchanged: in a test on October 30, 2026, auto mode on Opus 5.5 and Sonnet 5.5 was reviewed by the server, with only the main conversation's requests and no extra cost.
When the server does not review, Claude Code falls back to the old way: before each tool call it sends a separate classifier request with part of the transcript and the pending action to a model, which decides whether to allow it. The official documentation states that on API keys or relays these classifier requests count toward token usage. On CoreCode, the sessions that fall back are almost all ones that set CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS, which also turns server review off. Setting CLAUDE_CODE_AUTO_MODE_SERVER=0 does the same.
These checks can also be refused: a check hands the model part of the transcript and asks it to write out its reasoning before the verdict. On CoreCode we have repeatedly seen Anthropic's safety classifier refuse such requests as reasoning extraction (reasoning_extraction). What is refused is Claude Code's own check, not anything you wrote, and CoreCode does not penalize your account for it, but the same check is not forwarded again and a resend is stopped (see 403). Remove CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS and let the server review, and these separate checks stop.
Which model the classifier uses when it falls back: Anthropic's default is Claude Sonnet 5. CoreCode serves Sonnet 5.5, Opus 5.5, Haiku 5.5 and Fable 5.1, not Sonnet 5, and under Anthropic's rules Claude Code then uses your session's model instead. So when you code with Opus, every check is billed at Opus rates too.
When it falls back to separate classifier requests, this is what they cost.
The problem is that only the first small part of this check hits the cache. The remaining tens of thousands of tokens are written again every time, and the next check cannot use what this one wrote. In one real case:
- The main conversation hit the cache over 95% of the time, reading two to three hundred thousand cached tokens per turn, with no problem.
- Each tool call added a check request: only ten to twenty thousand cached tokens read, about 65 thousand newly written, and a few dozen output tokens.
- These checks were a third of the requests but used 60% of the credit.
How to spot it
- The stream column in the usage logs shows Non-stream. Claude Code's main conversation always streams, so non-stream requests are almost always these checks.
- It usually follows a streaming request within seconds, with few cache reads, tens of thousands of cache writes and a very short output.
- The console marks it as a cache miss. Hovering shows a tooltip saying it is most likely an auto mode check, and the overview page's notice calls this out separately when such requests are the majority.
How to confirm auto mode is on
- From Claude Code v2.1.283, new terminal and VS Code sessions start in auto by default, with nothing set by you. The status bar shows
⏵⏵ auto mode on. - The launch command includes
--permission-mode auto. - You switched permission modes with Shift+Tab during the session, and the bar under the input box shows auto.
What to do
- Remove
CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS: check theenvblock of~/.claude/settings.json, your project's.claude/settings.jsonand your shell profile, and delete it, along with anyCLAUDE_CODE_AUTO_MODE_SERVER=0. CoreCode needs neither. Start a new session and auto mode is reviewed by the server, with no separate checks./statusshowingAuto mode serverasEnabledconfirms it. - Turn auto off when you do not need to leave it unattended: press Shift+Tab to switch to Manual or accept-edits mode, and the checks stop. To start every session in Manual, put this in
~/.claude/settings.json:
To start in accept-edits instead, use{ "permissions": { "defaultMode": "default" } }acceptEditsin place ofdefault. - Use a cheaper classifier model: since Claude Code v2.1.302 the environment variable
CLAUDE_CODE_AUTO_MODE_MODELsets the classifier model; give a full model ID. When you code with Opus, set it toclaude-sonnet-5-5and checks are billed at Sonnet rates:
The classifier judges whether an action is safe, and a smaller model judges less well; weigh that yourself.{ "env": { "CLAUDE_CODE_AUTO_MODE_MODEL": "claude-sonnet-5-5" } } - Accept the cost: auto mode buys you not having to confirm each action. If you need it, this spend is expected and not a relay problem.
Other causes of misses
These change the prefix Claude Code sends, so the next turn rewrites the whole cache:
| Case | Details |
|---|---|
| Switching models mid-session | The cache is per model, so another model starts from zero. When you switch back, the original model's cache may have expired. |
Changing thinking effort or /fast | Effort and fast mode also change the request and break the cache. |
| Pausing for more than 5 minutes | The default cache lasts only 5 minutes; after a coffee break the first turn rewrites everything. If you pause often, see One-hour cache. |
| An MCP server connecting or disconnecting | Tool definitions come first in the request, so a change to the tool list changes the whole prefix. Keeping Claude Code's default MCP tool search on avoids this; do not set ENABLE_TOOL_SEARCH=false. |
| Enabling or disabling a plugin | A plugin that brings an MCP server has the same effect as the previous row. |
/compact | Compacting rewrites the history, so the first turn after it writes again; afterwards the session is shorter and cheaper. |
| Upgrading Claude Code | A new version has a different system prompt, so the first turn after upgrading rewrites. |
A new session, /clear, or --resume after a long time | A new session writes the cache from the start. When you resume an old session, its cache has most likely expired. |
Editing CLAUDE.md does not break the cache right away, but it does not take effect right away either; it waits for /clear, /compact or a restart. How to write it well is in How to write CLAUDE.md.
To hit the cache more: finish a task in one session where you can, without switching models or thinking effort midway; when the context gets long, compact it with /compact rather than starting a new session and rebuilding the context.
One-hour cache
If you often stop to think for five to sixty minutes before continuing, have Claude Code write one-hour cache entries. Add one line to env in ~/.claude/settings.json (needs Claude Code v2.1.242 or later):
"CLAUDE_CODE_PROMPT_CACHE_TTL": "1h"
A one-hour cache write costs about 2× the input price, a five-minute write about 1.25×. With few pauses each write costs more; with many pauses the full rewrites you avoid save much more. CoreCode forwards the headers the one-hour cache needs unchanged, so nothing else needs setting.
Investigate in the logs
Open the Usage Logs and read consecutive requests of one session in time order:
- Cache reads keep growing and cache writes are a few hundred to a few thousand: normal; each turn writes only what is new.
- One request's cache read suddenly drops to zero or very little, and its cache write is close to the whole context: the prefix changed; compare with the table above for what you did then. If you had paused for more than five minutes before it, the cache expired.
- Non-stream requests in between, each writing tens of thousands: auto mode checks; see The cost of auto mode.
In Claude Code, /usage (or /cost) shows this session's token usage and cost, and /context shows what is filling the context.
If the logs still do not explain it, send us the times of those requests from your usage logs and we can check the upstream account and routing.
Other models on the bill
Even if you only code with Opus, Haiku or Sonnet can appear on the bill, usually because of:
- Background tasks: Claude Code uses a small model for background work such as conversation summaries and titles, costing very little each time.
- Subagents: a subagent can be set to Sonnet or Haiku.
- Auto mode's classifier: Sonnet by default; see above.
Find the matching records by time in the usage logs to see which model each one used and what it cost.