Tool · Case studyOpen source / developer tool · 2026
AI Session Doctor
Find out why your Claude Code and Codex sessions burn context, not only how many tokens they used.
npx ai-session-doctor --demo --open
- Role
- Product direction, diagnostic rules and release, with AI-assisted development
- Status
- Open source (MIT) · v0.1.0 on npm
- Disciplines
- Developer Tooling · AI Engineering · Data Analytics
- Links
- Source npm Release v0.1.0

The question
A token counter says how much a coding session used. It does not say why: whether the context kept growing, the cache was rebuilt after a pause, the same file was read again, or a failing command was retried unchanged.
What it diagnoses
Context growth and compaction, long-context load, cache rebuilds after idle gaps, files re-read without changes, identical tool calls, blind retry loops, large tool outputs, edit failures and bookkeeping turns. Every finding shows its evidence and suggests a concrete fix.
The detectors are deliberately conservative: a re-read after an edit or a compaction is not flagged, and re-running tests after changing code is not a retry loop.
Measured versus heuristic
Token counts, cache reads and writes, error flags and timestamps are read from the log. Interpretations are labelled as heuristic, with a note on what could make them wrong. The what-if replay is a simulation, not a promised saving.
Limits
Tool output sizes are estimated from characters. Models without a known price are reported as unpriced. Subscription plans meter usage differently and do not expose it in these logs.