TokenFlow prices the coding-agent logs already on your machine. A receipt for every branch, a brake for the session that blows the budget.
PR #476
+6,269 / -99 lines
of $26.7K went to re-sending context. Cache reads and writes are the cheap path per token, so this is the price of long sessions, not waste.
Nine weeks, one developer, priced with the shipped table.of spend sat in the top 1% of sessions. Across 22,698 sessions the median cost two cents.
Spend follows a power law. Averages hide it.The median turn costs $0.01 for the first fifty turns and $0.15 after that.
Per-request sources only.Every turn re-sends the conversation so far. Past a point, most of what you pay for is the conversation, not the answer. That step is where a brake belongs.
146,373 priced turns from Claude Code, Codex and OpenCode. Hermes reports whole sessions and is excluded.
Turns carrying more than 200K prompt tokens were 34% of turns and 75% of their spend. Reproduce with tokenflow receipt --sessions.
Every turn is attributed to the branch checked out when it ran. Branches join to merged pull requests by name. The result is a number your team can argue with.
A PR owns the turns up to its merge, including the work done before it was opened. That work is how the PR came to exist.
Turns after the merge sit beside the receipt, never inside it. They are follow-up on a checkout that kept the old branch name.
Long-lived branches are flagged. A receipt for main is a receipt for a period, not for one change.
| PR | Lines | To merge | Per 100 lines | Sessions | Turns | Subagent | After merge |
|---|---|---|---|---|---|---|---|
| #476 | +6,269 / -99 | $1,291 | $20.28 | 4 | 5,488 | 62% | $7 |
| #430 | +11,649 / -256 | $596 | $5.01 | 1 | 4,356 | 87% | $12 |
| #300 | +5,910 / -343 | $366 | $5.85 | 1 | 1,663 | 84% | $2 |
| #389 | +11,298 / -813 | $203 | $1.68 | 1 | 638 | 6% | $17 |
| #478 | +101 / -1 | $16 | $16.07 | 2 | 32 | 0% | $2,483 |
| #339 | 943 | $0.41 | $0.04 | 1 | 3 | 0% | none |
Six of 86 merged pull requests from one repository. Median PR $16.20. Across all of them, 46% of what those branches cost was spent after the merge and belongs to no PR. The $0.41 row is more likely under-attributed than cheap: Codex sessions carry no branch yet.
A Claude Code hook reads the live transcript, prices it with the same table, and warns or blocks against caps you declared. Nothing is invented: with no caps set it only informs.
# declare what you want guarded
tokenflow guard --set warnCostUsd=25,maxCostUsd=200
tokenflow guard --set warnContextTokens=200000
# then, mid-session, the hook says:
TokenFlow guard: session spend $61.48 passed the
warning level of $25.00; the prompt now carries
492K tokens (warning level 200K).
Most of each turn now pays to re-send earlier
context. Compact, or start a fresh session with a
short brief, and the per-turn cost drops.
Runs once per prompt and before each subagent is spawned, the two moments a session's cost curve bends. A cap that is reached blocks the next tool call with the reason on screen.
Dollars above each per-session cap in the author's nine weeks. An upper bound on what a guard could have held back, not a saving: some of that work would have happened anyway in a fresh session.
Each adapter looks in the conventional place for its own logs: Claude Code, Codex, OpenCode, Hermes, Cline, Cursor, gateways, git. Nothing scans your disk.
tokenflow setupEvery file resumes at its byte offset. Streaming re-reports collapse to their maximum, cache buckets stay exclusive, and a missing field stays missing instead of becoming zero.
tokenflow refreshA dashboard at loopback, a native menu bar app, receipts per branch, a guard for the session you are in, and one self-contained HTML file that opens anywhere, offline.
tokenflow upThe receipts need your transcripts and your repository on the same disk. That is exactly why nothing leaves it.
macOS gets the menu bar app. Everything else gets the CLI and the dashboard. Both are the same engine.
brew tap vimoxshah/tap https://github.com/vimoxshah/tokenflowbrew install --cask tokenflownpx @vimoxshah/tokenflow@latest setupTokenFlow.dmg from the latest releaseNeeds Node 22.5 or later. The app is unsigned, so macOS asks once: right-click, Open, Open.
tokenflow team serve. We host nothing and store nothing.export --focus writes the FinOps FOCUS column names, so these estimates can sit beside a real cloud bill in a tool that already reads FOCUS. Still an estimate at list price, and every row says so.+ Filter button, and removable chips for whatever is actually on. Pick a dimension and its values arrive with a search box and each value's share. Twenty-one views in a sidebar grouped by topic, collapsible to a rail of icons. A command palette with grouped commands and your recents. Hover any chart for a crosshair and every series at that point.
+ Filter button, and a chip for whatever is actually on. Pick two models and every number narrows, including the plain-language insight at the top.Not unless you send it. There is no telemetry and no hosted service. Adapters read token counts and metadata and discard prompt text, source code and file contents, and everything lives in ~/.tokenflow, which you can back up or delete. The paths that can leave the machine are all opt-in and all point at an address you chose: a folder you already sync, a team server you run, your own git remote for receipt notes, and a policy pull from that same team server. The MCP server is local stdio with no socket at all.
By branch and by merge. A pull request owns the turns on its branch up to the merge, including work done before it was opened. Turns after the merge are reported beside it. Sessions on a detached HEAD are reported as unattributed, never guessed.
Every built-in rate records its source URL and fetch date. Service tiers are applied as multipliers per request. Models without a published rate show blank with a reason, and every total states how many turns it priced.
No. It is a Claude Code hook that runs on your machine, reads the live transcript incrementally, and prints its verdict. With no thresholds declared it never blocks.
The app is unsigned because there is no Apple Developer account behind this free project. Right-click the app, choose Open, then Open again. The gate appears once.
Free and open source under MIT. Your tokens never leave your machine.