techwolf-ai/ai-first-toolkit/token-doctor
Claude Code and agent skill by techwolf-ai/ai-first-toolkit
- community
Checking that the SKILL.md file is still in the repository.
Personal diagnosis of where your Claude Code + Cowork spend goes. Reads local transcripts, prints your conversation length distribution, marathon share, cache rebuild costs, and per-project diagnosis (good projects and problem projects) right in the terminal. Then offers a deeper dive that fans out parallel Haiku subagents over your most expensive (and most efficient) sessions and writes a tight Markdown report. Use when the user asks "why is my Claude spend so high", "where am I burning tokens", "diagnose my Claude habits", "audit my Claude usage", or asks for a personal token-cost diagnosis.
Install
npx vskill@latest install techwolf-ai/ai-first-toolkit/token-doctorSKILL.md
The same SKILL.md was published earlier as techwolf-ai/ai-first-toolkit/token-doctor.
Token Doctor
Platforms: Claude Code / Cowork and Codex.scripts/inventory.pydetects the host (via theplatformstampinstall.shwrites, orAI_FIRST_PLATFORM) and routes: Claude Code (~/.claude/projects) + Cowork transcripts, or Codex rollouts (~/.codex/sessions). Codex token usage comes from Codex's own per-responsetoken_countevents; cost uses OpenAI list rates inpricing.py(gpt-5.4 family; unknown models show token counts with no fabricated cost). Antigravity is unsupported: its IDE store is AEAD-encrypted at rest and its CLI store has no parseable turn/token content, so the skill prints a clear "not available" message and exits.
Two-stage diagnostic. Stage 1 is fast and lands directly in the terminal so the user always walks away with their numbers. Stage 2 is opt-in, fans out subagents over hotspots, and writes a tight Markdown report.
Read this whole file before running.
When to run
Trigger phrases: "diagnose my Claude habits", "why am I spending so much", "where are my tokens going", "audit my spend", "token doctor", "what's driving my Claude bill".
Do NOT trigger for:
- "what tasks do I do with Claude" → that's
task-profile. - "where did I work on X" → that's
session-search.
The line is: token-doctor is about cost shape, not task inventory or recall.
Prerequisites
- Claude Code transcripts:
~/.claude/projects/*/*.jsonl(CLI and desktop app) - Sub-agent transcripts:
~/.claude/projects/*/<sid>/subagents/**/*.jsonl, including workflow agents undersubagents/workflows/<wf>/ - Claude Cowork transcripts (optional):
~/Library/Application Support/Claude/local-agent-mode-sessions/*/*/local_*/audit.jsonl - Python 3, stdlib only. No external services.
If neither path exists, stop and say so.
What counts as one session
Sub-agent transcripts are separate files but the same piece of work, so their cost rolls into the parent session rather than appearing as sessions of their own. This matters when you read the report:
cost_usdis main conversation plus fan-out.main_cost_usdandsubagent_cost_usdsplit it.- Turn counts, the timeline, cache rebuilds and the re-read ratio are main-session figures. They describe how that one conversation's context grew; sub-agents have their own context.
- So a session can show 100 turns and $641. That is not a contradiction, it is fan-out. Say so rather than letting the reader trip over it.
- One turn = one assistant message, not one transcript line. Claude Code writes a line per content block (thinking, text, each tool_use) and repeats the same
usageobject on every one, so counting lines inflates turns and cost by roughly 2-3x. The inventory dedupes bymessage.id. Turn counts from an older run of this skill are not comparable with these.
Automation excluded by default: sdk-cli background dispatch, paperclip, ditto-routines, scheduled tasks, and the automation slash commands. Desktop-app sessions are interactive work and are counted.
STAGE 1 — Fast diagnosis (always runs, you write the report)
The goal is: the user invokes the skill, sees a clean doctor's report within 10 seconds, knows which projects are healthy and which are bleeding, and can decide whether to go deeper. You write the report directly in your message based on the JSON the scripts produce. The scripts compute, you communicate.
Step 1.1 — Inventory (deterministic)
Default window: last 90 days. Flags: --since, --until, --all, --include-automation, --no-cowork. Automation runs (sdk-cli background dispatch, paperclip, /loop, /schedule, ditto-routines, scheduled-tasks) excluded by default.
--until YYYY-MM-DD means midnight at the start of that day, so it excludes that day's sessions. To include today, leave --until off.
The scan prints how many sub-agent transcripts it rolled into parent sessions. If it also reports sub-agents with no parent session on disk, that cost is not in the totals; mention it only if it is material.
Step 1.2 — Aggregate (deterministic)
Prints a single confirmation line. The full data is in out/user-stats.json.
Step 1.3 — Read the JSON and write the doctor's report
Read out/user-stats.json. Then write the report directly in your message as terminal-style ASCII with emojis. The user reads your message; no intermediate file.
Report structure (mandatory sections, in order)
Rules when writing the report
- Use the emojis above consistently. Box-drawing characters (─ ┌ └ │) are fine and make the report look like a medical printout.
- Traffic-light dots: 🔴 = bad, 🟡 = watch, 🟢 = healthy. Apply the bands in the rubric below.
- Per-project emoji must come from
by_cwd_top[i].emojiin the JSON. Do not re-classify. - Model mix comes from
model_mix, already sorted by cost. Show every model down to 1% of spend, then stop. Use readable names (claude-opus-5→ Opus 5,claude-fable-5-1→ Fable 5.1). Themain/subsplit is the point of the section: a model that is cheap in the main conversation and expensive across sub-agents is the clearest lever in the whole report, because sub-agent model tier is a one-line change in anAgent(...)call. Call that out when you see it. - Fan-out uses
fanout_conv/fanout_cost/fanout_share(sessions with ≥ 5 sub-agents) andsubagent_cost/subagent_share(fan-out's share of total spend). Ifsubagent_filesis 0, drop both the fan-out vital and the sub-agent line rather than printing zeroes. - Bars for the length distribution: build them with
█characters proportional to the share. Use a fixed width like 36 chars. - The diagnosis paragraph is yours to write — it is the doctor's read on the data. Be specific. Don't restate the numbers; conclude from them. Aim for 3-5 sentences max. Examples of good diagnostic sentences:
- "Your spend is concentrated in a small number of very long sessions: 22 conversations carry 70% of your bill."
- "Cache rebuilds are minor at $388, but the re-read ratio of 23× tells me your context grows fast inside those long sessions."
- "Three of your top five projects are evaluation runs from last month. Each is one long session; splitting them would compound."
- Treatment plan must include both "keep doing" AND "change first" sections. Skipping the positive section is forbidden. Pick from:
by_cwd_topentries withemoji == "✅"for cleanby_cwd_clean_deeperfor clean projects below the top 12short_shareif neither is available — frame as "X% of your spend is in short focused sessions, so the habit is there, you just don't use it everywhere"- Cite specific projects. Truncate cwds to the last 36-44 chars with a leading
…if they're long. Drop the/Users/<name>/prefix when it makes the line cleaner. - No em-dashes. Use commas, semicolons, or periods.
- No "waste", "burning", "bad habit". Use "cost", "spend", "context", "rebuild".
Traffic-light thresholds
| Metric | 🟢 | 🟡 | 🔴 | |
|---|---|---|---|---|
| Marathon share | < 20% | 20-50% | ≥ 50% | |
| Fan-out share | < 20% | 20-50% | ≥ 50% | |
| Zombie share | < 20% | 20-50% | ≥ 50% | |
| Cache rebuild $ | < $50 | $50-$200 | ≥ $200 | |
| Re-read ratio | ≤ 15× | 15-35× | ≥ 35× |
Asking about the deep dive
End with one short line, not a paragraph. Example:
Want me to pull apart your top sessions one by one — what specifically drove each marathon, plus a couple of your most efficient runs to learn from? Takes about a minute, runs ~15 Haiku subagents in parallel.
If they say no, stop. The report is the deliverable.
STAGE 2 — Deep dive (opt-in)
Step 2.1 — Pick hotspots
Selects ~14 sessions:
- 8 by absolute cost
- 3 by cache rebuild tokens
- 3 by raw turn count
- 3 by read:create ratio at ≥$5 cost
- 3 positive examples (lowest cost-per-turn at 20-100 turns)
Briefly tell the user the list before fan-out so they can drop sensitive sids. Keep it to one line per session: $X · N turns · short title.
Step 2.2 — Build payloads
Writes one redacted payload per hotspot. Payloads include token shape, tool-call counts, timeline samples, and a 120-char title. They do NOT include user prompt bodies or model output text.
Step 2.3 — Parallel subagent fan-out
For each payload in out/payloads/, dispatch one subagent. Send all calls in one message with multiple tool blocks so they run in parallel.
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingplugins/ai-adoption/skills/token-doctor/SKILL.md
Popularity
- Repository stars
- 82
- Repository forks
- 2
- 7-day trend score
- 22
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/techwolf-ai/ai-first-toolkit/token-doctor)