The short answer
- Why it matters: the API is stateless, so Claude Code re-sends the whole conversation as input every turn. Long context = a tax on every message.
- Biggest cost driver: in a long session, context size usually beats model choice and output for total spend.
- The tools:
/clearto start fresh between tasks;/compactto shrink a long thread you want to keep. - The habit: one session per focused task; reset before the context balloons, not after.
What the context window actually is
The context window is everything Claude "sees" on a given turn: the system prompt, any files you've loaded, and the full back-and-forth so far. Claude models have a large window — plenty of room — but room isn't free. Because the API keeps no memory between calls, Claude Code has to resend that entire window as input tokens every time you hit enter.
That's the crucial bit most people miss. A 40-message conversation doesn't send just your 41st message — it sends all 40 previous ones plus every loaded file, again, as input. Your short "yes, do that" can carry tens of thousands of tokens behind it.
Why it's usually the dominant cost
People fixate on model choice — and it matters (see Opus vs Sonnet) — but in a long session, context often outweighs everything. A marathon thread on Sonnet with a big context can easily out-spend a short, focused session on Opus. The lever isn't only which model; it's how much you're re-sending to it.
Prompt caching softens this a lot — re-sent context becomes cheap cache reads (see how caching works) — but caching discounts context, it doesn't erase it. Keeping the window lean still wins.
The two commands that keep it lean
| Command | What it does | Use when |
|---|---|---|
/clear | Starts fresh with minimal context | Switching to an unrelated task |
/compact | Summarizes the thread into a shorter form | Continuing the same work, but it's grown long |
The rule of thumb: clear between tasks, compact within one. If you've moved on to something new, there's no reason to keep paying to re-send the old thread — clear it. If you're deep in one job but the history is heavy, compact it: Claude keeps the important points, you drop the token weight. Claude Code can also auto-compact when the window gets large.
Habits that keep context small
- One session, one focused task. The marathon session where you did five unrelated things is the expensive one — every task paid for the others' context.
- Reset early. Clear or compact before the window balloons, not after you've already paid for ten heavy turns.
- Load deliberately. Don't dump a giant file in full if you only need a slice. Everything you load rides every future turn.
- Notice the creep. If a session's cost per turn keeps rising for simple questions, that's context, not difficulty.
See when context is the culprit
The tell is a lopsided token split: input tokens dwarfing output. That
pattern means you're paying mostly to re-send context, not to generate
code. It's invisible in the terminal, but Dinoradar shows your
input-versus-output split per session, so context-heavy sessions stand
out and you know exactly where a /clear would've paid off.
Frequently asked
Why does a longer Claude Code conversation cost more?+
The API is stateless, so Claude Code re-sends the entire conversation — every earlier message and loaded file — as input tokens each turn. The longer the thread, the more context is resent every message, so cost per turn creeps up even when your new question is short. Context is usually the dominant cost in a long session.
What does /compact do in Claude Code?+
It summarizes the conversation so far into a shorter form that keeps the important points, shrinking the context resent on future turns and lowering per-turn cost while letting Claude keep working. Claude Code can also compact automatically when the context grows large.
When should I use /clear versus /compact?+
Use /clear when switching to an unrelated task — it starts fresh with minimal context, the cheapest state. Use /compact to continue the same work when the thread has grown long — it keeps the thread while trimming token weight. Clear between tasks, compact within one.
How do I keep the Claude Code context window small?+
Start a fresh session per task, clear or compact when history balloons, avoid loading huge files you don't need in full, and keep one session to one focused job. Dinoradar shows your input-versus-output token split so context-heavy sessions are easy to spot.
Stop paying to re-send context you don't need.
Dinoradar shows your input/output split and cost per session, so a bloated context window stops hiding in your bill. Free forever · Pro $29 once.