# tokendoctor

> A Claude Code plugin that shows where your tokens go, audits your settings against the docs, and applies reversible fixes.

tokendoctor is an open-source, MIT-licensed plugin for Claude Code, published by rsaryev. It replays your own sessions to estimate what a smaller context window would have saved, shows where tokens went, and proposes settings changes as diffs that are applied only on approval. It runs on your machine.

## What It Is

tokendoctor is a cost-optimization and audit plugin for Claude Code. It reads local session transcripts and settings files, then reports where tokens and spend went. It also checks the setup against Claude Code's current documentation. Costs are computed at each model's Claude API list price, so on a subscription plan they show what the same work would cost on the API.

## How the workflow runs

The flow is see, look, fix, slide and undo.

- `/tokendoctor:sessions` replays your sessions at smaller compaction windows and estimates the savings for each, then breaks down where tokens went. It is read-only.
- `/tokendoctor:dashboard` builds a local HTML file with spend by day, token type, model, reasoning effort, main thread and subagent type, context size, project and hour.
- `/tokendoctor:audit` and `/tokendoctor:optimize` run 38 setting checks, each tied to the docs. Changes are shown as a diff first and applied only when you approve.
- `/tokendoctor undo` lists every change the plugin made and restores any one of them, without a model call.

## Slide instead of summarize

The optional slide feature is off by default. Where Claude Code would compact, tokendoctor elides old tool outputs into short pointers instead of summarizing, so the conversation stays word for word and there is no summary pause. In one recorded session, the author reports a summary taking 65.3 s against 0.04 s for the slide. On Team or Enterprise logins, the slide needs a one-time sudo install of a machine-level copy.

## Measured results and limits

The author reports a 38% lower main-thread cost per request over six weeks of their own use. The README also publishes benchmark runs, with results that vary by task. It states that there is no one pill: if sessions rarely pass 400K tokens, a smaller window changes little. Sessions on other machines and transcripts Claude Code has already cleaned up are not counted. The audit fetches two public Claude Code docs pages once a day and sends nothing of yours.

## Features
- Session replay estimating savings at smaller compaction windows
- Local HTML usage dashboard by day, model, effort, subagent, project and hour
- 38 setting checks linked to Claude Code docs
- Fixes shown as a diff and applied only on approval
- Slide mode that elides old tool outputs instead of summarizing
- Reversible changes with a list-and-undo command
- Session findings such as late compaction and idle cache rebuilds
- Status line script installable through a fix
- Shell commands for audit, sessions, replay, set, apply and undo

## Integrations
Claude Code

## Platforms
WINDOWS, WEB, API, CLI

## Pricing
Open Source

## Links
- Website: https://tokendoctor.dev
- Documentation: https://github.com/rsaryev/tokendoctor#readme
- Repository: https://github.com/rsaryev/tokendoctor
- EveryDev.ai: https://www.everydev.ai/tools/tokendoctor
