tokentracker
See where your agent sessions spend tokens: per session, per file, per skill. Local only, no account, no network calls.
Install
pipx install git+https://github.com/mgkvibez/tokentracker.git # works today
pipx install tokentracker-ai # once the PyPI release is live
Standard library only. Nothing to configure, nothing to sign into.
Three things it does
1. Find the expensive thing in a session log. Reads Claude Code's session JSONL, or any flat JSONL carrying a usage block:
tokentracker report ~/.claude/projects --top 6
That prints total tokens, estimated cost, the ranked list of what consumed context with percentages, and a per-session breakdown. A skill that eats 40% of a session is labelled as such instead of hiding in a 200-message transcript.
2. Watch it while you work. Same numbers, redrawn in place, so a runaway loop is visible in seconds rather than after the bill:
tokentracker watch ~/.claude/projects --interval 2
3. Record usage you cannot read from logs. If your harness keeps no logs, point the client's base URL at the proxy and work normally:
tokentracker proxy --port 8787 --upstream https://api.anthropic.com --log ~/.tokentracker/proxy.jsonl
tokentracker report ~/.tokentracker/proxy.jsonl
Why it exists
Token burn is invisible until the invoice, and the invoice says "$41" rather than "the threat-model skill ate 40% of your context." Every harness records the numbers somewhere; almost nothing turns them into an answer you can act on. This does, locally, without shipping your transcripts to a dashboard.
How it works
Three pieces, deliberately small:
- Adapters (
tokentracker/adapters.py) turn a log line into anEvent: session, model, usage, and the files or skills that call touched. Claude Code's JSONL is understood natively; anything else needs a flatusageblock. Adding a harness is one function plus one fixture. - Attribution (
tokentracker/attribute.py) splits each call evenly across everything it touched, and puts a call that touched nothing into(unattributed). That means the percentages always sum to 100% of real spend, and the honest answer for a call that read three files is "a third each" rather than a guess. - Cost (
tokentracker/pricing.py) is a data table, not code. The defaults are starting points stamped with the date they were written,cache_readis billed at 0.1x the input rate andcache_writeat 1.25x, and an unknown model producescost: unavailableinstead of a fabricated number. Override the whole table with--prices prices.json.
Known limits, stated plainly: streamed responses are proxied but not counted, because usage arrives in fragments; and a call's tokens cannot be attributed more precisely than the tool calls inside it reveal.
Contributing
scripts/verify.sh is the gate, and CI runs the same script on Python 3.9 and 3.12:
python3 -m pip install -e ".[dev]"
bash scripts/verify.sh
It checks install, that pyproject.toml and __version__ agree, the full test suite, and that the CLI still produces a report. A new adapter needs a real log fixture, not a hand-written dict. See CONTRIBUTING.md.
License
MIT.
Metadata
Release files for tokentracker-ai 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| tokentracker_ai-0.2.0.tar.gz | 9.2 kB | With provenance | Details for tokentracker_ai-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| tokentracker_ai-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for tokentracker_ai-0.2.0-py3-none-any.whl |
Total release size: 13.4 kB
Release files / tokentracker_ai-0.2.0.tar.gz
| Download URL | tokentracker_ai-0.2.0.tar.gz |
|---|---|
| Size | 9.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
be8df49e8bdab1127ea225128f285d153777a2ccd2739697985ea3a237c94c81
|
|
BLAKE2b-256 checksum How to use checksums |
9d1e0d53daa7a76f28b12abc767b24e36fc408f1a4c0e40ea5c1a039c16b767b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 30, 2026.
Transparency logRelease files / tokentracker_ai-0.2.0-py3-none-any.whl
| Download URL | tokentracker_ai-0.2.0-py3-none-any.whl |
|---|---|
| Size | 4.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1d6568f08d24ff3a0c667c7bea615cd53f0793e3ad537ec4c7d70c4d9374198b
|
|
BLAKE2b-256 checksum How to use checksums |
cf20029213f9b895ad8c24407c99dc11552df7443450b38d60d8fdd718ac9795
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 30, 2026.
Transparency logSecurity for tokentracker-ai 0.2.0
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.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for tokentracker_ai-0.2.0.tar.gz
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 30, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.