Blog / Cost
Context Size vs Cost: When to /clear and When to /compact
Long Claude Code contexts cost more per request. When to use /clear, when /compact pays for itself, with list-price arithmetic and numbers from 54,344 requests.

In one team's transcripts, requests carrying more than 200k tokens of context were 45.5% of requests and 63.8% of the list-price cost. Context size is the biggest cost lever Claude Code gives you, and
/clearand/compactare how you pull it.
Short verdict. Use /clear when the next task is unrelated to the last one. It costs nothing and removes everything. Use /compact when you are mid-task, the context is large, and you need continuity. Compact while the prompt cache is still warm, because compacting after a long break reprocesses the whole history as uncached input. Do neither for small contexts: below roughly 50k tokens the savings are pennies. The rules below come from Anthropic's docs and price page; the data comes from our own transcripts, with the method and limits stated.
Prices and docs checked 2026-11-23. Prices change, so verify them before acting on any figure here.
Table of contents
- What the two commands do
- Why context size drives cost
- What our transcripts show
- The arithmetic: when does /compact pay for itself
- /clear vs /compact: a decision table
- Making compaction keep what matters
- Mistakes that make this worse
- Pick /clear if, pick /compact if
- Conclusion
- FAQ
What the two commands do
/clear |
/compact |
|
|---|---|---|
| What it does | Starts a fresh session with empty conversation context | Summarizes the conversation so far and continues from the summary |
| What you keep | Nothing from the conversation (CLAUDE.md still loads in the new session) | A summary; you can steer it with focus instructions |
| Cost of running it | "/clear costs nothing" |
It "reads the conversation it summarizes, so compacting a large context is itself a large request" |
| Cost counter | Totals reset: "the next session's total cost starts at $0" | Not reset |
| Best for | Switching to unrelated work | Continuing the same task with less baggage |
| Source | Claude Code costs | Claude Code costs, prompt caching |
Sources checked 2026-11-23. The costs page gives the rule for /clear directly: "Use /clear to start fresh when switching to unrelated work. Stale context wastes tokens on every subsequent message. Use /rename before clearing so you can find the session later, then /resume to return to it." For /compact it gives an example of steering: "/compact Focus on code samples and API usage tells Claude what to preserve during summarization."
Claude Code also compacts on its own: the costs page describes "auto-compaction, which summarizes conversation history when approaching context limits." A context warning near that window is, in the docs' words, "not a usage limit."
Why context size drives cost
The mechanism is simple, and the costs page states it: "Claude Code sends your full conversation with every request, and each time Claude uses tools it sends another request carrying that batch of tool results." With prompt caching, that history is re-read "at the cached token rate, so a one-line question in a session that has been open all day still draws usage for the whole conversation."
So the price of a request is roughly the cost of reading the whole context plus the new tokens. Here are the list prices that matter, from Anthropic's pricing page, checked 2026-11-23:
| Per million tokens | Opus 5.5 | Sonnet 5.5 |
|---|---|---|
| Base input (uncached) | $4 | $2 |
| 5-minute cache write | $5 | $2.50 |
| 1-hour cache write | $8 | $4 |
| Cache read (hit) | $0.20 | $0.10 |
| Output | $20 | $10 |
The pricing page also says Claude 4.6 and later models other than Haiku 5.5 include the full 1M-token window at standard per-token rates: "A 900k-token request is billed at the same per-token rate as a 9k-token request." That means there is no price cliff at some context size. Cost grows linearly with context, request after request, which is why it adds up quietly.
Two things follow:
- Each extra 100k of context costs about $0.02 per request on Opus 5.5 when the cache is warm (100,000 tokens at $0.20 per million). That sounds small. A long session makes hundreds of requests.
- A cold cache changes the scale. After a break longer than the cache lifetime, the next request pays to rewrite the context, at $5 or $8 per million on Opus. We cover that in prompt caching and cold resumes.
What our transcripts show
Method, so you can judge the numbers. We read one team's Claude Code transcripts from 2026-10-02 to 2026-11-23 (about 7.5 weeks): 792 sessions and 54,344 model requests, from a small team running its own products. Each request was counted once, subagent requests included. "Context size" is the input plus cache read plus cache write tokens of one request. Cost is the API list-price equivalent (tokens times the published prices above), not what anyone was billed; on a subscription plan it is the value of the usage. Opus 5.5 made up 99.2% of the cost. Only aggregates were kept.
| Context size of the request | Requests | List-price cost | Average per request |
|---|---|---|---|
| Under 50k | 165 | $7 | about $0.04 |
| 50k to 100k | 7,014 | $567 | about $0.08 |
| 100k to 200k | 22,434 | $1,599 | about $0.07 |
| 200k to 400k | 13,120 | $1,351 | about $0.10 |
| 400k and over | 11,611 | $2,474 | about $0.21 |
Total: $5,998 across the period. Requests above 200k context were 24,731, or 45.5% of requests, and cost $3,825, which is 63.8% of the total. The 11,611 requests above 400k cost more ($2,474) than the 22,434 requests between 100k and 200k ($1,599).
How to read this carefully:
- The per-request average is not monotonic between the 50k and 200k bands. Averages mix cache reads, cache writes and output, and the 50k to 100k band includes requests where the cache was being written. Do not read the table as a clean price curve.
- The shape is the point. Requests over 400k cost about twice as much on average as requests in the 200k to 400k band and several times those under 100k.
- This is one team, mostly on one model, for about 7.5 weeks. It describes one team's usage, not Claude Code in general. Your split depends on how long your sessions run and how often you clear.
- Cold resumes are a separate cost. In the same period 405 requests came after a gap of more than an hour and rewrote 20k or more tokens to the cache, costing $681 in cache rewrites, 11.4% of the total.
We did not measure whether compacting or clearing changed answer quality. This article covers cost.
The arithmetic: when does /compact pay for itself
This is our own arithmetic from the list prices, not a measurement. Assumptions: Opus 5.5, a 400k-token context, a compaction that leaves 30k tokens, a 5k-token summary written as output, and a 5-minute cache write for the new prefix. Change the inputs for your case.
Warm cache (you were working a minute ago):
| Step | Tokens | Rate (per million) | Cost |
|---|---|---|---|
| Read the 400k conversation (cache hit) | 400,000 | $0.20 | $0.08 |
| Write the summary (output) | 5,000 | $20 | $0.10 |
| Write the 30k new prefix to cache | 30,000 | $5 | $0.15 |
| Total | about $0.33 |
Each later request now reads 30k instead of 400k, saving 370,000 tokens times $0.20 per million, about $0.074 per request. The compaction pays for itself in about 4.5 requests.
Cold cache (you came back after the cache expired):
| Step | Tokens | Rate (per million) | Cost |
|---|---|---|---|
| Read the 400k conversation (uncached input) | 400,000 | $4 | $1.60 |
| Write the summary (output) | 5,000 | $20 | $0.10 |
| Write the 30k new prefix to cache | 30,000 | $5 | $0.15 |
| Total | about $1.85 |
Same saving per request, about $0.074, so break-even moves to about 25 requests. The docs say why: "After a break longer than the cache lifetime, there is no cache left to read, so the summarization request reprocesses that history as uncached input."
Compare with not compacting after a break: your next request would also miss the cache and write 400k tokens at $5 per million, which is $2.00, before any answer. So if you are going to continue the task, compacting after a break is not much worse than not compacting, and it leaves a small context for everything afterward. If you are not going to continue the task, /clear skips all of it.
What this arithmetic leaves out: the summary is lossy, which is a quality cost; the new context grows again with every tool result; and a model's cache lifetime depends on how you sign in. The prompt caching docs say the main conversation gets a one-hour lifetime on a Claude subscription within plan usage, and five minutes with usage credits, an API key or a cloud provider. Subagents and compaction requests default to five minutes. Source: Claude Code prompt caching, checked 2026-11-23.
On a flat subscription the dollars are not your bill, but the same tokens count against your plan windows, which we explain in Claude Code usage limits explained.
/clear vs /compact: a decision table
| Situation | Do this | Why |
|---|---|---|
| Finished a task, starting something unrelated | /clear |
Stale context "wastes tokens on every subsequent message" |
| Mid-task, context large, cache warm | /compact with focus text |
Cheapest moment to compact; keeps the thread |
| Mid-task, back after a long break, context large | /compact or /clear plus a short brief |
Either way the cache is gone; compare the break-even above |
| Same repo, new feature, old decisions still matter | /compact |
Continuity is worth the summary |
| Debugging a dead end, want a fresh angle | /clear and restate the problem |
The old context may be steering the model wrong |
| Context under about 50k | Neither | Savings are small |
| You want to come back to this conversation | /rename, then /clear, later /resume |
The docs give this sequence |
| Auto-compact warning appears | Compact now, with instructions, or clear | Auto-compaction summarizes without your focus text |
The last row is the one people miss. Auto-compaction will run anyway when the context approaches the window, but it does not know what you care about. Compacting yourself, earlier, with a focus instruction, gives you the same cost saving and a better summary.
Making compaction keep what matters
Two documented ways to steer it.
On the command line:
/compact Focus on code samples and API usage
And in your project's CLAUDE.md, as the costs page shows:
# Compact instructions
When you are using compact, please focus on test output and code changes
Good focus text names what would be expensive to rediscover: the decision you reached, the files you changed, the failing test and its output, the constraint you were given. Bad focus text is generic ("keep everything important"), which is what the model does anyway.
If you have rules that must survive compaction no matter what, there is a hook for it: the hooks guide describes a SessionStart hook with a compact matcher that re-injects critical context after every compaction. Anything that must be present in every session belongs in CLAUDE.md in the first place, and the costs page suggests keeping it under 200 lines.
Related habits from the same page that reduce context before you ever need either command:
- Delegate bulky work to subagents. Their verbose output stays in their own context, and "only a summary returns to your main conversation." Their own requests still draw on your usage.
- Keep MCP overhead down. Tool definitions are deferred by default, and the page suggests
/contextto see what is using space, and/mcpto disable servers you do not use. - Move specialized instructions from CLAUDE.md to skills, which load only when invoked. This walk-through on turning a CLAUDE.md section into a skill shows the move step by step.
- Give specific prompts. "Improve this codebase" triggers broad scanning; naming the function and file does not.
Mistakes that make this worse
Compacting after lunch. The most expensive time to compact is after the cache expired, because the summarizer pays the uncached rate on the full history. If you know you are leaving, compact before you go, or accept a fresh start.
Never clearing between tasks. The costs page says high spend on an API or cloud-provider plan "usually traces back to long sessions that were never cleared or to Opus left as the default model." The second half is a separate lever, covered in Opus vs Sonnet in Claude Code.
Clearing when you needed the thread. /clear is free in tokens and expensive in knowledge. If you will spend ten minutes re-explaining the task, you have paid for the context anyway, just in your time.
Assuming /cost tells you the truth on a plan. On Pro, Max and Ultra, the session cost figure "isn't relevant for billing purposes", and Claude Code computes it "locally from token counts at list price." It is a good proxy for usage, not an invoice. Tools that read transcripts, such as the ones in ccusage vs /cost vs Code Tycoon, can show context size per request, which is the number that matters here.
Switching models mid-session. Each model has its own cache, and the prompt caching docs list switching models among the actions that invalidate the cache. Clearing first, then switching, avoids paying to rewrite a large prefix on a model you will not keep.
Watching only the total. A session can cost $4 because it ran for two hours at 50k context or because it spent twenty minutes at 500k. Those need different fixes. Code Tycoon's cost-habits view flags oversized contexts and cold resumes for exactly this reason; you can also read the same numbers from raw transcripts yourself.
Pick /clear if, pick /compact if
Pick /clear if:
- The next task has no dependency on the last conversation.
- You can state the new task in a sentence or two.
- The old context may be steering the model in the wrong direction.
- You have run for a long time and are back after a break.
Pick /compact if:
- You are mid-task and decisions made earlier still matter.
- The cache is warm, so the summary request is cheap.
- You can write a focus instruction naming what to keep.
- The context is large enough that the per-request saving adds up (hundreds of thousands of tokens, not tens).
When this advice does not apply. If your sessions rarely pass 50k tokens, the commands save pennies and your time is worth more. If you are on a flat plan and nowhere near your limits, the dollar figures do not apply to you. And if you work in many short single-task sessions, as parts of our own data do, you are already clearing by default.
Conclusion
Context size is the quiet multiplier on every request. In our transcripts, requests above 200k tokens were under half the requests and nearly two thirds of the list-price cost. /clear is free and right between unrelated tasks. /compact is right mid-task while the cache is warm, with a focus instruction, and it pays for itself in a handful of requests under the assumptions above. After a long break, either start fresh or compact knowing the price.
To see which of your sessions sit above 200k and how much of your cost they carry, self-host Code Tycoon for free with npx code-tycoon, or get your server. Both read your transcripts the way this article did.
Frequently asked questions
What is the difference between /clear and /compact in Claude Code?
/clear starts a fresh session with no conversation context. /compact summarizes the conversation and continues from the summary. Per Anthropic's costs page, /clear costs nothing, while compacting a large context is itself a large request.
When should I use /compact?
Use it mid-task when the context is large, the cache is warm, and you need continuity. Add a focus instruction, for example /compact Focus on test output and code changes, so the summary keeps what you would find expensive to rediscover.
Does /compact save money?
Usually, once the saved per-request cost exceeds the cost of the compaction. Under our list-price assumptions (Opus 5.5, 400k context shrinking to 30k) a warm-cache compaction costs about $0.33 and saves about $0.074 per later request, so it pays back in about 4.5 requests. A cold-cache compaction costs about $1.85 and pays back in about 25. These are illustrations, not measurements.
Why is compacting after a break more expensive?
After a break longer than the cache lifetime there is no cache to read, so the summarization request reprocesses the history as uncached input, per Claude Code's prompt caching docs. The main conversation's lifetime is one hour on a subscription within plan usage and five minutes on API keys, usage credits or cloud providers.
How much of Claude Code cost comes from large contexts?
In one team's transcripts (54,344 requests over about 7.5 weeks, mostly Opus 5.5), requests with more than 200k tokens of context were 45.5% of requests and 63.8% of the list-price cost. This is one team's usage and not a general benchmark.
Can I get a conversation back after /clear?
Yes, if you name it first. The costs page suggests /rename before clearing, then /resume to return to it. Resuming after a long gap can mean a cache miss on the full history.
Does auto-compact make /compact unnecessary?
No. Auto-compaction summarizes when you approach the context limit, but without your focus instruction. Running /compact yourself earlier, with instructions, gives you a better summary and a lower cost for the requests in between.
Related articles
- Prompt Caching in Claude Code: Why Cold Resumes Cost Money
- What Does Claude Code Really Cost Per Month?
- Claude Code Usage Limits Explained
About this research
Anton Goldshtein is a two-time founder who previously bootstrapped a company to $100M in revenue. His team runs its own products on Code Tycoon every day.
Rules and prices come from Claude Code's costs and prompt caching documentation and Anthropic's pricing page, checked 2026-11-23. The usage figures come from one team's Claude Code transcripts (792 sessions, 54,344 requests, 2026-10-02 to 2026-11-23), reduced to aggregates; costs are list-price equivalents, not invoices. The break-even figures are our arithmetic under stated assumptions. We did not measure answer quality before and after compaction.
Content reviewed and updated: 2026-11-26
Keep reading
Cost Per Committed Task: Benchmarking Your Claude Code Use
Cost per session hides what you got. Our 792 sessions show a $3.28 median overall and $6.59 for sessions that committed. How to measure yours, with caveats.
Claude Code Habits That Burn Usage Limits (Our Data)
Six Claude Code habits ranked against our own transcripts: huge contexts, Opus for everything, cold resumes, marathon sessions, idle gaps, model switches.
Claude Code API Billing vs Subscription: When Max Pays Off
Compare Claude Code API billing with Pro and Max: break-even math at Opus 5.5 prices, what each route caps, and which one fits solo, heavy and team use.