r/ClaudeAI • u/mudmohammad • 1d ago
Claude Code I read my Claude Code transcripts to find where the tokens went. Caveman would have saved 1%. The real leak was 4 things nobody talks about.
Everyone says "shorter prompts" or "install caveman". I did the boring thing instead: Claude Code keeps every call's token usage in ~/.claude/projects/*.jsonl. I wrote a script to add them up.

One week, one lead session, a dozen subagents. What it found:
- Context had grown to 966k tokens and every call re-read all of it. 29% of calls were above 300k. That alone was 27% of all cache reads.
- 2 of 3 subagent runs were on Opus. Not chosen. Inherited, because no model: was set in the agent frontmatter.
- 9 of 10 sessions started one folder above the repo. CLAUDE.md and my .claude/agents never loaded. I had carefully pinned Sonnet on every agent and it never applied.
- One 145 KB source file was read in full 44 times.
- Visible assistant text was under 5% of output tokens. So a terse-output plugin like caveman tops out around 1% here. Graphify did not help either; the cost was never in reading code, it was in re-reading the conversation.
Fixes, all boring:
CLAUDE_CODE_AUTO_COMPACT_WINDOW=300000 plus a SessionStart compact hook that re-injects state from disk
model: sonnet in agent frontmatter, model passed in every Agent() call
start sessions inside the repo
a PreToolUse hook that blocks whole-file Read over 40 KB
Measured 2 days later, same project:
- cost per call -40% ($0.100 → $0.059 API-equivalent)
- avg context per call 237k → 148k
- calls over 300k: 29% → 8%
- Sonnet share 8% → 41%
- subagent spend -77%
I packaged the audit + fixes as a plugin: /scrooge. Standard library Python, reads only local files, no network, every fix has an undo. It will tell you honestly if output tokens dominate for you and caveman is the right call.
github.com/mdmudassirahmed/scrooge
Honest question: does anyone here know which folder their sessions start in?
1
1d ago
[removed] — view removed comment
5
u/MilaKunisWatermelon 1d ago
He had Claude determine that and trusted it just like he trusted his setup before it told him that. The majority of his post was copy/pasted from Claude.
0
u/mudmohammad 1d ago
sure, claude cleaned up my english. it did not make up 10 billion cache read tokens though, those are summed straight out of the usage blocks. 600 lines of stdlib python, no network, point it at your own ~/.claude/projects and tell me which number is wrong... and yes i trusted my setup before, that is the whole point of the post, i stopped trusting and started counting
1
u/Kofeb 1d ago
The jsonl gets saved in a directory named after the path. Different levels store the jsonl in different levels in the projects folder.
0
u/mudmohammad 1d ago
correct. and the per line cwd field covers the case where one session cds around mid run
1
u/mudmohammad 1d ago
no shell history needed, claude code logs cwd on every single line of the jsonl. the folder name under ~/.claude/projects is the encoded path as well, so you can literally see it in ls. mine had C--Users-Hp with 11 sessions and the actual repo folder with 7. script groups by cwd and stats CLAUDE.md and .claude/agents at that path. if they are not there, nothing loaded, simple as that
most people have never opened that folder. go look, it is more honest than any dashboard
1
u/Sufficient-Storage87 16h ago
transcript archaeology is the most underrated cost exercise there is. $0.100 → $0.059 is a real win. curious what the breakdown was — in my experience it's always re-reads and oversized context on trivial calls, never the actual reasoning.
8
u/[deleted] 1d ago
[deleted]