SLOPSHOPPER

flappy

Flappy above the Claude Code prompt: flap through the gaps in the pipes. Plays while Claude works, pauses when the turn ends, keeps your best score; zero…

newbandcommandtoast
A shopper browsing a rack in a slop shop
Preview · a replayed session in a sandbox
claude · ~/work/app · flappy
› fix the failing auth test and add an audit log call ⏺ Read(src/auth.ts) ⎿ Read 6 lines ⏺ Update(src/auth.ts) ⎿ Added 2 lines, removed 1 line ⏺ Bash(bun test) ⎿ 3 pass, 1 fail ● Done. refresh now rejects expired claims and logs an audit event. ✻ Worked for 42s · done 4:20 PM › /flappy ⎿ flappy: $Flappy · click the board to play · Esc returns to the prompt · /flappy stop closes [ close ] ▣ client module ./boards/flappy.tsx ⟨Claude Code's own drawing⟩ ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── › ? for shortcuts

Draws

Band
[ close ] ▣ client module ./boards/flappy.tsx ⟨Claude Code's own drawing⟩
README

flappy

Flappy above the Claude Code prompt, for the minutes Claude spends working: flap through the gaps in the pipes. The game pauses and its status line says so when Claude finishes the turn, so you never miss a reply. Playing costs no tokens: the mod answers every key and click itself.

A single game split out of sezaakgun/cc-arcade (MIT, by Seza Akgün). Want all nine games, a picker and the pet in one plugin? Install games/cc-arcade instead.

Play

  1. /flappy opens the board above the prompt (/flappy stop or the close button closes it).
  2. Click the board to give it the keyboard; Esc gives the keyboard back to the prompt.
  3. Space, ↑, w, Enter or a click flaps. p pauses, r restarts. Touching the ceiling only stops you; the floor and the pipes end the round.

Your best score is kept in the plugin's store across sessions.

Install

npx claude-code-templates@latest --mod games/flappy
claude

It is written to .claude/skills/flappy/, which Claude Code auto-loads as flappy@skills-dir. For one session with hot reload: claude --plugin-dir .claude/skills/flappy.

Requirements

  • Claude Code 2.1.287 or later (mods are on by default from that version).
  • An interactive terminal that reports the mouse. Nothing draws in claude -p, the desktop app or mobile.
  • A terminal font with box-drawing and block characters.

Clones of the genre, not affiliated with or endorsed by the original publishers.

Source 5 files
hooks/register.tsx 95 lines
1/* @jsx h */
2import type { Register } from 'claude-code'
3import { isBetter } from './games/best.ts'
4
5// Flappy above the Claude Code prompt, split out of cc-arcade (https://github.com/sezaakgun/cc-arcade,
6// MIT, by Seza Akgün) as a single-game mod. `/flappy` opens it, `/flappy stop` closes it. The board in
7// ./boards is a surface module that runs on the drawing thread; this module mounts it, keeps the best
8// score in $.store and pauses the game when Claude finishes a turn. Playing costs no tokens.
9
10const GAME = 'flappy' // what the board posts its score under
11const TITLE = 'Flappy'
12const LOWER_IS_BETTER = false
13const UNIT = ''
14
15let open = false
16// bumped at each finished turn; the open game pauses when it sees a new value
17let turnsDone = 0
18let best = 0
19
20export const register: Register = on => {
21  on('session.start', async ($, e, next) => {
22    const r = await next(e)
23    // a store that cannot be read costs the best score, never the game
24    const score = Number(await $.store.get('best').catch(() => undefined))
25    if (score) best = score
26    await $.command.register({
27      name: 'flappy',
28      description: `$Flappy above the prompt, while Claude works (stop closes)`,
29      argumentHint: '[stop]',
30      immediate: true,
31    }).catch(err => $.ui.log(`flappy: /flappy not registered: ${err}`))
32    return r
33  })
34
35  on('command.run', { command: 'flappy' }, async ($, e) => {
36    const arg = e.args.trim().toLowerCase()
37    if (arg === 'stop' || arg === 'close') {
38      open = false
39      $.ui.invalidate('ui.render')
40      return { text: `$Flappy closed` }
41    }
42    open = true
43    $.ui.invalidate('ui.render')
44    const score = best ? ` · best ${best}$` : ''
45    return { text: `$Flappy · click the board to play · Esc returns to the prompt · /flappy stop closes${score}` }
46  })
47
48  on('turn.complete', async ($, e, next) => {
49    const r = await next(e)
50    // a subagent's turn is not the one the person is waiting for
51    if (e.agentId) return r
52    if (open) {
53      turnsDone++
54      $.ui.invalidate('ui.render')
55    }
56    return r
57  })
58
59  // a finished round, posted by the board: keep the best score and hand it back with the next props
60  on('ui.message', async ($, e, next) => {
61    const data = e.data as { game?: unknown; score?: unknown } | null
62    if (data?.game !== GAME || typeof data.score !== 'number') return next(e)
63    if (isBetter(data.score, best || undefined, LOWER_IS_BETTER)) {
64      best = data.score
65      await $.store.set('best', best).catch(err => $.ui.log(`flappy: store write failed: ${err}`))
66      $.ui.toast(`$Flappy: new best ${best}$`)
67    }
68    return { props: { best, done: turnsDone, safe: false } }
69  })
70
71  on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
72    // the board needs a terminal's keys and mouse; the desktop and mobile surfaces draw their own band
73    if (!open || e.props.hasSurvey || e.surface !== 'terminal') return next(e)
74    const { Box, Button, Client } = $.ui.resolve(e)
75    // the band's own width: the transcript column's while a Pane is docked beside it
76    const cols = e.props.bodyColumns || (e.viewport?.columns ?? 80)
77    // one row for the close button, one for whatever else draws in the band
78    const rows = Math.max(8, e.props.maxRows - 2)
79    const tall = (max: number) => Math.min(rows, max)
80    const close = () => {
81      open = false
82      $.ui.invalidate('ui.render')
83    }
84    return (
85      <Box flexDirection="column">
86        <Box flexDirection="row" columnGap={1}>
87          <Button key="flappy:close" label="close" onPress={close} />
88        </Box>
89        <Client key="board:flappy" module="./boards/flappy.tsx" width={cols} height={tall(19)} props={{ best, done: turnsDone, safe: false }} />
90        {await next(e)}
91      </Box>
92    )
93  })
94}
95
hooks/games/best.ts 10 lines
1// Which score counts as a new best. Minesweeper's best is its fastest clear, so lower wins there;
2// everywhere else higher wins. A score of zero or less never counts: a Minesweeper board whose
3// first click clears it takes 0 s and would otherwise lock the best forever, and a Pong match you
4// lost posts a negative margin.
5export function isBetter(score: number, prev: number | undefined, lowerIsBetter = false): boolean {
6  if (!Number.isFinite(score) || score <= 0) return false
7  if (prev === undefined || prev <= 0) return true
8  return lowerIsBetter ? score < prev : score > prev
9}
10
hooks/boards/flappy.tsx 76 lines
1/* @jsx h */
2import type { ClientSurface } from 'claude-code'
3import { base, claudeDone, grid, statusLine, type Base, type Props } from './common.tsx'
4import { BIRD_X, birdRow, flap, gapSize, newFlappy, tick, type FlappyGame } from '../games/flappy.ts'
5
6type State = Base & { game?: FlappyGame }
7
8export default function Flappy(props: Props, surface: ClientSurface<State>) {
9  const { Box, Text } = surface.elements
10  const size = () => ({
11    bw: Math.max(12, Math.min(40, Math.floor((surface.columns - 2) / 2))),
12    bh: Math.max(6, Math.min(16, surface.rows - 3)),
13  })
14  const start = () => {
15    const s = surface.state
16    if (!s) return
17    const { bw, bh } = size()
18    surface.setState({ ...s, banner: false, playing: true, game: flap(newFlappy(bw, bh)) })
19  }
20  // space, up, Enter or a click: flap, or start a new round when there is none
21  const press = () => {
22    const s = surface.state
23    if (!s) return
24    if (!s.game || s.game.over) return start()
25    surface.setState({ ...s, banner: false, playing: true, game: flap(s.game) })
26  }
27
28  if (surface.state === undefined) {
29    surface.setState(base(props))
30    surface.every(100, () => {
31      const s = surface.state
32      if (!s?.game || !s.playing || s.game.over) return
33      const game = tick(s.game)
34      if (game.over) surface.post({ game: 'flappy', score: game.score })
35      surface.setState({ ...s, game })
36    })
37    surface.onKey(({ key }) => {
38      const s = surface.state
39      if (!s) return
40      // the space bar may arrive as the character or by name
41      const k = key === 'space' ? ' ' : key.toLowerCase()
42      if (k === 'p') {
43        if (s.game && !s.game.over) surface.setState({ ...s, banner: false, playing: !s.playing })
44      } else if (k === 'r') {
45        start()
46      } else if (k === ' ' || k === 'up' || k === 'w' || k === 'return') {
47        press()
48      }
49    })
50    surface.onPointer(ev => { if (ev.type === 'down') press() })
51  }
52  claudeDone(props, surface)
53
54  const s = surface.state
55  const g = s?.game
56  const { bw, bh } = g ? { bw: g.w, bh: g.h } : size()
57  const row = g ? birdRow(g) : Math.floor(bh / 2)
58  const opening = gapSize(bh)
59  const rows = grid(Text, bw, bh, (x, y) => {
60    if (x === BIRD_X && y === row) return ['▓▓', g?.over ? 'red' : 'yellowBright']
61    const pipe = g?.pipes.find(p => p.x === x)
62    if (pipe && (y < pipe.gap || y >= pipe.gap + opening)) return ['██', 'green']
63    return ['  ']
64  })
65  const text = !g ? 'flappy · click here, then space or click to flap · p pause'
66    : g.over ? `flappy · crashed · score ${g.score} · space or click flies again`
67    : !s?.playing ? `flappy · paused · score ${g.score} · p resumes`
68    : `flappy · score ${g.score} · space or click flaps`
69  return (
70    <Box flexDirection="column">
71      <Box flexDirection="column" borderStyle="round" borderColor={g?.over ? 'red' : 'blue'} width={bw * 2 + 2}>{rows}</Box>
72      {statusLine(Text, !!s?.banner, `${text} · best ${props?.best ?? 0}`)}
73    </Box>
74  )
75}
76
hooks/boards/common.tsx 61 lines
1/* @jsx h */
2import type { ClientElements, ClientSurface } from 'claude-code'
3
4// Shared by every board. A board is a surface module: it runs on the drawing thread with its own
5// frame clock, keys (after a click gives it focus; Esc gives the prompt back) and mouse.
6//
7// Never name a local `h` in a board file: every JSX tag compiles to a call of `h`.
8
9export type Props = { best?: number; done?: number; safe?: boolean } | undefined
10export type Base = { playing: boolean; banner: boolean; seenDone: number }
11export type Paint = readonly [glyph: string, color?: string, bg?: string]
12type TextTag = ClientElements['Text']
13
14export const base = (props: Props): Base => ({ playing: false, banner: false, seenDone: props?.done ?? 0 })
15
16// the hooks module bumps props.done when Claude finishes a turn: pause and say so, once per turn
17export function claudeDone<S extends Base>(props: Props, surface: ClientSurface<S>) {
18  const s = surface.state
19  const done = props?.done ?? 0
20  if (s && done !== s.seenDone) surface.setState({ ...s, seenDone: done, banner: true, playing: false })
21}
22
23export function statusLine(Text: TextTag, banner: boolean, text: string) {
24  return banner
25    ? <Text color="yellow" bold wrap="truncate-end">{`● Claude is done · ${text}`}</Text>
26    : <Text dimColor wrap="truncate-end">{text}</Text>
27}
28
29export type Run = [text: string, color?: string, bg?: string]
30
31// one run per stretch of cells sharing both colors. A drawing the engine cannot fit in its node
32// budget is worse than a coarser one, so maxRuns folds neighbours together, pair by pair, until
33// the row fits: a merged pair keeps the left one's colors and every glyph.
34export function runs(cols: number, y: number, at: (x: number, y: number) => Paint, maxRuns = Infinity): Run[] {
35  let out: Run[] = []
36  for (let x = 0; x < cols; x++) {
37    const [glyph, color, bg] = at(x, y)
38    const last = out[out.length - 1]
39    if (last && last[1] === color && last[2] === bg) last[0] += glyph
40    else out.push([glyph, color, bg])
41  }
42  while (out.length > Math.max(1, maxRuns)) {
43    const folded: Run[] = []
44    for (let i = 0; i < out.length; i += 2) {
45      const [t, c, b] = out[i]
46      const next = out[i + 1]
47      folded.push(next ? [t + next[0], c, b] : [t, c, b])
48    }
49    out = folded
50  }
51  return out
52}
53
54// a board as rows of two-character cells (a terminal cell is about twice as tall as wide, so two
55// make a square), one styled span per run of the same colors
56export function grid(Text: TextTag, cols: number, rowCount: number, at: (x: number, y: number) => Paint, maxRuns = Infinity) {
57  return Array.from({ length: Math.max(0, rowCount) }, (_, y) => (
58    <Text>{runs(cols, y, at, maxRuns).map(([t, c, b]) => (b ? <Text color={c} backgroundColor={b}>{t}</Text> : <Text color={c}>{t}</Text>))}</Text>
59  ))
60}
61
hooks/games/flappy.ts 46 lines
1// Flappy: pure game logic, drawn by the Flappy module in ../surface.tsx.
2// Units are board cells; one tick is one 100 ms frame.
3
4export type Pipe = { x: number; gap: number }
5export type FlappyGame = { w: number; h: number; y: number; vy: number; pipes: Pipe[]; score: number; over: boolean }
6
7export const BIRD_X = 4
8// tuned so a flap every second or so holds height; the first try (0.3 / -1.1 / 1.2) hit the floor
9// about a second after the first flap
10const GRAVITY = 0.15
11const FLAP = -0.9
12const MAX_FALL = 0.8
13const SPACING = 12
14
15// the opening is a third of the board, at least three rows
16export const gapSize = (h: number) => Math.max(3, Math.floor(h / 3))
17const randomGap = (h: number, rand: () => number) => 1 + Math.floor(rand() * Math.max(1, h - gapSize(h) - 1))
18
19export function newFlappy(w: number, h: number, rand = Math.random): FlappyGame {
20  return { w, h, y: h / 2, vy: 0, pipes: [{ x: w - 1, gap: randomGap(h, rand) }], score: 0, over: false }
21}
22
23export const flap = (g: FlappyGame): FlappyGame => (g.over ? g : { ...g, vy: FLAP })
24
25// the bird's row, as drawn and as collisions see it
26export const birdRow = (g: FlappyGame) => Math.round(g.y)
27
28// one tick: gravity, the pipes move a column left, a pipe passing the bird scores, and the round
29// ends on the floor or a pipe; the ceiling stops the bird instead of ending the round
30export function tick(g: FlappyGame, rand = Math.random): FlappyGame {
31  if (g.over) return g
32  let vy = Math.min(MAX_FALL, g.vy + GRAVITY)
33  let y = g.y + vy
34  if (y < 0) {
35    y = 0
36    vy = 0
37  }
38  let pipes = g.pipes.map(p => ({ ...p, x: p.x - 1 })).filter(p => p.x >= 0)
39  const last = pipes[pipes.length - 1]
40  if (!last || last.x <= g.w - 1 - SPACING) pipes = [...pipes, { x: g.w - 1, gap: randomGap(g.h, rand) }]
41  const score = g.score + pipes.filter(p => p.x === BIRD_X - 1).length
42  const row = Math.round(y)
43  const hit = row < 0 || row >= g.h || pipes.some(p => p.x === BIRD_X && (row < p.gap || row >= p.gap + gapSize(g.h)))
44  return { ...g, y, vy, pipes, score, over: hit }
45}
46