Tokey
A Python terminal tool, built test-first, that tracks Claude Code token costs live
Real-time per-prompt token and cost tracker for Claude Code, built to make LLM spend visible inside the terminal while the work is still running.
How I built it
I built a Python terminal panel that finds the active Claude Code session from its newest transcript file and re-reads that file on every refresh. It parses each turn's token counts and prices them per model, so the cost of a prompt climbs while the response is still streaming. Older transcripts are backfilled into history on a background thread, so the panel never waits on them. I wrote it test-first, specifying each parser state and model pricing rule before writing the implementation.
Outcome
It shows the running cost of each prompt as it happens, so a runaway agent loop can be stopped mid-flight rather than discovered on an invoice. It is open source, with 350+ tests covering the parsing and pricing logic.
Built with
Python, Rich, pytest, TDD, CLI Architecture, Git