claude code token optimizer vscode extension
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…
A new Visual Studio Code extension called Claude Code Token Optimizer has been developed by the author. This free, MIT-licensed extension is available on the VSCode marketplace and is designed to help users understand their expenses while using Claude Code. The extension reads session transcripts from the ~/.claude/projects/ directory, where Claude Code writes detailed JSONL files containing information about each session turn, including input and output tokens, cache reads, writes, tool calls, and compactions.
The extension runs 10 detectors on each session transcript, estimating the token and dollar costs associated with each session. These detectors are categorized into two types: one-off fixes that address issues specific to a single session, and habits that identify patterns across multiple sessions. The extension tracks cache reuse and cost per day, warns users when their usage over the last 7 days is worse than the previous 7 days, and drills down into individual sessions to show where their tokens are being consumed.
However, the extension currently only supports Claude Code, and all costs are estimates based on a rate table. The extension operates on local data only, with no data being sent to any external service. The user interface consists of a sidebar view that displays a potential savings panel, token totals, a breakdown of wasted tokens by mistake category, and a ranking of the most common causes of excessive token usage. Additionally, a status-bar item shows the live spend and cache reuse for the current session.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.