Analyzing Claude Code Token Usage: Cache Reads Make Up 98 Percent
A developer analyzed 30 days of Claude Code local logs, discovering that 4.9 billion tokens were consumed, with 98.1% coming from prompt cache reads.

A developer recently investigated 30 days of local usage logs generated by Claude Code, revealing unexpected insights into how modern AI coding assistants consume tokens. By building a custom script to parse plain JSONL log files stored in the home directory, the developer tracked 4.9 billion tokens over a one-month period.
The most striking finding from the data was the dominance of prompt caching. A massive 98.1% of the total tokens logged were cache reads, where the conversation history is resent with every request and handled by Anthropic's prompt cache. Meanwhile, actual output written back by the model accounted for just 0.37% of the total token volume. Uncached input was virtually nonexistent at 49,000 tokens for the entire month.
When pricing these tokens at API list rates for comparison, the total theoretical value came out to $1,782. While cache reads accounted for 54% of that financial value, output tokens—despite representing a tiny fraction of the volume—made up 19% of the cost because output tokens are billed at a significantly higher rate than input tokens.
Decoding the Local Logs
Claude Code records every session locally as JSONL files located under the ~/.claude/projects/ directory. Each line logs events such as prompts, tool outputs, summaries, or assistant replies containing usage metadata. However, raw counting methods can easily overcount metrics because individual replies are frequently written across multiple lines or distributed across files when sessions are resumed.
To accurately count usage without duplication, developers can implement a simple script that groups replies by their message ID and request ID, keeping the maximum value for each token counter across copies. By filtering lines for the presence of usage data before parsing JSON, processing a 1.6 GB folder takes only seconds.
Developers should also monitor cleanup settings. By default, Claude Code deletes session files older than 30 days via cleanupPeriodDays. Adjusting this value in settings.json is necessary if anyone wants to retain a longer history.
What it means for developers
For engineers building workflows or managing subscription limits, the heavy reliance on prompt caching highlights why maintaining a clean context window is vital. Because every turn re-reads prior history, anything that invalidates the cache—such as altering system prompts mid-session—dramatically increases resource consumption.
Developers looking to optimize usage should focus on context size rather than worrying about shorter answers. Habitually using /clear between unrelated tasks prevents unnecessary inflation of the context window. Furthermore, developers can try top AI models cheaply through one API at https://apixoai.online to evaluate different workloads.
Tracking Plan Limits
Understanding token consumption is separate from monitoring strict plan limits like 5-hour or weekly caps on Pro or Max accounts. Claude Code exposes these rate limits via the status line input provided on standard input, which includes fresh percentage metrics and reset timestamps with every reply. Developers can capture these metrics using lightweight shell scripts to avoid relying on occasionally stale cache files stored in configuration directories.
Source: I Counted 30 Days of My Claude Code Tokens. 98% Were Cache Reads. — Towards AI. Written by the Apixo team from that report.
One key for Claude, GPT, GLM, DeepSeek and more. Pay per token with crypto.
Get your API key

