CLI and TUI · TypeScript
TokenLeak
A local command line tool that reads the usage logs AI coding tools already write to disk and shows where the tokens and money went. It covers Claude Code, Codex, Cursor, Gemini, Copilot and 20 other tools, and the usage data stays on your machine.
- 25AI coding tools it reads usage from
- 12tools in the bundled MCP server
- 6waste patterns the advisor looks for
Where do the tokens go
I wanted to see where my AI tokens actually go. The repo description says it more plainly: check your token usage before your prompts spiral out of control. The tricky part is that every coding agent keeps its own record. Claude Code writes JSONL logs under ~/.claude/projects, Codex writes JSONL sessions under ~/.codex/sessions, and tools like Goose, Zed and Hermes keep SQLite databases.
The data is already on disk, so I built TokenLeak to read it there and add it up in one place. It needs no account or API key and sends no telemetry. Your usage history is parsed and rendered on your own machine.
Reading 25 tools without double counting
The code is a Bun and TypeScript monorepo. A registry package holds one parser per provider, each with an availability check and a loader, and the CLI auto-detects whichever tools have data on the machine. Every parser normalizes into the same daily shape: input, output, cache read and cache write tokens, plus an estimated cost.
Most of the work is in the edge cases. A resumed or forked Claude Code transcript can copy messages into another file, so records are merged globally by message and request id before date filtering. Codex logs cumulative totals, so its parser extracts deltas. Zed rows that belong to an external agent are skipped so they are not counted twice, and Crush keeps its reported cost without inventing token counts it never logged. The first Claude Code, Codex and OpenCode parsers started as ports from slopmeter.
Cursor is the one exception to the local rule, because it does not write usage to disk. After a one time tokenleak cursor login, it fetches usage CSVs from Cursor's API into a local cache, and a response only replaces that cache if it passes schema validation.
What it shows
Run tokenleak in a terminal and it opens a full screen dashboard built on OpenTUI. The overview has a GitHub style heatmap of daily usage. Other views cover cache economics, model efficiency, a day by day explain report, period comparisons, and an AI ROI view that runs a read only git log --numstat to show tokens and cost per commit.
Cache ROI weighs read savings against write cost to get net savings and a payback ratio. The advisor flags six waste patterns, including context drag, wasted cache writes and premium models used for short outputs, and each finding comes with evidence and a recipe to try. Costs are API equivalent estimates priced from LiteLLM's model table. A model with no verified price shows as Unknown rather than a guess.
Sharing it and asking it from the editor
Reports export as JSON, SVG or PNG, can go to the clipboard or a GitHub gist, and there is a Wrapped card with streaks, top models and achievements. A commons export writes anonymized aggregates, or an LLM ready prompt, for when you want to share the shape of your usage without the logs.
TokenLeak also ships an MCP server, so Claude Code, Cursor or any MCP client can ask how much you spent this week and get the answer from local data. It exposes 12 tools, from usage summaries and cost breakdowns to efficiency advice and waste findings. The quota tool is the only one that calls provider endpoints, and only when asked.