All posts
6 min read

How to Keep Claude Code Costs Down (Without Making It Worse)

Claude Code usage is driven less by how much you ask and more by how much context every request carries. Where the tokens actually go, how to see them, and the habits that cut usage — clearing between tasks, picking the right model, trimming CLAUDE.md, and planning before building.

Claude CodecostAI agents

Whether you pay per token with an API key or have a Pro or Max subscription with usage limits, Claude Code has a cost — in dollars, or in how soon you hit the limit. And it often doesn't track how much you feel like you've used it. A quiet afternoon can use more than a busy morning.

That's because the main driver isn't the number of questions you ask. It's how much context each question carries. Once you see that, the ways to reduce cost are mostly obvious, and most of them make Claude work better, not worse.

Figures and commands reflect Claude Code as of September 2026. Anthropic's costs guide is the reference.

Where the tokens go

Every time Claude Code sends a request, it sends the conversation so far. Every time Claude uses a tool, it sends another request with the tool results added. So a session's cost grows roughly with length of conversation × number of requests.

A few consequences that surprise people:

  • A one-line question in a session that's been open all day still carries the whole day. Prompt caching makes re-reading that history much cheaper, but not free.
  • Coming back from a break can be expensive. Cached context expires — after an hour on a subscription, and after five minutes by default on an API key. The first message after that reprocesses everything at full price.
  • Compacting a big conversation is itself a big request, because summarising means reading it all.
  • Background activity counts. Scheduled tasks and loops fire on their interval, carrying the session's context each time.

For a sense of scale, Anthropic reports that across enterprise deployments the average is around $13 per developer per active day, with 90% of users under $30 a day. Heavy automation and parallel agents sit above that.

See it first

Run /usage. API users get a session cost estimate and token breakdown. Subscribers get plan usage bars and a breakdown of what's consuming them — skills, subagents, MCP servers, and flags for patterns like long context or cache misses.

Run /context to see what's filling the current context window right now. It's usually illuminating: a large CLAUDE.md, a pile of MCP tool definitions, or one enormous file Claude read an hour ago.

The habits that matter most

1. Clear between unrelated tasks

The single biggest lever. When you finish one task and start something unrelated, run /clear. The old conversation is saved — you can /resume it — but it stops riding along with every new request.

Name the session first with /rename so it's easy to find again.

If you want continuity rather than a fresh start, /compact replaces the history with a summary. You can steer it: /compact keep the API design decisions and the list of failing tests.

2. Match the model to the job

The most capable model is not the right model for every task. Anthropic's guidance: a Sonnet-class model handles most coding work well and costs less; save Opus for complex architecture and multi-step reasoning. Switch with /model mid-session.

The same applies to subagents. A subagent that runs tests or searches files can use a cheaper model — set model: haiku in its definition. See Claude Code Subagents.

3. Turn effort down for simple work

Extended thinking improves hard reasoning, and thinking tokens are billed as output. For a rename or a simple fix, lowering the effort level with /effort saves tokens without hurting the result.

4. Keep CLAUDE.md short

CLAUDE.md loads into every session. A 600-line file of detailed procedures is paid for in every conversation, whether or not the procedures are relevant. Keep it to essentials — Anthropic suggests under 200 lines — and move specialised workflows into skills, which load only when used. (How to Write a CLAUDE.md and Claude Code Skills cover both.)

5. Be specific

"Improve this codebase" triggers a broad scan: many files read, most of them irrelevant. "Add input validation to the login function in auth.ts" reads one file. Specific prompts are cheaper and produce better work.

6. Plan before building

The most expensive thing in any session is re-work: code written in the wrong direction, then read back, then rewritten, with the failed attempt still in context. Five minutes in plan mode is cheap compared to one wrong direction.

7. Stop early

When Claude heads the wrong way, press Escape immediately. Then /rewind to a good checkpoint. Letting it finish a wrong approach "to see where it goes" is paying for work you'll throw away.

8. Push noisy work into subagents or hooks

Test output, logs, and documentation dumps are huge and mostly irrelevant. A subagent can run the tests and return "two failures, here's why." A hook can filter a command's output to just the error lines before Claude ever sees it. Either way, the noise never enters your main conversation.

9. Prune MCP servers

Each connected MCP server adds some overhead, and large tool results add a lot. Disable servers you're not using with /mcp. Where a good CLI exists (gh, aws, gcloud), Claude can run it directly with less overhead. See Connecting MCP Servers to Claude Code.

For automation and teams

  • Cap headless runs. claude -p accepts --max-turns and --max-budget-usd. Set both on anything that runs on a schedule. (Running Claude Code Headless.)
  • Watch parallel work. Several agents in parallel use several times the tokens. That's often worth it; it should be a choice.
  • Set spend limits. API organisations can set workspace spend limits in the Claude Console; Team and Enterprise admins can set limits on usage beyond the seat allowance.

Subscription or API?

Whether a flat subscription or pay-per-token works out cheaper depends almost entirely on how much you use it and how evenly. We compare them in detail in Claude Pro vs Max vs API Key for Claude Code.

What not to cut

Two economies make things worse:

  • Don't skip verification to save tokens. Letting Claude run the tests costs tokens. Shipping untested code costs more, later.
  • Don't starve it of context it needs. A task that needs to understand three modules needs those three modules read. The target is irrelevant context, not context in general.

The summary

Cost follows context. Clear between tasks, keep permanent instructions short, pick the model and effort for the job, plan before building, stop early when it's wrong, and keep noisy output out of the main conversation. Every one of those also makes Claude more focused — which is why they're worth doing even if cost isn't your concern.


EasySpawn is bring-your-own-subscription: you connect your own Claude plan or API key and Anthropic bills you directly, with no markup — EasySpawn's flat monthly price covers only the infrastructure. See pricing or join the waitlist.

Related: Agent Hosting Is Becoming Free. Here's What Isn't. · How to Resume a Claude Code Session · What Are Tokens in AI?

Keep reading