Are your AI tokens paying off? CLI that classifies your Claude Code sessions and shows ROI.
Project description
tokenpayback
Are your AI tokens paying off?
A 100% local CLI that turns your Claude Code sessions into a ROI dashboard โ in 60 seconds.
๐ Live demo ยท ๐ฆ Install ยท ๐ง How it works ยท ๐ Privacy
The problem
You're paying for Cursor ($20/mo) + Copilot ($19/mo) + Claude API (variable) + maybe a Claude Max plan ($100/mo) โ and you have no idea if it's actually shipping more code.
Your CFO / your boss / your inner skeptic keeps asking "is this AI spend paying off?" and you've been answering with vibes.
tokenpayback reads the session logs Claude Code already keeps in ~/.claude/projects/ and gives you a real number:
This week: spent $264 โ estimated $10,830 value โ ROI 41ร
Tokens went to: new-feature 47% refactor 23% bug-fix 18% research 12%
Top project: your-app $182 (8 PRs, +3,120 lines)
It's a heuristic โ but it's a heuristic you can see and tune. Everything is transparent (config.local.yaml). Everything stays on your Mac.
What it actually does
For every session in ~/.claude/projects/**/*.jsonl:
- Parses โ extracts prompts, tool calls, files touched, exact token usage
- Classifies via LLM โ what was this session actually doing? Picks one of:
new-feature/extend-feature/bug-fix/debug/refactor/config-ops/research/brainstorm/personal-task/chat-misc - Computes ROI per week โ combines token spend with your GitHub output (PRs merged, lines added/deleted, reverts) via a transparent formula
- Serves a local dashboard โ opens in your browser at
http://localhost:PORT/, no cloud
All data persists in ~/.tokenpayback/. Nothing leaves your machine.
Install
Requires Python 3.9+.
pipx install tokenpayback # recommended (isolated)
# or
pip install --user tokenpayback
You'll need an LLM API key for session classification โ set ONE of these:
export ANTHROPIC_API_KEY=sk-ant-... # recommended โ you probably already have one
export OPENAI_API_KEY=sk-...
# or any OpenAI-compatible endpoint:
export LITELLM_API_KEY=...
export LITELLM_BASE_URL=https://your-proxy/v1
export LITELLM_MODEL=gpt-4o-mini
Or skip classification entirely:
tokenpayback --no-classify # faster, no API key needed, still shows cost & GitHub output
Run
tokenpayback # scan + classify + serve + open browser
tokenpayback scan # just scan & write data
tokenpayback serve # serve existing data on local port
First run takes ~60 seconds (LLM call per session). Subsequent runs are instant for cached sessions.
Optional: real cost numbers from your API providers
By default we approximate weekly cost from your fixed monthly subscriptions. For exact API spend, drop in an admin key:
export ANTHROPIC_ADMIN_KEY=sk-ant-admin-... # console.anthropic.com/settings/admin-keys
export OPENAI_ADMIN_KEY=sk-admin-... # platform.openai.com/settings/organization
These are read-only keys โ they only fetch usage reports, never modify anything.
How it works
โโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ~/.claude/projects/ โ parse JSONL โ extract:
โ *.jsonl โ โ prompts, tool calls, tokens, files touched
โโโโโโโโโโโโโโฌโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโ LLM classifier โโโโโโโโโโโโโโโโโโโโโโโโ
โ raw session data โ โโโโโโโโโโโโโโโโโโถ โ classified sessions โ
โโโโโโโโโโโโโโโโโโโโโโโโ (category, project,โ + per-session ROI โ
summary, value) โโโโโโโโโโโโฌโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโโโโโ โ
โ Anthropic / OpenAI โ weekly $$$ โโโโ โ
โ admin APIs โ โ โ
โโโโโโโโโโโโโโโโโโโโโโโโ โผ โผ
โโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ GitHub search API โ โโโโโโโถ โ ROI dashboard (localhost) โ
โ (PRs / commits) โ weekly โ data.json in ~/.tokenpaybackโ
โโโโโโโโโโโโโโโโโโโโโโโโ output โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
The ROI formula is intentionally simple and visible. Tune to your reality:
value_usd = prs_merged ร value_per_pr # default $600
+ lines_added ร value_per_line ร 0.5 # default $0.30
โ reverts ร value_per_pr # penalty
roi = value_usd / total_weekly_cost
Edit ~/.tokenpayback/config.yaml (or ./config.local.yaml) to change the multipliers.
Privacy
This is a privacy-first tool. The whole point is to NOT do what other observability tools do.
- โ No tracking, no analytics, no phone-home
- โ No account, no email, no sign-up
- โ Your session data NEVER leaves your machine
- โ The only outbound calls are: (1) your chosen LLM for classification, (2) Anthropic/OpenAI usage APIs if you opt in, (3) GitHub API if you opt in
- โ Open source. Read every line.
The LLM classification step sends a one-paragraph summary of each session (first prompt, tool call counts, sample bash commands) โ not full prompts or code. Skip it entirely with --no-classify.
What it's not
- Not a SaaS. No cloud. We have nothing to sell you.
- Not a tracker. It cares about your spend, not your activity in aggregate.
- Not an attribution oracle. Linking "AI did X" โ "$ saved Y" is an estimate, not a measurement. We're transparent about that.
- Not a replacement for evals. Use Braintrust / Langfuse / DSPy / Inspect for output quality. This is the spend layer.
Roadmap
Things on the table for v0.2 โ file issues for what you want:
- Cursor & Codex CLI session ingestion (today: Claude Code only)
- Per-task-type ROI ("you spend $X on testing PRs and they always merge โ keep doing that")
- Bash subcommand profiler (
tokenpayback bashโ find the most expensive Bash patterns) - LLM-graded PR value (replace flat $600/PR with case-by-case)
- Native macOS app via Tauri or pywebview (no more "open the browser" feel)
- Team mode โ opt-in shared aggregation
- Sankey / time-series charts
PRs welcome. Open an issue first for anything non-trivial.
Contributing
git clone https://github.com/gongyibob-ctrl/tokenpayback.git
cd tokenpayback
python3 -m venv .venv && .venv/bin/pip install -e .
.venv/bin/tokenpayback --no-classify # smoke test on your own ~/.claude/
Code style: small modules, no premature abstraction, transparent heuristics. If you find yourself hiding numbers behind clever code, stop and write a comment about why the number is what it is.
Why "tokenpayback"?
Because the question isn't "how many tokens did I burn?" โ every tool answers that. The question is "did those tokens come back as something?"
Made by @gongyibob-ctrl โ built in a weekend, shipped because it shouldn't have to be a startup.
License
MIT. Use it, fork it, sell improvements built on it. Just don't blame me when the ROI number is uncomfortable.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tokenpayback-0.1.0.tar.gz.
File metadata
- Download URL: tokenpayback-0.1.0.tar.gz
- Upload date:
- Size: 29.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
98c01e634737a009ab61752b64ba8e2f29597e52b0c6101b6f93ba62ebba1fdd
|
|
| MD5 |
7ff3863b4baeaf9d2719531cadcead43
|
|
| BLAKE2b-256 |
1a81f9bd387f1e0e47e84c8d4833b153e2046371316a627dd9cd42daac4d79d1
|
File details
Details for the file tokenpayback-0.1.0-py3-none-any.whl.
File metadata
- Download URL: tokenpayback-0.1.0-py3-none-any.whl
- Upload date:
- Size: 30.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
80baaaac6929daf8be34bb6ce9350b34a572ae2c1d4b37873a69776ece7031b2
|
|
| MD5 |
ece3dfc0023c2f26a5d75efe199df35f
|
|
| BLAKE2b-256 |
8abfe351ed7fc262aa0b7c66e7c31229e4f2f824ba443dfdaeebb27a82626b55
|