
Tokendoctor – See what your Claude Code use overpays
See what your Claude Code use overpays, fix it, undo it any time. Runs on your machine.
以下正文同步自 Hacker News,版权归原站所有,已转换为易读排版。
See what your Claude Code use overpays, fix it, undo it any time. Runs on your machine.
There is no one pill. If your sessions rarely pass 400K tokens, the window changes nothing for you; a summary that lands just before you finish can cost more than it saves; your models, effort and work all move the number. So tokendoctor shows you yours first: /tokendoctor:sessions replays your own sessions at smaller windows before anything changes.
/tokendoctor:dashboard: every token by day, model, effort, main thread and each subagent, context size and project. One local file; this is the author's own.
claude plugin marketplace add localixai/tokendoctor claude plugin install tokendoctor@tokendoctor
Update with claude plugin marketplace update tokendoctor and claude plugin update tokendoctor@tokendoctor, then restart Claude Code. To try it without installing, clone the repository and run claude --plugin-dir /path/to/tokendoctor.
Command What it does
/tokendoctor:sessions [days] What a smaller window would have saved you (your sessions replayed), then where tokens went over the last 30 days (or days), with findings. Read-only.
/tokendoctor:audit Setting checks by severity, each linked to the docs, a read of your memory and CLAUDE.md, then the usage dashboard. Read-only.
/tokendoctor:dashboard [days] Builds and opens a local dashboard of every session on this machine: spend by day, kind of token, model, reasoning effort, main thread and each subagent type, context size, project and hour, with filters. One HTML file, no network.
/tokendoctor:optimize [focus] Proposes up to five changes from your numbers and applies the ones you pick.
/tokendoctor [name] [value] Shows the main settings, explains one or changes it. No model call, no tokens.
/tokendoctor fix <finding-id> Applies one audit fix after showing it, with a backup of the file.
/tokendoctor undo [n] Lists the changes tokendoctor made, newest first, and puts change n back.
/tokendoctor is answered by the plugin itself, so it costs nothing. Tab completes the names (window, slide, cache, effort, model, subagents, and /tokendoctor all for the rest) and their values; /tokendoctor window 400k applies as typed, /tokendoctor window reset goes back to the default, --project or --local writes there instead of your user settings. A model name must be an alias (opus, sonnet, haiku) or a claude-… id.
optimize changes only settings on the tunable list and /config rows. Every change opens a dialog that shows it and runs only on Apply; with no one to ask, as in a -p run, nothing changes. Hooks and permissions are never on the list.
The plugin's bin/ directory is on the Bash tool's PATH while it is enabled:
tokendoctor-audit [--project <dir>] [--json] tokendoctor-sessions [--days <n>] [--project <dir>] [--by day|week] [--json] tokendoctor-set --list | <key> <value>|--unset [--scope user|project|local] [--write] tokendoctor-apply <finding-id> [--scope user|project|local] [--project <dir>] [--write] tokendoctor-undo [--json] | <n> [--write] tokendoctor-replay [--days <n>] [--window 200k,400k] [--json] # what a smaller window would have saved tokendoctor-org-install [--write] [--uninstall] # the slide under a Team/Enterprise login (see below) tokendoctor-selfcheck [--log <file>] [--json] # what really loaded, from a debug log (one small Haiku request, or a log you have)
What it costs to keep installed The skills are user-invoked only (disable-model-invocation). claude plugin details tokendoctor@tokendoctor estimates about 235 tokens of always-on cost for the five of them. The plugin has no MCP server. Its hooks module adds the optimize tools (mcp__tokendoctor__*) behind ToolSearch, so only their names are listed until /tokendoctor:optimize loads them. /tokendoctor and the slide run in the hooks module too, with no model call, so they add no tokens. Its one command hook runs tokendoctor-record in the background when a session starts. The hook is async and prints nothing, so it adds no tokens. It appends each finished day's totals to ~/.claude/tokendoctor/history.jsonl, so the trend outlives Claude Code's transcript cleanup.
Errors are settings that are wrong or ignored, warnings are likely to cost real money, and info is worth a look. Rules that depend on a Claude Code release are skipped on older versions.
templates/statusline.sh is the status line script the fix installs into your Claude config folder. templates/agents/ holds three generic subagents (Explore, test-runner, docs-lookup), each pinned to a small model with read-only or narrow tools. A plugin cannot override a built-in agent or ship settings.json keys such as autoCompactWindow, env or permissions, so the apply step copies the template into ~/.claude/agents/ or .claude/agents/ and edits your settings files itself, with a backup.
Claude Code changes every few days, so the audit does not trust a list frozen into the plugin:
Off by default. With /tokendoctor slide on (or tokendoctor-set tokendoctor.slide true --write, or /tokendoctor:optimize), where Claude Code would compact, the plugin's hooks module elides old tool outputs into short pointers instead of summarizing, the way llx does. Every prompt, answer and decision stays word for word, and there is no summary pause.
In one real session, at the same size: Claude Code's summary took 367K to 35K in 65.3 s; the slide took 368K to 36K in 0.04 s. Summaries in the author's real sessions take 79 s on average (109 of them, 22 September to 1 November).
On bench/, Claude Code doing a TypeScript project against fixed acceptance tests, Haiku 5.5, a 100K window so that it compacts several times (medians). A short task with one compaction gains time but not money; the longer the work, the more the slide saves:
The earlier, smaller runs of node bench/window.mjs (60 files of 300 lines read one by one, then a follow-up in the same session, 200K window) cost the same both ways:
What a summary loses, measured with --task recall: the session starts with five decisions from the person, the files are deleted after reading, and the follow-up asks for the decisions and eight KEYs the model noted. Claude Code's summary kept them all: 6/6 and 8/8 in every run on both models. The slide did the same on Haiku 5.5 (3 runs, 2% dearer); on Sonnet 5.5 (1 run) it missed one KEY, which the model skipped noting in its first reply after a slide. So far no test shows the slide answering better, or worse: it saves time and money, not quality.
npm test # node's built-in test runner, no dependencies npm run test:mod # the hooks module's tests (claude plugin test) claude plugin validate . bun bench/run.ts --task fixkit --window 100000 --arm factory --arm factory+slide # see bench/README.md
test/private.test.mjs fails if anything git would commit holds an API key or token, a home folder path or a temporary folder of the machine: benchmark results come from runs on someone's account, so only their summaries are committed and the transcripts stay local.
The landing page lives in site/ (cd site && npm install && npm run dev; npm run build prerenders it, node scripts/og.mjs redraws the social card). The demo is a real session recorded with asciinema; site/scripts/RECORDING.md says how to record it again.
Rules are pure functions over a snapshot (lib/rules.mjs); reading the disk lives in lib/collect.mjs and writing in lib/apply.mjs. Adding a rule means adding one entry and its test. Session analysis is in lib/sessions.mjs and lib/history.mjs, the settings tokendoctor-set may change in lib/tunables.mjs, the /tokendoctor command in lib/console.mjs, the replay in lib/replay.mjs, the slide in hooks/window.ts, and the optimize tools in hooks/register.ts.
正文由 探How 从来源站点 RSS 同步,内容未经改写;遇到排版缺失或需要图片、视频时请以原文为准。