open source ยท single file ยท stdlib-only python ยท no API keys

Track your tokens, feature by feature.

Make sure you track your Return On Token Spend (ROTS).
# every branch. every agent. every machine. posted on the PR.

~/anywhere โ€” zsh
$ pipx install tokenchecker # or: uv tool install tokenchecker $ tokenchecker install --global   # done. every repo on this machine now reports token usage on push.
โ— LIVE incoming pull requests โ€” token usage attached
 github.com/acme/voicebox โ€” pull requests โ› ROTS MONITOR
#482
โŠ™ Open @sana-dev wants to merge feature/streaming-tts +1,204 โˆ’87
๐Ÿค– tokencheckerBOT commented

๐Ÿค– AI token usage for feature/streaming-tts

ToolModelSessionsMsgs InputCache readCache write OutputTotalEst. cost

ROTS
how it works

No database. No SaaS.
Just git refs.

Your agents already log every token to disk. tokenchecker parses those logs, dedupes them, and publishes per-machine totals to custom git refs on origin โ€” then a hook or Action renders the table on the PR.

 your laptop                          origin (GitHub)                 PR
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”             โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ claude / codex /     โ”‚  git push   โ”‚ refs/token-usage/     โ”‚   GitHub Action:
โ”‚ gemini / cursor logs โ”‚ โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บ โ”‚   laptop-a1b2c3d4     โ”‚   fetch refs/token-usage/*
โ”‚         โ”‚            โ”‚ (pre-push   โ”‚   desktop-e5f6a7b8    โ”‚   aggregate head branch
โ”‚         โ–ผ            โ”‚  hook runs  โ”‚   coworker-c9d0e1f2   โ”‚   upsert PR comment
โ”‚ tokenchecker sync    โ”‚  `sync`)    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
01

collect

Scans local logs of all four agents, keeps records matching the current repo, and normalizes them into dedupable records under .git/tokenchecker/.

02

push

Publishes to refs/token-usage/<machine-id> on origin. One ref per machine โ€” zero conflicts, zero external storage, never double-counts.

03

hook

A pre-push hook runs sync automatically, so usage data lands on origin together with the branch you're pushing. No CI or repo files required.

04

comment

The hook (via gh) or the optional tokenchecker@v0 Action upserts a sticky PR comment with per-tool, per-model totals and estimated cost.

supported agents

Reads the logs your agents already write.

Parsed straight from local session files โ€” no API keys needed. Branch attribution is exact where recorded, and reconstructed from your HEAD reflog where it isn't.

Claude Code

~/.claude/projects/<project>/*.jsonl

Per-message usage blocks. Branch attribution: exact โ€” gitBranch recorded per message.

Codex CLI

~/.codex/sessions/Y/M/D/*.jsonl

token_count events. Branch attribution: recorded in session metadata.

Gemini CLI

~/.gemini/tmp/<sha256(cwd)>/chats/

Per-message tokens. Branch attribution: inferred from HEAD reflog at message time.

Cursor

state.vscdb (bubble records)

Per-message tokenCount. Branch attribution: inferred from HEAD reflog at message time.

design goals

Paranoid about correctness.

Never double-counts

Every record has a stable id (message / session / bubble). Streaming snapshots, re-collection, and multi-machine overlap all collapse to the max-total record. Idempotent by construction.

Real cost estimates

Four token buckets priced at each model's API list rates โ€” cache reads counted separately from fresh input (they're billed differently and dominate agent usage). Prices via LiteLLM's community table, a pinned file, or an embedded fallback โ€” every report says which.

Whole team, every machine

Each machine owns one ref: refs/token-usage/<machine-id>. Laptop, desktop, coworkers โ€” all aggregate into a single PR comment with a per-machine breakdown.

Zero infrastructure

Single-file, stdlib-only Python 3.9+. Storage is plain git refs on origin. Cleanup is git push origin --delete refs/token-usage/<id>. Nothing else is stored anywhere.

commands

Five verbs. That's the whole tool.

tokenchecker --help
$ tokenchecker sync# collect + publish (what the hook runs)
$ tokenchecker collect --dry-run# preview per-branch usage, write nothing
$ tokenchecker status# when did it last run, what's synced where
$ tokenchecker report# all branches, all machines, with costs
$ tokenchecker report --branch feature/x --markdown# PR-comment format
$ tokenchecker comment# post/update the PR comment for this branch
deploy

Know what every feature
actually cost.

Two commands. Every repo on your machine. Forever.

STAR ON GITHUB