DEV Community

Cover image for I found 41.5% of my Claude Code tokens were pure waste so I built a free profiler
Yaswanth
Yaswanth

Posted on

I found 41.5% of my Claude Code tokens were pure waste so I built a free profiler

The question nobody could answer

Last week I got curious: where do my Claude Code tokens actually go? Every session burns thousands of tokens, but there was no way to see the breakdown — no profiler, no dashboard, nothing. So I built one.

What I found shocked me

I profiled my hackathon session: 75,111 tokens across 274 messages.

  • Tool results consumed 77.4% of all tokens
  • Tool calls took another 14.6%
  • My actual typed messages? 0.6%
  • Total waste detected: 41.5% of the session

One single bloated tool result consumed 24% of the entire session by itself. I had no idea this was happening.

The tool: tokenscope

npx tokenscope-ai
Enter fullscreen mode Exit fullscreen mode

That's the entire setup. No config, no API key, no account. It auto-detects your latest Claude Code session and shows you:

  • Category breakdown — where every token went (system, user, assistant, tools)
  • Waste findings — linter-style warnings with codes (W001: repeated content, W002: bloated tool results) and concrete fixes
  • Dollar estimates — session cost and waste cost based on model pricing
  • HTML treemap report — add --html report.html for a visual breakdown you can open in your browser

Design principles I didn't compromise on

100% offline. No API key, no account, no telemetry. It reads the JSONL logs Claude Code already writes to your machine. Nothing leaves your computer. Ever.

Zero config. One command. It finds your logs automatically on Windows, Mac, and Linux.

Honest numbers. Token counts are estimates (~±5%) using a local tokenizer, and we label them as such. Profiling is about proportions and finding waste, not billing precision.

Actionable findings. Every finding comes with a concrete fix and an estimated saving — like ESLint for your context window, not a vanity dashboard.

Example output

What's next

  • Proxy mode — intercept any AI tool's traffic, not just Claude Code
  • Compare mode — profile before and after to prove your optimizations worked
  • Cache-miss detection — find tokens that should have been cached but weren't
  • GitHub Action — set token budgets in CI

Try it

npx tokenscope-ai
Enter fullscreen mode Exit fullscreen mode

Run it on your own Claude Code sessions. I'm genuinely curious what waste percentage you find — drop it in the comments.

If it crashes on your logs (it's v0.1, built this week), open an issue: github.com/yaswanthme007/tokenscope

Built with Claude Code. Yes, it profiled its own creation.

Top comments (0)