modscode JA

modscode / Gallery / agent-swarm

agent-swarm

Mission control for your subagents: every spawned agent becomes a live, animated card above the prompt, with its phase, effort, tools, cost and a timeline you can follow

Code you can checkTerminal + desktopBandStatus lineToastBoxButtonText

What it does

  • Draws a band above the prompt, toasts
  • Adds /swarm
  • Watches tool calls
  • Hooks agent.spawn, config.set, prompt.submit, session.start and 3 more
  • Keeps its own state between turns

Good points

  • No network calls
  • Starts no processes
  • Written in TypeScript
  • Has a desktop-specific branch

Code to start from

Two kinds: a starter modscode writes from the design above, and the lines of the mod's own code that draw it.

Starter (register.tsx)

register.tsx
import type { Register } from 'claude-code'

// Drawn like agent-swarm by Jeff Arese (band, status, toast), as modscode read it from the mod's code:
// https://modscode.com/gallery/jeffarese-agent-swarm/
// Written by modscode from that reading, not copied from the mod: use it as you like.
// Each value below stands for one the mod works out at run time; put in your own.
export const register: Register = on => {
  // the band above the prompt; what else goes there is drawn under it
  on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
    const { Box, Text, Button } = $.ui.resolve(e)
    const done = '…'
    const failed = '…'
    const tools = '…'
    const usd = '…'
    const hint = '…'
    const compactLabel = '…'
    const clearLabel = '…'
    const lead = '…'
    const effort = '…'
    const who = '…'
    const at = '…'
    const length = '…'
    const head = '…'
    const facts = '…'
    const fold = '…'
    const clock = '…'
    const head2 = '…'
    const head3 = '…'
    const head4 = '…'
    const tail = '…'
    return (
      <Box flexDirection="column" borderStyle="round" borderDimColor paddingX={1}>
        <Box flexDirection="column" marginBottom={1}>
          <Box justifyContent="space-between" gap={2}>
            <Box flexShrink={1}>
              <Text wrap="truncate-end">
                <Text bold color="claude">
                  ◆
                </Text>
                <Text color="suggestion">
                  {"  0 live"}
                </Text>
                <Text dimColor>
                  {" · "}
                </Text>
                <Text color="success">
                  {`${done} done`}
                </Text>
                <Text dimColor>
                  {" · "}
                </Text>
                <Text color="error">
                  {`${failed} failed`}
                </Text>
                <Text dimColor>
                  {` · ⚒ ${tools}`}
                </Text>
                <Text dimColor>
                  {" · "}
                </Text>
                <Text color="warning">
                  {usd}
                </Text>
                <Text dimColor>
                  {hint}
                </Text>
              </Text>
            </Box>
            <Box gap={2} flexShrink={0}>
              <Button label={`${compactLabel}`} hotkey="v" plain dimColor />
              <Button label={`${clearLabel}`} hotkey="c" plain dimColor />
              <Button label="close" hotkey="x" plain dimColor />
            </Box>
          </Box>
          <Box gap={2} flexShrink={0}>
            <Button label={`${compactLabel}`} hotkey="v" plain dimColor />
            <Button label={`${clearLabel}`} hotkey="c" plain dimColor />
            <Button label="close" hotkey="x" plain dimColor />
          </Box>
        </Box>
        <Box gap={1}>
          0
          0
          0
        </Box>
        <Box gap={1}>
          0
          0
          0
        </Box>
        <Box gap={1}>
          0
          0
          0
        </Box>
        <Box flexDirection="column" marginTop={1} borderStyle="round" paddingX={1}>
          <Box justifyContent="space-between" gap={2} flexDirection="column">
            <Box flexShrink={1}>
              <Text bold wrap="truncate-end">
                {lead}
                <Text>
                  {effort}
                </Text>
                <Text bold={false} dimColor>
                  {`  ${who}`}
                </Text>
              </Text>
            </Box>
            <Box gap={2} flexShrink={0}>
              <Button label={`‹`} hotkey="p" plain dimColor />
              <Text dimColor>
                {`${at}1/${length}`}
              </Text>
              <Button label="›" hotkey="n" plain dimColor />
              <Button label="hide" hotkey="h" plain dimColor />
            </Box>
          </Box>
          <Text bold wrap="truncate-end">
            …
          </Text>
          <Text dimColor italic wrap="wrap">
            {head}
          </Text>
          <Text dimColor wrap="truncate-end">
            {facts}
          </Text>
          <Box marginTop={1} flexDirection="column">
            <Text dimColor>
              {`  ⋯ ${fold} earlier`}
            </Text>
            <Text dimColor>
              ◌ waiting for its first move…
            </Text>
            <Box flexDirection="column">
              <Box>
                <Box width={7} flexShrink={0}>
                  <Text dimColor>
                    {`+${clock}`}
                  </Text>
                </Box>
                <Box width={2} flexShrink={0} />
                <Box flexGrow={1} flexShrink={1} />
                <Box flexShrink={0} marginLeft={1} />
              </Box>
              <Box>
                <Text wrap="wrap">
                  {head2}
                </Text>
              </Box>
            </Box>
            <Box flexDirection="column">
              <Box>
                <Box width={7} flexShrink={0}>
                  <Text dimColor>
                    {`+${clock}`}
                  </Text>
                </Box>
                <Box width={2} flexShrink={0} />
                <Box flexGrow={1} flexShrink={1} />
                <Box flexShrink={0} marginLeft={1} />
              </Box>
              <Box>
                <Text wrap="wrap">
                  {head3}
                </Text>
              </Box>
            </Box>
            <Box flexDirection="column">
              <Box>
                <Box width={7} flexShrink={0}>
                  <Text dimColor>
                    {`+${clock}`}
                  </Text>
                </Box>
                <Box width={2} flexShrink={0} />
                <Box flexGrow={1} flexShrink={1} />
                <Box flexShrink={0} marginLeft={1} />
              </Box>
              <Box>
                <Text wrap="wrap">
                  {head4}
                </Text>
              </Box>
            </Box>
            <Box>
              <Box width={7} flexShrink={0}>
                <Text dimColor>
                  {`+${clock}`}
                </Text>
              </Box>
              <Box width={2} flexShrink={0}>
                <Text>
                  ✎
                </Text>
              </Box>
              <Box flexGrow={1} flexShrink={1}>
                <Text wrap="wrap">
                  {tail}
                  <Text>
                    ▍
                  </Text>
                </Text>
              </Box>
            </Box>
          </Box>
        </Box>
        {await next(e)}
      </Box>
    )
  })

  on('session.start', async ($, e, next) => {
    await $.ui.toast(`Agents view folded · /swarm to reopen`)
    return next(e)
  })
}

The mod's own code

Shown under the mod's licence (MIT); its text is below. Keep the notice if you copy these lines.

hooks/register.tsx lines 1719–1832 · Band
  on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
    const t0 = performance.now()
    try {
      const [isOpen] = await Promise.all([read($, openAtom), restore($)])
      if (e.props.hasSurvey) {
        mounted.delete(e.requestId)
        fullSite = undefined

        return next(e)
      }
      if (isOpen) return await drawFull($, e)
      if (fullSite === e.requestId) fullSite = undefined
      await read($, bandRevAtom)
      const list = ordered(snapshot.filter(a => isLive(a.phase) || (a.endedAt ?? 0) >= batchStart))
      if (list.length === 0) {
        mounted.delete(e.requestId)

        return next(e)
      }
      const { Box, Text, Button } = $.ui.resolve(e)
      const Raster = e.surface === 'terminal' ? $.ui.resolve(e).Raster : undefined
      const Client = e.surface === 'terminal' ? $.ui.resolve(e).Client : undefined
      /** A transparent region over the whole agent, last so it is on top: a click anywhere picks it. */
      const hitArea = (a: SwarmAgent, columns: number, rows: number, inset = 1) =>
        Client === undefined ? null : (
          <Box position="absolute" top={-inset} left={-inset}>
            <Client key={`hit-${coreKey(a.id)}`} module="./hit-area.tsx" props={{ id: a.id }} width={columns} height={rows} />
          </Box>
        )
      const width = Math.max(SQUARE, e.props.bodyColumns)
      const perRow = Math.max(1, Math.floor((width + GAP) / (SQUARE + GAP)))
      const fitRows = Math.max(1, Math.floor((e.props.maxRows - 1) / SQUARE_ROWS))
      const shown = list.slice(0, perRow * fitRows)
      const hidden = list.length - shown.length
      const inner = SQUARE - 2
      const live = list.filter(a => isLive(a.phase)).length
      const cost = totalCost(list)

      bandSite = e.requestId
      const prevCores = mounted.get(e.requestId)
      const cores = new Map<string, Core>()
      mounted.set(e.requestId, cores)

      const square = (a: SwarmAgent) => {
        const color = phaseColor(a.phase)
        const isOn = isLive(a.phase)
        let core
        if (Raster !== undefined) {
          core = <Raster key={coreKey(a.id)} columns={inner} rows={1} cells={coreCells(prevCores, cores, a, inner, 1)} />
        } else {
          core = <Text color={color}>{isOn ? '· • ● • ·' : a.phase}</Text>
        }

        return (
          <Box
            key={`sq-${a.id}`}
            flexDirection="column"
            width={SQUARE}
            borderStyle="round"
            borderColor={isOn ? color : hex(ramp(a.phase)[2])}
            borderDimColor={!isOn}
            hover={{ borderColor: hex(ramp(a.phase)[4]), borderDimColor: false }}
          >
            <Button
              key={`band-pick-${a.id}`}
              label={head(`${PHASE_GLYPH[a.phase]} ${a.name ?? a.type}`, inner)}
              plain
              dimColor={!isOn}
              onPress={() => void select($, a.id, { toggle: false, open: true })}
            />
            {core}
            <Box justifyContent="space-between">
              <Box>
                {effortCells(a.effortLevel).map(c =>
                  c.isOn ? (
                    <Text color={c.color} dimColor={!isOn}>
                      {c.ch}
                    </Text>
                  ) : (
                    <Text dimColor>{c.ch}</Text>
                  ),
                )}
              </Box>
              <Text dimColor>
                {a.phase === 'tool' && a.tool ? a.tool.slice(0, 8) : (costLabel(a) ?? `⚒${a.tools}`)}
              </Text>
            </Box>
            {hitArea(a, SQUARE, SQUARE_ROWS)}
          </Box>
        )
      }

      const rows: SwarmAgent[][] = []
      for (let i = 0; i < shown.length; i += perRow) rows.push(shown.slice(i, i + perRow))

      return (
        <Box flexDirection="column">
          <Text wrap="truncate-end">
            <Text bold color={BRAND}>◆ </Text>
            <Text color="suggestion">{live > 0 ? `${live} working` : 'all finished'}</Text>
            {cost !== undefined && <Text color={COST_COLOR}>{` · ${usd(cost)}`}</Text>}
            <Text dimColor>{`${hidden > 0 ? ` · +${hidden} more` : ''} · click one for details · /swarm unfolds`}</Text>
          </Text>
          {rows.map((row, i) => (
            <Box key={`band-row-${i}`} gap={GAP}>
              {row.map(square)}
            </Box>
          ))}
        </Box>
      )
    } finally {
      record('render.band', performance.now() - t0)
    }
  })
hooks/register.tsx lines 857–1016 · Band
async function drawFull($: EngineInterface, e: RenderInput<'AbovePrompt'>) {
  const t0 = performance.now()
  try {
    const { Box, Text, Button } = $.ui.resolve(e)
    const Raster = e.surface === 'terminal' ? $.ui.resolve(e).Raster : undefined
    const Client = e.surface === 'terminal' ? $.ui.resolve(e).Client : undefined
    /** A transparent region over the whole agent, last so it is on top: a click anywhere picks it. */
    const hitArea = (a: SwarmAgent, columns: number, rows: number, inset = 1) =>
      Client === undefined ? null : (
        <Box position="absolute" top={-inset} left={-inset}>
          <Client key={`hit-${coreKey(a.id)}`} module="./hit-area.tsx" props={{ id: a.id }} width={columns} height={rows} />
        </Box>
      )
    const [, isCompact, selectedId, now] = await Promise.all([
      read($, paneRevAtom),
      read($, compactAtom),
      read($, selectedAtom),
      $.clock.now(),
      restore($),
    ])
    const list = ordered(snapshot)
    const selected = list.find(a => a.id === selectedId)
    shownId = selected?.id ?? ''

    const bodyColumns = Math.max(8, e.props.bodyColumns - FRAME)
    const width = Math.max(MIN_CARD, bodyColumns)
    const perRow = Math.max(1, Math.min(Math.floor((width + GAP) / (MIN_CARD + GAP)), list.length || 1))
    const cardWidth = Math.floor((width - GAP * (perRow - 1)) / perRow)
    const inner = Math.max(8, cardWidth - 4)

    const live = list.filter(a => isLive(a.phase)).length
    const done = list.filter(a => a.phase === 'done').length
    const failed = list.filter(a => a.phase === 'failed' || a.phase === 'stopped').length
    const tools = list.reduce((n, a) => n + a.tools, 0)
    const cost = totalCost(list)
    const isNarrow = bodyColumns < 64
    const closesIn = closeAt === undefined ? undefined : Math.max(0, Math.ceil((closeAt - now) / 1000))

    const prevCores = mounted.get(e.requestId)
    const cores = new Map<string, Core>()
    const surfaceKey = `${e.surface}|${isLightTheme()}`
    fullSite = e.requestId
    mounted.set(e.requestId, cores)

    const heading = (a: SwarmAgent, width?: number) => {
      const isOn = isLive(a.phase)
      const { lead, effort } = headingParts(a)

      return (
        <Box width={width} flexShrink={1}>
          <Text bold={isOn} dimColor={!isOn} color={phaseColor(a.phase)} wrap="truncate-end">
            {lead}
            {effort !== '' && <Text color={effortColor(a.effortLevel)}>{effort}</Text>}
          </Text>
        </Box>
      )
    }

    const badgeOf = (a: SwarmAgent) => {
      const badge = BADGE[a.phase]

      return badge !== undefined ? (
        <Text bold color={BADGE_INK} backgroundColor={phaseColor(a.phase)}>
          {` ${badge} `}
        </Text>
      ) : (
        <Text dimColor>{a.phase.toUpperCase()}</Text>
      )
    }

    /** The agent's description as the control that opens it in the inspector; 1–9 press it. */
    const picker = (a: SwarmAgent, i: number, room: number) => {
      const hotkey = i < 9 ? String(i + 1) : undefined
      const isShown = a.id === selected?.id

      return (
        <Button
          key={`pick-${a.id}`}
          label={head(a.description || a.name || a.type, Math.max(4, room - (hotkey === undefined ? 0 : 3)))}
          hotkey={hotkey}
          plain
          dimColor={!isLive(a.phase) && !isShown}
          onPress={() => void select($, a.id)}
        />
      )
    }

    const borderOf = (a: SwarmAgent) => {
      const isOn = isLive(a.phase)
      const isShown = a.id === selected?.id

      return {
        borderStyle: isShown ? 'bold' : 'round',
        borderColor: isOn || isShown ? phaseColor(a.phase) : hex(ramp(a.phase)[2]),
        borderDimColor: !isOn && !isShown,
        hover: { borderColor: hex(ramp(a.phase)[4]), borderDimColor: false },
      }
    }

    // Compact: one line per agent, headings padded to one width so the animations line up.
    const BADGE_W = 7
    const headW = Math.min(
      Math.floor(width / 3),
      Math.max(0, ...list.map(a => headingParts(a)).map(p => p.lead.length + p.effort.length)),
    )
    const lineCore = Math.max(4, width - headW - BADGE_W - 2)

    const activityOf = (a: SwarmAgent, elapsed: number): string => {
      switch (a.phase) {
        case 'tool':
          return `▸ ${a.tool ?? 'tool'}${a.toolArg ? `  ${a.toolArg}` : ''}`
        case 'thinking':
          return `✻ thinking · step ${a.steps}`
        case 'writing':
          return `✎ writing · step ${a.steps}`
        case 'spawning':
          return `◌ starting${a.isBackground ? ' in background' : ''}…`
        default:
          return `${PHASE_GLYPH[a.phase]} ${a.phase} in ${clock(elapsed)} · ${a.steps} step${a.steps === 1 ? '' : 's'}`
      }
    }

    const line = (a: SwarmAgent, i: number) => {
      const isOn = isLive(a.phase)
      let core
      if (Raster !== undefined) {
        core = <Raster key={coreKey(a.id)} columns={lineCore} rows={1} cells={coreCells(prevCores, cores, a, lineCore, 1)} />
      } else {
        core = (
          <Text color={phaseColor(a.phase)} dimColor={!isOn} wrap="truncate-end">
            {isOn ? '· • ● • ·' : (a.description || '')}
          </Text>
        )
      }

      const elapsed = (a.endedAt ?? now) - a.startedAt
      const cost = costLabel(a)
      const stats = `${cost === undefined ? '' : `${cost} · `}⚒${a.tools} · ${clock(elapsed)}`
      const isShown = a.id === selected?.id

      return (
        <Box key={`line-${a.id}`} flexDirection="column">
          <Box gap={1}>
            {heading(a, headW)}
            <Box width={lineCore}>{core}</Box>
            <Box width={BADGE_W} justifyContent="flex-end">
              {badgeOf(a)}
            </Box>
          </Box>
          <Box paddingLeft={1}>
            <Text color={phaseColor(a.phase)}>{isShown ? '▸' : ' '}</Text>
            {picker(a, i, width - 2)}
          </Box>
          <Box justifyContent="space-between" gap={2} paddingLeft={2}>
            <Box flexShrink={1}>
              <Text color={phaseColor(a.phase)} dimColor wrap="truncate-end">
                {activityOf(a, elapsed)}
              </Text>
            </Box>
            <Box flexShrink={0}>
Licence text (MIT)
MIT License

Copyright (c) 2026 Jeff Arese

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

What its code calls

drives Claudetool callsremembers

The design, read from code

Drawn from the mod's source at the commit read, not from a run: a list is drawn three times, a condition takes its first branch that draws in the desktop app, and a value only the run time knows is shown as a made-up sample (dotted underline) or left out. Colours and type are this site's.

What its code shows

Read from the source at commit eccf465133a5 on 2026-10-06. The first group decides whether a mod is listed; the rest is for you to weigh. A later commit is not read until the next crawl.

Decides the listing: code you can check
Entry readEvery module hooks/hooks.json names was read.hooks/register.tsx
ParsesEvery file parses as TypeScript or JavaScript.5 files parsed
All its code is in the modEvery import is a file of the mod or the engine's own module; no packages, no require.all its code is in the mod
ReadableNo minified lines, no eval or new Function, no import of a computed path, no encoded blobs.no minified code, no eval, no encoded blobs
Calls in the openNetwork and programs are reached as $.http.fetch and $.process.run in place, never passed around.every call outside goes through $ in the open
For you to weigh before installing
Where it drawsThe terminal, the desktop app, both, or nothing (hooks only: a guard or a prompt rewriter), as its code says. Shown, never a reason to leave a mod out.draws in the terminal and the desktop app, the same in both
Install lineWhether its repository's own .claude-plugin/marketplace.json lists it, so it installs from that marketplace with the lines on its page.its repository's .claude-plugin/marketplace.json does not list it: no install line to give
Programs on WindowsWhether every program it starts through $.process exists on Windows (tail, date, open, osascript, /usr/… do not).runs no program a Windows PC lacks
NetworkWhether every fetch names its https host in the code.no network
ProgramsWhether every program it starts is named in the code and is not a shell, an interpreter or a network tool.starts no programs
Reads and sendsWhether it both reads files or environment variables and reaches the network.reaches no network
Keys in the sourceWhether the source holds what looks like an API key or a private key.no keys in the source
LicenceAn open licence (MIT, Apache-2.0, BSD, ISC, Unlicense, 0BSD, CC0) with its text lets modscode show its code; otherwise the code is linked.MIT

This is a reading of the code text, not a security review: it does not run the mod, and it cannot see what a program the mod starts does. The check before installing is yours. How mods are chosen

Install it

Check it yourself before you install it. Mods run unsandboxed, with your permissions, and modscode does not vouch for what this code does. Read the code below (or run claude plugin validate . in its folder), weigh what it reaches, and install the commit you read.

Its repository's .claude-plugin/marketplace.json does not list it, so there is no install line to give. Read it as code, or follow its author's README.

Ask Claude about it

With the modscode connector added, Claude can read this design, what its code reaches and its code, and build on them. Ask it like this:

Read the modscode design "jeffarese-agent-swarm" with its code and make me a pane like it

Search them from Claude: the MCP connector

Similar designs