How to Reduce Claude Code Token Usage

Why long Claude Code sessions burn tokens and usage limits, and 9 practical ways to use fewer: /clear, guided compaction, earlier autoCompactWindow, lean CLAUDE.md, subagents and shorter tool output.

By Shryxa · Updated · 8 min read

Short answer

Claude Code re-reads the whole conversation on every reply, so token usage is driven by how long your conversations get. To use fewer tokens:

  • run /clear between unrelated tasks;
  • run /compact with instructions before a session gets long, or set autoCompactWindow so it happens earlier;
  • keep CLAUDE.md, MCP servers and command output small.

Why Claude Code uses so many tokens

A language model has no memory between replies. Each time Claude answers, Claude Code sends the full conversation again: your messages, Claude's replies, every file it read, every command it ran and that command's output, plus the system prompt, CLAUDE.md and tool definitions.

That means the cost of one reply grows with the length of the conversation. A reply in a 400k-token conversation re-reads twice as much as one at 200k. A two-hour session where Claude reads a dozen files and runs the test suite ten times can carry hundreds of thousands of tokens into every reply.

By default, Claude Code only compacts automatically when the conversation gets close to the model's context limit. On models with a very large context window, that can be near a million tokens, so long sessions stay expensive for a long time. In our own measurements across real sessions, more than 80% of the cost came from replies where the conversation was already over 200k tokens.

See where your tokens go

  • /context shows how full the context window is and what is filling it: system prompt, tools, MCP servers, memory files and messages.
  • /cost shows token usage and cost for the current session if you pay per token through the API.
  • /usage shows how much of your plan's 5-hour and weekly limits you have used on a Pro or Max subscription.

Check /context at the start of a fresh session. If a large share is used before you type anything, start with techniques 4 and 5 below.

9 ways to use fewer tokens in Claude Code

1. Use /clear between unrelated tasks

Finished the bug fix and moving on to a new feature? Run /clear. Nothing from the old task helps the new one, but without clearing, every reply keeps paying for it. This is the single cheapest habit to build.

2. Save a handoff note before you clear

If you need some of the old context, ask Claude to write it down first, then clear:

> Write the current plan, decisions and open issues to NOTES.md
> /clear
> Read NOTES.md and continue with step 3

A one-page note replaces a conversation of 100k+ tokens.

3. Compact with instructions

When you want to stay on the same task but the conversation is long, run /compact. Claude Code replaces the conversation with a summary. Tell it what matters, so the summary keeps the right details:

/compact keep the goal, the files changed, the failing test names and the next steps

4. Make auto-compaction start earlier

The autoCompactWindow setting controls the conversation size, in tokens, at which Claude Code compacts on its own. Setting it lower keeps every reply smaller:

// ~/.claude/settings.json
{
  "autoCompactWindow": 200000
}

It is a trade-off. Each compaction costs one summary call and can lose detail, and a fresh session already starts with tens of thousands of tokens of system prompt and tools, so a very small window compacts over and over. Around 150k–300k tokens is a reasonable range for most work.

5. Keep CLAUDE.md and MCP servers lean

Your CLAUDE.md files are loaded into every session, and the tool definitions of every connected MCP server are part of the context too. Keep CLAUDE.md to the facts Claude cannot work out from the code, and disconnect MCP servers you are not using in this project.

6. Send broad searches to a subagent

"Find everywhere we handle payments" can mean reading 30 files. Ask Claude to use a subagent for it: the subagent works in its own context window and returns only a summary, so the main conversation never carries those 30 files.

7. Keep command output short

Test runners, package installs and builds print a lot of lines that Claude does not need. Quiet flags and filters help:

pytest -q 2>&1 | tail -n 30
npm install --silent
npm run build 2>&1 | grep -iE "error|warn" | head -n 40

You can ask for this in CLAUDE.md, for example "run tests with -q and pipe long output through tail". Claude Code also truncates very long Bash output on its own (30,000 characters by default), but that cuts by position, so a useful error in the middle can be lost.

8. Read only the part of a file you need

Point Claude at a function or a line range instead of a whole 2,000-line file, or ask it to search first and read only the matches. Every file read stays in the conversation until the next compaction or /clear.

9. Start new sessions for new work

Resuming an old session brings its whole history back. If the old work is done, start a new session, and bring along only a short note (see technique 2).

Which techniques save the most

TechniqueTypical impactEffort
/clear between tasks, with a handoff noteHigh in long workdaysA habit
Earlier auto-compaction (autoCompactWindow)High in long sessionsOne setting
/compact with instructionsHigh, when used before a session gets longA habit
Lean CLAUDE.md and fewer MCP serversMedium, on every replyOne-off cleanup
Subagents for broad searchesMediumAsk for it
Shorter command output, partial file readsLow to mediumCLAUDE.md instructions

The pattern is clear: conversation length matters more than any single tool result. Fix that first.

Tokens vs plan usage limits

If you use Claude Code on a Pro or Max plan, you care about the 5-hour and weekly limits more than raw tokens. They are related but not the same: most of a long conversation is re-read from the prompt cache, and cached reads count for much less than new input and output.

So cutting a conversation in half saves far more than half of the tokens shown in a transcript, but a smaller share of your limit. In our own A/B test of a long session, using 79% fewer tokens used about 25% less of the 5-hour limit, for the same work. Real, but be wary of anyone who presents token savings as limit savings.

Automate it

Techniques 2, 3, 4 and 7 can run automatically through Claude Code's hooks and settings. That is what Lighten does: it sets auto-compaction to 200k tokens and tells the summary what to keep, hands Claude a short note after a compaction or /clear, and shortens noisy test and build output before Claude sees it. It is free and runs on your machine.

For the bigger picture of what goes into the context window and why, read Context Engineering for Claude Code.

Frequently asked questions

Why does Claude Code use so many tokens?

Every reply re-reads the whole conversation, including earlier tool output such as file contents and test logs. The longer a session runs without /clear or compaction, the more each reply costs.

Does /clear reduce token usage?

Yes. /clear starts a fresh conversation, so the next reply no longer re-reads everything before it. Use it between unrelated tasks. Save anything you need, such as a plan or open issues, to a file first.

What is the difference between /clear and /compact?

/clear drops the conversation entirely. /compact replaces it with a summary, so Claude keeps the gist and you keep working on the same task with a much smaller context. You can add instructions, for example /compact keep the failing test names.

How do I make Claude Code compact earlier?

Set autoCompactWindow in ~/.claude/settings.json to the conversation size, in tokens, where auto-compaction should start, for example 200000. Smaller windows save more but compact more often, and each compaction can lose detail.

Do MCP servers use tokens?

Yes. The tool definitions of every connected MCP server are part of the context, and large MCP tool results add more. Disconnect servers you are not using in a session.

Does using fewer tokens save my Pro or Max usage limit?

Yes, but by less than the token count suggests. Re-read conversation history is usually served from the prompt cache, which counts far less than new work. Cutting a long conversation saves a large share of tokens and a smaller share of the plan limit.

Shryxa is not affiliated with or endorsed by Anthropic. "Claude" and "Claude Code" are trademarks of Anthropic. Claude Code changes often; check the official docs for the latest behaviour.