SLOPSHOPPER

agent-crabs

A pixel-art crab for every running subagent, dressed for its role, showing what it is working on.

bandguardtimer
v0.2.0no licenseupdated 2026-10-21Arkboi-GG/claude-mods/mods/agent-crabs
A shopper browsing a rack in a slop shop
README

claude-mods

A small collection of Claude Code mods.

Install

/plugin install <mod> --marketplace Arkboi-GG/claude-mods

The bars stack above the prompt, so you can install any combination.

Mods

  • task-progress: the band above the prompt. While Claude works on a multi-step task it shows one block per step: the running step fills as "In Progress", finished steps turn green "Completed", and a turn that stops with steps still open turns amber "Paused". When Claude is idle it shows usage rings (context, 5-hour and 7-day limits) with a Compact button. It reads the task list Claude keeps while working, so it appears for multi-step tasks. The Compact button runs /compact with instructions to keep the thread (goal, decisions, files, key values, open questions, next steps) so work carries on in the same topic; change them with the compactInstructions option. The 5-hour and 7-day rings show the time left until they reset (the ring still fills with the share used). If you also use the skins mod, run /skin band off once so its own usage band doesn't show twice.
  • repo-status: branch, ahead/behind, changed-file count and the open PR's check state (needs git; gh is optional).
  • stack-health: status dots for your Docker Compose services and any local ports you list (web=5173,api=3000).
  • preflight: a live pre-commit checklist. After Claude edits files it re-runs your typecheck/lint (auto-detected, or set checks) and shows pass/fail with an error count.
  • env-guard: a green LOCAL badge that turns red PROD when a tool call matches your production patterns, and toasts when it happens.
  • agent-crabs: a pixel-art crab for every running subagent, dressed for its role (beret, hard hat, postman cap and more), with the agent's name, what it is working on and a timer. Finished crabs cheer and leave after a few seconds; failed ones turn grey. Name an agent by starting the Agent call's description with Name: , e.g. Olivia: rewrite welcome email; map names to outfits with the outfits option. While an agent runs, a playful stage word (Waking up, Analyzing, Cooking, Wrapping up) follows what its tool calls show it doing; "Wrapping up" is a guess, since an agent reports no progress.
Source 2 files
hooks/register.tsx 319 lines
1import { atom, read, update } from 'claude-code'
2import type { Register } from 'claude-code'
3
4import type { Crab, Stage } from '../types'
5
6const crabsAtom = atom({ plugin: 'agent-crabs', key: 'crabs' } as const, {} as Record<string, Crab>)
7const tickAtom = atom({ plugin: 'agent-crabs', key: 'tick' } as const, 0)
8
9const ORANGE = '#fb923c'
10
11// Pixel art. The crab is a 16 x 11 grid; every letter is a colour in PALETTE, a dot is empty.
12const W = 16
13const H = 11
14const SCALE = 2
15
16const PALETTE: Record<string, string> = {
17  o: '#e2724a', // body
18  d: '#b4512f', // legs
19  c: '#f4977a', // claws
20  w: '#ffffff',
21  k: '#1a1a1a',
22  R: '#dc2626',
23  B: '#3b82f6',
24  b: '#3b82f6',
25  g: '#9ca3af',
26  N: '#1e3a8a',
27  K: '#1f2937',
28  Y: '#facc15',
29  y: '#facc15',
30  h: '#94a3b8',
31  l: '#67e8f9',
32  T: '#b08968',
33}
34
35// The grey a failed crab turns.
36const GREY: Record<string, string> = { o: '#6b7280', d: '#4b5563', c: '#9ca3af' }
37
38type Rows = Record<number, string>
39
40const BODY: Rows = {
41  4: '..oooooooooooo..',
42  5: '.oowkooooowkooo.',
43  6: '.oowwooooowwooo.',
44  7: '.oooooooooooooo.',
45  8: '..oooooooooooo..',
46}
47
48const LEGS: Rows[] = [
49  { 9: '..d.d.d..d.d.d..', 10: '.d.d.d....d.d.d.' },
50  { 9: '.d.d.d....d.d.d.', 10: '..d.d.d..d.d.d..' },
51]
52
53const CLAW_LEFT_UP: Rows = { 1: 'c.c.............', 2: 'ccc.............', 3: '.c..............', 4: '.c..............' }
54const CLAW_RIGHT_UP: Rows = { 1: '.............c.c', 2: '.............ccc', 3: '..............c.', 4: '..............c.' }
55const CLAW_LEFT_DOWN: Rows = { 5: 'c.c.............', 6: 'ccc.............', 7: '.c..............' }
56const CLAW_RIGHT_DOWN: Rows = { 5: '.............c.c', 6: '.............ccc', 7: '..............c.' }
57
58const OUTFITS: Record<string, Rows> = {
59  plain: {},
60  beret: { 1: '........R.......', 2: '.....RRRRRR.....', 3: '....RRRRRRRR....' },
61  hoodie: { 2: '.....BBBBBB.....', 3: '....BBBBBBBB....', 7: '.....gggggg.....', 8: '.....gggggg.....' },
62  postman: { 2: '.....NNNNNN.....', 3: '...NNNNNNNNNN...', 7: '......wwww......', 8: '......wddw......' },
63  grad: { 2: '..KKKKKKKKKKKK..', 3: '.....KKKKKK.Y...', 4: '............Y...' },
64  headset: { 2: '.....hhhhhh.....', 3: '....h......h....', 4: '...h........h...', 5: '...h........h...' },
65  magnifier: {
66    2: '......TTTT......',
67    3: '.....TTTTTT.....',
68    6: '.......ll.......',
69    7: '......l..l......',
70    8: '......l..l......',
71    9: '.......ll.......',
72    10: '..........T.....',
73  },
74  megaphone: { 7: '...........yy...', 8: '...........yyy..', 9: '............yyy.' },
75  hardhat: { 1: '.......YY.......', 2: '.....YYYYYY.....', 3: '...YYYYYYYYYY...', 7: '..........bb....', 8: '..........bw....' },
76  explorer: { 1: '......TTTT......', 2: '.....TTTTTT.....', 3: '...TTTTTTTTTT...' },
77}
78
79// Agent name (lowercase) or agent type to outfit. Anything else gets a plain crab.
80const DEFAULT_OUTFITS: Record<string, string> = {
81  olivia: 'beret',
82  jack: 'hoodie',
83  achilles: 'postman',
84  dexter: 'grad',
85  erica: 'headset',
86  paul: 'magnifier',
87  joanne: 'megaphone',
88  simon: 'hardhat',
89  explore: 'explorer',
90  plan: 'hardhat',
91}
92
93// One crab as an SVG: claws alternate with the frame, both raised when it has finished.
94function crabSvg(outfit: string, frame: number, state: Crab['state']): string {
95  const grid: string[][] = Array.from({ length: H }, () => Array(W).fill('.'))
96  const paint = (rows: Rows) => {
97    for (const [y, row] of Object.entries(rows)) {
98      for (let x = 0; x < W; x++) if (row[x] && row[x] !== '.') grid[Number(y)][x] = row[x]
99    }
100  }
101  paint(BODY)
102  paint(LEGS[frame % 2])
103  if (state === 'done') {
104    paint(CLAW_LEFT_UP)
105    paint(CLAW_RIGHT_UP)
106  } else if (frame % 2 === 0) {
107    paint(CLAW_LEFT_UP)
108    paint(CLAW_RIGHT_DOWN)
109  } else {
110    paint(CLAW_LEFT_DOWN)
111    paint(CLAW_RIGHT_UP)
112  }
113  paint(OUTFITS[outfit] ?? OUTFITS.plain)
114
115  const colour = (ch: string) => (state === 'failed' && GREY[ch] ? GREY[ch] : PALETTE[ch])
116  let rects = ''
117  for (let y = 0; y < H; y++) {
118    let x = 0
119    while (x < W) {
120      const ch = grid[y][x]
121      if (ch === '.' || !PALETTE[ch]) {
122        x++
123        continue
124      }
125      let run = 1
126      while (x + run < W && grid[y][x + run] === ch) run++
127      rects += `<rect x="${x}" y="${y}" width="${run}" height="1" fill="${colour(ch)}"/>`
128      x += run
129    }
130  }
131  return `<svg xmlns="http://www.w3.org/2000/svg" width="${W * SCALE}" height="${H * SCALE}" viewBox="0 0 ${W} ${H}" shape-rendering="crispEdges">${rects}</svg>`
132}
133
134const mmss = (ms: number) => {
135  const s = Math.max(0, Math.floor(ms / 1000))
136  return `${Math.floor(s / 60)}:${String(s % 60).padStart(2, '0')}`
137}
138
139// What an agent is doing, read from its tool calls. There is no progress figure to read, so
140// "wrap" is a guess: it made tool calls, nothing is running, and it has gone quiet, which
141// usually means it is composing its final answer.
142const WORDS: Record<Stage, string[]> = {
143  wake: ['Waking up', 'Stretching claws', 'Finding the keys', 'Yawning'],
144  analyze: ['Analyzing', 'Scuttling through files', 'Sniffing around', 'Squinting at the code'],
145  cook: ['Cooking', 'Pinching pixels', 'Stirring the pot', 'Seasoning'],
146  wrap: ['Wrapping up', 'Tidying shells', 'Polishing claws', 'Plating it up'],
147}
148const STAGE_COLOUR: Record<Stage, string> = { wake: '#9ca3af', analyze: '#60a5fa', cook: '#fb923c', wrap: '#a78bfa' }
149const WRAP_QUIET_MS = 3500
150const WORD_EVERY_MS = 3500
151
152// Writing, editing and running things is "cook"; reading and looking things up is "analyze".
153const COOKING = /^(Edit|Write|NotebookEdit|Bash|PowerShell)$|^mcp__.*(create|update|delete|set|send|publish|add|write)/i
154const kindOf = (tool: string): Stage => (COOKING.test(tool) ? 'cook' : 'analyze')
155
156type Activity = { calls: number; inflight: number; lastAt: number; lastTool: string }
157
158// 'Olivia: rewrite welcome email' -> name Olivia, task 'rewrite welcome email'.
159// The brain's router puts the agent's name in front of every named dispatch.
160const NAMED = /^([A-Za-z][\w.-]{0,24}):\s+(.+)$/
161
162export const register: Register = (on, options) => {
163  const lingerMs = Math.max(1, Number(options.lingerSeconds ?? 6)) * 1000
164  const maxShown = Math.max(1, Number(options.maxShown ?? 4))
165
166  const outfits: Record<string, string> = { ...DEFAULT_OUTFITS }
167  for (const pair of String(options.outfits ?? '').split(',')) {
168    const [name, outfit] = pair.split('=').map(s => s.trim())
169    if (name && outfit) outfits[name.toLowerCase()] = outfit
170  }
171
172  const describe = (a: { id: string; description: string; type: string }) => {
173    const m = a.type === 'general-purpose' ? NAMED.exec(a.description) : null
174    const name = m ? m[1] : a.type === 'general-purpose' ? '' : a.type
175    const task = m ? m[2] : a.description
176    const outfit = outfits[name.toLowerCase()] ?? outfits[a.type.toLowerCase()] ?? 'plain'
177    return { id: a.id, name, outfit, task }
178  }
179
180  // Crabs that have already left. The engine keeps a finished agent in its list for a while,
181  // so without this a crab would come back each time it was cleared away.
182  const gone = new Set<string>()
183
184  // Each agent's tool calls, by agent id (a subagent's calls carry its id as `agentId`).
185  const activity: Record<string, Activity> = {}
186
187  on('tool.call', async ($, e, next) => {
188    const id = (e as { agentId?: string }).agentId
189    if (!id) return next(e)
190    const a = (activity[id] ??= { calls: 0, inflight: 0, lastAt: 0, lastTool: '' })
191    a.calls++
192    a.inflight++
193    a.lastTool = String(e.tool)
194    a.lastAt = await $.clock.now()
195    try {
196      return await next(e)
197    } finally {
198      a.inflight = Math.max(0, a.inflight - 1)
199      a.lastAt = await $.clock.now()
200    }
201  })
202
203  const stageOf = (id: string, now: number): Stage => {
204    const a = activity[id]
205    if (!a || a.calls === 0) return 'wake'
206    if (a.inflight === 0 && now - a.lastAt >= WRAP_QUIET_MS) return 'wrap'
207    return kindOf(a.lastTool)
208  }
209
210  on('session.start', async ($, e, next) => {
211    const poll = async () => {
212      try {
213        const list = await $.agent.list()
214        const now = await $.clock.now()
215        const prev = await read($, crabsAtom)
216        const out: Record<string, Crab> = {}
217        const seen = new Set<string>()
218        for (const a of list) {
219          if (a.type === 'teammate') continue
220          seen.add(a.id)
221          const state: Crab['state'] =
222            a.status === 'completed' ? 'done' : a.status === 'failed' || a.status === 'killed' ? 'failed' : 'running'
223          if (gone.has(a.id)) {
224            // Only an agent that runs again (resumed) brings its crab back.
225            if (state !== 'running') continue
226            gone.delete(a.id)
227          }
228          const old = prev[a.id]
229          const base: Crab = old ?? { ...describe(a), startedAt: now, state }
230          out[a.id] = {
231            ...base,
232            state,
233            stage: state === 'running' ? stageOf(a.id, now) : undefined,
234            endedAt: state === 'running' ? undefined : (old?.endedAt ?? now),
235          }
236        }
237        // An agent the engine has dropped from the list has finished.
238        for (const [id, c] of Object.entries(prev)) {
239          if (!seen.has(id)) out[id] = c.state === 'running' ? { ...c, state: 'done', endedAt: now } : c
240        }
241        for (const [id, c] of Object.entries(out)) {
242          if (c.endedAt !== undefined && now - c.endedAt > (c.state === 'failed' ? lingerMs * 3 : lingerMs)) {
243            delete out[id]
244            delete activity[id]
245            gone.add(id)
246          }
247        }
248        await update($, crabsAtom, p => (JSON.stringify(p) === JSON.stringify(out) ? p : out))
249        // Once a second while there are crabs, so claws move and the timers count.
250        if (Object.keys(out).length > 0) await update($, tickAtom, n => n + 1)
251      } catch {
252        // the agent list is not ready: keep what is on screen
253      }
254    }
255    $.clock.every(1000, poll)
256    return next(e)
257  })
258
259  on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
260    const below = await next(e)
261    if (e.props.hasSurvey) return below
262    const crabs = Object.values(await read($, crabsAtom)).sort((a, b) => a.startedAt - b.startedAt)
263    const tick = await read($, tickAtom)
264    if (crabs.length === 0) return below
265
266    const now = await $.clock.now()
267    const { Box, Text, Svg } = $.ui.resolve(e)
268    const shown = crabs.slice(-maxShown)
269    const hidden = crabs.length - shown.length
270
271    const rows = shown.map(c => {
272      const label = c.name || 'agent'
273      const stamp = mmss((c.endedAt ?? now) - c.startedAt)
274      // The stage word changes every few seconds within its stage; the last digit of the
275      // id keeps two crabs from saying the same thing at once.
276      const stage: Stage = c.stage ?? 'wake'
277      const words = WORDS[stage]
278      const word = words[(Math.floor((now - c.startedAt) / WORD_EVERY_MS) + c.id.charCodeAt(c.id.length - 1)) % words.length]
279      const status =
280        c.state === 'running' ? (
281          <Box gap={1}>
282            {e.props.bodyColumns >= 50 ? <Text color={STAGE_COLOUR[stage]}>{word}…</Text> : null}
283            <Text dimColor>{stamp}</Text>
284          </Box>
285        ) : c.state === 'done' ? (
286          <Text color="#22c55e">✓ {stamp}</Text>
287        ) : (
288          <Text color="#ef4444">✗ failed</Text>
289        )
290      return (
291        <Box paddingX={1} alignItems="center" gap={1}>
292          <Box flexShrink={0}>
293            <Svg source={crabSvg(c.outfit, tick, c.state)} alt={`${label} crab`} />
294          </Box>
295          <Box flexShrink={0}>
296            <Text bold color={ORANGE}>{label}</Text>
297          </Box>
298          <Box flexGrow={1} flexShrink={1} minWidth={0}>
299            <Text dimColor wrap="truncate-end">{c.task}</Text>
300          </Box>
301          <Box flexShrink={0}>{status}</Box>
302        </Box>
303      )
304    })
305
306    const zone = (
307      <Box key="agent-crabs" flexDirection="column">
308        {rows}
309        {hidden > 0 ? (
310          <Box paddingX={1}>
311            <Text dimColor>+{hidden} more</Text>
312          </Box>
313        ) : null}
314      </Box>
315    )
316    return below ? <Box flexDirection="column">{zone}{below}</Box> : zone
317  })
318}
319
types/index.d.ts 19 lines
1export type Stage = 'wake' | 'analyze' | 'cook' | 'wrap'
2
3export type Crab = {
4  stage?: Stage
5  id: string
6  name: string
7  outfit: string
8  task: string
9  startedAt: number
10  endedAt?: number
11  state: 'running' | 'done' | 'failed'
12}
13
14declare module 'claude-code' {
15  interface PluginState {
16    'agent-crabs': { crabs: Record<string, Crab>; tick: number }
17  }
18}
19