ClaudeMod
ModsDashboardsWrites / Shell

TokenDoctor

tokendoctor: the same Claude Code for up to 38% less. Replays your own past sessions to show what each change would have saved, then changes only what you pick

Install· Claude Code 2.1.330+
$claude plugin marketplace add localixai/tokendoctor
$claude plugin install tokendoctor@tokendoctor
Run claude plugin validate to auditGuide →
Access & PermissionsWrites / Shell

Writes files, executes local shell processes, or programmatically drives Claude.

Runs shell commandsChanges configDrives ClaudeReads settingsDraws UI

Statically scanned from hooks & source. Learn how to audit

rsaryev181 starsAdded 1 months ago

tokendoctor

tokendoctor

The same Claude Code for up to 38% less
Replays your own past sessions to show what each change would have saved, then changes only what you pick.

CI Version License: MIT

Install • Docs • Website • Changelog

tokendoctor in a real Claude Code session: /tokendoctor:sessions, then the daily trend

Your past sessions decide, not anyone's benchmark. What a setting saves depends on how you work: how long your sessions run, which models you use, what the work is. A number from someone else's sessions, mine included, says little about yours. So tokendoctor starts by looking back at your own.

① Look back at your last 30 days. /tokendoctor:sessions replays every session you had, request by request, at compaction windows of 200K, 300K, 400K and 600K, and shows what each would have cost. It only reads your transcripts, makes no model calls and changes nothing. The figure is an upper bound: a replay can't see work the model would have redone after a summary.

② Change only what your sessions show pays, and undo it. /tokendoctor:optimize proposes changes from those numbers and checks your settings against Claude Code's docs; it applies only the ones you pick, each shown as a diff first. /tokendoctor undo puts any of them back.

③ Optional: slide instead of summarize. When Claude Code would stop to summarize the conversation, tokendoctor drops old tool output instead and keeps every message. There is no model call, so it takes milliseconds, not a minute.

④ Optional: keep the cache warm through a break. Come back after the prompt cache's hour and the next message writes the whole conversation into it again, at twice the input price. With /tokendoctor keepalive on, a one-word fork of the conversation reads it from the cache six minutes before the hour runs out, which starts the hour again. Only conversations of 200K tokens or more, and never on a cache that may already be cold. /tokendoctor:sessions shows first what it would have saved you (more below).

Install

claude plugin marketplace add localixai/tokendoctor
claude plugin install tokendoctor@tokendoctor

Restart Claude Code and run /tokendoctor:sessions to see what your last 30 days would have cost at each window. Nothing changes until you pick it.

What it found in mine

Every request sends the whole conversation to the model. On models with a 1M window, Claude Code compacts only near 967K tokens, so the end of a long session is the expensive part. For me, two thirds of main-thread cost went to requests with more than 400K in context.

So I set a 400K window and Sonnet for subagents. Comparing the month before with the week after, about 23K and 19K main-thread requests, context per request went from 412K to 219K and cost per request fell 38% at API list prices. That's one person's before and after, not a controlled experiment.

The catch is more summaries, and each is a pause: 79 seconds on average in my sessions. That's what the slide is for. Your sessions may show something else entirely, which is the point of looking at them first.

What the benchmark shows

On the benchmark, Claude Code builds a TypeScript project against tests it can't change, so a run counts only if the tests pass. Cost is per task, on Haiku 5.5:

ComparedCostTime
Slide against a summary, a day of work−19%−33%
Slide against a summary, an eval harness−35%−28%
Slide against a summary, a short task+6%−17%
The settings advice alone, against Claude Code as it shipsdearer in 3 of 4 runs
The advice and the slide, a week of work−11% to −21%

Every test passed in every run. The advice alone didn't pay here because these tasks rarely pass 400K, which is where the window starts to matter. If your sessions don't either, your replay will show it, and you should leave your window alone. Every run, the losing ones too, is in bench/HISTORY.md.

The author's tokendoctor dashboard: 57% of the spend was Claude re-reading the conversation
/tokendoctor:dashboard: where every token went, by day, model, subagent and project. One local file; this one is mine.

Keep the cache warm through a break

On a plan, Claude Code keeps the main conversation in the prompt cache for an hour. Come back later than that and the next message writes the whole conversation into the cache again, at twice the input price. With /tokendoctor keepalive on, six minutes before the hour runs out tokendoctor sends a one-word fork of the conversation. The fork reads the conversation from the cache, which starts the hour again, and adds nothing to yours.

One live session on Sonnet 5.5, 26 November 2026, with a ping at minute 54 and nothing else in between:

MinuteRequestRead from cacheWritten
0yours21,8770
54the ping21,8800
70yours21,88011

It pings only conversations of 200K tokens or more, and only when it knows the cache is warm. A break starts with 4 pings, and the number moves between 2 and 6 as it learns from your breaks: at most 3 an hour and 30 a day on the machine, none past 80% of a plan limit.

It is off by default because it rarely pays much. Over my last 30 days (41 sessions), 9 of 23 breaks longer than 54 minutes would have come back to a warm cache: $26.21 of rewrites saved for $5.51 of pings, 1.6% of the month. In 12 the pings ran out before I came back, and in 2 I was back within the hour anyway. /tokendoctor:sessions runs the same replay over your own breaks. The rest is in the docs.

Commands

CommandWhat it does
/tokendoctor:sessions [days]Replays your past sessions (30 days, or days) at smaller windows: what each would have saved, then where your tokens went. Reads only.
/tokendoctor:auditYour settings, memory and CLAUDE.md checked against the docs, by severity. Reads only.
/tokendoctor:dashboard [days]Opens a local dashboard of every session on this machine.
/tokendoctor:optimize [focus]Proposes up to five changes from your numbers and applies the ones you pick.
/tokendoctor [name] [value]Shows, explains or changes a setting, with no model call.
/tokendoctor undo [n]Lists every change tokendoctor made and puts one back.

Nothing leaves your machine: the only network call is to two public pages of Claude Code's docs, once a day. It never switches your models on its own.

Documentation

tokendoctor.localix.ai/docs has the rest: the 38 checks, every setting, how the slide works (and Team and Enterprise logins), the cache keepalive, the commands from a shell, the measurements and the limits. To work on tokendoctor itself, see CONTRIBUTING.md.

License

MIT

Details

GitHub Stars
181
Sub-category
Dashboards
License
MIT
Surfaces
terminal
Added
1 months ago
Last synced
today
Events hooked
tool.callsession.startcommand.runprompt.autocompletesession.compacttool.check

Weekly Mods Digest

Top new Claude Code mods and install commands, once a week. No fluff, unsubscribe anytime.

More Mods

Claude Flightdeck
ModsSecurity

Claude Flightdeck

Live agent dashboard pane with context consumption, advisor timeline, permission verdicts, and subagent swimlanes.

Reads Files
by Sam Casella
GitHub
ModsInterface

Terminal Browser

Browse documentation, GitHub pull requests, and web pages in a split terminal pane directly beside your Claude Code conversation.

Network
by Zenbu Labs
GitHub
Agent Flow
ModsAutomation

Agent Flow

Interactive visual tree of the active session's subagents, background tasks, and teammates beside the transcript via /flow.

UI Only
by Charlie
GitHub

Command Palette

Search for a command to run...