Skip to main content

tracegauge

tracegauge

tracegauge reads your Claude Code session transcripts on your own machine and shows where the tokens and dollars went, which retries were pure waste, and which cache re-writes cost you money.

CI License: Apache-2.0 Python 3.10+ PyPI

Terminal recording of tracegauge quickstart on the bundled synthetic sample session: a token economy verdict, one deterministic waste finding and the cost breakdown

Install and try it

pip install tracegauge
tracegauge quickstart   # scores a bundled synthetic session: no network, no files of yours read
tracegauge score        # scores your most recent Claude Code session

What it finds

Real output of this version on data in the repository. Lines are selected from the report, never edited. scripts/gen_readme_demo.py regenerates both blocks and the recording above, and tests/test_readme_demo.py fails when this README or the recording drifts from what the command prints.

tracegauge quickstart on the bundled sample, a synthetic session shipped in the package. It gets a token verdict against the research-recon band, one deterministic waste finding with its proof turns, and the cost split by where the money went:

tracegauge quickstart -- no local judge, no network call, no files of yours read.
── TOKEN ECONOMY ───────────────────────────────────────────────────────────
  Real tokens: 531,840
  Verdict:     within_band
  Baseline:    research-recon — p25: 411,052 / median: 620,842 / p75: 1,194,136
── TRAJECTORY QUALITY ──────────────────────────────────────────────────────
  Verdict:     UNAVAILABLE (no local judge configured)
── DETERMINISTIC WASTE ─────────────────────────────────────────────────────
  Events:  1 event(s)
  [1] REPEATED-FAILED-RETRY — 2 retries, turns: 61→62, 64→65  ~$0.041
── COST BREAKDOWN ──────────────────────────────────────────────────────────
  Context re-send (cache reads)                       $1.89   51.3%
  Context growth (cache writes)                       $0.33    8.8%
  Output                                              $0.80   21.8%
  Fresh input                                         $0.63   17.0%
  Detected waste (redundant reads, retry loops)       $0.04    1.1%
  Total (priced)                                      $3.69

The cache-churn detector, on a second synthetic session with three planted cache re-writes (an idle gap past the cache lifetime, a model switch and a compaction; seeded generator, tests/churn_synth.py). It reports what each re-write cost above reading the cache back, and says the cause is a rule on transcript markers and timestamps, not a verified fact. Method and limits: docs/CACHE_CHURN.md.

── CACHE CHURN ─────────────────────────────────────────────────────────────
  3 event(s) where cached context was re-written instead of read: $0.38
  above what reading it would have cost. Main chain $0.38 (3), subagents
  $0.00 (0).
    TTL gap (idle past the cache lifetime)      1       $0.06
    model switch                                1       $0.16
    compaction                                  1       $0.17
  Plausibly avoidable (a judgement): $0.21; not avoidable by a setting (idle
  over an hour, compaction): $0.17.
    [main] turn 29→30: compaction, gap 78s vs 300s TTL, 35,615 tokens re-
    written, $0.17
    [main] turn 19→20: model switch, gap 53s vs 300s TTL, 32,860 tokens re-
    written, $0.16
    [main] turn 9→10: ttl gap, gap 2,632s vs 300s TTL, 23,145 tokens re-
    written, $0.06
  Cause = a rule on transcript markers and timestamps, not a verified fact.

Every figure in this block is rounded independently, and totals use the unrounded values. So the three cause rows add to $0.39 while the $0.38 total is the sum of the unrounded amounts, and the $0.21 "plausibly avoidable" figure sits beside model-switch and TTL-gap rows ($0.16 + $0.06) that add to $0.22.

Commands

tgauge is a short alias for tracegauge. The old tes command still works until 0.18 (migration guide). Full usage and the SDK: docs/COMMANDS.md.

Command What it does
tracegauge quickstart Scores the bundled sample session. No network, none of your files read.
tracegauge score [PATH] Scores a session file, a directory, or (no path) your most recent session. --pick chooses from a list, --json prints machine-readable output, --judge adds the optional trajectory judge.
tracegauge / tracegauge serve Starts the localhost-only dashboard (127.0.0.1:4747) and a watcher that scores finished sessions.
tracegauge cost Spend for a period (--week, --month, --since DATE); --roi compares it with your plan cost.
tracegauge budget Where your spend pace is heading, from your own trailing window.
tracegauge monitor One-shot check of the session being written now; exits 3 if the cost/context alarm fires.
tracegauge impact Lines added and removed and the most-edited files, from edit tool calls.
tracegauge patterns, tracegauge ask Behavioural archetypes over your sessions and an explainer over them (need pip install "tracegauge[patterns]").
tracegauge rescore, tracegauge backfill-waste Re-score sessions stored by older versions.
tracegauge export-contribution Writes a redacted, content-free local file. Nothing is sent.

Supported agents

Claude Code is supported. Other agents are planned; none is supported today. Each needs its own transcript adapter and a fresh validation run, not a flag.

Methodology

Three readings, never blended into one score. Token economy compares a session's tokens (each API response counted once, cache re-reads excluded) with the p25 to p75 band for the same task type. The bundled bands come from 71 Claude Code sessions of one developer, not filtered for quality, so "above the band" means heavier than that developer's typical session, not wasteful, and not heavier than other developers. Trajectory quality is an optional LLM judge: it is UNAVAILABLE without one, it was checked against a reference model and not against human labels, and its negative verdicts are model-dependent. The waste detectors catch two observable patterns only (identical failed retries and re-reads of unchanged files) and miss judgment-of-progress waste by design. Cache churn is a separate section of the score output, not a third waste detector: it finds turns where a cached prefix that the previous turn had read was written again, and prices each re-write above what reading it back would have cost; its cause label is a rule over transcript markers and timestamps, not a measurement of the vendor's cache, and the transcript cannot settle the cause (docs/CACHE_CHURN.md). Costs are API-equivalent rates from a bundled, dated price table, and a model missing from it is shown as unpriced, never as $0. Scoring makes no external network call (the optional local Ollama endpoint aside); the only data that can leave your machine is an opt-in API judge you consent to per session. Figures whose source data is not in this repository are labelled as the maintainer's unpublished local measurement. Everything, with every caveat and where each number comes from: docs/METHODOLOGY.md. Privacy: PRIVACY.md.


Apache-2.0 from 0.16.0 onward. Releases 0.15.0 and earlier on PyPI were published under AGPL-3.0-only and remain under that license for anyone who received them; the change applies to 0.16.0 and later only. Third-party fonts bundled in the package keep their own SIL OFL 1.1 license, and third-party datasets in the repository keep theirs; see NOTICE and DATA_SOURCES.md.

Metadata

Release files for tracegauge 0.16.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tracegauge 0.16.0
File Size Uploaded
tracegauge-0.16.0.tar.gz 334.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tracegauge 0.16.0
File Interpreter ABI Platform
tracegauge-0.16.0-py3-none-any.whl Python 3 none any Details

Total release size: 657.3 kB

Release files / tracegauge-0.16.0.tar.gz

Download URL tracegauge-0.16.0.tar.gz
Size 334.7 kB
Tags Source
SHA-256 checksum
How to use checksums
da510328d6f89cdb7c0c020f899a37cbbf2dd6f43df22639184f931aa99c17ba
BLAKE2b-256 checksum
How to use checksums
f85268a80b6d741ea2bf7eca90ef3f417c43a659c151d0617584345dd5fb363e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 18, 2026.

Transparency log

Release files / tracegauge-0.16.0-py3-none-any.whl

Download URL tracegauge-0.16.0-py3-none-any.whl
Size 322.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1db03715eb250f38073cf5e32b486db6f0de9a1b1fa736c7f30d285098943f4d
BLAKE2b-256 checksum
How to use checksums
42c67a6b33e5b5812afa7cbbb9ab1558d12d503b51b3f0da2794af66a519075c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 18, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.16.0 This release

2 release files

0.15.0

2 release files

0.13.0

2 release files

0.12.4

2 release files

0.12.3

2 release files

0.12.2

2 release files

0.12.1

2 release files

0.12.0

2 release files

0.11.1

2 release files

0.11.0

2 release files

0.10.2

2 release files

0.10.1

2 release files

0.8.0

1 release file

0.7.1

1 release file

0.7.0

1 release file

0.6.0

2 release files

0.5.0

2 release files

0.3.1

1 release file

0.3.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page