Don't just count AI coding tokens — blame them.
Zero-config, 100% offline multi-agent token ledger with out-of-repo Git commit provenance, fixed-horizon (t+30/60/90d) & Squash-Merge-resilient line retention, and exit-code-aware burn forensics.
TokenBlame is a single-user local observability CLI that joins transcripts across Claude Code, Codex CLI, Gemini CLI, and Antigravity with your local Git repositories (strictly read-only via git --no-optional-locks) — without mutating Git commit history, trailers, or .git/refs.
Token accounting, commit attribution, and code survival each have strong existing tools (ccusage, Tokscale, Git AI, Entire, survived). TokenBlame's design choice is combining zero repo mutation, zero third-party runtime dependencies (Python 3.11+ stdlib), local SQLite retention archiving, and strict fidelity separation in one offline personal workflow:
| Tool | Primary Focus | Token Bucket Breakdown | Git / Outcome Linkage | Repo Mutation | Runtime |
|---|---|---|---|---|---|
ccusage / Tokscale |
Multi-agent token & cost accounting (+ Tokscale recovery ledger & task reports) | Yes (input / cache / output / reasoning) |
Cost/task-focused (no git blame retention) |
None | Node / Rust |
Git AI (OSS / Teams) |
Line-level AI authorship + Teams PR cost, rework & churn analytics | Yes (spec covers buckets & 90d DB; team analytics in Teams tier) | Line-level authorship + PR cost/churn | Git notes / metadata | Rust / Cloud |
Entire |
Session checkpoints & token hotspot diagnostics | Yes (fresh / cache / output / subagent) |
Session checkpoints linked to commits | Checkpoint metadata | Go |
survived |
Fixed-horizon t+30/60/90d code survival (with notYet cohort separation) |
No | Fixed-horizon commit survival | None | TypeScript |
TokenBlame (v2.2) |
Local offline multi-agent cost + commit provenance + t+30/60/90d cohorts & HEAD retention + exit-code burn loops |
Yes (4-bucket + strict unbucketed separation) | Out-of-repo record-hook spool + revert, HEAD retention & matured cohorts (notYet separated) |
None | Python 3.11+ stdlib only |
Honest measurement scope:
- HEAD Line Retention vs. Fixed-Horizon Cohorts (
t+30/60/90d):line_survival_30d_pcttracks HEAD retention of lines from the recent 30-day window (with Squash-Merge / Rebase fallback andunobserved_lineskept separate ongit blameerrors). Alongside it,durability.cohorts(t30d,t60d,t90d) measures matured fixed-horizon cohorts explicitly separated from immaturenotYetcommits.- Pre-Indexed Query Latency (
3.5ms): Refers specifically to filteredtokenblame summaryreads against an already-builtobservatory.sqlite, not cold full-history harvesting orgit blamescans.- Diagnostic Signals ≠ Causal Proof:
FAILURE_LOOP(nonzero exit/error streaks),ITERATION_LOOP(zero-error verification repeats), uncommitted high-burn sessions, and line retention are investigative signals — not automatic proofs of wasted effort, code correctness, or causal ROI.
- Allowlisted Tool Forensics (Zero Leakage): Extracts peak turn spikes (
Peak #T: Out / Fresh) and exit-code-aware loop classifications (FAILURE_LOOP(Bash:pytest x6, err=4)vs normalITERATION_LOOP(Bash:pytest x4)) using an allowlist of tool/command basenames — never storing command arguments, stdout/stderr, file paths, or prompts. - Privacy-Sealed
--shareableMode:tokenblame build --shareableproduces a standalone offline HTML dashboard (shareable-observatory.html) with salted SHA-256 aliases (repo-01,c-9a4f1b2c) and zero local paths, usernames, or commit subjects.
# Instant zero-install run via uvx:
uvx tokenblame
# Or install globally:
uv tool install tokenblame
# or: pip install tokenblame
# Harvest logs + build offline HTML + print 30-day summary in one command:
tokenblame
# Also emit privacy-redacted shareable HTML + IR:
tokenblame build --shareable
# Open dashboard in your browser (or Orca tab when running inside Orca):
tokenblame open
tokenblame open --shareable
# Sub-10ms filtered queries powered by indexed observatory.sqlite:
tokenblame summary --days 7
tokenblame summary --days 30 --lane my-repo --json
# Check environment, detected agent logs, timezone, and hook status:
tokenblame doctor
# One-click 1:1 provenance hook setup (with automatic backup & --uninstall):
tokenblame init
tokenblame init --dry-run
tokenblame init --uninstall
# Override local OS timezone when needed:
tokenblame summary --days 7 --tz America/New_YorkBy default, TokenBlame discovers local Git repos under ~/projects, ~/code, ~/dev, ~/src, ~/work, ~/repos, and ~/GitHub (plus repeatable --scan-root /custom/dir) and writes all local artifacts with 0600 permissions to:
- macOS:
~/Library/Application Support/tokenblame/ - Linux:
${XDG_DATA_HOME:-~/.local/share}/tokenblame/ - Override:
TOKENBLAME_DIR=/path/to/dir
To upgrade concurrent same-repo agent sessions from time-window heuristics ([-2h, +12h]) to deterministic 1:1 EXACT_HOOK_OID attribution without adding files, trailers, or git notes to your repositories:
{
"hooks": {
"PostToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "tokenblame record-hook --provider claude"
}
]
}
]
}
}{
"hooks": {
"AfterTool": [
{
"matcher": "run_shell_command",
"hooks": [
{
"type": "command",
"command": "tokenblame record-hook --provider gemini_cli --emit-empty-json"
}
]
}
]
}
}- Strict Fidelity Separation: Unexposed IDE transcripts or legacy unbucketed SQLite threads are never blended into exact 4-bucket totals; estimated byte-volume side ledgers (
ESTIMATED_TRANSCRIPT) are reported separately. - Honest API-Equivalent Pricing: Uses pinned official token rates (
input,cache_write,cache_read,output), labels alias/fast-mode tiers explicitly, and leaves unpriced preview models asunpricedrather than fabricating USD totals. - Transparent Causality Tiers: Separately badges
1:1 HOOK,SHA_META,WINDOW_HEURISTIC, andDAY_EPISODElinks so attribution strength is never overstated.
TokenBlame measures post-hoc token burn, retry loops, and 30-day patch survival. To prevent AI test shortcuts, tautological assertions, and surviving mutants before code merges on GitHub PRs, check out NoCheat Merge Gate — a deterministic, zero-LLM CI verification gate (Apache-2.0).
Apache-2.0 — see LICENSE.

