top of page

Managing Token Costs in Claude Code on Your Mac

Writer: MacSmithAI
MacSmithAI
Jul 1
6 min read

Claude Code is the surface where token waste is easiest to rack up and easiest to control. A single vague prompt against a large repo can burn through context fast, and if you're on a Pro or Max plan, that same context is drawn from a pool shared with Claude.ai and Cowork — so being sloppy in the terminal costs you headroom in the chat app too. The good news: the controls are all built in, and most of them are one keystroke or one slash command.


For a rough sense of scale, Anthropic's own figure for enterprise deployments is around $13 per developer per active day, and $150–250 per developer per month, with 90% of users staying under $30 on any given active day. Your mileage depends almost entirely on the habits below.


First, see what you're spending

You can't manage what you can't see, and Claude Code gives you three views. The most useful for keeping context lean is /context, which shows what's currently occupying the window — CLAUDE.md, MCP servers, skills, conversation history — so you can spot the bloat. /usage gives you the spend and plan-limit picture, and on paid plans it attributes recent usage to individual skills, subagents, plugins, and MCP servers as a percentage of the total. Press d or w to toggle between the last 24 hours and the last 7 days.


One caveat worth knowing: the dollar figures in /usage are estimated locally from token counts on that machine, so they can differ from your actual bill and don't include usage from other devices or from claude.ai. For authoritative numbers, the Console Usage page is the source of truth. If you want a constant readout instead of checking on demand, you can surface context-window usage in your status line so it's always visible while you work.


Clear between tasks — the single highest-value habit

Every message in a session carries the whole conversation with it. When you finish one task and start something unrelated, that old context is now dead weight riding along on every subsequent message. /clear wipes it and starts fresh. This is the terminal equivalent of "start a new chat," and it's the same lever from Part 1 — just more consequential here because coding context gets heavy fast.


If you might want to come back to a session, name it first: /rename before you /clear, then /resume to return to it later. You get the clean slate without losing the thread.


Steer compaction instead of letting it guess

When a conversation approaches the context limit, Claude Code auto-compacts — summarizing earlier history to keep going. By default it decides what's worth keeping. You can take that decision back. /compact Focus on code samples and API usage tells it exactly what to preserve, so the summary keeps the details you actually need rather than a generic recap.

You can make that behavior permanent by putting it in your CLAUDE.md:

# Compact instructions

When you are using compact, please focus on test output and code changes

Keep CLAUDE.md lean, and push detail into skills

Your CLAUDE.md loads into context at the start of every session. That's the point of it — but it means every line is present even when it's irrelevant to what you're doing. If yours has grown to hold detailed PR-review checklists, database-migration steps, and deployment runbooks, you're paying for all of that on a session where you're just fixing a typo.


The fix is to move specialized instructions into skills, which load on demand only when invoked, and keep CLAUDE.md to essentials — the guidance is to aim for under 200 lines. A "codebase-overview" skill describing your architecture and key directories, for instance, gets pulled in when relevant instead of spending tokens on every session and forcing Claude to read files to reconstruct the same picture.


This is the Part 1 "keep your project instructions short" principle, one level deeper: context that's always loaded should only be what's always needed.


Right-size the model and the thinking

Same logic as the API piece, different controls. Sonnet handles most coding well and costs less than Opus; reserve Opus for genuine architectural or multi-step reasoning. Switch mid-session with /model, set a default in /config, and for simple subagent work specify model: haiku in the subagent config.


Extended thinking is on by default because it genuinely helps hard problems — but thinking tokens bill as output tokens, and the default budget can run to tens of thousands of tokens per request. For routine work that doesn't need deep reasoning, drop the effort level with /effort, turn thinking off in /config, or cap it with MAX_THINKING_TOKENS=8000 on models that honor a fixed budget. This is the highest-leverage knob most people never touch, since output tokens are the expensive side of the ledger.


Trim MCP overhead

If you've followed the MacSmith MCP setup posts, you may have several servers wired up. Modern Claude Code defers MCP tool definitions by default — only tool names enter context until Claude actually calls one — but servers still add up, and it's worth a periodic audit. Run /mcp to list configured servers and disable ones you're not using, and /context to see what's actually consuming space.


One counterintuitive tip from the docs: where a plain CLI tool exists — gh, aws, gcloud — it's often more context-efficient than the equivalent MCP server, because Claude can just run the command with no per-tool listing overhead. MCP earns its keep when you need structured, typed access; for straightforward operations, the CLI Claude already knows how to drive is leaner.


Offload the verbose stuff

Some of the biggest token sinks are things Claude reads that it didn't need in full. Two patterns fix most of it. Hooks can preprocess data before Claude sees it — instead of it reading a 10,000-line log to find errors, a PreToolUse hook can grep for ERROR and hand back only the matching lines, turning tens of thousands of tokens into hundreds. Subagents isolate verbose operations — running a test suite, fetching docs, chewing through logs — so the noisy output stays in the subagent's context and only a summary returns to your main session.


For typed languages, code-intelligence plugins are a quieter win: they give Claude precise "go to definition" navigation instead of grepping and then reading several candidate files, which cuts the exploratory reads that inflate context when it's working through unfamiliar code.


Don't go down the wrong path at full speed

The most expensive tokens are the ones spent building the wrong thing. A few habits prevent that. Plan mode (Shift+Tab) makes Claude explore and propose an approach for your approval before it starts editing, which heads off costly rework when the initial direction is off. If it does start drifting, hit Escape to stop immediately, and use /rewind (or double-tap Escape) to roll conversation and code back to a checkpoint rather than paying to unwind a bad path in-line.


And write specific prompts. "Improve this codebase" triggers broad, expensive scanning; "add input validation to the login function in auth.ts" lets Claude work with minimal file reads. Specificity is a cost control, not just a quality one.


One warning if you use Agent Teams

Agent teams spawn multiple Claude Code instances, each with its own context window, so token use scales with team size. Anthropic notes they can run roughly 7x the tokens of a standard session when teammates work in plan mode. They're off by default for a reason — keep teams small, use Sonnet for teammates, keep spawn prompts focused, and shut teammates down when their work is done.


Where to start

Open a session you've had running for a while and type /context. Look at what's actually filling the window — it's usually a bloated CLAUDE.md or a couple of MCP servers you forgot were on. Trim the obvious offender, then make /clear-between-tasks a reflex. Those two habits alone move most people well under that $30-a-day line, and they're free to adopt this afternoon.


That closes out the token-management series. Part 1 covered the everyday chat window, Part 2 the API, and this one the coding agent — three surfaces, one underlying idea: you pay for context, so keep only what the task in front of you actually needs.

Comments


bottom of page