Back to UsageCut

Claude Code /compact vs /clear: which one actually saves you tokens?

8 min read

On this page

/clear deletes your conversation and starts the next turn from nothing - genuinely free, no request sent to produce it. /compact sends a real request: your full history plus a summarization instruction, which Claude Code reads from cache while the cache is warm and reprocesses at full price the moment it isn't. Neither one is the "safe default" the forum threads make them out to be - which one actually saves tokens depends on whether you need what's in the conversation and how long it's been since your last message.

TL;DR: /clear costs $0, always - there's nothing to summarize, so nothing gets sent. /compact costs a real request every time: a fraction of your context's size if the cache is still warm (within the hour on a subscription, within 5 minutes by default on an API key), and the full size, billed as fresh input, the moment that window has passed. If you don't need the conversation later, /clear wins outright. If you do, whether /compact is worth it depends entirely on your cache's timing.

What /compact actually re-sends to summarize your context

/compact doesn't edit your history in place. Claude Code sends a separate API request carrying the same system prompt, the same tool definitions, and your entire conversation so far, with a summarization instruction appended as the final message. The response comes back wrapped in a compaction block, and everything before that block gets dropped from what the next turn sends.

That request is genuinely just a request, priced like any other: input tokens for what it reads, output tokens for the summary it writes. While your cache is still warm, it reads your prefix at the cache-read rate (roughly a tenth of standard input pricing) and spends most of its cost generating the summary. That's why a mid-session /compact "costs a fraction of what the context size suggests," as Claude Code's own docs put it - most of the size you're worried about is being read at the cheap rate, not the expensive one.

You can steer what survives with a trailing instruction: /compact focus on the failing test and the last three edits replaces the default summarization prompt outright rather than adding to it. Run it in a session with no real history yet and it just prints Not enough messages to compact. - there's nothing to summarize, so nothing gets sent either.

What /clear throws away, and why that costs nothing

/clear doesn't summarize anything. It discards the conversation outright and starts the next turn from an empty history - no request to Anthropic's API describes what got thrown away, because nothing needs to. Claude Code's own docs are direct about it: "when you want a fresh start instead of continuity, /clear costs nothing."

That's also why /clear resets the running total in /usage back to $0 for the new session, where /compact doesn't - /compact is still the same session, continuing from a summary. /clear is a genuinely new one. Project context - your CLAUDE.md, auto memory - gets reloaded from disk either way, so an edit you made mid-session finally takes effect on whichever command you run next.

Same full context, two completely different bills
/compact

Sends a new request: system prompt + full history + a summarize instruction

Cache warm (within TTL): reads the history from cache, pays mostly for the summary output

cheap

Cache cold (gap passed the TTL): re-reads the entire history as fresh, uncached input

full price

Next turn: cache rebuilds for just the short summary

/clear

Discards the conversation outright, no request sent to summarize it

Nothing to read, nothing to write - the discard itself is free

$0

Next turn: cold start, cache rebuilds from an empty conversation

/compact only looks free because most of the time your cache is still warm. The moment the gap between messages passes the cache TTL, that same command reprocesses the whole conversation as billed input before it can summarize it.

Real numbers: how big a session's context gets before anyone reaches for either command

Numbers on this trade-off are almost always hypothetical - a made-up 50K-token example, a round number picked to make the math clean. Every real Claude Code session leaves its full turn-by-turn usage on disk, so instead of guessing, I pulled the last-turn context size (fresh input plus cache write plus cache read) from 38 real local session transcripts, the ones with at least one billed turn.

Final-turn context size, 38 real Claude Code sessions

Total tokens (input + cache write + cache read) on each session's last billed turn

50K - 100K tokens15 of 38
100K - 150K tokens6 of 38
150K+ tokens17 of 38

Median final-turn size: 141,186 tokens. Largest: 226,867. That is the size of the re-read a cold /compact would bill on the worst of these sessions, and the size /clear would have discarded for nothing.

Almost half of those sessions - 17 of 38 - had already passed 150,000 tokens of accumulated context by their final turn, before anyone reached for /compact or /clear at all. The largest hit 226,867. That's not a hypothetical: it's what a long, tool-heavy Claude Code session (a lot of file reads, a lot of tool calls, the exact kind of session where this question actually comes up) accumulates in practice. It's also the exact number a cold /compact would reprocess as fresh input on that session, and the exact number /clear would have discarded for nothing.

The token math: when compacting costs more than just starting over

/compact costs more than /clear in two situations, and they're both common:

  • You don't actually need the continuity. /clear is $0. /compact is never $0 - it's always at least the cost of generating a summary you may not read. If nothing in the conversation matters to the next task, paying anything to preserve it is a pure loss next to the free option.
  • Your cache has gone cold. Claude Code's cache lives for an hour on a subscription, five minutes by default on an API key (ENABLE_PROMPT_CACHING_1H=1 extends that on either). Step away longer than that and the next request - including a /compact summarization request - has no cache left to read. It reprocesses the entire history as billed input before it can even start writing a summary. This is why the docs single out resuming an old session as the single most expensive time to run /compact: on the largest of the 38 real sessions measured above, a cold /compact would mean reprocessing all 226,867 tokens as fresh input, just to produce a summary a /clear plus one sentence of recap would have replaced for a rounding error in cost.

Put plainly: /compact is a bet that the continuity is worth what it costs. When the cache is warm and you genuinely need the history, that bet usually pays off - the request reads cheap and the next turn starts from a short, cache-fresh summary instead of nothing. When the cache has gone cold, or when you didn't need the history in the first place, it's the more expensive way to end up in roughly the same place /clear gets to for free.

A simple rule for choosing between them mid-task

Two questions decide which command to run

Do you need any of this conversation later?

No →/clear

Nothing to preserve, so nothing to pay for. Free start on the next task.

Has it been under the cache TTL since your last message? (1 hour on a subscription, 5 minutes on an API key by default)

No →/clear + a short recap

A cold /compact re-reads everything at full price just to write a summary you could type yourself for a fraction of the tokens.

Yes to both →/compact

You want continuity and the cache is still warm - the summarization request reads the history from cache and mostly pays for the output. Add instructions to keep it tight: /compact focus on the failing test.

| | /compact | /clear | | --- | --- | --- | | What it does | Summarizes history, replaces it with the summary | Discards history outright | | Request sent | Yes - reads your full history, writes a summary | No | | Cost, cache warm | Cheap - history read at cache-read rate | $0 | | Cost, cache cold | Full price - entire history reprocessed as fresh input | $0 | | /usage session total | Continues (same session) | Resets to $0 (new session) | | Custom steering | /compact <instructions> replaces the default summary prompt | Not applicable - nothing survives | | Fresh session | Prints "Not enough messages to compact." | Always available |

Not sure how close your own session already is to the point where this decision matters? The context window calculator turns your session pattern into an estimate of how much headroom you have left before auto-compact would fire on its own.

When neither command is the right move

If you went down a path mid-task and just want to undo it rather than summarize or discard it, neither command is the cheap option - /rewind is. It truncates your conversation back to an earlier turn, and because that earlier turn is content the cache was already built from, the next request reads straight from the existing cache entry instead of paying to build a new one, warm or cold.

And if you're compacting every few turns because auto-compact keeps firing, the fix usually isn't picking between these two commands faster - it's the size of what's accumulating in the first place. How to reduce Claude Code's context window usage covers the actual levers (offloading exploration, trimming tool output) that stop you from needing either command as often.

FAQ

  • Is /compact ever completely free? No. Even at its cheapest, cache-warm case, it's a real request that reads your history at the cache-read rate and pays full price to generate the summary's output tokens. /clear is the only one of the two that's actually $0.
  • Does /clear lose my work? It loses the conversation, not your files. Edits already made to your repo stay made; /clear only discards the message history and starts the next turn's context from empty.
  • Why does /compact sometimes feel instant and sometimes feel slow? Cache state. Within the TTL, the summarization request reads your prefix from cache and mostly waits on the model writing the summary. Past the TTL, it's reprocessing your entire history as fresh input first - that's the slow, expensive case.
  • Can I control what /compact keeps? Yes - /compact followed by an instruction (for example, /compact keep the API contract, drop the exploration) replaces Claude Code's default summarization prompt with yours.
  • Does editing CLAUDE.md mid-session apply after /compact or /clear? Yes for either. Project context reloads from disk at that point, so an edit that didn't apply mid-session finally takes effect on whichever command you run next.
  • What's the difference between /compact and auto-compact? Same underlying mechanism, different trigger. Auto-compact fires on its own once your context approaches the configured window (/autocompact to change it); /compact is the same summarization run on demand, at a time you choose instead of the one Claude Code would have picked.

None of this requires guessing at your own numbers - the free scan reads your real Claude Code session history and shows you where a session's tokens actually went before you decide when to clear it. If cache behavior in general is still fuzzy, prompt caching and compaction, explained simply is the plain-language version, and what actually changed with Claude Code's cache TTL covers the exact tier your account is on.

See your own numbers

These are aggregates from real sessions. Your setup is different - run the free scan and get the breakdown for your own Claude Code history. It runs locally; nothing about your code or prompts leaves your machine.

npx usagecutRun a free scan →

NeoMade by Neo

UsageCut by ClockedCode - not affiliated with Anthropic. The figures on this page are measured on real Claude Code sessions and labeled measured or estimated where it matters.