I analyzed my coding agent's logs: where the quota actually goes
I keep hitting usage limits in Claude Code, and for months my answer to "why?" was a guess. The usage tools I tried told me how much I used, not why. So I wrote a log reader, quota-autopsy, and ran it on my own machine. This post is what it found in one week of my own logs, plus how to run it on yours. I am the author of the tool. It is MIT-licensed and free.
One caveat up front: this is one person's week (7 days up to 2026-11-30), not a study. Your numbers will differ. The value is in the method and the categories, not in my totals.
What I measured
Claude Code saves a transcript of every session under ~/.claude/projects. Each API response in those files carries token counts: fresh input, cache writes, cache reads and output. That is enough to rebuild a cost picture without any network call.
My week: 1,281 log files (12.9 GB), 36,689 requests, 78 sessions. The cache hit rate was 98%, which sounds perfect and is not the whole story, as the rest of this post shows.
Costs here are estimates at API list prices. On a subscription they are not your bill, so I only use them to compare causes against each other. That is also why I quote shares and counts below, not currency.
As a sanity check, I compared the per-session estimates with the cost records Claude Code writes itself. The median ratio was 1.00 over 68 sessions (10th to 90th percentile: 0.88 to 1.13). Good enough to rank causes, not good enough to treat as exact.
Cause 1: cache misses after idle gaps
Prompt caching makes a long conversation cheap, as long as the cache is still alive. The cache has a time to live: 5 minutes or 1 hour, depending on the session. If you pause longer than that, the next request re-writes the whole prefix instead of reading it.
I had 192 cache rebuilds. 70 came after a pause longer than the TTL in use. The other 122 had no pause at all. Those are a different problem: the prefix changed, or the model changed, or I switched between fast and standard mode.
The worst single rebuild re-wrote 791K tokens after a 3.1-hour pause, with a 1-hour TTL. That is a single request, and it is the kind of cost that is invisible until something lists it.
What this suggests: resuming a very large session after a long break pays for the whole context again. Starting fresh with a short summary may be cheaper. Check your own report before you decide.
Cause 2: big tool results that stay in context
A tool result (a file read, a test log, a web page) goes into the conversation once, but it is sent again with every later request. A 10K-token result read early in a session is paid for on every turn after it.
1,290 tool results of 10K tokens or more stayed in my context. Re-sending them accounted for about 6.6% of my estimate. Not the biggest item, but one of the more avoidable ones: a filtered view of a long log is often enough.
How the tool sizes a result: the API reports how much the next prompt grew, so quota-autopsy uses that number rather than guessing from characters. 98.5% of tool-result sizes were measured this way. For the rest it falls back to a character estimate, which ran 1.26 times too low, so it rescales by the ratio of each thread.
It also flags repeated reads: the same file and range read again with no edit in between.
Cause 3: subagents
This was the surprise. 71% of my estimate came from subagent threads (440 of them). When the main agent delegates to a subagent, that subagent runs its own conversation with its own context and its own cache. It is easy to forget that each one is a full set of requests.
I do not conclude that subagents are bad. The log shows what they cost, not whether the work was worth it. But I would not have guessed the share.
Cause 4: tool and MCP definitions
Every tool definition, including the ones an MCP server adds, is part of the prompt. A server that exposes many tools makes every request bigger, and a change to the definitions in the middle of a session can change the cache prefix. quota-autopsy reads the definition sizes where Claude Code logs them and lists them as a cause. I have no headline number for this one from my week, so I will not make one up. Check yours: it is quick to see.
Long context
23,944 of my requests ran with more than 200K tokens of context. The part of those prompts beyond 200K was about 28% of the estimate. Long context is where several of the causes above stack up: a rebuild after an idle gap costs more the longer the context is, and so does every re-sent tool result.
How to see it for your own logs
Everything runs offline and read-only. There is no telemetry. Pick one:
npx -y github:vladtarrow/quota-autopsy Windows (PowerShell):
irm https://github.com/vladtarrow/quota-autopsy/releases/latest/download/quota-autopsy-windows-x64.exe -OutFile quota-autopsy.exe .\quota-autopsy.exe macOS and Linux (x64 or arm64):
curl -fsSLo quota-autopsy https://github.com/vladtarrow/quota-autopsy/releases/latest/download/quota-autopsy-$(uname -s | tr A-Z a-z)-$(uname -m | sed 's/x86_64/x64/;s/aarch64/arm64/') chmod +x quota-autopsy && ./quota-autopsy Useful flags:
quota-autopsy --demo # full report on synthetic logs, if you have no logs yet quota-autopsy --since 24h # time window; default is 7d; also 30d, 2026-11-01, all quota-autopsy --html report.html # one self-contained HTML page quota-autopsy --json > report.json # machine-readable output quota-autopsy --redact --html a.html # hide projects, paths and commands before sharing quota-autopsy --verbose # add the log file and line for every finding The report is a "why it burned" list of causes. Each finding has the session id and the time, so you can go back and look. A cache miss from an idle gap reads like "idle 12m > 5m TTL". A rebuild with no pause is labelled as such. On my 12.9 GB week the compiled binary took 74 seconds, with other work running on the machine. Expect a minute or more on a large history.
What it cannot tell you
- It cannot see server-side limits. If your quota shrank on the provider's side, no local log shows that. It only shows where your requests went.
- Dollar figures are list-price estimates. On a subscription, compare causes with each other.
- Some things are not in the logs and are not counted: the separate search request behind each WebSearch call (estimated and shown as a note), compaction summary calls and title generation.
-
--redacthides projects, paths and commands, but keeps host names, model names and numbers. Read a report before you share it. - Codex CLI support is experimental. I tested it on 13 Codex Desktop rollouts only. Gemini CLI and OpenCode are planned, not supported.
What I would do with this
Three things I plan to look at after this week: resuming an expired giant context after a break, dumping long logs into the conversation, and what I delegate to subagents. None of that is clever. It just needed a list of causes with timestamps, instead of a total.
If you run it and find a cause I have missed, or a log shape it misreads, please open an issue (a --redact report helps): https://github.com/vladtarrow/quota-autopsy