Claude Code Token Cost Analysis
Anthropic published a blog post explaining the token cost model of Claude Code, highlighting that prefill (input) tokens cost 5 times more than decode (output) tokens. Prompt caching relies on prefix matching rules, and every item in the context window is re‑sent dozens of times across iterations, causing large variations in token consumption even for the same bug fix. The analysis aims to help users maximize the value of their sessions by managing context and leveraging caching efficiently.
Key insights
The 5x Cost Asymmetry Between Prefill and Decode Drives the Need for Input Optimization
In Claude Code, prefill tokens are five times more expensive than decode tokens. This means that reducing the size of the input context, especially by removing redundant or stale information, can significantly lower overall costs. The blog suggests that users should be mindful of what stays in the context window to avoid paying the premium for repeated processing.
Context Re‑sending Explains Why Token Usage Can Balloon Unexpectedly
The blog reveals that every piece of information in the context is re‑sent to the model dozens of times across conversation turns, including previous outputs and tool calls. This explains why fixing the same bug can consume vastly different token amounts depending on the accumulated history. Developers are advised to prune context aggressively to control costs.