Does it make the agent worse?
Not in the benchmark: 40 of 40 runs passed in both arms on Sonnet 5, and every run in both Haiku 4.5 batches, each checked by a script. The rules forbid saving tokens by guessing a file, hiding the error or skipping verification.
Isn't shorter output enough?
Output is the small part of the bill in agentic coding. In the benchmark runs without tokenleak, everything the model wrote (replies, tool calls, thinking) was about 7% of the cost on Sonnet 5 and a little more on Haiku 4.5; the rest was context. tokenleak works on what enters the context, and the audit shows the split on your own sessions.
How accurate is the audit?
Session token totals come from the usage the transcripts record. The size of each tool result is estimated at about four characters per token, and "avoidable" only counts what exceeds a sane budget. It is an estimate: the audit can't know whether a big read was truly needed, so read each finding as a suspect and judge the trend with --compare.
What saves the most on long sessions?
When the auto-compact happens. On a 1M-token window Claude Code compacts only near the limit, so everything, the model’s own thinking included, is re-sent on every call. The audit replays your sessions with an earlier autoCompactWindow, a native Claude Code setting, and recommends a value only if the replay says it pays (on short sessions, compacting early can cost more). Measured live on 1M-token sessions, 300000 cut the cost by 16% (95% interval −36% to −6%) and the context re-sent in the main session by 80%, and every run passed in both arms (4 runs per arm).
ccusage or tokenleak?
Both read the same local transcripts. ccusage tells you how much you spent, by day, session or model. tokenleak tells you which tool results made it expensive and plugs them, with rules and a read guard. They work well side by side.
What about rtk, caveman and the rest?
They complement it. rtk compresses command output at the shell level and output-style skills shorten replies. tokenleak changes what the agent asks for and measures the result. Run the audit before and after anything you install.
Does anything leave my machine?
No. The audit reads files under ~/.claude/projects and ~/.codex/sessions, plus your CLAUDE.md and AGENTS.md to size them, and prints a report (or writes one with --html). It makes no network calls; the source is one readable Python file.