Claude Code's /compact costs about 9x more on a cold prompt cache than a warm one
A dev.to test measured Claude Code 2.1.289's /compact at $0.056 to $0.059 on a warm 136k-token session and $0.53 to $0.54 after the cache expired. The default cache lifetime is five minutes, so a longer pause sets the price.
The Engineer · Build desk
An 85k-token /compact sent right after the file-reading turn cost at least $0.30, up to $0.32. A warm-cache /compact of a 136k-token session cost at least $0.056, up to $0.059. The same 136k compaction after the cache expired cost at least $0.53, up to $0.54.
| Figure | Value | Note | Claim |
|---|---|---|---|
| /compact right after file-read turn, 85k tokens, at least | $0.3 | range $0.30 to $0.32 | 4 |
| Warm-cache /compact, 136k session, at least | $0.056 list price | range $0.056 to $0.059 | 1 |
| Expired-cache /compact, same session, at least | $0.53 | range $0.53 to $0.54 | 3 |
What happened
- In the warm run, the compaction took 136,275 of its 138,344 input tokens from the prompt cache.
- When compaction ran immediately after the turn that read the files, those files were billed at full price: $0.30 to $0.32 for an 85k-token compaction.
- Across 13 runs, /clear made no API request at all. The next request came to 15,303 tokens, compared with 14,254 to 14,923 following a warm compaction.
- On 2026-10-05 the lab ran 38 claude -p processes, with --model opus resolving to claude-opus-5-5, on sessions built from real JavaScript files.
Why it matters
- cost A pause past the cache lifetime multiplies the same command's bill by 9.0 to 9.6, a gap of about 47 to 48 cents per compaction at this session size.
- constraint Compaction cost follows cache state more than context size: the 85k-token compaction after a file read cost 5.1 to 5.7 times the warm 136k-token one.
- decision Resuming a stale session forces a choice between a summary at the cold price and a clean start with /clear and a short handoff note.
- contradiction The costs page calls compaction a large request, while the prompt caching page says a warm one costs a fraction of its context size. The lab's numbers support both, depending on cache state.
Warm compaction is cheap because the cache sees it as the same conversation. According to the prompt caching page, Claude Code sends a separate request with the same system prompt, tools and history as the session, plus a summarization instruction appended as a final user message [10]. The prefix matches, so the request reads it from cache [11]. In the lab's warm run that left 2,069 input tokens billed as uncached, about 1.5% of the request [19].
The cold case has no match to read. The same page says: "After a break longer than the cache lifetime, there is no cache left to read, so the summarization request reprocesses the full history as uncached input." [12] Compaction sits in the "Everything else" bucket, and that bucket's lifetime defaults to five minutes, apart from a few server-controlled helper requests [13]. That is shorter than most stand-ups. To get the cold runs, the lab set FORCE_PROMPT_CACHING_5M=1, a variable the docs list for debugging cache behavior [14].
Warm is a property of the content as well as the clock. In the post-read run, the files added in the last turn were billed in full [4]. We'd treat a compaction straight after a large read as partly cold.
The /clear path costs nothing at the moment of clearing. The costs page says: "When you want a fresh start instead of continuity, /clear costs nothing" [9]. The first request after /clear ran 380 to 1,049 tokens larger than the first request after a warm compaction [23]. The saving from clearing is the summarization request itself, and the new session starts from the same fixed prompt either way.
These are one lab's figures. They come from Opus 5.5 at list price, one day of runs, and sessions built from real JavaScript files [6][7]. For the cold ratio to hold elsewhere, the cache lifetime has to be five minutes and most of the session has to sit in the prefix the summarization request replays [10]. A session dominated by fresh tool output would look more like the post-read case.
Automatic compaction adds a size question. On the Anthropic API, models with a native 1M window, including Opus 4.7 and later, compact at about 967K tokens by default [16]. The lab's 136k session is about one-seventh of that [22], and the figures we have stop there. The window can be set through /autocompact, the autoCompactWindow setting, the --autocompact flag or CLAUDE_CODE_AUTO_COMPACT_WINDOW, and the environment variable takes precedence over the other three [15].
In our view the cheaper habit is to compact before leaving a long session, since compacting on return pays the cold price. That holds for Opus 5.5 at list price, a five-minute cache and sessions near 136k tokens.
What to watch
- Any measurement of a compaction near the roughly 967K-token default trigger, where the cold cost is untested and the session is about seven times the size the lab ran.
- Changes to the five-minute default cache lifetime for the Everything else bucket, since a longer lifetime would shrink the window in which compaction runs cold.
- Repeat runs on other models or on sessions heavy with tool output, where the post-read pattern could dominate.
Clarity's read
What the record supports and how the coverage leans. The claims behind it follow.
Reality
- Evidence72
- Adoption
- Insufficient
- Hype gap−5
- Incentives
- Insufficient
- Confidence68
Claim ledger
Ranked by verification strength, evidence, and original report placement.
- [1]
On Claude Code 2.1.289 with Opus 5.5, a /compact of a 136k-token session with a warm prompt cache cost $0.056 to $0.059 at list price, about two ordinary turns.
- [2]
The warm /compact of the 136k-token session took 136,275 of its 138,344 input tokens from the prompt cache.
- [3]
The same compaction after the cache had expired cost $0.53 to $0.54.
- [4]
A /compact sent right after the turn that read the files paid full price for those files, $0.30 to $0.32 at 85k tokens.
- [5]
/clear sent no API request in 13 of 13 runs, and the first request after it was 15,303 tokens, against 14,254 to 14,923 after a warm compaction.
- [6]
Thirty-eight claude -p processes ran on 2026-10-05 (UTC) with Claude Code 2.1.289 and --model opus, which resolved to claude-opus-5-5.
- [7]
The lab built sessions of three sizes by having Claude read real JavaScript files, then compacted or cleared them, and read the usage of every API request from the request and response bodies that Claude Code can write to disk.
- [8]
The Claude Code costs page says /compact "reads the conversation it summarizes, so compacting a large context is itself a large request".
- [9]
The costs page says: "When you want a fresh start instead of continuity, /clear costs nothing".
- [10]
To produce the summary, Claude Code sends a separate request with the same system prompt, tools, and history as the conversation, plus a summarization instruction appended as a final user message.
- [11]
While the cache is warm, the summarization request reads the prefix from the cache, so a mid-session /compact "costs a fraction of what the context size suggests".
- [12]
The prompt caching page says: "After a break longer than the cache lifetime, there is no cache left to read, so the summarization request reprocesses the full history as uncached input."
- [13]
The prompt caching page puts compaction in the "Everything else" bucket for cache lifetime, which defaults to five minutes apart from a few server-controlled helper requests.
- [14]
FORCE_PROMPT_CACHING_5M=1 "forces five minutes for both buckets", is listed for debugging cache behavior, and the lab used it for the cold runs.
- [15]
The model configuration page lists four places to set the auto-compact window: the /autocompact command, the autoCompactWindow setting, the --autocompact flag, and the CLAUDE_CODE_AUTO_COMPACT_WINDOW environment variable, which takes precedence over the command, the flag, and the setting.
- [16]
Models running with a native 1M window compact at about 967K tokens by default; on the Anthropic API these include Sonnet 5, the Fable models, and Opus 4.7 and later.
- [17]
The prompt caching page says the turn after compaction rebuilds the conversation cache for only the much shorter summary, in both warm and cold cases.
- [18]
The cold compaction cost 9.0 to 9.6 times the warm compaction of the same 136k-token session.
- [19]
The warm compaction billed 2,069 input tokens as uncached, about 1.5% of its 138,344 input tokens.
- [20]
The 85k-token compaction sent right after the file-reading turn cost 5.1 to 5.7 times the warm 136k-token compaction, on a session 51k tokens smaller.
- [21]
The gap between cold and warm compaction of the 136k-token session is about 47 to 48 cents.
- [22]
The 136k-token test session is about one-seventh of the roughly 967K-token default auto-compact trigger.
- [23]
The first request after /clear was 380 to 1,049 tokens larger than the first request after a warm compaction.
Get this ledger inside ChatGPT. Ask about any of our stories and the answer brings its figure, each claim’s verdict and the sources. Free, no account.
Sources
1 independent publisher whose own reporting we read for this story.
Topics and entities
Follow any of these and your For You feed starts watching them — no settings page required.