Skip to content

Build Not yet confirmed elsewhere1 publisher 3 min read Published

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

How we use AI Send a correction

Full-price 85k compaction cost more than warm 136k Cost of one /compact in the dev.to lab's tests, shown at the low end of each measured range.

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.

Full-price 85k compaction cost more than warm 136k
FigureValueNoteClaim
/compact right after file-read turn, 85k tokens, at least$0.3range $0.30 to $0.324
Warm-cache /compact, 136k session, at least$0.056 list pricerange $0.056 to $0.0591
Expired-cache /compact, same session, at least$0.53range $0.53 to $0.543

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
Why these scores

Claim ledger

Ranked by verification strength, evidence, and original report placement.

  1. [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.

    Reported Supported Source: dev.to lab measurementView cited source
  2. [2]

    The warm /compact of the 136k-token session took 136,275 of its 138,344 input tokens from the prompt cache.

    Reported Supported Source: dev.to lab measurementView cited source
  3. [3]

    The same compaction after the cache had expired cost $0.53 to $0.54.

    Reported Supported Source: dev.to lab measurementView cited source

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.

Add to ChatGPTAdd to Claude

Sources

1 independent publisher whose own reporting we read for this story.

  1. dev.to

    1 article · October 13, 2026

    Claude Code's /compact cost $0.06 at 136k tokens with a warm cache, 9x that cold, and /clear sent zero requests

Share your take

Let Clarity write the post for you.

Signed-in readers get a short post drafted on this story in the register they choose — narrative, analytical, or a direct position — editable to the last word before it goes anywhere. The share buttons at the top of this story work without an account.

Topics and entities

Follow any of these and your For You feed starts watching them — no settings page required.

Loading related stories