# Tokendoctor replays Claude Code sessions to estimate context-cost savings
A new developer tool called Tokendoctor aims to show Claude Code users how different context-management settings could have affected their recent usage. Rather than applying a general benchmark, it replays request histories from the user’s own transcripts and estimates costs at several hypothetical compaction thresholds.
The project’s sessions command examines the previous 30 days and calculates what requests would have cost if compaction had occurred at context windows of 200,000, 300,000, 400,000 or 600,000 tokens. The analysis reads local transcripts, makes no model calls and does not change settings. Its creator describes the result as an upper bound because a replay cannot know what work a model might need to repeat after receiving a summary.
Tokendoctor is responding to a characteristic of long coding-agent sessions: each request can include the accumulated conversation, so later turns may carry much larger contexts than earlier ones. On models with a one-million-token window, the project says Claude Code may wait until close to 967,000 tokens before compacting. Users whose sessions rarely become large may see little or no advantage from an earlier threshold.
A separate optimize command turns the replay into proposed configuration changes. It checks settings against Claude Code documentation, presents selected modifications as diffs and applies only those approved by the user. An undo command can reverse them. The project says it does not switch models automatically.
The creator reports a personal before-and-after result in which average context per main-thread request fell from 412,000 to 219,000 tokens and estimated cost per request declined 38 percent at API list prices. The comparison covered about 23,000 requests before the change and 19,000 afterward. The author explicitly warns that this is one person’s uncontrolled result, not evidence that every user will save the same amount.
Earlier compaction also has a usability cost because summaries interrupt work. The creator measured an average pause of 79 seconds in personal sessions. Tokendoctor therefore includes an optional “slide” mechanism that discards older tool output while retaining messages, avoiding a model-generated summary. The project says that operation completes locally in milliseconds, though users must weigh the loss of old tool output against retaining more recent context.
A published benchmark used Haiku 5.5 to build a TypeScript project against fixed tests. Every counted run passed, but the recommended settings did not reduce costs because those tasks generally remained below 400,000 tokens. The result reinforces the project’s central claim that changes should follow an individual workload rather than a universal prescription.
Tokendoctor also provides a local dashboard breaking usage down by day, model, subagent and project. Its repository says transcript analysis remains on the machine, with only a daily request to two public documentation pages.


![500px provided description: Anohter Laptop With Cool Free Software Stickers At Guadec [#stickers ,#2015 ,#Tech ,#GNOME ,#FOSS ,#Open Source ,#Free Software ,#GUADEC ,#Confrance]](/media/articles/commons-e039f8ff3448.avif)
