Claude Code mods: Minesweeper and testkit A developer built Minefield, a Minesweeper mod for Claude Code that opens a game pane beside the transcript while the agent works, shipping with 31 tests run via `claude plugin test` on two pinned Claude Code builds. The developer found that four bugs passed the test kit but only surfaced in real sessions, including a pane that could not take keyboard focus because Claude Code 2.1.285 refuses a `focus: true` request while the command's own text is still in the prompt. The fix re-requests focus after `/mines` returns, retrying at 250 ms, 500 ms and 1000 ms while checking `$.ui.panes()` so a pane the user closed is never reopened. My own harness, the tooling I run around Claude Code, comes with a custom trust score. That trust score decides whether I can leave the agent alone yet, without supervision or if it's in my best interest to babysit it. As you see in the header image, it's babysitting era, so I built a Minesweeper to kill time between turns. From Claude Code 2.1.287, mods load by default. A mod is a plugin whose hooks are JavaScript or TypeScript functions running inside Claude Code instead of shell commands, and it can open and draw its own panes. Minefield is Minesweeper as a mod: /mines opens a pane beside the transcript, and you clear the board while Claude works. It is one 9×9 board with 10 mines, a game for the few minutes Claude works. The first reveal is always safe and opens an area, clicking a fully flagged number opens the cells around it, and the best time is kept between sessions. The orange face follows your cursor. Stop for six seconds and it pretends to read the transcript beside it, eyes half shut, line by line. It only looks; the mod sees nothing of the transcript. It winks at flags and puts on sunglasses when you win. This was the most fun part to implement. It ships with 31 tests that run through claude plugin test , and CI runs them on two pinned Claude Code builds. Four of its bugs passed the test kit anyway and only showed up in a real session: the pane couldn't take the keyboard, the hotkeys did nothing, the face wrapped, and the mouse wasn't there. In claude plugin test , nearly every engine call your mod makes ui.open , ui.panes , store.get is answered by an on ... stub you write in the test file; the kit answers a few itself, such as $.ui.invalidate . That is why it runs fast and without credentials. It also means the host in your tests behaves exactly as well as your doubles do. /mines opened the pane, and the keys kept going to the prompt. Seen in live sessions on 2.1.285: a pane takes the keyboard only over an empty prompt. Anthropic's docs list focus: true from a command as one way a pane gets the keyboard, but while command.run runs, the command's own text is still in the prompt, and on 2.1.285 the request was refused. The pane opens and the keyboard stays where it was. In the tests, ui.open is answered by my own double, and my double says yes: js on 'ui.open', $, e = { opened.push { rows: e.rows, columns: e.columns, closeOnEscape: e.closeOnEscape } return { value: { isPlaced: true } } } The fix is to open the pane, then ask for the keyboard again once /mines has returned. register.ts waits 250 ms, then 500, then 1000 between tries FOCUS RETRIES MS , three tries inside two seconds, and every retry first asks $.ui.panes whether the pane is still open and still without the keyboard. If the pane is gone, the person closed it, and a retry must not bring it back. // Ask for the keyboard again once /mines has returned, while the pane is open // and still without it; never reopen a pane the person has closed. function focusSoon $: EngineInterface, attempt: number : void { const wait = FOCUS RETRIES MS attempt if wait === undefined return try { $.clock.after wait, = void refocus $, attempt } catch { // No timer; a click on the pane gives it the keyboard. } } async function refocus $: EngineInterface, attempt: number : Promise