tokengolf 0.4.3 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -6,6 +6,16 @@ TokenGolf patch notes — what changed, what it measures, and why the mechanic e
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ### Changed
10
+ - **Design D HUD** — StatusLine HUD redesigned with `██` accent bar, inline `▓░` progress bars for budget and context, no separator lines. 1 line when context <50%, 2 lines when context visible. Accent bar turns red when budget >75%. Matches Design D across all UI surfaces.
11
+ - **Design D block accent UI** — All bordered boxes replaced with left-only `██` block accent bars. Eliminates persistent right-border misalignment caused by emoji/unicode width differences across terminals. Color-coded: yellow for won, red for died, gray for neutral.
12
+ - ScoreCard, StatsView, ActiveRun, StartRun components all use custom Ink `borderStyle` with `left: '██'`, no right/top/bottom borders
13
+ - session-end.js ANSI scorecard uses `██` prefix per line with `─` horizontal separators
14
+ - Achievement badges in StatsView rendered inline (no individual bordered boxes)
15
+ - Death tip in ScoreCard rendered as indented text (no bordered box)
16
+ - Landing page terminal demos updated to match `██` style
17
+ - README screenshots replaced with inline code block demos — no more stale PNGs
18
+
9
19
  ### Fixed
10
20
  - StatusLine HUD effort label now reads exclusively from live `settings.json` — `/model` changes (High, Low, Max) reflect immediately without requiring a new session
11
21
  - Medium effort no longer shown in HUD or scorecard — it's the default, so it's omitted (same as not annotating Sonnet as "normal difficulty")
package/CLAUDE.md CHANGED
@@ -347,10 +347,13 @@ Nine hooks in `hooks/` directory, installed via `tokengolf install`. Most comple
347
347
  ### `StatusLine` (`statusline.sh`)
348
348
  - Bash script; uses `TG_SESSION_JSON=... python3 - "$STATE_FILE" <<'PYEOF'` pattern to avoid heredoc/stdin conflict
349
349
  - Receives live session JSON (cost, context %, model) via stdin
350
- - Shows: quest/mode | tier emoji + cost [/budget pct%] | [efficiency rating] | [🪶/🎒/📦 ctx%] | model label | [floor]
350
+ - **Design D accent bar**: `██` prefix on each line, color-coded (yellow normal, red when budget >75%)
351
+ - Line 1: `██ ⛳ quest $cost/budget ▓▓▓░░░ pct% RATING model F1/5`
352
+ - Line 2 (optional, when context ≥50%): `██ 🧠 ▓▓▓▓░░░ ctx% 🪶/🎒/📦`
353
+ - Budget progress bar: `▓` filled, `░` empty, 11 chars wide. Red when >75%, yellow otherwise
354
+ - Context progress bar: `▓░` 10 chars wide. Green (50–74%), yellow (75–89%), red (90%+); hidden below 50%
351
355
  - Model label: `⚔️ Sonnet`, `⚔️ Sonnet·High`, `🏹 Haiku`, `🧙 Opus·Max`, etc. Effort appended only when explicitly set in settings.json (medium omitted — it's the default)
352
- - Context load: 🪶 green (50–74%), 🎒 yellow (75–89%), 📦 red (90%+); hidden below 50%
353
- - Separator lines (`───────────────`) above and below HUD row
356
+ - 1 line when context <50% (flow mode is often just 1 line), 2 lines when context visible
354
357
  - statusLine config must be an object: `{type:"command", command:"...statusline.sh", padding:1}`
355
358
 
356
359
  ### Hook installation
@@ -388,9 +391,11 @@ Thinking tokens are estimated from character count ÷ 4 (approximate — display
388
391
 
389
392
  7. **Death marks fire before the early return** — `calculateAchievements` has an `if (!won) return []` early exit, but death marks (blowout, so_close, tool_happy, silent_death, fumble, expensive_taste, hubris) fire before it. `indecisive` (model switches) and `expensive_taste` also fire on won runs — they're behavior patterns, not death verdicts.
390
393
 
394
+ 8. **Design D: ██ block accent, no right borders** — All UI cards use a left-only `██` block accent bar instead of full box borders. This eliminates persistent right-border misalignment caused by emoji/unicode width calculation differences across terminals. Color-coded: yellow `██` for won, red `██` for died, gray `██` for neutral (stats, wizard). Ink components use a custom `borderStyle` object with `left: '██'` and `borderRight/Top/Bottom={false}`, `paddingLeft={3}`. session-end.js ANSI scorecard uses `██` prefix + `─` horizontal separators. No screenshots — README uses inline code block demos.
395
+
391
396
  ---
392
397
 
393
- ## Current Status: v0.3
398
+ ## Current Status: v0.4
394
399
 
395
400
  ### Done
396
401
  - [x] Full project scaffold with esbuild pipeline
@@ -418,6 +423,9 @@ Thinking tokens are estimated from character count ÷ 4 (approximate — display
418
423
  - [x] 28 new achievements: prompting skill, tool mastery, cost/prompt, time, subagents, turn discipline, death marks
419
424
  - [x] 3 new hooks: PostToolUseFailure, SubagentStart, Stop
420
425
  - [x] Vitest test suite — 120 tests covering all achievements + pure score functions
426
+ - [x] Design D block accent UI — ██ left bar, no right borders, color-coded state
427
+ - [x] Landing page terminal demos updated to ██ style
428
+ - [x] README inline code block demos (replaced PNG screenshots)
421
429
 
422
430
  ### Next up (v0.4)
423
431
  - [ ] `tokengolf floor` command to advance floor manually
package/README.md CHANGED
@@ -1,49 +1,73 @@
1
- # ⛳ TokenGolf
2
-
3
- > Flow mode tracks you. Roguelike mode trains you.
4
-
5
- Turn Claude Code token efficiency into a game. Declare a quest, commit to a budget, pick a character class. Work normally. At the end, get a score based on how efficiently you used your budget.
6
-
7
- **Better prompting → fewer tokens → higher score.**
1
+ <p align="center">
2
+ <img src="docs/assets/banner.svg" alt="TokenGolf" width="800" />
3
+ </p>
8
4
 
9
- **[tokengolf.dev](https://josheche.github.io/tokengolf/)** · [npm](https://www.npmjs.com/package/tokengolf) · [GitHub](https://github.com/josheche/tokengolf)
5
+ <p align="center">
6
+ <strong>Flow mode tracks you. Roguelike mode trains you.</strong>
7
+ </p>
10
8
 
11
- ---
9
+ <p align="center">
10
+ <a href="https://www.npmjs.com/package/tokengolf"><img src="https://img.shields.io/npm/v/tokengolf?style=flat&color=d4a840&label=npm" alt="npm version" /></a>
11
+ <a href="https://www.npmjs.com/package/tokengolf"><img src="https://img.shields.io/npm/dm/tokengolf?style=flat&color=6bb54a&label=downloads" alt="npm downloads" /></a>
12
+ <a href="https://github.com/josheche/tokengolf/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/tokengolf?style=flat&color=7cb8d4" alt="license" /></a>
13
+ <a href="https://nodejs.org"><img src="https://img.shields.io/node/v/tokengolf?style=flat&color=9a9180" alt="node version" /></a>
14
+ </p>
12
15
 
13
- <!-- SCREENSHOT: tokengolf start wizard — quest/class/effort/budget selection -->
16
+ <p align="center">
17
+ <a href="https://josheche.github.io/tokengolf/">tokengolf.dev</a> · <a href="https://www.npmjs.com/package/tokengolf">npm</a> · <a href="https://github.com/josheche/tokengolf">GitHub</a>
18
+ </p>
14
19
 
15
20
  ---
16
21
 
17
- ## Why "TokenGolf"?
22
+ Turn Claude Code token efficiency into a game. Declare a quest, commit to a budget, pick a character class. Work normally. At the end — a scorecard, achievements, and a score that measures how well you prompt.
18
23
 
19
- [Code golf](https://en.wikipedia.org/wiki/Code_golf) is the engineering practice of solving a problem in as few characters (or lines, or bytes) as possible. The constraint isn't the point — the *discipline the constraint creates* is the point. Writing the shortest possible solution forces you to understand the problem deeply and use your tools precisely.
24
+ **Better prompting fewer tokens higher score.** 60+ achievements. 9 hooks. 4 character classes. Zero config beyond `npm install`.
20
25
 
21
- 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.**
26
+ ```
27
+ ██ 🏆 SESSION COMPLETE
28
+ ██ add pagination to /users endpoint
29
+ ██ ──────────────────────────────────────────────────
30
+ ██ $0.2300 /$1.50 15% ⚔️ Sonnet 🥇 Gold
31
+ ██ 🌟 LEGENDARY
32
+ ██ ──────────────────────────────────────────────────
33
+ ██ 🎯 Sniper 🥈 Silver 🔥 No Rest ✅ Clean Run 🧰 Toolbox 🤫 Silent Run
34
+ ```
22
35
 
23
36
  ---
24
37
 
25
- ## Two Modes
26
-
27
- ### ⛳ Flow Mode
28
- Just work. TokenGolf auto-creates a tracking session when you open Claude Code. `/exit` the session and the scorecard appears automatically. No pre-configuration required.
38
+ ## Quick Start
29
39
 
30
- ### ☠️ Roguelike Mode
31
- Pre-commit before you start. Declare a quest, pick a class and effort level, set a budget. Go over budget = permadeath — the run is logged as a death. The deliberate pressure trains better prompting habits, which makes your Flow sessions cheaper over time.
40
+ **npm** (recommended)
41
+ ```bash
42
+ npm install -g tokengolf
43
+ ```
32
44
 
33
- ---
45
+ **Homebrew**
46
+ ```bash
47
+ brew tap josheche/tokengolf
48
+ brew install tokengolf
49
+ ```
34
50
 
35
- ## Install
51
+ **curl**
52
+ ```bash
53
+ curl -fsSL https://raw.githubusercontent.com/josheche/tokengolf/main/install.sh | bash
54
+ ```
36
55
 
56
+ Then set up the hooks (npm and brew only — curl does this automatically):
37
57
  ```bash
38
- npm install -g tokengolf
39
- tokengolf install
58
+ tokengolf install # patches ~/.claude/settings.json
40
59
  ```
41
60
 
42
- `tokengolf install` patches `~/.claude/settings.json` with the hooks that power live tracking, the HUD, and the auto scorecard.
61
+ That's it. Open Claude Code, work normally, `/exit` scorecard appears automatically (Flow mode). Or declare a run first:
43
62
 
44
- ---
63
+ ```bash
64
+ tokengolf start # pick quest, class, effort, budget
65
+ # ... work in Claude Code ...
66
+ tokengolf win # complete run, auto-detect cost
67
+ ```
45
68
 
46
- ## Commands
69
+ <details>
70
+ <summary>All commands</summary>
47
71
 
48
72
  ```bash
49
73
  tokengolf start # declare quest + class + effort + budget, begin a run
@@ -53,103 +77,92 @@ tokengolf bust # manual permadeath override
53
77
  tokengolf scorecard # last run scorecard
54
78
  tokengolf stats # career dashboard
55
79
  tokengolf install # patch ~/.claude/settings.json with hooks
56
- tokengolf demo # show all HUD states (for screenshots)
80
+ tokengolf demo # show all UI states (for screenshots)
57
81
  ```
58
82
 
83
+ </details>
84
+
59
85
  ---
60
86
 
61
- ## Character Classes & Effort
87
+ ## Two Modes
62
88
 
63
- | Class | Model | Effort | Feel |
64
- |-------|-------|--------|------|
65
- | 🏹 Rogue | Haiku | — *(skips effort step)* | Glass cannon. Prompt precisely or die. |
66
- | ⚔️ Fighter | Sonnet | Low / **Medium** / High | Balanced. The default run. |
67
- | 🧙 Warlock | Opus | Low / **Medium** / High / Max | Powerful but costly. |
68
- | ⚜️ Paladin | Opus (plan mode) | Low / **Medium** / High / Max | Strategic planner. Thinks before acting. |
69
- | ⚡ Warlock·Fast | Opus + fast mode | any | 2× cost. Maximum danger mode. |
89
+ ### Flow Mode
90
+ Just work. TokenGolf auto-creates a tracking session when you open Claude Code. `/exit` and the scorecard appears. No pre-configuration.
70
91
 
71
- `max` effort is Opus-only — the API returns an error if used on other models. Fast mode is toggled mid-session with `/fast` in Claude Code and is auto-detected by TokenGolf.
92
+ ### ☠️ Roguelike Mode
93
+ Pre-commit before you start. Declare a quest, pick a class and effort level, set a budget. Go over budget = permadeath — the run is logged as a death. The pressure trains better prompting habits, which makes your Flow sessions cheaper over time.
72
94
 
73
95
  ---
74
96
 
75
- ## Budget Presets (Model-Calibrated)
97
+ ## Character Classes
76
98
 
77
- The wizard shows different amounts depending on your class — same relative difficulty, different absolute cost. Anchored to the ~$0.75/task Sonnet average from Anthropic's $6/day Claude Code benchmark.
78
-
79
- | Tier | Haiku 🏹 | Sonnet ⚔️ | Opus 🧙 | Feel |
80
- |------|---------|---------|--------|------|
81
- | 💎 Diamond | $0.15 | $0.50 | $2.50 | Surgical micro-task |
82
- | 🥇 Gold | $0.40 | $1.50 | $7.50 | Focused small task |
83
- | 🥈 Silver | $1.00 | $4.00 | $20.00 | Medium task |
84
- | 🥉 Bronze | $2.50 | $10.00 | $50.00 | Heavy / complex |
85
- | ✏️ Custom | any | any | any | Set your own bust threshold |
99
+ | Class | Model | Difficulty | Feel |
100
+ |-------|-------|------------|------|
101
+ | 🏹 **Rogue** | Haiku | Nightmare | Glass cannon. Prompt precisely or die. |
102
+ | ⚔️ **Fighter** | Sonnet | Standard | Balanced. The default run. |
103
+ | 🧙 **Warlock** | Opus | Casual | Powerful but expensive. |
104
+ | ⚜️ **Paladin** | Opus (plan mode) | Tactical | Strategic planner. Thinks before acting. |
105
+ | **Warlock·Fast** | Opus + fast mode | Danger | 2× cost. Maximum risk, maximum speed. |
86
106
 
87
- These are **bust thresholds** your commitment. Efficiency tiers derive as percentages of whatever you commit to.
107
+ Effort levels: Low / **Medium** / High / Max (Opus-only). Fast mode toggled with `/fast` in Claude Code, auto-detected by TokenGolf.
88
108
 
89
109
  ---
90
110
 
91
111
  ## Scoring
92
112
 
93
- **Efficiency rating** (roguelike mode — % of your budget used):
113
+ **Efficiency** (roguelike — % of budget used):
94
114
 
95
115
  | 🌟 LEGENDARY | ⚡ EFFICIENT | ✓ SOLID | 😅 CLOSE CALL | 💀 BUSTED |
96
116
  |---|---|---|---|---|
97
117
  | < 25% | < 50% | < 75% | < 100% | > 100% |
98
118
 
99
- **Spend tier** (absolute cost, shown on every scorecard):
119
+ **Spend tier** (absolute, shown on every scorecard):
100
120
 
101
- | 💎 | 🥇 | 🥈 | 🥉 | 💸 |
121
+ | 💎 Diamond | 🥇 Gold | 🥈 Silver | 🥉 Bronze | 💸 Reckless |
102
122
  |---|---|---|---|---|
103
123
  | < $0.10 | < $0.30 | < $1.00 | < $3.00 | > $3.00 |
104
124
 
105
- ---
106
-
107
- ## Ultrathink
108
-
109
- Write `ultrathink` anywhere in your prompt to trigger extended thinking mode. It's not a slash command — just say it in natural language:
110
-
111
- > *"ultrathink: is this the right architecture before I write anything?"*
112
- > *"can you ultrathink through the tradeoffs here?"*
113
-
114
- Extended thinking tokens are billed at full output rate. A single ultrathink on Sonnet can cost $0.50–2.00 depending on problem depth. TokenGolf detects thinking blocks from your session transcripts and tracks invocations and estimated thinking tokens — both show on your scorecard.
115
-
116
- **The skill is knowing when to ultrathink.** One expensive deep-think that prevents five wrong turns is efficient. Ultrathinking every prompt when you're at 80% budget is hubris.
125
+ Budget presets are model-calibrated — Haiku Diamond is $0.15, Opus Diamond is $2.50. Same relative difficulty, different absolute cost.
117
126
 
118
127
  ---
119
128
 
120
- ## The Meta Loop
121
-
122
- The dungeon crawl framing maps directly to real session behaviors:
123
-
124
- - **Overencumbered** = context bloat slowing you down
125
- - **Made Camp** = hit usage limits, came back next session
126
- - **Ghost Run** = surgical context management before the boss
127
- - **Hubris** = reached for ultrathink on a tight budget and paid for it
128
- - **Silent Run** = solved it with pure prompting discipline, no extended thinking needed
129
- - **Lone Wolf** = didn't spawn a single subagent; held the whole problem in one context
130
- - **Agentic** = gave Claude the wheel and it ran with it — 3+ turns per prompt
129
+ ## Achievements
131
130
 
132
- Roguelike mode surfaces these patterns explicitly. Flow mode lets them compound over time. The meta loop: **roguelike practice makes Flow sessions better. Better Flow = lower daily spend = better scores without even trying.**
131
+ 60+ achievements tracking how you prompt, what tools you use, and how efficiently you spend. Here are some highlights:
133
132
 
134
- ---
133
+ | | Achievement | How |
134
+ |---|---|---|
135
+ | 🥊 | **One Shot** | Completed in a single prompt |
136
+ | 🎯 | **Sniper** | Under 25% of budget used |
137
+ | 💎 | **Diamond** | Haiku under $0.10 total |
138
+ | 🔪 | **Surgeon** | 1–3 Edit calls, under budget |
139
+ | 🤫 | **Silent Run** | No extended thinking, SOLID or better |
140
+ | 👑 | **Archmagus** | Opus at max effort, completed |
141
+ | 🥷 | **Ghost Run** | Manual compact at ≤30% context |
142
+ | 🐺 | **Lone Wolf** | No subagents spawned |
143
+ | 🤦 | **Hubris** | Used ultrathink, busted anyway *(death mark)* |
144
+ | 💥 | **Blowout** | Spent 2× your budget *(death mark)* |
135
145
 
136
- ## Achievements
146
+ <details>
147
+ <summary><strong>Full achievement list (60+)</strong></summary>
137
148
 
138
149
  **Class**
139
150
  - 💎 Diamond — Haiku under $0.10 total spend
140
151
  - 🥇 Gold — Completed with Haiku
141
152
  - 🥈 Silver — Completed with Sonnet
142
153
  - 🥉 Bronze — Completed with Opus
154
+ - ⚜️ Paladin — Completed as Paladin (Opus plan mode)
155
+ - ♟️ Grand Strategist — LEGENDARY efficiency as Paladin
143
156
 
144
157
  **Efficiency**
145
158
  - 🎯 Sniper — Under 25% of budget used
146
159
  - ⚡ Efficient — Under 50% of budget used
147
160
  - 🪙 Penny Pincher — Total spend under $0.10
148
- - 🪙 Cheap Shots — Under $0.01 per prompt (≥3 prompts)
161
+ - 💲 Cheap Shots — Under $0.01 per prompt (≥3 prompts)
149
162
  - 🍷 Expensive Taste — Over $0.50 per prompt (≥3 prompts)
150
163
 
151
164
  **Prompting skill**
152
- - 🎯 One Shot — Completed in a single prompt
165
+ - 🥊 One Shot — Completed in a single prompt
153
166
  - 💬 Conversationalist — 20+ prompts in one run
154
167
  - 🤐 Terse — ≤3 prompts, ≥10 tool calls
155
168
  - 🪑 Backseat Driver — 15+ prompts but <1 tool call per prompt
@@ -164,12 +177,12 @@ Roguelike mode surfaces these patterns explicitly. Flow mode lets them compound
164
177
  - 🧰 Toolbox — 5+ distinct tools used
165
178
 
166
179
  **Effort**
167
- - 🎯 Speedrunner — Low effort, completed under budget
168
- - 💪 Tryhard — High/max effort, LEGENDARY efficiency
180
+ - 🏎️ Speedrunner — Low effort, completed under budget
181
+ - 🏋️ Tryhard — High/max effort, LEGENDARY efficiency
169
182
  - 👑 Archmagus — Opus at max effort, completed
170
183
 
171
184
  **Fast mode**
172
- - Lightning Run — Opus fast mode, completed under budget
185
+ - ⛈️ Lightning Run — Opus fast mode, completed under budget
173
186
  - 🎰 Daredevil — Opus fast mode, LEGENDARY efficiency
174
187
 
175
188
  **Time**
@@ -179,19 +192,29 @@ Roguelike mode surfaces these patterns explicitly. Flow mode lets them compound
179
192
 
180
193
  **Ultrathink**
181
194
  - 🔮 Spell Cast — Used extended thinking during the run
182
- - 🧠 Calculated Risk — Ultrathink + LEGENDARY efficiency
195
+ - 🧮 Calculated Risk — Ultrathink + LEGENDARY efficiency
183
196
  - 🌀 Deep Thinker — 3+ ultrathink invocations, completed under budget
184
- - 🤫 Silent Run — No extended thinking, SOLID or better *(think without thinking)*
185
- - 🤦 Hubris — Used ultrathink, busted anyway *(death achievement)*
197
+ - 🤫 Silent Run — No extended thinking, SOLID or better
198
+ - 🤦 Hubris — Used ultrathink, busted anyway *(death mark)*
186
199
 
187
200
  **Multi-model**
188
201
  - 🏹 Frugal — Haiku handled ≥50% of session cost
189
202
  - 🎲 Rogue Run — Haiku handled ≥75% of session cost
203
+ - 🔷 Purist — Single model family throughout
204
+ - 🦎 Chameleon — Multiple model families used, under budget
205
+ - 🔀 Tactical Switch — Exactly 1 model switch, under budget
206
+ - 🔒 Committed — No switches, one model family
207
+ - ⚠️ Class Defection — Declared one class but cost skewed to another
208
+
209
+ **Paladin planning ratio**
210
+ - 🏛️ Architect — Opus handled >60% of cost (heavy planner)
211
+ - 💨 Blitz — Opus handled <25% of cost (light plan, fast execution)
212
+ - ⚖️ Equilibrium — Opus/Sonnet balanced at 40–60%
190
213
 
191
214
  **Rest & recovery**
192
- - No Rest for the Wicked — Completed in one session
215
+ - 🔥 No Rest for the Wicked — Completed in one session
193
216
  - 🏕️ Made Camp — Completed across multiple sessions
194
- - 💪 Came Back — Fainted (hit usage limits) and finished anyway
217
+ - 🧟 Came Back — Fainted (hit usage limits) and finished anyway
195
218
 
196
219
  **Context management (gear)**
197
220
  - 📦 Overencumbered — Context auto-compacted during run
@@ -199,16 +222,16 @@ Roguelike mode surfaces these patterns explicitly. Flow mode lets them compound
199
222
  - 🪶 Ultralight — Manual compact at ≤40% context
200
223
  - 🥷 Ghost Run — Manual compact at ≤30% context
201
224
 
202
- **Tool reliability** *(requires PostToolUseFailure hook)*
225
+ **Tool reliability**
203
226
  - ✅ Clean Run — Zero failed tool calls (≥5 total)
204
227
  - 🐂 Stubborn — 10+ failed tool calls, still won
205
228
 
206
- **Subagents** *(requires SubagentStart hook)*
229
+ **Subagents**
207
230
  - 🐺 Lone Wolf — Completed with no subagents spawned
208
231
  - 📡 Summoner — 5+ subagents spawned
209
232
  - 🪖 Army of One — 10+ subagents, under 50% budget used
210
233
 
211
- **Turn discipline** *(requires Stop hook)*
234
+ **Turn discipline**
212
235
  - 🤖 Agentic — 3+ Claude turns per user prompt
213
236
  - 🐕 Obedient — Exactly one turn per prompt (≥3 prompts)
214
237
 
@@ -218,60 +241,153 @@ Roguelike mode surfaces these patterns explicitly. Flow mode lets them compound
218
241
  - 🔨 Tool Happy — Died with 30+ tool calls
219
242
  - 🪦 Silent Death — Died with ≤2 prompts
220
243
  - 🤡 Fumble — Died with 5+ failed tool calls
244
+ - 🎲 Indecisive — 3+ model switches
245
+ - 🍷 Expensive Taste — Over $0.50 per prompt
246
+
247
+ </details>
221
248
 
222
249
  ---
223
250
 
224
251
  ## Live HUD
225
252
 
226
- After `tokengolf install`, a status line appears in every Claude Code session:
253
+ After `tokengolf install`, a status line appears in every Claude Code session showing quest, cost, efficiency, context load, and model class.
227
254
 
228
- - **tier emoji** (💎🥇🥈🥉💸) updates live as cost accumulates
229
- - **🪶 green** at 50–74% context traveling light
230
- - **🎒 yellow** at 75–89% context — getting heavy
231
- - **📦 red** at 90%+ context — overencumbered, consider compacting
232
- - **💤** instead of ⛳ if the previous session fainted (hit usage limits)
233
- - Roguelike runs show floor progress; Flow runs omit budget/efficiency
255
+ ```
256
+ ██ add pagination to /users $0.54/1.50 ▓▓▓▓░░░░░░░ 36% EFFICIENT ⚔️ Sonnet F2/5
234
257
 
235
- Run `tokengolf demo` to see all HUD states rendered in your terminal:
258
+ ██ refactor auth middleware $0.82/4.00 ▓▓░░░░░░░░░ 21% LEGENDARY 🧙 Opus F3/5
259
+ ██ 🧠 ▓▓▓▓▓░░░░░ 52% 🪶
260
+ ```
236
261
 
237
- ![TokenGolf HUD demo all game states](assets/demo-hud.png)
262
+ Budget bar turns red above 75%. Context bar (line 2) appears at 50%+: **🪶** green · **🎒** yellow · **📦** red. Accent `██` turns red in danger. **💤** replaces ⛳ when fainted.
238
263
 
239
264
  ---
240
265
 
241
266
  ## Auto Scorecard
242
267
 
243
- When you `/exit` a Claude Code session, the scorecard appears automatically — cost, model breakdown, achievements, ultrathink stats, tool usage.
268
+ When you `/exit`, the scorecard appears automatically — cost, model breakdown, achievements, tool usage.
244
269
 
245
- <p align="center">
246
- <img src="assets/scorecard.png" alt="TokenGolf scorecard — session complete" width="620" />
247
- </p>
270
+ ```
271
+ ██ 🏆 SESSION COMPLETE
272
+ ██ add pagination to /users endpoint
273
+ ██ ──────────────────────────────────────────────────
274
+ ██ SPENT BUDGET USED MODEL TIER
275
+ ██ $0.2300 $1.50 15% ⚔️ Sonnet 🥇 Gold
276
+ ██
277
+ ██ 🌟 LEGENDARY
278
+ ██ ──────────────────────────────────────────────────
279
+ ██ Achievements unlocked:
280
+ ██ 🎯 Sniper — Under 25% budget
281
+ ██ 🥈 Silver — Completed with Sonnet
282
+ ██ 🔥 No Rest for the Wicked — One session
283
+ ██ ✅ Clean Run — Zero failed tool calls
284
+ ██ 🧰 Toolbox — 5+ distinct tool types
285
+ ██ 🤫 Silent Run — No extended thinking
286
+ ██ ──────────────────────────────────────────────────
287
+ ██ Model usage: 🏹 17% Haiku
288
+ ██ Sonnet 83% $0.19 Haiku 17% $0.04
289
+ ██ ──────────────────────────────────────────────────
290
+ ██ Tool calls:
291
+ ██ Read ×8 Edit ×4 Bash ×3 Grep ×2 Glob ×1
292
+ ```
248
293
 
249
- *Real scorecard from building TokenGolf itself. $40 flow session, 27 ultrathink invocations, Class Defection for declaring Sonnet but spending 89% on Opus. The game plays you back.*
294
+ ```
295
+ ██ 💀 BUDGET BUSTED
296
+ ██ migrate postgres schema to v3
297
+ ██ ──────────────────────────────────────────────────
298
+ ██ $3.8700 /$1.50 258% ⚔️ Sonnet 💸 Reckless
299
+ ██ ──────────────────────────────────────────────────
300
+ ██ 🤦 Hubris 💥 Blowout 🤡 Fumble 🔨 Tool Happy
301
+ ██ ──────────────────────────────────────────────────
302
+ ██ Cause of death: Budget exceeded by $2.37
303
+ ██ Tip: Use Read with line ranges instead of full file reads.
304
+ ```
250
305
 
251
306
  ---
252
307
 
253
- ## Hooks
308
+ <details>
309
+ <summary><strong>Ultrathink</strong></summary>
310
+
311
+ Write `ultrathink` anywhere in your prompt to trigger extended thinking mode. It's not a slash command — just say it in natural language:
312
+
313
+ > *"ultrathink: is this the right architecture before I write anything?"*
314
+ > *"can you ultrathink through the tradeoffs here?"*
315
+
316
+ Extended thinking tokens are billed at full output rate. A single ultrathink on Sonnet can cost $0.50–2.00 depending on problem depth. TokenGolf detects thinking blocks from your session transcripts and tracks invocations and estimated thinking tokens — both show on your scorecard.
317
+
318
+ **The skill is knowing when to ultrathink.** One expensive deep-think that prevents five wrong turns is efficient. Ultrathinking every prompt when you're at 80% budget is hubris.
319
+
320
+ </details>
321
+
322
+ <details>
323
+ <summary><strong>The Meta Loop</strong></summary>
324
+
325
+ The dungeon crawl framing maps directly to real session behaviors:
326
+
327
+ - **Overencumbered** = context bloat slowing you down
328
+ - **Made Camp** = hit usage limits, came back next session
329
+ - **Ghost Run** = surgical context management before the boss
330
+ - **Hubris** = reached for ultrathink on a tight budget and paid for it
331
+ - **Silent Run** = solved it with pure prompting discipline, no extended thinking needed
332
+ - **Lone Wolf** = didn't spawn a single subagent; held the whole problem in one context
333
+ - **Agentic** = gave Claude the wheel and it ran with it — 3+ turns per prompt
334
+
335
+ Roguelike mode surfaces these patterns explicitly. Flow mode lets them compound over time. The meta loop: **roguelike practice makes Flow sessions better. Better Flow = lower daily spend = better scores without even trying.**
336
+
337
+ </details>
338
+
339
+ <details>
340
+ <summary><strong>Budget presets (model-calibrated)</strong></summary>
341
+
342
+ The wizard shows different amounts depending on your class — same relative difficulty, different absolute cost. Anchored to the ~$0.75/task Sonnet average from Anthropic's $6/day Claude Code benchmark.
343
+
344
+ | Tier | Haiku 🏹 | Sonnet ⚔️ | Opus 🧙 | Feel |
345
+ |------|---------|---------|--------|------|
346
+ | 💎 Diamond | $0.15 | $0.50 | $2.50 | Surgical micro-task |
347
+ | 🥇 Gold | $0.40 | $1.50 | $7.50 | Focused small task |
348
+ | 🥈 Silver | $1.00 | $4.00 | $20.00 | Medium task |
349
+ | 🥉 Bronze | $2.50 | $10.00 | $50.00 | Heavy / complex |
350
+ | ✏️ Custom | any | any | any | Set your own bust threshold |
351
+
352
+ These are **bust thresholds** — your commitment. Efficiency tiers derive as percentages of whatever you commit to.
353
+
354
+ </details>
355
+
356
+ <details>
357
+ <summary><strong>Why "TokenGolf"?</strong></summary>
254
358
 
255
- Nine hooks installed via `tokengolf install`:
359
+ [Code golf](https://en.wikipedia.org/wiki/Code_golf) is the engineering practice of solving a problem in as few characters (or lines, or bytes) as possible. The constraint isn't the point — the *discipline the constraint creates* is the point. Writing the shortest possible solution forces you to understand the problem deeply and use your tools precisely.
360
+
361
+ 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.**
362
+
363
+ </details>
364
+
365
+ <details>
366
+ <summary><strong>Hooks (9 total)</strong></summary>
367
+
368
+ All installed via `tokengolf install`:
256
369
 
257
370
  | Hook | When | What it does |
258
371
  |------|------|-------------|
259
- | `SessionStart` | Session opens | Injects quest/budget/floor into Claude's context. Auto-creates Flow run if none active. Increments session count for multi-session runs. |
372
+ | `SessionStart` | Session opens | Injects quest/budget/floor into Claude's context. Auto-creates Flow run if none active. |
260
373
  | `PostToolUse` | After every tool | Tracks tool usage by type. Fires budget warning at 80%. |
261
374
  | `PostToolUseFailure` | After a tool error | Increments `failedToolCalls` — powers Clean Run, Stubborn, Fumble. |
262
375
  | `UserPromptSubmit` | Each prompt | Counts prompts. Injects halfway nudge at 50% budget. |
263
376
  | `PreCompact` | Before compaction | Records manual vs auto compact + context % — powers gear achievements. |
264
- | `SessionEnd` | Session closes | Scans transcripts for cost + ultrathink blocks, saves run, displays ANSI scorecard. Detects Fainted if session ended unexpectedly (usage limit hit). |
377
+ | `SessionEnd` | Session closes | Scans transcripts for cost + ultrathink, saves run, displays scorecard. |
265
378
  | `SubagentStart` | Subagent spawned | Increments `subagentSpawns` — powers Lone Wolf, Summoner, Army of One. |
266
379
  | `Stop` | Claude finishes a turn | Increments `turnCount` — powers Agentic, Obedient. |
267
380
  | `StatusLine` | Continuously | Live HUD with cost, tier, efficiency, context %, model class. |
268
381
 
269
- ---
382
+ </details>
270
383
 
271
- ## State
384
+ <details>
385
+ <summary><strong>State</strong></summary>
272
386
 
273
387
  All data lives in `~/.tokengolf/`:
274
388
  - `current-run.json` — active run
275
389
  - `runs.json` — completed run history
276
390
 
277
391
  No database, no native deps, no compilation.
392
+
393
+ </details>