[ cli · 100% local · v2.1.0 ]

see where your AI tokens
actually go.

tokenleak reads usage from claude code, codex, cursor, opencode, and pi — and renders heatmaps, advisor reports, and shareable cards straight from the terminal.

docs →★ star on github
~ tokenleak
tokenleak TUI overview view
// auto-detects local data from
claude codecodexcursorgeminicopilotampopencodeqwenroo codekilo codeopenclawhermespi
// the dashboard

11 views, one keypress away.

tokenleak ships a full-screen TUI built with @opentui/core. arrow keys to switch, number keys to jump straight to a view.

overview view
01
overview
heatmap, stats, providers, top models
matrix view
02
matrix
4-page deep-dive: cache economics, sessions, attribution
advisor view
03
advisor
model-switch recs + waste patterns with $ savings
focus view
04
focus
deep-work sessions ranked by score
explain view
05
explain
narrative day-by-day breakdown
compare view
06
compare
side-by-side period comparison with deltas
export view
07
export
save png, wrapped, or launch a live server
wrapped view
08
wrapped
spotify-style story card with achievements
▁▂▅▇▆▃▁
░▒▓██▓▒
  ▶ play
replay
new
09
replay
browser scrub · play the day · cost odometer
repo  ┐
  →  $$
  →  ↑↑↑
nutrition
new
10
nutrition
tokens vs. git output · $/commit · roi by repo
─────
$  ───
$$ ───
$$$───
receipts
new
11
receipts
itemized spend by prompt behavior, sortable
// what it does

three things, well.

01
auto-detect

13 providers, zero config. point it at the machine where you actually code — it finds the logs.

02
analyze

streaks, rolling windows, cache ROI, model efficiency, attribution clusters, focus scoring.

03
share

png · svg · json · wrapped · gist upload · clipboard · live browser dashboard.

// how it works

100% local. zero telemetry.

every number you see comes from logs your AI tools already write to disk. tokenleak just reads, parses, and renders. nothing is uploaded, nothing is phoned home.

01
read

scan local log directories. nothing leaves your machine.

02
parse

extract per-message token usage + model + timestamp from jsonl / csv / json.

03
aggregate

fold into daily stats, streaks, rolling windows, cache roi, model efficiency.

04
render

tui · terminal · json · svg · png · wrapped · live server · mcp.

// exact data sources

tokenleak reads from these paths on your machine. you can override each with an env var. cursor needs a one-time login to populate the cache; everything else is automatic.

claude code~/.claude/projects/**/*.jsonlauto
codex~/.codex/sessions/**/*.jsonlauto
cursor~/.config/tokenleak/cursor-cache/usage*.csvmanual
gemini~/.gemini/tmp/**/*.{json,jsonl}auto
copilot~/.copilot/otel/**/*.jsonlauto
amp$XDG_DATA_HOME/amp/threads/T-*.jsonauto
opencode~/.local/share/opencode/storage/message/**/*.jsonauto
qwen~/.qwen/projects/**/*.jsonlauto
roo code~/.config/Code/.../rooveterinaryinc.roo-cline/tasks/**/ui_messages.jsonauto
kilo code~/.config/Code/.../kilocode.kilo-code/tasks/**/ui_messages.jsonauto
openclaw~/.openclaw/agents/**/*.jsonl*auto
hermes${HERMES_HOME:-~/.hermes}/state.dbauto
pi~/.pi/agent/sessions/**/*.jsonlauto
local-only
no api keys. no accounts. no upload.
audit-friendly
MIT licensed. read the parsers on github.
cursor caveat
one optional fetch to cursor's API to refresh your cache.
// model efficiency advisor

stop overpaying.

real-time pricing via litellm. tokenleak watches your sessions for cheaper-model swaps and surfaces six deterministic waste patterns with local recipes to fix them.

$ tokenleak --advisor --days 30
downgrade
claude-sonnet-4 → claude-haiku-4
12 short-output sessions · projected −$47/mo
high
waste
[wasted-cache-writes] · 4 sessions
cache writes never reused. recipe: drop --no-cache · est. −$8/mo
medium
waste
[premium-short-output] · 7 sessions
opus on <300-token replies. recipe: route to haiku · est. −$22/mo
high
trend
cost trend +28% week-over-week
3 burst days drove the spike · review explain 2026-04-22
medium
// waste taxonomypremium-short-outputlow-cache-hit-ratewasted-cache-writescontext-dragburst-spikemodel-switch-churn
// nutrition label

see what your tokens actually shipped.

tokenleak nutrition cross-references token spend with local git output — commits, changed lines — and tells you the cost-per-outcome for every repo you touched.

$ tokenleak nutrition --days 30
repotokenscostcommits$/commitroi signal
tokenleak3.4M$18.2042$0.43strong · shipping
tokenleak-landing1.1M$6.4011$0.58healthy
yc-api2.8M$22.603$7.53exploring · low yield
experiments0.9M$9.100research only
↳ uses read-only `git log --numstat`. nothing leaves the box.
// compare

this week vs. last.

auto-split your range or compare against a fixed period. ships json · png · svg with delta cards.

$ tokenleak --compare auto
$ tokenleak --compare 2026-01-01..2026-03-31
metric
period a
period b
tokens
12.4M
9.1M +36%
cost
$84.20
$67.10 +25%
streak
14d
9d +5d
active days
22
18 +4
avg/day
563k
506k +11%
cache hit
42%
34% +8pp
// ai coding wrapped

your year, one card.

12 sections of stats, achievements, and habit data. export as a tall png or run as an interactive 12-slide browser deck.

view live demo →tokenleak --format wrapped --open
↳ or: tokenleak --wrapped-live --days 365
tokenleak wrapped card
// mcp server

ask claude "how much have i spent?"

tokenleak ships an MCP server. drop it into any MCP-compatible client and your AI gets full read access to your local usage.

  • list_providers
  • get_usage_summary
  • get_daily_usage
  • get_cost_breakdown
  • get_streaks_and_habits
  • compare_periods
  • get_efficiency_advice
{
  "mcpServers": {
    "tokenleak": {
      "command": "bun",
      "args": ["run", "/path/to/tokenleak/packages/mcp/dist/index.js"]
    }
  }
}
// install

one line. no signup.

bun
$ bun install -g tokenleak
npm
$ npm install -g tokenleak
npx
$ npx tokenleak
requires node 18+ · ships as a single bundled cli · MIT
// quick reference

the commands you'll actually run.

# everything in one keystroke
$ tokenleak  # tui dashboard
$ tokenleak --advisor --days 30  # cost-saving recs + waste patterns
$ tokenleak nutrition --days 30  # tokens vs git output by repo
$ tokenleak --compare auto  # this period vs last
$ tokenleak --format wrapped --open  # share your year
$ tokenleak replay 2026-04-22 --interactive  # browser scrub UI
$ tokenleak focus --provider codex --days 30  # deep-work ranking
$ tokenleak explain 2026-04-22  # narrative breakdown
$ tokenleak commons prompt --clipboard  # llm-ready analysis prompt
$ tokenleak --wrapped-live --days 365  # browser deck