DEV Community

Zayd Mulani
Zayd Mulani

Posted on

I built a local token cost tracker for Claude Code in Rust

After one too many surprise Claude Code bills, I built agentwatch.
It's a local HTTP proxy written in Rust. Point your agent at localhost:7878, and it intercepts every request, parses the token usage, and shows a live Ratatui TUI dashboard of what you're spending — in real time.
Everything stays local. SQLite database, zero signup, single binary via cargo install agentwatch.
Supports Claude Code, Codex, and Gemini CLI.
github.com/zaydmulani09/agentwatch

Top comments (3)

Collapse
 
alexshev profile image
Alex Shev

Local cost visibility is one of those tools that feels small until you lose it.

Model spend is easy to ignore when it is hidden behind sessions, retries, and long context rebuilds. A local tracker gives developers a feedback loop while the behavior is still fresh: which tasks were expensive, which loops got stuck, and which habits quietly burn tokens.

That is more useful than only seeing the bill later.

Collapse
 
zaydmulani09 profile image
Zayd Mulani

exactly right — the feedback loop while the behavior is still fresh is the whole point. by the time you see the bill the context is gone and you can't connect the cost to the decision that caused it. agentwatch makes that connection visible in real time

Collapse
 
alexshev profile image
Alex Shev

Yes, the timing is the product.

A monthly bill can tell you something went wrong, but it cannot reliably tell you which prompt, model choice, retry loop, or workflow decision caused it. Seeing cost while the work is still fresh makes the behavior correctable instead of just expensive.