Every time Claude Code re-reads a file you just showed it, the text goes back into the conversation and lands on the bill again. You're charged by the token, a piece of text smaller than a word, and a repeated read counts as a new read. It's like paying for a photocopy every time someone asks for the same page of the same book. Token Optimizer, a plugin built by alexgreensh (PolyForm Noncommercial license, free for non-commercial use), goes after that waste: it cuts what Claude re-reads and shows, in a local dashboard, where your tokens went.
If you don't know what a mod is yet, start with this post:
Token Optimizer is a plugin, and the strip above the prompt, which you'll see below, is the part that's a mod.
Claude stops paying twice for the same read
The plugin sits in the path of every file read and every command. When Claude re-reads a file that changed a little, only the difference comes back. When it re-reads one that didn't change, a skeleton of the code comes back instead of the whole file. Long tool results (over about 4,000 characters) go to a file on disk, and Claude fetches the original with the expand command if it needs it.
You ask Claude to review a file. It edits it and, two steps later, reads the same file again. Instead of the whole text, only what changed comes back. On a 2,000-token re-read, the author measures something close to 50.
The same goes for command output: a test run that spits out hundreds of lines is trimmed before it reaches the model. In the author's own measurements, a 564-token pytest output becomes 115, and a 500-line grep becomes 20.
The dashboard shows where the money went
After each session, the plugin generates a local HTML page with spend per turn, cost across four pricing tiers, how much of the cache was used, a quality score per session, subagent costs and how much was saved. You open the file in your browser, and nothing leaves your machine. For a fixed localhost address, run measure.py setup-daemon once.
You don't spend less by asking cheaper. You spend less by no longer paying for what was already read.
The strip above the prompt warns you before the conversation degrades
This is the mod part. Above the prompt, in the desktop app, five marks appear: the conversation's quality grade, how full the context is, the cache countdown (what Claude already read, stored so it costs less, and which expires), and your 5-hour and weekly usage limits. A mascot, Clawd, changes with the session: reading, editing, waiting for permission or napping.
There are three buttons: compact with guidance, start fresh with a checkpoint, and refresh the cache by hand. The cache countdown is an estimate, because Anthropic doesn't publish the exact moment it expires. It only works in the desktop app, with Claude Code 2.1.287 or newer. In the terminal and in VS Code, the status line stays as it always was.
Before compacting, it saves what matters
Compacting means summarizing the conversation to free up space, and the summary tends to lose detail. The plugin creates checkpoints as the context fills (at 20%, 35%, 50%, 65% and 80%) and, before each compaction, stores the task, the decisions, the files changed and the git branch. Afterwards, it injects a digest of what was read and which errors showed up, without spending a model call.
How to install it
/plugin marketplace add alexgreensh/token-optimizer
/plugin install token-optimizer@alexgreensh-token-optimizer
/token-optimizerThe last command runs a first audit, and after that the hooks (the parts that react to each action Claude takes) handle the rest. It needs Python 3.9 or newer. On Windows, only the plugin install works. To hide the strip, put "TOKEN_OPTIMIZER_STATUS_BAR": "0" in ~/.claude/settings.json.
Everyone looks at what AI costs per month. Few people ask how much of that bill is the same page photocopied for the fifth time. Next time your Claude bill gives you a scare, it's worth finding out which part of it you paid for twice.





Comments (0)
Comments are moderated and if they violate our Terms and Conditions of use, the comment will be deleted. Persistence in violation will result in a ban of your account.