Skip to main content

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.

MIT PyPI stars local private

๐ŸŒ 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:

  1. Parses โ€” extracts prompts, tool calls, files touched, exact token usage
  2. 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
  3. Computes ROI per week โ€” combines token spend with your GitHub output (PRs merged, lines added/deleted, reverts) via a transparent formula
  4. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tokenpayback-0.1.0.tar.gz (29.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tokenpayback-0.1.0-py3-none-any.whl (30.7 kB view details)

Uploaded Python 3

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

Hashes for tokenpayback-0.1.0.tar.gz
Algorithm Hash digest
SHA256 98c01e634737a009ab61752b64ba8e2f29597e52b0c6101b6f93ba62ebba1fdd
MD5 7ff3863b4baeaf9d2719531cadcead43
BLAKE2b-256 1a81f9bd387f1e0e47e84c8d4833b153e2046371316a627dd9cd42daac4d79d1

See more details on using hashes here.

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

Hashes for tokenpayback-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 80baaaac6929daf8be34bb6ce9350b34a572ae2c1d4b37873a69776ece7031b2
MD5 ece3dfc0023c2f26a5d75efe199df35f
BLAKE2b-256 8abfe351ed7fc262aa0b7c66e7c31229e4f2f824ba443dfdaeebb27a82626b55

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page