mintwork

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
tokenscope HTML report: estimated waste by pattern with a fix for each, and a flame graph of token spend

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

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 session

tokenscope 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.