TokenPincherGet started

How to Reduce Claude Code Token Usage

TokenPincher

If you use Claude Code for real work, you have almost certainly hit a usage limit sooner than you expected, or watched a single session blow through more tokens than the actual coding problem seemed to justify. This isn't bad luck. It's how agentic coding tools work by default, and there is a lot you can do about it. This guide covers why token usage balloons in the first place, then every practical tactic — from free habits to an always-on automated option — for cutting it down.

Why Claude Code token usage balloons

Claude Code (and coding agents generally) are not stateless chatbots answering one question at a time. Every turn resends the entire conversation so far — every message, every file it read, every command it ran, every line of output — because the model has no persistent memory between requests. Understanding this is the key to understanding your bill.

1. Full-conversation resend, every turn

When you send message 40 in a long session, Claude isn't just processing message 40. It's processing messages 1 through 40, because the API is stateless and the entire context has to be included again for the model to have any memory of what happened earlier. A session that feels like "one more quick question" can be re-sending tens of thousands of tokens of history you've long since stopped thinking about.

2. Tool output is bigger than anything you typed

This is the big one. Claude Code is agentic: it reads files, greps across your repo, runs your test suite, and reads the results back into context so it can decide what to do next. A single catof a 2,000-line file, a verbose test run, or a build log with a stack trace can dwarf every message you've typed in the session combined. Because that output becomes part of the conversation history, it gets resent on every subsequent turn too — the cost compounds.

3. Logs and boilerplate you don't actually need re-read

Command output often contains far more than the model needs to make its next decision: full stack traces when only the top frame matters, entire directory listings when only a few files are relevant, verbose npm/build logs where only the error line counts. None of this is wrong to produce — it's just wasteful to keep verbatim in context turn after turn.

4. A bloated CLAUDE.md tax on every single request

Your CLAUDE.md (or AGENTS.md) file gets prepended to every request in the project, whether or not it's relevant to the current task. A tight, well-organized 40-line file costs you nothing you'll notice. A sprawling 600-line file with outdated sections, long code samples, and duplicated instructions gets billed on every single turn of every single session, forever — until you trim it.

Tactics that actually work

None of these require giving up on agentic workflows — they're about being deliberate with context instead of letting it grow unchecked. Roughly ordered from "do this today, costs nothing" to "bigger workflow changes."

Use /clear between unrelated tasks

/clearwipes the conversation and starts fresh. If you're switching from debugging an auth bug to writing a new feature, there is no reason to keep dragging the auth debugging history along. It's the single highest-leverage habit: end a task, /clear, start the next one clean. The instinct to keep one long-running session "just in case you need the context" is usually what causes the usage-limit hit.

Use /compact when you need continuity but are running long

/compactsummarizes the existing conversation into a shorter form instead of wiping it, which is the right call when you genuinely need the thread of a long task to continue. It's not free — summarization is lossy, and it only compresses chat history, not the tool output problem above. See our full breakdown of what /compact does and doesn't do.

Choose the right model for the task

Not every step of a coding session needs your most capable (and most expensive) model. Simple mechanical work — renames, boilerplate, straightforward edits — is often better handled by a cheaper, faster model, saving your top-tier model's budget for the steps that actually need deep reasoning: architecture decisions, tricky bugs, multi-file refactors. Mixing model tiers deliberately, rather than defaulting to the biggest model for everything, is one of the simplest ways to cut spend without cutting capability where it matters.

Keep CLAUDE.md lean

Treat your CLAUDE.md like a hot path in your code, not a wiki. Every line in it is billed on every request. Practical rules:

  • Keep it to the instructions that change model behavior — coding conventions, commands to run, things it keeps getting wrong — not general project background a human would read once.
  • Delete or archive sections tied to finished migrations or old conventions. Stale instructions cost the same as fresh ones.
  • Move long reference material (full API docs, long code samples) into a file the agent reads on demand rather than a file that's force-fed on every turn.
  • If you have several unrelated concerns (backend conventions, frontend conventions, deploy steps), consider splitting into nested CLAUDE.mdfiles scoped to subdirectories so irrelevant instructions aren't loaded for every task.

Compress or filter tool output before it hits context

This is the highest-impact lever because tool output is usually the biggest line item. A few manual habits:

  • Ask for targeted greps instead of full-file reads when you only need one function or section.
  • Pipe verbose command output through something that trims it (e.g. just the failing test, not the whole suite's passing output) before it goes back to the model.
  • Avoid re-reading files the agent has already seen this session unless they've changed — re-reads re-add the same tokens to history a second time.
  • Prefer commands with quiet/summary flags over defaults that dump everything.

Doing this consistently, by hand, on every tool call is tedious — which is the gap the automated option below is built to close.

Audit your MCP servers

Every MCP server you have connected adds its tool definitions to every request's context, whether you use it in that session or not. It's easy to accumulate MCP servers over time and forget one is even connected. Periodically check what's active and disconnect anything you're not actively using for the project at hand — it's pure overhead otherwise.

Practice session hygiene

A few habits compound over a week of real usage:

  • Start a new session per feature or bug, not per day — session length should track task boundaries, not time.
  • Don't paste large blobs (full error logs, entire config files) into chat when a file reference or a trimmed excerpt would do.
  • Watch for "context window full" warnings as a signal to wrap up or /clear, not to push through — see our guide on what to do when the context window fills up.
  • If you're bumping into the rolling usage window regularly, read our breakdown of why the usage limit hits and how to stop hitting it.

The automated option

Every tactic above works, and costs nothing but a habit change. The catch is that they're manual — you have to remember to do them, every session, every tool call. TokenPincherdoes the tool-output compression tactic automatically, lossless by default, on every request, without you changing how you use Claude Code. It's a one-line install — no desktop app, no background process to babysit — that sits between Claude Code and the model and shrinks large tool output and logs before they're added to context. The model still gets what it needs; you just stop paying to resend the bulk of it turn after turn.

Install
npx tokenpincher init
Example session, 58% saved$5,381$2,264

It's not a replacement for good habits — /clear between tasks and a lean CLAUDE.mdstill matter. Think of it as the automatic backstop for the one thing that's hardest to do manually and consistently: compressing tool output on every single call. Read the full Claude Code token usage overviewor see how it compares to Claude Code's built-in /compact command.

Also using Codex?

The same dynamics apply to OpenAI Codex CLI — full-history resend, heavy tool output, the works. See reduce Codex token usage or the Codex-specific guide.

Not sure how much you're spending?

Use the free Claude Code token calculator to estimate your current usage and what compression would save before you change anything.