← Back to Blog

Claude Code Token Saving Tips: 10 Ways to Cut Usage

Zivv••23 min read
Claude Codetokenscost

After a few weeks with Claude Code, many developers notice the bill growing faster than expected: a handful of edited files, yet the usage log shows millions of tokens. There is nothing mysterious about it. Claude Code is an agent, and every turn resends the system prompt, your CLAUDE.md, tool definitions and the entire conversation so far. Longer, messier sessions make every turn more expensive. The good news is that most of that waste can be removed with features Claude Code already ships — no quality trade-off required. Here are ten techniques that actually work, followed by how to verify the savings with real usage data.

Where the Tokens Go

Each request Claude Code sends contains roughly:

  • The system prompt and tool definitions, including tools exposed by connected MCP servers
  • Memory files such as CLAUDE.md
  • The full session history: your messages, model replies, every file it read, every command output
  • The new message for this turn

Output covers the reply, code edits and, with extended thinking enabled, the thinking itself. The key insight: session history is the largest and fastest-growing part of the input. Twenty files read and ten test runs ride along on every subsequent turn. Prompt caching lowers the cost of those repeated prefixes, but it does not make them free. So there are only two levers: keep the per-turn context small, and use a model priced for the task.

Run /context inside Claude Code to see what is occupying the context window right now. It is the fastest way to spot the biggest offender before optimizing anything.

1. Keep CLAUDE.md Short and Specific

CLAUDE.md loads at the start of every session, so every line of it is part of every request in that session. Written well, it saves tokens the model would otherwise spend exploring. Bloated, it is a fixed tax.

  • Include only what the model needs every time and cannot infer quickly from code: build and test commands, directory conventions, hard style rules, things it must not touch
  • Use terse bullets, not background essays or decision histories
  • Do not paste whole API docs or long configs; reference specific files with @path imports or let the model read them on demand
  • Put a CLAUDE.md in a subdirectory when the rules only apply there — it is pulled in when Claude works in that directory
# Conventions
- pnpm only. Tests: pnpm test -- <file>. Types: pnpm typecheck
- Frontend in web/, backend in server/, shared types in shared/
- Run only the relevant tests after a change
- Never edit existing files in migrations/

/init drafts one for a new project — then delete half of it. Edit later with /memory.

2. Use /clear Between Unrelated Tasks

/clear wipes the session history. Finished a bug and moving to an unrelated feature? Clear first. The common anti-pattern is a single session from morning to evening, where the afternoon's feature work still drags along dozens of files read while debugging in the morning. The test is simple: does the next task need anything from the current conversation? If not, clear.

3. Compact Proactively With Instructions

When a task is unfinished but the context is getting long, /compact summarizes the history and keeps going. You can tell it what matters:

/compact Keep only: files changed, API changes, and the two failing tests still open

Claude Code auto-compacts near the context limit, but that happens late and without knowing your priorities. Compacting at natural milestones is cheaper and more predictable.

4. Match the Model to the Task

Opus-tier models cost noticeably more per token than Sonnet-tier models. Most coding work — reading code, routine features, tests, simple fixes — is well within Sonnet's range. Save Opus for architecture, gnarly bugs and large cross-module refactors.

TaskSuggested modelWhy
Everyday coding, tests, small fixesclaude-sonnet-5Best value, fast
Architecture, refactor planningclaude-opus-4-8Deeper reasoning, fewer redo cycles
Hard bug huntsSonnet first, Opus if stuckMost bugs do not need Opus
Bulk formatting, simple text choresA cheaper lightweight modelNo heavy reasoning needed

Switch any time with /model. The opusplan alias uses Opus while planning and Sonnet while executing, a good fit for think-then-build tasks. Through Zivv you can map aliases to concrete ids with ANTHROPIC_DEFAULT_SONNET_MODEL and ANTHROPIC_DEFAULT_OPUS_MODEL; check ids in the Model Hub. The broader approach is in the multi-model routing guide.

5. Plan Before Executing

The most expensive waste is rework: the model misreads the request, edits a dozen files, and you ask it to undo everything. Plan mode (cycle to it with Shift+Tab) reads code and proposes an approach without touching files. Agree on the plan, then let it execute.

Likewise, press Esc the moment you see it heading the wrong way. Every extra line it writes is output, and output tokens cost several times more than input tokens.

6. Be Specific and Name the Files

"Figure out why login is broken" makes the model search widely and read anything plausibly related. "The refresh logic around line 80 in src/auth/session.ts doesn't retry on expiry — fix it" needs one file. Reference files with @ to minimize exploration. When sharing errors, paste the relevant stack lines, not thousands of lines of logs.

7. Block Directories It Should Never Read

Build output, dependency folders and large data files silently inflate context when read. Deny them in the project's .claude/settings.json:

{
  "permissions": {
    "deny": [
      "Read(./dist/**)",
      "Read(./node_modules/**)",
      "Read(./data/**/*.csv)"
    ]
  }
}

Commit it so the whole team benefits. Watch command output too: "run the related test file" beats "run the full suite", and piping noisy logs through a filter or tail keeps them out of the history.

8. Offload Exploration to Subagents

A subagent works in its own context window and returns only its conclusion to the main session. That makes it ideal for read-heavy exploration: "find every call site of this function", "read these ten files and summarize the data flow". The main conversation stays lean.

Create one with /agents or as a Markdown file in .claude/agents/, and set a cheaper model in the frontmatter:

---
name: code-searcher
description: Finds definitions and call sites; returns paths with one-line notes
tools: Read, Grep, Glob
model: sonnet
---
Search and summarize only. Never modify files. Return a list, one item per line.

Be clear about what this saves. A subagent still spends tokens reading files, so total usage is not automatically lower. The win is that the main context stays small, which makes every later turn cheaper — and the subagent can run on a less expensive model than your main session.

9. Trim MCP Servers and Thinking Budgets

Every connected MCP server adds its tool definitions to the context, so a pile of rarely used servers is a surcharge on every request. Review them with /mcp and disable what you are not using, or configure them only in projects that need them.

Extended thinking is billed as output. Hard problems deserve it; trivial edits do not. The MAX_THINKING_TOKENS environment variable caps the thinking budget when you want a ceiling.

10. Verify With Usage Data

Measure instead of guessing, at two levels:

  • In the session: /cost shows token usage and an estimated cost at official prices; /context shows window usage. When routing through a gateway, treat the /cost figure as an estimate — the console is the source of truth
  • In the account: the Zivv console logs each request with model, input and output tokens and the charge, filterable by key and model

A practical habit: separate keys for separate purposes — daily development versus batch scripts, for instance — so the expensive bucket is obvious. Teams can use Team mode to break usage down by member, key and model, and set daily budgets so one runaway session cannot drain the month. For the arithmetic, see the token cost calculator guide.

Quick Reference

SituationAction
Switching to an unrelated task/clear
Milestone in a long task/compact with what to keep
Unsure how big the context is/context
Routine coding/model to Sonnet
Complex taskPlan mode first, or opusplan
Model going off trackEsc immediately
Heavy exploratory readingDelegate to a subagent
Build output being readdeny Read rules in settings.json
Unused MCP serversDisable via /mcp

FAQ

Why does Claude Code use so many tokens? Each turn resends the system prompt, CLAUDE.md, tool definitions and the full history, including every file read and command output. Longer sessions mean pricier turns; that is how agentic tools work.

What is the difference between /compact and /clear? /clear drops everything and suits a switch to an unrelated task. /compact replaces the history with a summary and continues, which suits a long task that is not finished yet.

How long should CLAUDE.md be? There is no hard rule. Include only what is needed every time and not obvious from the code — usually a few dozen lines. It rides along on every request, so length is a fixed cost.

Do subagents reduce token usage? They reduce main-session context, not necessarily total tokens. The savings come from a leaner main conversation and the option to run the subagent on a cheaper model.

Is the /cost number accurate when using a gateway? It is an estimate at official prices. On Zivv, the actual charge is the group multiplier times the official model price on real token counts, shown in the console. The rules are in the billing docs.

What is the cheapest way to use Claude Code heavily? Cut wasted tokens first with the steps above, then pick the right billing model. For long daily sessions, look at the Claude MAX group; the trade-offs are in subscription vs API.

Wrap-Up

Saving tokens is about wasting less, not working less: clear between tasks, compact between milestones, default to Sonnet, plan the hard parts, delegate exploration, and check the numbers. Make those habits and the same workload costs noticeably less. Not set up yet? Follow the macOS and Linux setup guide, then register and start in minutes.