Build a Claude Code Game Mod¶
| Category | Creative & Real-World AI Builds |
| Status | โ Completed |
| Repo | nextwork-build-a-claude-code-game-mod |
| Original NextWork guide | nextwork.ai |
Learning project
Practice work following a NextWork guide, separate from my production projects.
๐ NextWork learning project. This is a practice project I built while working through NextWork's Build a Claude Code Game Mod guide. It is part of my Learning portfolio and is fully separate from my production projects.
Category: Learning โบ Creative & Real-World AI Builds
Status: โ
Completed
Overview¶
Waiting on an agent is dead time. This mod uses Claude Code's Mods API (turn.start / turn.complete, with only $.env, $.fs, $.process and $.ui) to open a small word-typing game while the agent works, then switch it to a finished page. Rounds last 45 seconds and the best round is kept in the browser.
Summary¶
My while-you-wait mod is built, validated (claude plugin validate passes), and proven in live Claude Code sessions. When a main turn starts, turn.start writes and opens my word-rounds game ("Agent turn running"). When the turn ends, turn.complete opens the finished page, with the banner shown and the input locked. The best round survives a full browser restart (localStorage). Secret mission: the mod is zipped, a fresh user with an empty HOME and Claude Code config ran it from the zip, and a proof image puts the game beside the turn's hook log.
The checks behind this are in docs/verification.txt.
Skills & tools¶
Claude Code Mods API, Plugin packaging, JavaScript, localStorage, Browser testing
What I built¶
while-you-wait/(my own code):hooks/turns.js(named turn.start and turn.complete handlers, main turns only; a failing opener shows a toast and never blocks the turn),hooks/hooks.json,.claude-plugin/plugin.json, a short plugin README, andgame/index.html. The game shows one word at a time, counts it the moment it matches, flags a wrong letter witharia-invalid, runs 45-second rounds, saves the best round to localStorage straight away, and has a__TURN_STATE__token that the hook fills in.docs/claude-code-session.md+docs/browser-open-log.txt: a live Claude Code 2.1.335 turn (3 Dec, 01:27 CT) with the plugin loaded via--plugin-dir. The hook openedindex.htmlat turn start anddone.htmlsix seconds later at turn end. The stand-in model's one-line reply was unhelpful, which doesn't matter to the mod.docs/game-working.png/docs/game-done.png: what the opener captured for each state.tests/game.test.mjs(Playwright, 8 checks): words count, best round is set, a wrong letter is flagged and clears when corrected, best round survives a browser relaunch, and the finished page locks the input.- Secret mission:
package.shvalidates and zips the mod.friend_test.shunpacks it for a brand-new user and runs one turn (docs/friend-test.txt: both pages opened).docs/proof-game-beside-turn.pngis composed from the turn's hook log and the screenshot taken at turn start, not a single screen capture.
How to run¶
claude plugin validate ./while-you-wait
claude --plugin-dir ./while-you-wait # the game opens on each main turn
bash package.sh # secret mission: while-you-wait.zip
WYW_OPENER=xdg-open (the default is macOS open).
Verification¶
I ran the verification command on 2026-12-03. The full output is in docs/verification.txt.
/workspace/nextwork-portfolio/tools-node/cc/node_modules/.bin/claude plugin validate ./while-you-wait | tail -1 && CLAUDE=/workspace/nextwork-portfolio/tools-node/cc/node_modules/.bin/claude bash package.sh >/dev/null && test -s while-you-wait.zip && grep -q 'FRIEND TEST OK' docs/friend-test.txt && grep -c opened docs/browser-open-log.txt && WD=$(mktemp -d) && mkdir -p $WD/w && for s in running done; do sed "s/__TURN_STATE__/$s/" while-you-wait/game/index.html > $WD/w/$( [ $s = running ] && echo index || echo done ).html; done && node tests/game.test.mjs $WD/w
Notes¶
Model substitution: the guide uses Claude Code with a Claude subscription. I don't have a Claude account, so I ran the real Claude Code CLI (v2.1.335) headlessly and pointed it at a substitute model, either a local Ollama model or a free OpenRouter model, through the Anthropic-compatible API (ANTHROPIC_BASE_URL). Claude Code's skills, hooks, settings, and tools behave the same; only the model answering is different. Platform substitution: the target setup is macOS with Safari. My box is headless Linux, so the opener is configurable (WYW_OPENER), and the live runs used a stand-in that logs the page and screenshots it with headless Chrome (tools/screenshot-browser.sh). I skipped the optional Intermission tour.
Rewritten 3 Dec 2026: the earlier game and hook followed the guide's reference code. The game, hooks, manifest and tests are now my own, and the live session, friend test and screenshots were redone.
Original project: https://nextwork.ai/projects/82958509-1915-41b4-b96b-f90dacfe953f ยท Part of my NextWork Learning portfolio (hub).
Verification output¶
From docs/verification.txt:
$ /workspace/nextwork-portfolio/tools-node/cc/node_modules/.bin/claude plugin validate ./while-you-wait | tail -1 && CLAUDE=/workspace/nextwork-portfolio/tools-node/cc/node_modules/.bin/claude bash package.sh >/dev/null && test -s while-you-wait.zip && grep -q 'FRIEND TEST OK' docs/friend-test.txt && grep -c opened docs/browser-open-log.txt && WD=$(mktemp -d) && mkdir -p $WD/w && for s in running done; do sed "s/__TURN_STATE__/$s/" while-you-wait/game/index.html > $WD/w/$( [ $s = running ] && echo index || echo done ).html; done && node tests/game.test.mjs $WD/w
โ Validation passed
2
ok running page says the turn is running
ok three typed words count 3
ok and set the best round to 3
ok a wrong letter marks the field invalid
ok deleting back to a correct prefix clears it
ok best round is still 3 after closing and reopening the browser
ok done page says the turn finished
ok done page shows the banner and locks the input
GAME OK
[exit code 0]