modscode JA

modscode / Gallery / usage-ball

usage-ball

A two-row band above the Claude Code prompt: rate-limit and context usage, plus a little orange ball that hops along your project's task track. Unofficial.

Code you can checkTerminal + desktopBandToastBoxSvgText

What it does

  • Draws a band above the prompt, toasts
  • Watches TaskCreate, TaskUpdate, TodoWrite calls
  • Hooks session.measure, session.start, turn.complete, turn.start
  • 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 usage-ball by nccu1133060 (band, toast), as modscode read it from the mod's code:
// https://modscode.com/gallery/nccu1133060-usage-ball/
// 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, Svg, Text } = $.ui.resolve(e)
    const track = '…'
    const done = '…'
    const total = '…'
    const counter = '…'
    const ctx = '…'
    const label = '…'
    const amount = '…'
    const reset = '…'
    const label2 = '…'
    const amount2 = '…'
    const reset2 = '…'
    return (
      <Box flexDirection="column">
        <Box flexDirection="row" justifyContent="space-between" alignItems="flex-end" columnGap={5}>
          <Box flexDirection="row" alignItems="flex-end" flexShrink={1}>
            <Svg source={`${track}`} alt={`progress ${done} of ${total}`} height={40} />
            <Box flexDirection="row" alignItems="center" columnGap={1} marginLeft={1}>
              <Text wrap="truncate-end">
                {counter}
              </Text>
              <Text dimColor>
                ctx
              </Text>
              <Box marginLeft={1}>
                <Svg source="#4EBA65" alt="ctx unknown" width="36" height={8} />
              </Box>
              <Text>
                {ctx}
              </Text>
            </Box>
          </Box>
          <Box flexDirection="column" flexShrink={0}>
            <Box flexDirection="row" alignItems="center" columnGap={2}>
              <Box width={3} flexShrink={0}>
                <Text dimColor>
                  {label}
                </Text>
              </Box>
              <Svg source="#4EBA65" alt={`${label} unknown`} height={8} />
              <Box flexShrink={0} justifyContent="flex-end">
                <Text>
                  {amount}
                </Text>
              </Box>
              <Box width={8} flexShrink={0} justifyContent="flex-end">
                <Text dimColor>
                  {reset}
                </Text>
              </Box>
            </Box>
            <Box flexDirection="row" alignItems="center" columnGap={2}>
              <Box width={3} flexShrink={0}>
                <Text dimColor>
                  {label2}
                </Text>
              </Box>
              <Svg source="#4EBA65" alt={`${label} unknown`} height={8} />
              <Box flexShrink={0} justifyContent="flex-end">
                <Text>
                  {amount2}
                </Text>
              </Box>
              <Box width={8} flexShrink={0} justifyContent="flex-end">
                <Text dimColor>
                  {reset2}
                </Text>
              </Box>
            </Box>
          </Box>
        </Box>
        {await next(e)}
      </Box>
    )
  })

  on('session.start', async ($, e, next) => {
    const kind = '…'
    const ctxWarn = '…'
    const reset = '…'
    await $.ui.toast(`${kind} usage passed ${ctxWarn}%${reset}`)
    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 249–338 · Band
  on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
    if (e.props.hasSurvey) return next(e)
    if (!minuteTimer) minuteTimer = $.clock.every(60_000, async () => {
      const display = (await $.state.get(displayRef)).value
      await $.state.set(displayRef, { ...display, startedAt: display?.startedAt ?? 0, minute: Math.floor((await $.clock.now()) / 60_000) })
    })
    const usage = (await $.state.get(usageRef)).value as UsageState | undefined
    const display = (await $.state.get(displayRef)).value
    const flash = (await $.state.get(flashRef)).value
    const now = await $.clock.now()
    const progress = await progressView($, !e.props.isWorking)
    const showWarning = warningVisible((flash?.tick ?? 12) * 250)
    if (e.surface !== 'terminal') {
      // Proportional fonts: bars and track are vector images; columns are boxes, never padding spaces.
      const { Box, Text, Svg } = $.ui.resolve(e)
      const width = e.props.bodyColumns
      const band = layoutBand(width, usage ?? {}, now, warn, ctxWarn, showWarning, display, progress)
      if (e.props.isWorking && !hopTimer) hopTimer = $.clock.every(100, async () => {
        await $.state.set(hopRef, { tick: ((await $.state.get(hopRef)).value?.tick ?? 0) + 1 })
      })
      if (!e.props.isWorking && hopTimer) { hopTimer.cancel(); hopTimer = undefined }
      const hopTick = (await $.state.get(hopRef)).value?.tick ?? 0
      const hop = e.props.isWorking ? HOP[hopTick % HOP.length]! : 0
      const track = trackSvg({ total: Math.max(1, progress.total), shown: progress.shown, pose: progress.pose, hop })
      const level = (percent: number | undefined, limit: number) =>
        percent === undefined ? { dimColor: true } : { color: levelColor(percent, limit) }
      const bar = (label: string, shownPercent: number, percent: number | undefined, limit: number, size: number) =>
        <Svg source={barSvg(shownPercent, size, percent === undefined ? 'success' : levelColor(percent, limit))} alt={`${label} ${percent === undefined ? 'unknown' : Math.round(percent) + '%'}`} width={size} height={8} />
      const quotaSize = band.narrowBars ? 60 : 120
      const quota = (part: typeof band.parts.five, percent: number | undefined, shownPercent: number | undefined) =>
        <Box flexDirection="row" alignItems="center" columnGap={2}>
          <Box width={3} flexShrink={0}><Text dimColor>{part.label.trim()}</Text></Box>
          {band.showBar && bar(part.label.trim(), shownPercent ?? percent ?? 0, percent, warn, quotaSize)}
          <Box width={band.parts.amountWidth} flexShrink={0} justifyContent="flex-end"><Text {...level(percent, warn)}>{part.amount.trim()}</Text></Box>
          {band.showReset && <Box width={8} flexShrink={0} justifyContent="flex-end"><Text dimColor>{part.reset.trim()}</Text></Box>}
        </Box>
      return <Box flexDirection="row" justifyContent="space-between" alignItems="flex-end" columnGap={5} width={width}>
        <Box flexDirection="row" alignItems="flex-end" flexShrink={1}>
          <Svg source={track} alt={progress.total ? `progress ${progress.done} of ${progress.total}` : 'no progress yet'} width={svgWidth(track)} height={TRACK_HEIGHT} />
          <Box flexDirection="row" alignItems="center" columnGap={1} marginLeft={1}>
            {band.parts.counter.trim() && <Text wrap="truncate-end">{band.parts.counter.trim()}</Text>}
            <Text dimColor>ctx</Text>
            {band.showBar && <Box marginLeft={1}>{bar('ctx', display?.context ?? usage?.context ?? 0, usage?.context, ctxWarn, band.narrowBars ? 36 : 64)}</Box>}
            <Text {...level(usage?.context, ctxWarn)}>{band.parts.ctx.trim()}</Text>
          </Box>
        </Box>
        <Box flexDirection="column" flexShrink={0}>
          {quota(band.parts.five, usage?.fiveHour?.percent, display?.fiveHour)}
          {quota(band.parts.seven, usage?.sevenDay?.percent, display?.sevenDay)}
        </Box>
      </Box>
    }
    const { Box, Text } = $.ui.resolve(e)
    const width = Math.max(0, e.props.bodyColumns - 4)
    const rows = composeBand(width, usage ?? {}, now, warn, ctxWarn, showWarning, display, progress)
    const paint = (line: string) => {
      const pieces = []
      const pattern = /●|[┄○…]+|ctx|5h|7d|[⣿⡇⣀]+|⚠️? \d+% left|\d+%|—|\([^)]*\)/gu
      let cursor = 0
      let section: 'ctx' | '5h' | '7d' = '5h'
      for (const match of line.matchAll(pattern)) {
        const at = match.index ?? 0
        if (at > cursor) pieces.push(line.slice(cursor, at))
        const part = match[0]
        if (/^[┄○…]+$/.test(part)) {
          pieces.push(<Text dimColor>{part}</Text>)
          cursor = at + part.length
          continue
        }
        if (part === '●') {
          pieces.push(<Text color="#D97757">{part}</Text>)
          cursor = at + part.length
          continue
        }
        if (part === 'ctx' || part === '5h' || part === '7d') section = part
        const percent = section === 'ctx' ? usage?.context : section === '5h' ? usage?.fiveHour?.percent : usage?.sevenDay?.percent
        const themed = part.startsWith('⣿') || part.startsWith('⡇') || part.startsWith('⣀') || part.includes('%')
        pieces.push(themed && percent !== undefined
          ? <Text color={levelColor(percent, section === 'ctx' ? ctxWarn : warn)}>{part}</Text>
          : <Text dimColor>{part}</Text>)
        cursor = at + part.length
      }
      if (cursor < line.length) pieces.push(line.slice(cursor))
      return pieces
    }
    return <Box flexDirection="column">
      <Text wrap="truncate-end">{paint(rows[0])}</Text>
      <Text wrap="truncate-end">{paint(rows[1])}</Text>
    </Box>
  })
Licence text (MIT)
MIT License

Copyright (c) 2026 nccu1133060

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

reads filestool 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 2fded1b4c99d 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.10 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 nccu1133060/usage-ball
/plugin install usage-ball@usage-ball

This installs the marketplace's latest commit, which may not be the one read here (2fded1b4c99d). 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 "nccu1133060-usage-ball" with its code and make me a pane like it

Search them from Claude: the MCP connector

Similar designs