DEV Community

AgentGuard
AgentGuard

Posted on

My Claude Code quota died twice a week. I wrote a forensics tool to find out why.

I burn through Claude Code quota fast — and the counters never explained it. They answer how much. Not where, not why.

So I pointed a script at my local session transcripts (~/.claude/projects/**/*.jsonl) and started digging. Then I turned it
into a tool: quota-autopsy.                                                                                                  

What the data actually showed (46 of my sessions)                                                                            

• 1,162 unique API calls, 276.58M tokens ≈ $187.80
• ≈ $10.47 was avoidable — that's the number counters never tell you                                                         
• 4 warm contexts re-sent uncached (≈ $3.39), repeated file reads (≈ $2.39), oversized tool outputs (≈ $4.69)
• One session re-sent 610.5k fresh tokens after a 15h idle gap — $3.08 for doing literally nothing                           

The mechanisms it finds                                                                                                      

1. Cache re-creates — the cached prefix gets rewritten while still fresh. A cache read costs 0.1×, a cache write 1.25×. A  
cache-bust costs 12.5× a cache hit, and Claude Code does it silently.
2. Warm re-sends — a call reading zero from cache, seconds after a full-context call. Two full-context bills back-to-back.   
3. TTL downgrades — cache writes shifting from 1h to 5m mid-session (the documented post-quota penalty).                     
4. Paid bloat — 600KB terminal dumps and screenshots re-inflating context on every later turn.                               
5. Session-split double counting — dedupe by message.id collapsed 3,600 duplicate rows in my corpus. Naive parsers           
over-count by ~40%.                                                                                                          

Why I trust the numbers                                                                                                      

• Token counts exact (streaming partials deduped by API response id)
• Dollar estimates cross-checked against Claude Code's own cost-state rows                                                   
• Independent second implementation recomputes every metric (45/45 tests green)
• 100% local — zero dependencies, no telemetry, no account                                                                   

Try it                                                                                                                       

  ─ bash           
  npx quota-autopsy                                                                                                          

Free overview for everyone. Pro ($24, lifetime) unlocks the per-session autopsy with exact turns and fixes. Model-agnostic
(editable pricing table for any provider/router).                                                                            

Website: https://quota-autopsy.pro — happy to answer questions in the comments.  
Enter fullscreen mode Exit fullscreen mode

Top comments (0)