cd /news/ai-tools/claude-code-token-optimizer-vscode-e… · home › topics › ai-tools › article
[ARTICLE · art-145026] src=dev.to ↗ pub= topic=ai-tools verified=true sentiment=↑ positive

claude code token optimizer vscode extension

A developer built Claude Code Token Optimizer, a free, MIT-licensed VS Code extension that parses the JSONL session transcripts Claude Code writes to ~/.claude/projects/ and displays estimated spending, token usage, and rule-based suggestions for reducing waste. The extension runs ten detectors locally with no data leaving the machine, and estimates costs from a rate table since Claude Code's local stats report costUSD: 0.

by read2 min views1 publishedOct 4, 2026

TL;DR

I built a vscode extension that reads the session transcripts claude code already writes to ~/.claude/projects/ and turns them into a dashboard that shows users the estimated $ spent, how a session could have been improved, and which actions caused excessive tokens to be used. It's free, MIT licensed, and on the vscode

marketplace. This post is to introduce the extension, how it works, and hopefully to get feedback or future collaborators to help me improve it!

what it does:

limits: claude code only (for now), all costs are estimates from a rate table.

claude code writes every turn of every session to a JSONL file in ~/.claude/projects/, with full usage on each line including input and output tokens, cache reads, writes, tool calls, and compactions. So the data to answer "where did that session's money go" already exists.

claude code token optimizer preforms read-only operations those transcripts, then runs them through a rules engine, and formats the results in the sidebar view. everything stays local, no data leaves the machine or is sent to any service.

the view:

It's on the [vs code marketplace](https://marketplace.visualstudio.com/items?itemName=side-quests.claude-code-token-optimizer),

and the source is at [github.com/emihiggins/ai-insights-ext](https://github.com/emihiggins/ai-insights-ext).

currently there are 10 detectors in place, one file each in src/rules/:

most of the work is in what they don't flag. the redundant command detector only counts read-only inspection commands grep, rg, find, cat, ls, git status, git log, git diff run repeatedly 3 or more times in one session. re-running tests or a build is the agent doing its job, so those are deliberately left out. the regression banner has the same problem in a different place, a quiet week makes everything look like a regression, so it only fires when both 7-day windows have a minimum of 3 active sessions and 20k tokens. low usage history still renders the chart, it just doesn't raise an alert.

claude code's local stats report costUSD: 0, so every dollar figure is an estimate from a rate table in src/pricing.ts: per 1M tokens, Opus $5/$25, Sonnet $3/$15, Haiku $1/$5, with cache reads at 0.1× input and cache writes at 1.25× (5-minute TTL) or 2× (1-hour TTL). if your pricing differs, you should edit the table. (this is also something I plan to keep updating as more models and updated pricing becomes available)

I build the data layer (parser), session model, pricing, rules, discovery — has no vscode dependency and is tested against fixtures and a temp ~/.claude tree. chokidar and chart.js are bundled at build time, so the .vsix ships no runtime node_modules.

── more in #ai-tools 4 stories · sorted by recency
── more on @claude code 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/claude-code-token-op…] indexed:0 read:2min 2026-10-04 · —