XNews

Claude Code Token Cost and Usage Analysis

Claude Code Token Cost and Usage Analysis

Anthropic released a detailed blog post explaining why fixing the same bug with Claude Code can consume vastly different amounts of tokens. The cost model shows a5x price difference between prefill and decode, how prompt caching works with prefix matching, and that every item in context is re-sent every conversation turn. Recommendations stress using /clear, /compact, and @- mention commands frequently, keeping sessions short, minimizing context, matching model and effort to the task, and avoiding breaks in the prompt cache. The guide covers what determines a token’s price (model, input/output split, caching, cache-breaking factors), how many tokens a session sends (nothing sent once, content in context, number of turns, sub-agents), and where to prioritize optimizations.

Key insights

Anthropic Dissects Token Cost Structure, Highlighting the5x Prefill/Decode Price Gap

Token price is driven by model choice, input vs. output tokens, and especially prompt caching. The prefill/decode split creates a5x price differential. Properly leverageing caching—and understanding whatactions break it—can substantially change session costs.

Repetitive Context Sendings in Every Turn Drove Up Token Spend

A core insight is that no information is sent just once; everything in the contex—including tools, memories, and mcp resources—is re-submitted dozens of times per session. This makes long sessions and bloated contexts particularly expensive, even for simple tasks.

Practical Commands and Session Management Can Significantly Reduce Costs

The blog advocates regular use of /clear, /compact, and precise @- mention commands. Users are advised to avoid overly long sessions, limit context size, use only the model and effort level necessary for the task, and guard against breaking the prompt cache. These adjustments avoid sending unnecessary data repeatedly.

Source posts