modscode JA

modscode / Gallery / bugdex

bugdex

A monster-battle layer for your coding sessions: failing tests become wild bugs, fixes earn XP, and regression tests catch them for your Bugdex.

Code you can checkTerminal + desktopPaneBandToastBoxButtonSvgText

What it does

  • Draws a band above the prompt, a pane, toasts
  • Adds /bugdex
  • Watches tool calls and can refuse them
  • Hooks prompt.submit, session.measure, session.start, turn.complete
  • 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 bugdex by Ahmet Sahin (pane, band, toast), as modscode read it from the mod's code:
// https://modscode.com/gallery/ahmtsahin-bugdex/
// 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)
    return (
      <Box flexDirection="column">
        <Box flexDirection="row" justifyContent="space-between">
          <Text dimColor wrap="truncate">
            All quiet. Failing tests will show up here.
          </Text>
          <Box flexDirection="row" gap={1}>
            <Button label="Battle" plain dimColor />
            <Button label="Bugdex" plain dimColor />
            <Button label="Hide" plain dimColor />
          </Box>
        </Box>
        {await next(e)}
      </Box>
    )
  })

  // the pane: open it with $.ui.open({ id: 'my-pane', title: "Battle" })
  on('ui.render', { component: 'Pane', requestId: 'my-pane' }, async ($, e) => {
    const { Box, Svg, Text, Button } = $.ui.resolve(e)
    const source = '…'
    const alt = '…'
    const name = '…'
    const level = '…'
    const line = '…'
    const line2 = '…'
    const line3 = '…'
    return (
      <Box flexDirection="column" gap={1}>
        <Box flexDirection="row" justifyContent="space-between" alignItems="flex-end">
          <Svg source={`${source}`} alt={`${alt}`} />
          <Box flexDirection="column" borderStyle="round" paddingX={1}>
            <Box flexDirection="row" justifyContent="space-between">
              <Text bold color="#3fbfa8">
                {name}
              </Text>
              <Text>
                Lv
                {level}
              </Text>
            </Box>
            <Box flexDirection="row" gap={1}>
              <Text bold color="#f8b830">
                HP
              </Text>
              <Box flexDirection="row" height={1}>
                <Box />
                <Box flexGrow={1} backgroundColor="#808080" />
              </Box>
            </Box>
            <Text dimColor>
              {"free context "}
              --
            </Text>
            <Box flexDirection="row" height={1}>
              <Box />
              <Box flexGrow={1} backgroundColor="#808080" />
            </Box>
          </Box>
        </Box>
        <Box flexDirection="row" gap={1}>
          <Box flexDirection="column" flexGrow={1} borderStyle="round" borderColor="#e06050" paddingX={1}>
            <Text>
              {line}
            </Text>
            <Text>
              {line2}
            </Text>
            <Text>
              {line3}
            </Text>
          </Box>
          <Box flexDirection="column" borderStyle="round" paddingX={1}>
            <Button label="Bugdex" plain />
            <Button label="Hide" plain />
          </Box>
        </Box>
      </Box>
    )
  })

  on('session.start', async ($, e, next) => {
    const nameOf = '…'
    await $.ui.toast(`A wild ${nameOf} appeared! Press Battle to watch the fight.`)
    await $.ui.toast(`Bugdex band hidden. /bugdex band on brings it back.`)
    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 278–378 · Band
  on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
    const beneath = await next(e)
    if (e.props.hasSurvey || (await isBandHiddenNow($))) return beneath

    const { Box, Text, Button } = $.ui.resolve(e)
    const [battle, encounter, hp, profile, message] = await Promise.all([
      read($, battleAtom),
      read($, encounterAtom),
      read($, hpAtom),
      profileNow($),
      read($, messageAtom),
    ])
    const level = levelOf(profile.xp)
    const mascot = mascotFor(level).name
    const hpFraction = hp === null ? 1 : hp / 100
    const me = (
      <Text wrap="truncate">
        <Text color={MASCOT_COLOR} bold>
          {mascot}
        </Text>
        <Text dimColor> Lv{level} </Text>
        <Text color={hpColor(hpFraction)}>{bar(hpFraction, 10)}</Text>
        <Text dimColor> {hp === null ? '--' : `${hp}%`}</Text>
        {battle?.isConfused ? <Text color="#c050c0"> Confused</Text> : ''}
      </Text>
    )

    let top
    if (encounter !== null) {
      top = (
        <Text wrap="truncate">
          <Text color="#e8833a" bold>
            A wild {encounter.tool} appeared!
          </Text>
          <Text> {encounter.label}</Text>
          <Text dimColor> Approve to let it through, deny and it flees.</Text>
        </Text>
      )
    } else if (battle !== null) {
      const species = speciesById(battle.speciesId)
      const fraction = battle.maxHp === 0 ? 0 : battle.hp / battle.maxHp
      top = (
        <Box flexDirection="row" justifyContent="space-between">
          <Text wrap="truncate">
            <Text dimColor>Wild </Text>
            <Text color={species?.color ?? '#e06050'} bold>
              {species?.name ?? 'Bug'}
            </Text>
            <Text dimColor> Lv{battle.level} </Text>
            <Text color={hpColor(fraction)}>{bar(fraction, 10)}</Text>
            <Text dimColor>
              {' '}
              {battle.hp}/{battle.maxHp} failing
            </Text>
          </Text>
          {me}
        </Box>
      )
    } else {
      const caught = SPECIES.filter(one => (profile.caught[one.id] ?? 0) > 0).length
      top = (
        <Box flexDirection="row" justifyContent="space-between">
          {me}
          <Text dimColor wrap="truncate">
            XP {profile.xp}/{xpForLevel(level + 1)} · Bugdex {caught}/{SPECIES.length}
          </Text>
        </Box>
      )
    }

    return (
      <Box flexDirection="column">
        {top}
        <Box flexDirection="row" justifyContent="space-between">
          <Text dimColor wrap="truncate">
            {message ?? (battle === null ? 'All quiet. Failing tests will show up here.' : '')}
          </Text>
          <Box flexDirection="row" gap={1}>
            {battle !== null ? (
              <Button key="bugdex-battle" label="Battle" plain dimColor onPress={() => $.ui.open({ id: BATTLE_PANE, title: 'Battle' })} />
            ) : (
              ''
            )}
            <Button key="bugdex-open" label="Bugdex" plain dimColor onPress={() => $.ui.open({ id: PANE, title: 'Bugdex' })} />
            <Button
              key="bugdex-hide"
              label="Hide"
              plain
              dimColor
              onPress={async () => {
                await $.store.set('bandHidden', true)
                await update($, hiddenAtom, () => true)
                $.ui.toast('Bugdex band hidden. /bugdex band on brings it back.')
              }}
            />
          </Box>
        </Box>
        {beneath}
      </Box>
    )
  })
hooks/register.tsx lines 382–482 · Pane
  on('ui.render', { component: 'Pane', requestId: BATTLE_PANE }, async ($, e) => {
    const [battle, hp, profile, message] = await Promise.all([
      read($, battleAtom),
      read($, hpAtom),
      profileNow($),
      read($, messageAtom),
    ])
    const level = levelOf(profile.xp)
    const mascot = mascotFor(level)
    const species = battle === null ? undefined : speciesById(battle.speciesId)
    const toNext = xpForLevel(level + 1) - xpForLevel(level)
    const xpFraction = toNext === 0 ? 1 : (profile.xp - xpForLevel(level)) / toNext
    const hpFraction = hp === null ? 1 : hp / 100
    const cardWidth = Math.min(30, Math.max(20, e.props.bodyColumns - 18))
    const barWidth = cardWidth - 8

    const { Box, Text, Button } = $.ui.resolve(e)

    let foe
    if (battle !== null) {
      const fraction = battle.maxHp === 0 ? 0 : battle.hp / battle.maxHp
      foe = (
        <Box flexDirection="row" justifyContent="space-between" alignItems="flex-start">
          <Box flexDirection="column" borderStyle="round" paddingX={1} width={cardWidth}>
            <Box flexDirection="row" justifyContent="space-between">
              <Text bold color={species?.color} wrap="truncate">
                {species?.name ?? 'Bug'}
              </Text>
              <Text>Lv{battle.level}</Text>
            </Box>
            <Text dimColor wrap="truncate">
              Type: {species?.type ?? 'Bug'}
            </Text>
            <Box flexDirection="row" gap={1}>
              <Text bold color="#f8b830">
                HP
              </Text>
              {meter($, e, fraction, barWidth, hpColor(fraction))}
            </Box>
            <Text dimColor>
              {battle.hp}/{battle.maxHp} failing
            </Text>
          </Box>
          {species === undefined ? '' : picture($, e, `foe-${species.id}`, species, species.name, { scale: BATTLE_PIXEL })}
        </Box>
      )
    } else {
      foe = (
        <Box height={e.surface === 'terminal' ? 6 : 1} alignItems="center" justifyContent="center">
          <Text dimColor>No wild bugs around.</Text>
        </Box>
      )
    }

    const me = (
      <Box flexDirection="row" justifyContent="space-between" alignItems="flex-end">
        {picture($, e, 'mascot', mascot, mascot.name, { scale: BATTLE_PIXEL })}
        <Box flexDirection="column" borderStyle="round" paddingX={1} width={cardWidth}>
          <Box flexDirection="row" justifyContent="space-between">
            <Text bold color={MASCOT_COLOR}>
              {mascot.name}
            </Text>
            <Text>Lv{level}</Text>
          </Box>
          <Box flexDirection="row" gap={1}>
            <Text bold color="#f8b830">
              HP
            </Text>
            {meter($, e, hpFraction, barWidth, hpColor(hpFraction))}
          </Box>
          <Text dimColor>free context {hp === null ? '--' : `${hp}%`}</Text>
          {meter($, e, xpFraction, barWidth + 3, '#40a8f8')}
        </Box>
      </Box>
    )

    const lines =
      battle === null
        ? [message ?? 'All quiet. Failing tests will show up here.']
        : battle.isConfused
          ? [message ?? `${mascot.name} is confused!`, 'Maybe step in.']
          : [message ?? `A wild ${species?.name ?? 'Bug'} appeared!`, 'What will Claude do?']

    return (
      <Box flexDirection="column" gap={1}>
        {foe}
        {me}
        <Box flexDirection="row" gap={1}>
          <Box flexDirection="column" flexGrow={1} borderStyle="round" borderColor="#e06050" paddingX={1}>
            {lines.map((line, i) => (
              <Text key={`line-${i}`}>{line}</Text>
            ))}
          </Box>
          <Box flexDirection="column" borderStyle="round" paddingX={1}>
            <Button key="battle-dex" label="Bugdex" plain onPress={() => $.ui.open({ id: PANE, title: 'Bugdex' })} />
            <Button key="battle-hide" label="Hide" plain onPress={() => $.ui.close({ id: BATTLE_PANE })} />
          </Box>
        </Box>
      </Box>
    )
  })
hooks/register.tsx lines 83–107 · Pane
function picture(
  $: Dollar,
  e: ResolveInput,
  key: string,
  sprite: Sprite,
  alt: string,
  look: { isSilhouette?: boolean; canvas?: Canvas; scale?: number } = {},
) {
  if (e.surface === 'terminal') {
    const { Box, Raster } = $.ui.resolve(e)
    const packed = spriteCells(sprite, look.isSilhouette)
    const raster = <Raster key={key} columns={packed.columns} rows={packed.rows} cells={packed.cells} />
    if (look.canvas === undefined) return raster
    // The canvas in cells, the sprite at its bottom center, as spriteSvg places it.
    return (
      <Box width={look.canvas.columns} height={Math.ceil(look.canvas.rows / 2)} flexDirection="column" justifyContent="flex-end" alignItems="center">
        {raster}
      </Box>
    )
  }
  const { Svg } = $.ui.resolve(e)
  const drawn = spriteSvg(sprite, look.isSilhouette, look.canvas)
  const scale = look.scale ?? CARD_PIXEL
  return <Svg key={key} source={drawn.source} alt={alt} width={drawn.columns * scale} height={drawn.rows * scale} />
}
hooks/register.tsx lines 64–79 · Pane
function meter($: Dollar, e: ResolveInput, fraction: number, width: number, color: string) {
  const { Box, Text } = $.ui.resolve(e)
  if (e.surface === 'terminal') {
    return (
      <Text color={color} wrap="truncate">
        {bar(fraction, width)}
      </Text>
    )
  }
  return (
    <Box flexDirection="row" width={width} height={1}>
      <Box width={filledOf(fraction, width)} backgroundColor={color} />
      <Box flexGrow={1} backgroundColor={TRACK_COLOR} />
    </Box>
  )
}
Licence text (MIT)
MIT License

Copyright (c) 2026 Bugdex contributors

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

tool 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 c25b287348bb 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.4 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.listed in its repository's .claude-plugin/marketplace.json: installs from there
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 is its marketplace. Add that marketplace (in the terminal with these commands, or in the desktop app's plugin settings) and install the mod from it:

/plugin marketplace add ahmtsahin/bugdex
/plugin install bugdex@bugdex

This installs the marketplace's latest commit, which may not be the one read here (c25b287348bb). Compare them before you install.

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 "ahmtsahin-bugdex" with its code and make me a pane like it

Search them from Claude: the MCP connector

Similar designs