Detailed Analysis
A Reddit user's deep dive into Claude Code's local usage logs has surfaced a counterintuitive but economically significant pattern: the most expensive API calls in a coding session are often the most trivial messages, not the substantive ones. By parsing every API response's usage block stored locally in `~/.claude/projects`, the author priced 12,992 requests at list rates and found that a simple "good morning" could cost $5.18 despite metering only 66 input tokens of actual content. The catch was a 512,749-token cache write triggered because the prompt cache had expired overnight, forcing Anthropic's infrastructure to re-process and re-cache the entire accumulated context from scratch. The single most expensive message in the dataset, a five-word commit confirmation, cost $7.72 for the same structural reason.
This behavior stems from how Claude's prompt caching system works: it uses a time-to-live (TTL) window, refreshed on every read, that keeps a session's context "warm" in the cache as long as activity continues within roughly 60 minutes. The author's data shows this isn't a gradual cost curve but a genuine step function. Small follow-up messages sent within an active session cost as little as 4 cents, while functionally identical messages sent after the cache expired jumped to $4.75-$5.31, a roughly 100x difference for the same trivial content. Notably, the trigger isn't strictly time-based idle duration, since the writeup documents a $4.10 cache-rebuild charge after just six seconds of idle, apparently caused by a mid-session configuration change that invalidated the cached prefix outright.
The analysis also uncovered an apparently undocumented tiering distinction between how the main agent loop and subagents write to cache: the main loop writes to a 1-hour-TTL tier priced at 2x base input cost, while subagent writes go to a cheaper 5-minute tier at 1.25x. Across 63.7 million main-loop write tokens, only 21 tokens landed on the cheaper tier, suggesting this is a deliberate architectural choice by Anthropic rather than a quirk, though it isn't spelled out in public documentation. This kind of granular, tier-based cache pricing reflects the increasing sophistication of how AI providers monetize context reuse in agentic coding tools, where sessions can accumulate hundreds of thousands of tokens of file contents, tool outputs, and conversation history that would be prohibitively expensive to reprocess on every turn without caching.
Despite the eye-catching outlier costs, the broader takeaway from the data cuts the other way: caching is overwhelmingly a cost-saver, not a cost-driver. The author found that 93.8% of all input tokens across the entire usage history were cache reads rather than fresh writes, meaning that without caching, the same workload would have cost roughly $9,500 instead of the actual ~$2,000 spent. This underscores a broader trend in agentic AI tooling, where the economics of long-running, tool-heavy sessions depend heavily on cache architecture, and where small implementation details, like TTL refresh behavior, tier assignment for subagents, and config-change invalidation, can produce highly visible cost anomalies even as the underlying system remains net cost-efficient. The viral "$20 hey" phenomenon that motivated this investigation turns out to be a predictable artifact of session cache expiry rather than a pricing bug, a distinction that matters for developers trying to budget or optimize their use of Claude Code and similar agentic coding assistants.
Read original article →