I hit Claude Code's usage limits often enough that I wanted to know what was actually filling the context. Claude Code keeps a
transcript of every session on disk (~/.claude/projects/...), with the real API usage of every request. So I read a week of
them for one project and counted.
The project is a content site with a few scheduled agents, so it is busier than most. The numbers:
- 177 sessions, about 10,000 requests, 1.8 billion input tokens, 6.3 million output tokens.
- 98% of the input came from the prompt cache. Cache reads are cheap, but they still count against usage limits.
Almost all the cost is input, and almost all of the input is the same context sent again with every request. What you type
hardly matters. What stays in the context matters a lot.
1. Every session starts at ~28k tokens
Before I typed anything, the median session was already at about 28,000 tokens. Only ~2k of that was my instruction files
(AGENTS.md and the memory index). 79% of the fixed part was tool definitions: 54 tools, each with its JSON schema, sent
with every request.
Some of those tools almost never get used. The transcripts record which tools each conversation started with and which ones it
called:
~tokens loaded in used in calls tool ~9.3k 139 3 16 Artifact ~1.3k 178 0 0 Workflow ~1.0k 139 0 0 MCP visualize (2 tools) One tool's definition is about 9,300 tokens. It was loaded in 139 conversations and called in 3. Across the list, that is up to
~19k tokens of context in every conversation that loads them, and every subagent loads its own copy.
Fix: turn off MCP servers and plugins you don't use in that project, and deny built-in tools you never call
(permissions.deny in settings). Tools loaded later through tool search cost nothing until they are used.
2. Long sessions are where the tokens go
30 of the 177 sessions grew past 150k tokens of context. In those, every request re-sent 150k+ tokens.
I replayed the week as if each session had been compacted at 100k. Input would have dropped from 1.8B to 901M, -51%. That
is the single largest saving, bigger than everything else in this post put together.
Fix: run /compact with a one-line note of what you are doing when the context reaches ~100k, and /clear when you switch
tasks. The note matters: it tells the summary what to keep.
3. One big read early in a session is paid for hundreds of times
A tool output stays in context until the next compaction, so its real cost is its size times the number of later requests.
- A 6.4k-token file read early in a session was re-sent with 277 later requests (~1.8M tokens for one read).
- My own browser-automation script printed big output on 86 runs (~221k tokens).
- Subagents read the same data file 22 times, because each one starts with an empty context.
Fix: have the agent grep first and read with offset/limit; give your scripts a quiet mode and put the quiet command in
CLAUDE.md so the agent uses it by default; pass the needed part to a subagent in its prompt instead of telling it to read the
file.
4. Model per kind of work
Every session and subagent can be sorted by what its tool calls show: searching and reading, running commands, editing code, or
mixed. Searching and reading done on the biggest model is the easy one to move: a subagent that only greps and reads files does
the same job on a small model.
The tool
I packaged the counting as a small CLI, token-diet. It reads the transcripts locally (no network calls, no dependencies,
Node 18+) and prints each finding with its fix:
npx claude-token-diet # this project, last 7 days npx claude-token-diet now # what fills your current context, like /context npx claude-token-diet models # model per kind of work, API cost, cheaper suggestions npx claude-token-diet all # every project on the machine It also ships as a Claude Code plugin with three hooks:
- Compact reminder: one line when a session passes 150k tokens, then again every +50k.
- Output clip: a Bash/PowerShell output over ~4k tokens is saved to a file, and the agent sees the first and last 60 lines plus the path. MCP tool output (page text, search results) is clipped the same way past 24k characters.
- Handoff on
/clear: a script (no model call) writes the plan, the last reply, open tasks, changed files and recent commits to a ~5k-character file, so the next session starts with ~1k tokens and reads the file only when it needs a detail.
/plugin marketplace add congptvinadic-debug/token-diet /plugin install token-diet@token-diet Source (MIT): https://github.com/congptvinadic-debug/token-diet
Session analysis is Claude Code only for now; instruction-file checks also cover AGENTS.md, GEMINI.md, Cursor and Copilot rules.
If you run it on your own logs, I'd like to hear what your biggest line was.