deniz.in

Markets

Weather

Loading weather

· via Hacker News – Front Page (hnrss.org)

Tokendoctor plugin audits Claude Code locally, author reports up to 38% lower API costs

Tokendoctor, an open-source Claude Code plugin featured on Hacker News, replays your own sessions, runs 38 setting checks and applies fixes you approve — its author reports up to 38% lower main-thread API costs.

Tokendoctor plugin audits Claude Code locally, author reports up to 38% lower API costs

What Tokendoctor does

Tokendoctor, a new open-source plugin for Anthropic's Claude Code agent, reached the Hacker News front page on November 17. It runs entirely on the user's machine and targets a familiar pain point for developers: the token bills that agentic coding sessions generate as context grows. According to the project's GitHub README, its author recorded a 38% drop in main-thread cost per request — priced at API list rates — after moving to a 400K compaction window and routing subagents to Sonnet, with context per request falling from 412K to 219K tokens.

The plugin's central idea is measurement before intervention. Its sessions command replays your existing sessions at smaller context windows and reports what each would have saved, without modifying anything. Only after you have seen your own numbers does it offer changes.

See, fix, slide, undo

Tokendoctor organises itself around four actions. An audit command runs 38 setting checks against the Claude Code documentation, sorted by severity: errors catch settings that are wrong or silently ignored, warnings flag configurations likely to waste money, and info-level findings suggest cheaper defaults. Examples include a settings file with invalid JSON that therefore never applies, a compaction setting written under a key Claude Code does not actually read, disabled prompt caching, every subagent forced onto a single model, and fast mode saved as a default so every session pays the higher rate.

The optimize command proposes at most five changes drawn from your own usage data, shows each one as a diff, and applies only what you approve. In non-interactive runs nothing changes at all, and hooks and permissions are never on the list of tunable settings.

The most unusual feature is what the README calls the "slide": where Claude Code would normally generate a summary to shrink context, the plugin drops old tool outputs instead. The conversation text is preserved exactly, and there is no pause while a summary is written.

Finally, undo lists every change the plugin made and reverts any of them without a model call, so restoring a previous configuration costs no tokens.

The numbers, and their limits

The 38% headline comes from the author's six weeks of real use, and the README is unusually frank about variance. Replaying identical sessions with only the window changed cut 33% of main-thread cost and 20% of overall spend. A benchmark comparing the slide against a summary on the same day of work saved 19% in cost and 33% in time. A week-long benchmark of 27 steps showed median savings between 11% and 21%, but individual runs ranged from a 40% saving to a 17% increase; all tests passed in either configuration.

The project also cautions that sessions that rarely exceed 400K tokens gain nothing from the window change, and that a summary landing just before you finish can cost more than it saves — which is precisely why it shows your numbers before touching anything.

Local by design

The plugin ships with no MCP server, and its skills only activate when you invoke them, which the author estimates at roughly 235 tokens of standing overhead. The optimize tools remain hidden behind tool search until explicitly loaded, and a background hook records session totals without adding tokens. A dashboard command builds a single local HTML file breaking down every token by day, model, reasoning effort, main thread versus each subagent type, context size and project — with no network access. Daily totals are appended to a local history file so spending trends survive Claude Code's transcript cleanup.

Installation is a standard plugin marketplace add and install through the Claude Code CLI, and the tool can also be tried from a cloned repository without a full install.

Why it matters

Agentic coding tools bill by the token, and long sessions that balloon past 400K tokens of context get expensive quickly. Most advice on trimming that spend is generic; Tokendoctor's approach — replay your own sessions, quantify the saving, apply opt-in diffs, undo for free — is a sensible template for cost tooling around AI agents. The headline figure is self-reported and unverified, and single-run results vary widely. But even skeptical developers can run the read-only audit to surface settings that may be silently inflating their bills, at essentially no cost.

  • #claude-code
  • #developer-tools
  • #open-source
  • #ai-costs
  • #anthropic

Related posts