← All articles

Tutorial

How to Cut Token Usage in Claude Code Without Making the Agent Stupid

A step-by-step setup: measure the leak, cap the session, then pull only the switches that remove waste instead of context.

How to Cut Token Usage in Claude Code Without Making the Agent Stupid

You want to cut token usage in Claude Code, and the internet hands you the same advice: paste fewer files, ask for shorter answers. That advice is not wrong so much as late. Your session does not run out because your codebase is large. It runs out because your agent is polite.

Wednesday afternoon, a refactor half finished, and Claude Code stops mid-thought: the five-hour window is empty. The plan was meant to carry you to Friday. You have already tried shorter answers, fewer pasted files, a stern line in the prompt about being concise. Each fix bought you an afternoon.

Start with a number. Without one you are guessing which habit to break, and guessing produces a quieter agent that is wrong more often.

How Do You Cut Token Usage in Claude Code Without Guessing?

Measure the leak before you plug it. Scan the sessions already saved on your machine, find which files, answers and repeated reads eat the context, put a hard cap on one session, and only then switch on compression or routing. Cutting blind makes the agent dumber and the bill larger, because every retry is paid twice.

The measuring tool is called Deep Scan, and it is free with no login. It reads the conversation history already on your disk and shows, session by session, where the context went. Nineteen other measurement and monitoring tools ship free beside it, which matters for a reason that has nothing to do with generosity: a vendor that hides the meter has no incentive to make the meter look good.

Installation is one command, npm install -g harnessup, and the app runs on Windows, macOS and Linux. Everything happens locally, on your machine.

Read the scan like a suspicious accountant. Look for the same file opened in four consecutive turns, answers that restate the request before starting, outputs that scroll far past what you needed, and the expensive model doing lint. Any of those repeating across a week is your leak. The Deep Scan walkthrough of where your tokens actually go traces one session line by line.

The transcript does not lie, and that is the annoying part.

Get one more number before you touch anything: when your window resets. If it lands at three in the afternoon, the frantic morning is a scheduling problem wearing a token costume. No compression switch rescues a deadline that ignores the calendar, so read up on when the Claude Code usage limit resets before you blame the agent.

Stop Blaming Your Files. The Waste Is the Agent's Manners.

Full disclosure: I am a product manager at HarnessUp, and the toolkit in this tutorial is ours. Weigh that, then weigh the mechanism, which you can check in your own transcripts tonight.

Here is the mechanism. Every token the model writes comes back on the next turn, and the turn after that. A chatty preamble is not a one-time cost; it is a subscription. The same goes for a file reread for the fifth time: the agent already had the answer, and you paid again for the privilege of it forgetting.

Developers who would never ship an N+1 query tolerate an N+1 read of the same header file all week.

HarnessUp exposes the fixes as individual switches, more than 200 of them, each reversible with one key. The order below is deliberate: remove repetition, trim output, compress bulk, cap the session, route the cheap work. Compressing first feels productive and is the wrong place to start.

  1. Delta Read stops the agent from rereading what it has already read. Best ratio of savings to risk, because the information stays available and only the duplicate trip disappears.
  2. Response Diet cuts the preamble and the oversized answer before either reaches the context, so the politeness tax stops compounding round after round.
  3. Smart Compress shrinks content without calling the model to do it. Compression that costs a model call can eat its own savings.
  4. Stop Loss sets a hard cap, five dollars in the panel's own example, and stops the session when the number is hit.
  5. Cheap Swarm routes the light work, search, lint, builds, docs, to cheaper models and lower effort, and leaves the expensive model to decide. It sorts tasks into 26 classes, with the orchestrator choosing in milliseconds.

HarnessUp's own claim is up to 78% of work tokens saved, with up to three times more work inside the same five-hour window. Both are best-case numbers from real windows, which is why the panel shows your own figure measured on your history, and why this tutorial starts with a scan instead of a subscription.

Side-by-side view of a Claude Code session rereading the same file four times versus a single read with the Delta Read switch on, with a token meter in the middle.

Counterargument time: cut too much and the agent forgets the constraint you gave it at minute two, then spends the savings on three retries. Context is not garbage. A forty-thousand-line log is waste; the one clause of the contract that decides the design is not. Remove repetition and politeness first, compress bulk second, touch the reasoning last, if at all.

Underneath sits the plumbing. HarnessUp attaches through the official Anthropic and OpenAI hooks, SessionStart, UserPromptSubmit, PreToolUse, PostToolUse and Stop, instead of intercepting the API. It works in the CLI, the desktop app and the IDE extensions, stays local with a p95 under 50 milliseconds, and commits in writing to never read, store or pass on your token or key. That promise is the one to verify with any tool of this kind, ours included, and HarnessUp's token-saving toolkit for Claude Code and Codex states it plainly.

None of this needs a leap of faith. The hooks are visible, the switches are individual, and the undo key works, which is a low bar that a surprising amount of tooling in this category still fails.

There is a quieter winner here. Waste is billable, so every preamble, every reread and every premium model spent on lint is revenue for someone, and no provider is paid to notice it for you. Nobody planned it that way. It is an incentive, and incentives do not need meetings. The five-hour window turns that incentive into a deadline you can feel, which is why a limit changes developer behaviour faster than any essay about efficiency.

Subagents deserve their own warning. Handing work to five helpers can look like parallelism and behave like five times the context, each one briefed from scratch. Cheap Swarm exists because the routing decision, which model, which effort, which task class, is where the money hides. A cheap model on lint is a bargain; a cheap model on the migration that decides your schema is a false economy.

What Do You Do When the Setup Breaks Mid-Session?

Undo everything with Z, then enable keys one at a time until the failure comes back. Every switch in the panel reverses with a single click, the 1 to 8 shortcuts toggle the first keys, and the rollback tools can restore files and secrets when a command already did damage.

Three failures deserve names. Delta Read can turn too strict and refuse a file the agent genuinely needs after an edit; undo that key, or allow one read per changed file. Response Diet can leave an answer so terse that you lose the reasoning and ask again, which turns a saving into a bill you pay twice. Stop Loss can halt a migration at the worst possible moment, which is what a cap is for and why you choose the number rather than accept a default.

If something worse already happened, a deleted file, an exposed .env, a force push to main, the recovery side exists for that. Secret Lock masks passwords and keys before they enter the conversation, Smart Return rolls files back to before a chosen command, Checkpoint writes a restore point in git without touching your branches, No Delete refuses rm, del, Remove-Item and git clean, and Git Shield keeps secrets and generated folders out of a push. Recovery is damage control, and a bad afternoon should not cost you the week.

A cap you chose is a decision; one you discover at four in the afternoon is a surprise.

Verification is where most tutorials wave their hands. Do it with two windows of comparable work: one before the switches, one after. If the second window finishes the same shape of task with room left over, the saving is real. If it finishes sooner because the agent gave up halfway, you saved nothing and deferred the bill to the retry. The demo numbers in any panel are illustrative by design; your own history is the only benchmark that survives a code review.

When the numbers refuse to move, check the mix before you blame compression. An expensive model still answering every small question will swamp a Delta Read saving. A cap set too high never fires, which makes it decoration. A week of turning on every switch at once teaches you nothing, because you cannot tell which one helped; three keys, one week, then judge.

Run the scan again afterwards. Deep Scan is free and local, so the second reading costs nothing, and the gap between two scans is the closest thing this field has to a receipt.

Then give it a normal week with the meter visible. Compare windows, not vibes: how much work landed before the limit, how many turns went into rereading, what the cap caught. If a long task still dies at the boundary, handing the session off with a written state file stops the next window from starting cold, and if you want the shopping done first, how token-saving tools for Claude Code and Codex compare is the map.

The window will still empty on a hard Thursday. What changes is whether it empties on work you can point to or on an agent announcing that it will help with that, for the ninth time. Measure the leak, cut the manners, keep the context that earns its rent, and the plan stops being a countdown.

This article was drafted with AI assistance in HarnessUp Publish and approved by the HarnessUp team before publishing.