Articles Article 008

Claude Code's prompt cache: a cold miss costs more than no cache

How Claude Code's prompt cache works, what breaks it, what a miss costs, and the habits that keep long sessions cheap, as of November 2026.

Published
Nov 9, 2026
Length
7 min read · 1528 words
Diagram titled 'A cold miss costs more than no cache': the same request (system + tools, CLAUDE.md, messages, new) drawn twice. On the warm turn a grey line marks the prefix as read at 0.05x and a green line marks the new message as written at 1.25–2x. On the cold turn one green line marks everything written again. Beside it, bars for the input cost of one Opus 5.5 turn at 100k tokens: warm $0.03, no caching $0.41, cold 5 min $0.51, cold 1 hour $0.82, the cold bars in green.
Contents
  1. 1The cache only matches the start of the request
  2. 2A cold miss costs more than no cache
  3. 3Seven habits do most of the work
  4. 4Most switches break it; most settings don’t
  5. 5How long the cache lives depends on how you pay
  6. 6Where people disagree
  7. 7Watch two open questions
In short
  1. Every Claude Code turn re-sends the whole conversation. A warm cache bills that history at 5% of the input price on Opus 5.5; a cold miss rewrites it at 125% or 200%, more than no caching at all1,2.
  2. Common causes of misses include switching model, fast mode or (on most models) effort, compacting, and idling past the cache lifetime. Editing CLAUDE.md, running skills and spawning subagents keep the cache1.
  3. Pick the model at the start, compact while the cache is warm, start fresh from a handoff once you no longer need the full history, watch the cache timer, and if you pay per token, consider a 1-hour cache1,3,4,5.

In a long Claude Code session, your next prompt is cheap. The expensive one is the first after lunch or after a model switch, when the prompt cache misses and the whole conversation is processed and stored again. As of November 2026, Claude Code shows the cache state and lets you choose its lifetime, so you can see and avoid those misses1,4,5.

The dollar figures below apply to token billing: an API key, a cloud provider or usage credits. On a Pro, Max or Ultra plan, usage comes out of your plan’s limits instead, Anthropic says the session’s dollar figure “isn’t relevant for billing purposes”, and it doesn’t publish how cache reads and writes count against those limits. The habits still help there, but the savings can’t be computed from these prices4.

The cache only matches the start of the request

Every Claude Code turn is a new API request carrying the system prompt, tools, project context and every earlier message1. The server finds the longest start of that request, the prefix, that a recent request already stored, and bills it at the cheap read rate1,6. The match is exact: change one byte, and everything from there on is processed again3. That is why Claude Code orders the request from stable to volatile and puts file changes and the date in messages at the end, not in the system prompt1,7.

Each turn reads the old prefix and writes only the new tail
× base input price
Source: Layers and miss causes: Anthropic1,2. Widths are not to scale.

A cold miss costs more than no cache

Storing a prefix costs a premium and reading it earns a discount: 1.25x the base input price for a 5-minute write, 2x for a 1-hour write, and 0.1x for a read, or 0.05x on Opus 5.5 and Sonnet 5.52. Each read also resets the timer6.

One turn at 100k tokens: warm vs cold
US dollars, input only
Source: 100k tokens of cached context plus 2k new tokens, input only (output excluded). Opus 5.5 list prices per million tokens as of October 2026: $4 input, $5 5-minute write, $8 1-hour write, $0.20 read. Elmayan3, recomputed from Anthropic’s price list2.

A 5-minute write pays for itself from the second request, a 1-hour write from the third2. Everything else in this post is about staying in the top two rows.

Video thumbnail: the words 'Prompt Caching' above a hand-drawn stack of system prompt, tools and skills, and messages, labelled 'prefix (discounted price)', with a new message at full price below it, next to the presenter.
Watch on YouTube: “Prompt Caching Explained: Stop Overpaying for AI Agents” (Alejandro AO, Hugging Face channel, 10 August 2026, 17:15). From 11:30, a session chart shows lunch and dinner breaks as fresh cache writes. Not Claude Code-specific8.

Seven habits do most of the work

  1. Choose model, effort and fast mode at session start. Each model has its own cache, so /model mid-task rereads everything1. At 100k tokens of context, staying on Opus 5.5 reads the history for $0.02; switching to Sonnet 5.5 writes it for $0.25, or $0.40 with a 1-hour cache (our arithmetic from Anthropic’s price list)2. For cheaper-model work, hand the task to a subagent instead: it builds its own cache and leaves yours warm. A fork (/fork, or a skill with context: fork) reads your cache only while it stays on your model1,7.
  2. Compact while the cache is warm. A warm /compact “costs a fraction of what the context size suggests”; a cold one reprocesses the whole history uncached1. Compact at natural breaks between tasks, not mid-task, because the summary is lossy3.
  3. Start fresh from a handoff when you no longer need the full history. /clear “costs nothing”4, and a short handoff note that Claude writes while the cache is warm carries what matters into the next session3. Elapsed time alone shouldn’t decide: if you still need the history, one rebuild can be worth paying for. Just know that /resume after the cache has expired rewrites the whole history1; /rename keeps the old session findable for when you need it4.
  4. To abandon a path, rewind. /rewind returns to a turn whose prefix is already cached and kept warm by every later turn1.
  5. Watch the timer. The cache lifetime, or time to live (TTL), is 5 minutes or 1 hour. /usage has a “Prompt cache (main)” line: hit ratio, misses, warm or cold, the TTL in effect and the likely cause of the last miss4. The status line receives a prompt_cache object with expires_at and recache_tokens_if_cold, the tokens your next request rewrites if the cache has gone cold5. One command generates the script5,3:

    /statusline show the prompt cache status: warm or cold, the TTL and the minutes left before it expires
  6. Keep the base context small. Cached reads are cheap but not free: a one-line question in an all-day session “still draws usage for the whole conversation”4. Keep CLAUDE.md under 200 lines, move specialised instructions into skills, and send noisy test or log output to subagents4.
  7. Leave tool search on, and keep /advisor off if cost matters. Tool search, the default on supported models, stops Model Context Protocol (MCP) server changes from breaking the cache1. The advisor reads the full transcript uncached on every call9.

Most switches break it; most settings don’t

Breaks the cache / keeps the cache
November 2026
Breaks the cacheKeeps the cache
  • /model switch, including opusplan plan-mode toggles and skills that name another model
  • Effort change, except on Opus 5.5, Sonnet 5.5, Haiku 5.5 and Fable 5.1 with an API key or subscription
  • Fast mode on or off
  • Connecting or disconnecting an MCP server, or denying a whole tool, only when tool search is off
  • /compact (conversation layer only)
  • Dropping the oldest images
  • Upgrading Claude Code
  • Idling past the TTL
  • Editing repo files
  • Editing CLAUDE.md (applies at /clear, /compact or restart)
  • Permission mode
  • Output style
  • Skills and commands
  • Plugin skills, hooks and agents
  • /advisor toggle
  • /recap
  • /rewind
  • Spawning a subagent
Source: Anthropic, as of 6 November 20261.

The pattern follows from the prefix rule: anything that changes the start breaks the cache, anything appended at the end keeps it3. A subagent has its own system prompt and tools, so it builds its own cache on a 5-minute TTL and leaves yours intact. A fork inherits your prefix exactly and reads your cache, as long as it runs on the same model1.

How long the cache lives depends on how you pay

Who gets the 1-hour cache
November 2026 defaults
RequestSubscription, within plan usageUsage credits, API key or cloud provider
Main conversation1 hour5 minutes
Everything else: subagents, workflows, teammates, forks, compaction, titles5 minutes5 minutes
Source: Anthropic, as of 6 November 20261. Some server-controlled helper requests get 1 hour on a subscription.

Once you draw on usage credits, the main conversation drops to 5 minutes too. Since v2.1.242, promptCacheTtl and subagentPromptCacheTtl take 5m or 1h, and claude -p "hello" --output-format json shows which one you get under usage.cache_creation1.

On an API key, 1 hour costs more up front: at 102k tokens, the first write is $0.31 more than a 5-minute one. One pause of 5 to 60 minutes saves about $0.47, more than that premium. For agent loops that never pause, or breaks longer than an hour, 5 minutes is cheaper (our arithmetic from Anthropic’s price list)2,3. Subagents that wait on a long test run or a permission prompt are the exception: give only those cacheTtl: 1h under the experimental field of their frontmatter (v2.1.248+)1.

Where people disagree

Much of the argument traces to 6 March 2026, when Anthropic changed how Claude Code picks a TTL per request and many requests moved to 5 minutes, mostly subagent requests according to one user’s logs10,11. On Hacker News (HN) the complaint was trust: “One of the largest AI companies on Earth cannot figure out an algorithm for when not to drop caches in long-running sessions?”10. Anthropic’s Jarred Sumner said the change made Claude Code cheaper, because “a meaningful share of Claude Code’s requests are one-shot calls where the cached context is used once and not revisited”11. An HN commenter who runs Anthropic models through pi, a different coding agent, agreed: “the much higher cost of 1h caches is almost never a good tradeoff”10.

The advice to clear gets pushback too: “/clear only works for new, completely different jobs — that’s rare in development”12. That is the case for a handoff note over a bare /clear.

Watch two open questions

Anthropic doesn’t publish how cache reads and writes count against subscription limits. Asked on GitHub, Anthropic replied in April 2026 “we’ll follow up there”; as of November, the docs still don’t say10,4. Until they do, judge your habits by /usage, not by quota guesses. Keep-alive pings, a loop that messages Claude every few minutes to keep the cache warm, are a community workaround: each ping is a full cached read, and nobody has measured whether they pay off6,13. Revisit this when Anthropic documents quota weighting.

Notes

  1. 1Anthropic, “How Claude Code uses prompt caching”, Claude Code docs, updated 6 November 2026. code.claude.com
  2. 2Anthropic, “Pricing”, Claude API docs, 21 October 2026. platform.claude.com
  3. 3Marek Elmayan, “Prompt caching in Claude Code: why your coffee break costs more than your prompt”, melmayan.fr, 13 October 2026. melmayan.fr
  4. 4Anthropic, “Manage costs effectively”, Claude Code docs, 2 November 2026. code.claude.com
  5. 5Anthropic, “Customize your status line”, Claude Code docs, 30 October 2026. code.claude.com
  6. 6Anthropic, “Prompt caching”, Claude API docs, 15 September 2026. platform.claude.com
  7. 7Thariq Shihipar, “Lessons from building Claude Code: Prompt caching is everything”, claude.com, 30 April 2026. Vendor blog. claude.com
  8. 8Alejandro AO, “Prompt Caching Explained: Stop Overpaying for AI Agents”, Hugging Face on YouTube, 10 August 2026. youtube.com
  9. 9Anthropic, “Escalate hard decisions with the advisor tool”, Claude Code docs, 21 October 2026. code.claude.com
  10. 10Hacker News, “Anthropic downgraded cache TTL on March 6th”, discussion of GitHub issue #46829 and Anthropic’s reply, 12 April 2026. news.ycombinator.com
  11. 11Tim Anderson, “Anthropic: Claude quota drain not caused by cache tweaks”, The Register, 13 April 2026. theregister.com
  12. 12Comments on Sharbel A., “Paste This Into Claude Code, Never Run Out Of Tokens Again”, YouTube, 19 August 2026. youtube.com
  13. 13Chase AI, “You’re Paying Anthropic 20x MORE Than You Need To”, YouTube, 6 August 2026, and its comments. youtube.com
Get new articles by email

One email when something new is published. Unsubscribe any time.

Keep reading

All articles

We burn the tokens so you don't have to.

Interesting technical work, plus deep investigations with every claim sourced, so you get the answer without the rabbit hole.