Back to posts
AINews

Cut the tokens Claude Code spends before it reads your prompt

A measurement that reached the Hacker News front page put Claude Code at roughly 33,000 tokens of system prompt and tool schemas sent before the first word of the user's request. Part of that is fixed harness cost. A larger part is configuration you control — an oversized CLAUDE.md, servers you stopped using, unfiltered tool output, a thinking budget sized for harder work. How to read your own number with /usage and /context, and the five levers that move it.

In July, a team spliced a logging proxy between coding agents and the model API and counted what each harness sends before your prompt arrives. For a task whose answer was one line, Claude Code sent roughly 33,000 tokens of system prompt and tool definitions; OpenCode sent about 7,000. The write-up spent a day on the Hacker News front page, mostly framed as a harness comparison.

The more useful part of the measurement is what it found in production-shaped configurations, because those numbers describe your setup, not Anthropic's defaults. A 72 KB instruction file added around 20,000 tokens to every single request. Five connected MCP servers added 5,000 to 7,000 more. A modest two-subagent fan-out multiplied a task's total from 121,000 tokens to 513,000. The authors put the stakes plainly: every token of harness payload is a token of working context you cannot spend on your task.

This costs you on any billing model. On an API key, overhead is input you pay for on every request, cache discounts included. On a Pro or Max subscription, the same overhead drains your five-hour and weekly usage windows, which is why two people with the same plan and the same workload can hit limits days apart. And on both, a stuffed context measurably degrades output quality long before the window is full.

Read your number before changing anything

Claude Code ships the instruments for this; most people have never opened them. Update first (claude --version — the useful parts below landed across recent 2.1.x releases).

/context shows what is occupying the context window right now: system prompt, tool definitions, MCP tools, memory files, conversation. This is where an oversized CLAUDE.md or an upfront-loaded tool list becomes visible as a number instead of a feeling.

/usage shows where recent consumption went. On a subscription plan it attributes usage to individual skills, subagents, plugins, and MCP servers, each as a percentage of the total, and flags behaviors like long context or cache misses once one accounts for 10 percent or more of recent usage. Press d or w to switch between the last 24 hours and the last 7 days. One version note: before v2.1.222, one call to an MCP server caused every subsequent request to be attributed to that server, so an old build will overstate MCP share.

You can also put context usage in the status line and watch it move as you work.

Lever 1: the instruction file you grew for a year

CLAUDE.md loads into context at session start, every session, whether the session touches that material or not. The measured example above — 72 KB, roughly 20,000 tokens per request — is what a year of "just add a note to CLAUDE.md" produces.

Anthropic's own guidance is to keep the file under 200 lines and move specialized workflow instructions (PR review steps, migration procedures, deployment runbooks) into skills, which cost only a name and description until a task triggers them. The practical test for each section: does every session need this, or only sessions doing one specific job? If it is the latter, it is a skill. We covered the one failure mode of that migration — a skill that never fires because its description does not match how you phrase requests — in a separate post.

Lever 2: MCP servers you connected once and kept

The math on MCP overhead changed recently, and it changes what is worth doing. Claude Code now defers MCP tool definitions by default: at session start only tool names and server instructions enter context, and a schema loads when Claude searches for and uses that tool. Adding servers no longer costs thousands of tokens each per request — on a current version and default configuration. Two caveats keep this lever alive:

  • If you route through a custom ANTHROPIC_BASE_URL, a gateway, or certain cloud deployments, tool search can be off and full schemas load upfront. /context tells you which case you are in.
  • Tool results, not definitions, are now the dominant MCP cost. Claude Code warns when a single MCP tool output exceeds 10,000 tokens and caps it at 25,000 by default. A chatty server can dump the cap into your context on every call, and /usage attribution will show that server climbing.

So: open /mcp and toggle off the servers you are not using this week. The toggle is stored per project, and the configuration survives, so re-enabling later is one keystroke. And where a mature CLI exists — gh, aws, gcloud, sentry-cli — prefer it over the equivalent MCP server. Claude runs CLI commands directly, with no per-tool listing at any price.

Lever 3: output nobody filtered

A test run that prints 10,000 lines enters context as 10,000 lines unless something intervenes. Two documented patterns intervene:

A PreToolUse hook can rewrite the command before it runs. Anthropic's docs ship a working example that detects npm test, pytest, or go test and appends 2>&1 | grep -A 5 -E '(FAIL|ERROR|error:)' | head -100, so only failures reach the model. Tens of thousands of log tokens become hundreds, and the model reasons over exactly the part that matters.

For doc fetching, log analysis, and test loops that need the full output somewhere, delegate to a subagent: the verbose material stays in the subagent's context and only a summary returns. We wrote up how to route those subagents to cheaper models and trim their tool lists; the two changes compound.

Lever 4: a thinking budget sized for harder work

Extended thinking is on by default and billed as output tokens, and the default budget can run to tens of thousands of tokens per request. For refactors, migrations, and architecture that is money well spent. For renaming variables it is not. Lower the effort level with /effort for routine work, or on models with a fixed thinking budget set MAX_THINKING_TOKENS=8000 in your environment. Adaptive-reasoning models ignore a nonzero budget number, so effort levels are the control that works everywhere.

Lever 5: the session you never clear

Claude Code sends the full conversation with every request. Prompt caching makes that cheaper, not free — a one-line question in a session that has been open all day still draws usage for the entire history at cache-read rates, and the first message after a break longer than the cache lifetime reprocesses everything at full price. The lifetime is one hour on a subscription and five minutes on an API key, a gap we mapped in detail.

The habit that follows: /clear between unrelated tasks, with /rename first so /resume can find the session again if the work comes back. And check what fires while you are away — a scheduled task sends your full context on every interval, even while the session sits idle, so a recurring job belongs in a lean session, not the one carrying a week of history.

After a week, open /usage again. The attribution percentages are the before-and-after: if the MCP server you disabled and the 800-line CLAUDE.md you cut to 150 were real overhead, the flags disappear and the same work draws visibly less of your window. That margin is yours to spend on the task.

Get the next post when it ships

One email on Sunday with the new post and a short list of what shipped that week — new guides, tool updates, and a couple of links worth reading.