I built a local token cost tracker for Claude Code in Rust
📰 Dev.to AI
Learn how to build a local token cost tracker for Claude Code in Rust and track your expenses in real-time
Action Steps
- Build a local HTTP proxy using Rust to intercept requests and parse token usage
- Use a SQLite database to store token usage data locally
- Create a live dashboard using Ratatui TUI to display real-time spending
- Configure the proxy to support multiple AI models like Claude Code, Codex, and Gemini CLI
- Install the agentwatch binary via cargo install agentwatch
Who Needs to Know This
Developers and engineers working with AI models like Claude Code can benefit from this project to monitor and optimize their token usage and costs
Key Insight
💡 Building a local token cost tracker can help optimize AI model usage and reduce unexpected costs
Share This
🚀 Track your Claude Code token expenses in real-time with agentwatch, a local HTTP proxy built in Rust 💸
Key Takeaways
Learn how to build a local token cost tracker for Claude Code in Rust and track your expenses in real-time
Full Article
Title: I built a local token cost tracker for Claude Code in Rust
URL Source: https://dev.to/zaydmulani09/i-built-a-local-token-cost-tracker-for-claude-code-in-rust-500h
Published Time: 2026-07-13T21:58:53Z
Markdown Content:
[Skip to content](https://dev.to/zaydmulani09/i-built-a-local-token-cost-tracker-for-claude-code-in-rust-500h#main-content)
[](https://dev.to/)
[Powered by Algolia](https://www.algolia.com/developers/?utm_source=devto&utm_medium=referral)
[Log in](https://dev.to/enter?signup_subforem=1)[Create account](https://dev.to/enter?signup_subforem=1&state=new-user)
## DEV Community
0 Add reaction
0 Like 0 Unicorn 0 Exploding Head 0 Raised Hands 0 Fire
0 Jump to Comments 0 Save Boost
Copy link
Copied to Clipboard
[Share to X](https://twitter.com/intent/tweet?text=%22I%20built%20a%20local%20token%20cost%20tracker%20for%20Claude%20Code%20in%20Rust%22%20by%20Zayd%20Mulani%20%23DEVCommunity%20https%3A%2F%2Fdev.to%2Fzaydmulani09%2Fi-built-a-local-token-cost-tracker-for-claude-code-in-rust-500h)[Share to LinkedIn](https://www.linkedin.com/shareArticle?mini=true&url=https%3A%2F%2Fdev.to%2Fzaydmulani09%2Fi-built-a-local-token-cost-tracker-for-claude-code-in-rust-500h&title=I%20built%20a%20local%20token%20cost%20tracker%20for%20Claude%20Code%20in%20Rust&summary=After%20one%20too%20many%20surprise%20Claude%20Code%20bills%2C%20I%20built%20agentwatch.%20It%27s%20a%20local%20HTTP%20proxy%20written%20in...&source=DEV%20Community)[Share to Facebook](https://www.facebook.com/sharer.php?u=https%3A%2F%2Fdev.to%2Fzaydmulani09%2Fi-built-a-local-token-cost-tracker-for-claude-code-in-rust-500h)[Share to Mastodon](https://s2f.kytta.dev/?text=https%3A%2F%2Fdev.to%2Fzaydmulani09%2Fi-built-a-local-token-cost-tracker-for-claude-code-in-rust-500h)
[Share Post via...](https://dev.to/zaydmulani09/i-built-a-local-token-cost-tracker-for-claude-code-in-rust-500h#)[Report Abuse](https://dev.to/report-abuse)
[](https://dev.to/zaydmulani09)
[Zayd Mulani](https://dev.to/zaydmulani09)
Posted on Jul 13
# I built a local token cost tracker for Claude Code in Rust
[#ai](https://dev.to/t/ai)[#opensource](https://dev.to/t/opensource)[#productivity](https://dev.to/t/productivity)[#rust](https://dev.to/t/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 (0)
Subscribe

[](https://dev.to/)
[Powered by Algolia](https://www.algolia.com/developers/?utm_source=devto&utm_medium=referral)
[Log in](https://dev.to/enter?signup_subforem=1)[Create account](https://dev.to/enter?signup_subforem=1&state=new-user)
## DEV Community
0 Add reaction
0 Like 0 Unicorn 0 Exploding Head 0 Raised Hands 0 Fire
0 Jump to Comments 0 Save Boost
Copy link
Copied to Clipboard
[Share to X](https://twitter.com/intent/tweet?text=%22I%20built%20a%20local%20token%20cost%20tracker%20for%20Claude%20Code%20in%20Rust%22%20by%20Zayd%20Mulani%20%23DEVCommunity%20https%3A%2F%2Fdev.to%2Fzaydmulani09%2Fi-built-a-local-token-cost-tracker-for-claude-code-in-rust-500h)[Share to LinkedIn](https://www.linkedin.com/shareArticle?mini=true&url=https%3A%2F%2Fdev.to%2Fzaydmulani09%2Fi-built-a-local-token-cost-tracker-for-claude-code-in-rust-500h&title=I%20built%20a%20local%20token%20cost%20tracker%20for%20Claude%20Code%20in%20Rust&summary=After%20one%20too%20many%20surprise%20Claude%20Code%20bills%2C%20I%20built%20agentwatch.%20It%27s%20a%20local%20HTTP%20proxy%20written%20in...&source=DEV%20Community)[Share to Facebook](https://www.facebook.com/sharer.php?u=https%3A%2F%2Fdev.to%2Fzaydmulani09%2Fi-built-a-local-token-cost-tracker-for-claude-code-in-rust-500h)[Share to Mastodon](https://s2f.kytta.dev/?text=https%3A%2F%2Fdev.to%2Fzaydmulani09%2Fi-built-a-local-token-cost-tracker-for-claude-code-in-rust-500h)
[Share Post via...](https://dev.to/zaydmulani09/i-built-a-local-token-cost-tracker-for-claude-code-in-rust-500h#)[Report Abuse](https://dev.to/report-abuse)
[](https://dev.to/zaydmulani09)
[Zayd Mulani](https://dev.to/zaydmulani09)
Posted on Jul 13
# I built a local token cost tracker for Claude Code in Rust
[#ai](https://dev.to/t/ai)[#opensource](https://dev.to/t/opensource)[#productivity](https://dev.to/t/productivity)[#rust](https://dev.to/t/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 (0)
Subscribe
![Image 9: pic](https://media2.dev.to/dynamic/image/width=256,height=,fit=scale-down,gravity=auto,format=au
DeepCamp AI