Code golf is the engineering practice of solving a problem in as few characters as possible. The constraint isn't the point — the discipline the constraint creates is the point. Writing the shortest solution forces you to understand the problem deeply and use your tools precisely.
Token golf is the same idea applied to AI sessions. Your budget is par. Every unnecessary prompt, every redundant context dump, every "can you also…" tacked onto a request is a stroke over par. The game doesn't literally resemble golf — it borrows the concept: optimize under constraint, measure your score, improve your game.
Just work normally. TokenGolf runs in the background via Claude Code hooks.
/exitDeclare your quest, pick a budget, choose your class. Bust the budget = the run dies.
tokengolf demo to preview all states.
/exit. Real scorecard from building TokenGolf itself: $40 flow session, 27 ultrathink invocations, Class Defection for declaring Sonnet but spending 89% on Opus.
| Class | Model | Difficulty | Feel |
|---|---|---|---|
| 🏹 Rogue | claude-haiku-4-5 | Hard | Glass cannon. Must prompt precisely. |
| ⚔️ Fighter | claude-sonnet-4-6 | Normal | Balanced. The default run. |
| 🧙 Warlock | claude-opus-4-6 | Easy | Powerful but expensive. |
The dungeon crawl framing maps directly to real session behaviors. These aren't just flavor — they're patterns you already have, named so you can recognize and improve them.
Context bloat slowing you down. The model is carrying too much history to reason cleanly.
Hit usage limits mid-run. Came back next session and kept going.
Surgical context management. You compacted at 30% and still had plenty of room for the boss.
Reached for ultrathink on a tight budget and paid for it. The spell didn't save you.
Solved it with pure prompting discipline. No extended thinking needed.
No subagents. You held the whole problem in one context and saw it through.
Roguelike mode surfaces these patterns with stakes. Flow mode lets them compound over time. Roguelike practice makes Flow sessions better. Better Flow = lower daily spend = better scores without even trying.
Haiku run under $0.10
Completed with Haiku
Completed with Sonnet
Completed with Opus
Under 25% of budget used
Under 50% of budget used
Total spend under $0.10
Under $0.01 per prompt (≥3 prompts)
Over $0.50 per prompt — won or died
Completed in a single prompt
20+ prompts in one run
≤3 prompts, ≥10 tool calls
15+ prompts, less than 1 tool call per prompt
5+ tool calls per prompt (≥2 prompts)
Won with no Edit or Write calls
10+ Edit calls in one run
10+ Bash calls comprising ≥50% of tools
≥60% of tool calls were Reads (≥5 total)
1–3 Edit calls, completed under budget
5+ distinct tools used in one run
Completed in under 5 minutes
Session over 60 minutes
Session over 3 hours
Used extended thinking in a won run
Extended thinking + LEGENDARY efficiency
3+ thinking invocations, completed under budget
No extended thinking, SOLID or better
Haiku handled ≥50% of session cost
Haiku handled ≥75% of session cost
Completed in one session
Completed across multiple sessions
Fainted (hit usage limits) and finished anyway
Context auto-compacted during a won run
Manual compact at ≤50% context
Manual compact at ≤40% context
Manual compact at ≤30% context
Zero failed tool calls (≥5 tool calls total)
10+ failed tool calls and still won
Completed with no subagents spawned
5+ subagents spawned in one run
10+ subagents spawned, under 50% budget used
3+ Claude turns per user prompt
Exactly one turn per prompt (≥3 prompts)
Used extended thinking, busted anyway
Spent 2× your committed budget
Died within 10% of budget
Died with 30+ tool calls
Died with ≤2 prompts
Died with 5+ failed tool calls
# Install $ npm install -g tokengolf $ tokengolf install # patches ~/.claude/settings.json with hooks # Roguelike — declare before you start $ tokengolf start # quest wizard: model + budget $ tokengolf status # live run state $ tokengolf win # complete run, show scorecard $ tokengolf bust # permadeath — budget busted # Flow — just /exit Claude Code, scorecard auto-appears $ tokengolf scorecard # show last run's results $ tokengolf stats # career dashboard