The hidden costs of AI coding tools are becoming a focal point for developers. Anthropic recently published a technical blog post—a rare official, systematic breakdown of token waste in Claude Code—offering six concrete cost-saving recommendations. According to official data, Claude Code developers consume roughly $13 in tokens daily, with monthly costs ranging from $150 to $250, and that’s just the average.
Anthropic states bluntly in the post that the same task can cost several times more depending on how it’s executed. The core reason: every round of conversation in Claude Code re-sends the complete content of all previous rounds. The longer the session, the more expensive each subsequent round becomes.
To understand the math, one must start with how token pricing works. Every time a user issues a command in Claude Code, two things happen behind the scenes: prefill and decode. Prefill is when the model reads the entire request in one pass—including the system prompt, CLAUDE.md configuration files, the user’s message, and all accumulated conversation history—all of which count as input tokens. Decode is the process of the model generating a reply token by token, including reasoning content, tool calls, and the final displayed text, all of which count as output tokens.
The two operations work in fundamentally different ways. Prefill is parallelized: all input tokens pass through the GPU in a single batch. Decode is serial: each generated token requires a separate model run. This means a 200-token reply requires 200 independent computations. For this reason, output tokens are typically priced at 5x the rate of input tokens.
On this foundation, the final bill is determined by two variables: model selection sets the unit price, and reasoning effort determines token volume. At current pricing, Opus 5 costs $5 per million input tokens and $25 per million output tokens; Sonnet 5 costs $2 for input and $10 for output; Haiku 4.5 costs $1 for input and $5 for output. Reasoning effort controls how many thinking tokens are produced—the higher the setting, the longer the model thinks and the more tokens it consumes, with the highest and lowest tiers potentially differing by several multiples.
Anthropic’s first recommendation strikes at the heart of the problem: use /clear immediately after finishing a task. Clear the current session after fixing a bug to prevent files read and command outputs from the previous task from occupying context space in the next one.
The second recommendation is to lock in the model and reasoning effort from the very start. Switching models or adjusting reasoning effort mid-session invalidates all previously accumulated prompt cache, forcing the entire conversation history to be recomputed at full price.
The third recommendation is to use @ file references instead of manually typing paths. The @ reference attaches the file directly to the message, saving one tool-call read operation. If you only type a filename, Claude may search around first, then open multiple files to probe—all of these operations enter the conversation history and get re-billed in every subsequent round.
The fourth recommendation is to add quiet flags to high-output commands. Configure parameters like –reporter=dot in CLAUDE.md so test output shows only a few lines of summary instead of hundreds of lines of detail. The shorter the output, the less context it occupies.
The fifth recommendation concerns the timing of /compact. Running compression while the conversation is still within the cache validity window costs only one-tenth of the normal rate. If you wait until the cache expires, the system must re-read all content at full price.
The sixth recommendation is to delegate large-output tasks to subagents. Subagents run in independent context windows and only pass conclusions back to the main conversation after completion. Files read and command outputs generated during the process never enter the main conversation history.
Within the token cost structure, prompt caching is the most critical cost-saving lever. Every request in Claude Code starts with the same prefix—including the system prompt, tool definitions, CLAUDE.md, and conversation history. If the current request’s prefix matches the previous one byte-for-byte, the server loads previously computed results directly, and cache-read pricing is only one-tenth of the normal input price.
Take a conversation history containing 50,000 tokens as an example: without caching, every round requires re-reading those 50,000 tokens at full price. With a cache hit, the same content costs only one-tenth. Over a session running twenty to thirty rounds, the accumulated discount is substantial.
But caching has a fatal weakness: it must match continuously from the first byte of the request. Any change at any position invalidates everything from that point onward. Anthropic lists six scenarios that invalidate the cache: switching models, adjusting reasoning effort, toggling Fast mode, using /compact to compress the conversation, cache timeout (1-hour retention for subscribers, 5 minutes by default for API users), and resuming an overly old session.
One hidden trap worth noting is the opusplan mode. This mode switches models every time it enters or exits the plan phase—entering invalidates the cache once, exiting invalidates it again. Frequent switching means repeatedly paying full-price prefill fees.
While caching can compress the cost of repeatedly sending history to one-tenth, it cannot stop the conversation history itself from bloating. Every time Claude reads a file, the file’s contents are appended to the conversation; every time a command executes, its output is appended as well. From the round of appending onward, every subsequent round must carry that content. Round 40 requires re-sending all accumulated content from rounds 1 through 39—growth approaching quadratic complexity.
Claude Code has a fallback mechanism: when command output exceeds 30,000 characters, the content is written to a temporary file and only a summary is retained in the conversation. But output below that threshold is not processed. For example, if a test framework prints 400 lines of passing results, each a few dozen characters, totaling under 30,000, that content remains verbatim in the conversation history and gets re-sent in every subsequent round.
Beyond /clear, Anthropic also mentions a relatively obscure but free operation: /rewind. If the last few rounds have veered off course, /rewind can cut them directly, leaving the preceding cache completely unaffected.
Anthropic’s own practices provide a footnote to these recommendations. The company writes 80% of its code with AI, has seen code merge volume grow 8x in a year, and has accelerated benchmarks by 52x. Under such intensive AI usage, failing to manage token consumption could blow through budgets on inference costs alone.
From a broader perspective, this blog post’s significance extends beyond cost-saving tricks. It reveals an emerging skill domain: developers in the AI era need to understand what resources every operation consumes and how to extract more output from the same budget. This capability is independent of programming languages and frameworks, yet it directly determines whether the same task costs $3 or $30.