mintwork / tokenscope
Find the money your AI coding agent wasted
ccusage tells you what you spent. tokenscope tells you what you wasted, and how to stop it.
npx @mintwork/tokenscope # waste first, then spend
npx @mintwork/tokenscope --html --open # interactive report with a flame graph
Open the interactive demo report (synthetic logs).
The problem
You know the bill. You don't know which part was wasted: a prompt cache that expired while you read the answer, so a 500k-token context was re-written at cache-write price; the agent running npm test five times and getting the same failure; one 2,000-line file read 40 times without an edit; a 60k-token log pasted into context and paid for on every later request.
tokenscope reads the session logs your agents already keep on disk, finds these patterns, estimates what each one cost, and tells you how to stop it.
What it does
Cache rebuilds, explained
Finds prompt-cache rebuilds after you paused or a tool ran long, names the cause, and says when a 1-hour cache TTL would actually save money.
Loops and repeats
The same tool call with the same result, again and again, plus unchanged file re-reads and failed-edit retry storms.
Counterfactual estimates
Every dollar figure is the difference to one specific better choice, never the full cost of a request. Uncertain savings are shown separately.
Flame graph of spend
Project → session → turn → API call → subagent, in a self-contained HTML report you can click to zoom.
16 agents
Claude Code, Codex CLI, Gemini CLI, OpenCode, Cline, Roo Code, GitHub Copilot CLI, Goose, Amp, Aider and more.
100% local
Zero dependencies, no API keys, no network calls. Your logs never leave your machine.
Install
Needs Node 22+. No configuration.
npx @mintwork/tokenscope
npx @mintwork/tokenscope --html --open
npx @mintwork/tokenscope diff # what got more wasteful between two periods
npx @mintwork/tokenscope watch # live waste alerts during a Claude Code sessiontokenscope vs ccusage
ccusage is great at tracking spend: daily and monthly totals, a live status line, billing blocks. tokenscope answers a different question: what did I waste, and how do I stop? Use ccusage to track the bill. Run tokenscope when the bill surprises you.
Open source, MIT licensed
Built in CI and published to npm with signed provenance. The full docs, changelog and issues are on GitHub.