Skip to main content

tokentracker

See where your agent sessions spend tokens: per session, per file, per skill. Local only, no account, no network calls.

CI license: MIT PyPI python stars

tokentracker report in a terminal

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 an Event: session, model, usage, and the files or skills that call touched. Claude Code's JSONL is understood natively; anything else needs a flat usage block. 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_read is billed at 0.1x the input rate and cache_write at 1.25x, and an unknown model produces cost: unavailable instead 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.1

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

Source distribution (sdist)

Source distribution for tokentracker-ai 0.2.1
File Size Uploaded Provenance Actions
tokentracker_ai-0.2.1.tar.gz 17.4 kB With provenance Details for tokentracker_ai-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for tokentracker-ai 0.2.1
File Interpreter ABI Platform Actions
tokentracker_ai-0.2.1-py3-none-any.whl Python 3 none any Details for tokentracker_ai-0.2.1-py3-none-any.whl

Total release size: 32.8 kB

Release files / tokentracker_ai-0.2.1.tar.gz

Download URL tokentracker_ai-0.2.1.tar.gz
Size 17.4 kB
Tags Source
SHA-256 checksum
How to use checksums
de3f2332abd970105291666527c9f1044f96d46bab9d7e8b2d2f5ffbae6ba1e2
BLAKE2b-256 checksum
How to use checksums
8a4b9e9f59da897d91592efe191a147409a2608bac5b71a52a8a8ca0378eee92
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 log

Release files / tokentracker_ai-0.2.1-py3-none-any.whl

Download URL tokentracker_ai-0.2.1-py3-none-any.whl
Size 15.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cbf23deadd7bfce8272d09bb8d5cb07147a2dcb18fb3a5e2bdb530165c2650db
BLAKE2b-256 checksum
How to use checksums
8c320addf0027938216fa46e873e36dfe462ce3c5b2e57fd16583127b6e86c6b
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 log

Security for tokentracker-ai 0.2.1

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.

Select from 2 files

Attestation for tokentracker_ai-0.2.1.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 log

A 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.

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files Full provenance

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