ModsCode / Claude Code Mods / Ranking / usage-hud
usage-hud
输入框下方是三列对齐的模型/用量/状态面板,上方是一只会按工具做动作、带着子代理小螃蟹来回走的像素螃蟹(终端;Windows / macOS / Linux);配速预警和螃蟹情绪、每轮收据、一键压缩、额度恢复提醒、子代理看板 (/hud agents)、点档位切换
What it does
- Draws a pane, a band above the prompt, toasts
- Adds /hud
- Watches tool calls
- Hooks classic.Notification, classic.PermissionRequest, classic.SessionStart, classic.SubagentStart and 9 more
- Keeps its own state between turns
Good points
- No network calls
- Written in TypeScript
- Has a desktop-specific branch
- Handles errors
Code to start from
A starter ModsCode writes from the drawing it read, and the mod's own lines that draw, where there are any.
Starter (register.tsx)
import type { Register } from 'claude-code'
// Drawn like usage-hud by Ronan (pane, band, toast), as ModsCode read it from the mod's code:
// https://modscode.com/claude-mods/mods/ronanworks-usage-hud/
// 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 pane: open it with $.ui.open({ id: 'my-pane', title: "子代理" })
on('ui.render', { component: 'Pane', requestId: 'my-pane' }, async ($, e) => {
const { Box, Text } = $.ui.resolve(e)
const length = '…'
return (
<Box flexDirection="column">
<Box flexDirection="row" height={1}>
<Text color="#d97757" bold>
子代理
</Text>
<Text color="#71717a">
{` 运行中 ${length} · 已结束 ${length}`}
</Text>
</Box>
</Box>
)
})
// the band above the prompt; what else goes there is drawn under it
on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
const { Box, Svg } = $.ui.resolve(e)
const crab = '…'
const dash = '…'
const pct = '…'
return (
<Box flexDirection="column">
<Box flexDirection="row" alignItems="center" columnGap={2}>
<Box flexShrink={0}>
<Svg source={`${crab}`} alt="用量面板的小螃蟹" />
</Box>
<Box flexGrow={1} flexShrink={1} minWidth={0} overflow="hidden">
<Svg source={`${dash}`} alt={`上下文 ${pct}%,5小时 ${pct}%,本周 ${pct}%`} />
</Box>
</Box>
{await next(e)}
</Box>
)
})
on('session.start', async ($, e, next) => {
const err = '…'
await $.ui.toast(`已打开项目文件夹`)
await $.ui.toast(`打开失败: ${err}`)
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.
usage-hud/hooks/register.tsx lines 2341–2344 · Pane
on('ui.render', { component: 'Pane', requestId: AGENTS_PANE }, async ($, e) => {
const els: any = $.ui.resolve(e)
return buildAgentsPane($, els, (e.props as any).bodyColumns ?? 60)
})usage-hud/hooks/register.tsx lines 1827–1937 · Pane
async function buildAgentsPane($: any, els: any, W: number) {
const { Box, Text, Button } = els
const now = await $.clock.now()
await syncAgents($, now)
const shown = [...kids.values()].filter(k => k.known)
const running = shown.filter(k => k.endedAt === undefined).sort((a, b) => a.startedAt - b.startedAt)
const ended = shown
.filter(k => k.endedAt !== undefined)
.sort((a, b) => (b.endedAt ?? 0) - (a.endedAt ?? 0))
.slice(0, KEEP_ENDED)
const width = Math.max(30, W)
const wide = width >= 72
const line = (key: string, cols: Array<[string, number, string?]>) => (
<Box key={key} flexDirection="row" height={1}>
{cols.map(([text, w, color], i) => (
<Text key={key + '-' + i} color={color ?? VALUE}>
{padR(clip(text, w), w) + (i < cols.length - 1 ? ' ' : '')}
</Text>
))}
</Box>
)
// 宽面板一行一个: 状态 | 描述 | 时长 | 最后动静 | 最后工具 | 工具 (次数; 表头不能超过 FIX.n 格, 否则被截成 "工..")
const FIX = { st: 8, ran: 7, idle: 9, tool: 14, n: 5 }
const descW = Math.max(8, width - (FIX.st + FIX.ran + FIX.idle + FIX.tool + FIX.n) - 5)
const row = (k: Kid) => {
const isRun = k.endedAt === undefined
const quiet = now - k.lastAt
const stuck = isRun && quiet > STUCK_MS
const [stText, stColor] = stuck ? ['可能卡住', WARN] : (KID_STATUS[k.status] ?? [safe(k.status) || '已结束', DIM])
const name = k.desc || k.type || safe(k.id)
const ran = dur((k.endedAt ?? now) - k.startedAt)
const idle = isRun ? dur(quiet) + ' 前' : '--'
const tool = k.lastTool ? shortTool(k.lastTool) : '--'
const color = isRun ? (stuck ? WARN : VALUE) : DIM
if (wide) {
return [
line('k-' + k.id, [
[stText, FIX.st, stColor],
[name, descW, color],
[ran, FIX.ran, color],
[idle, FIX.idle, stuck ? WARN : color],
[tool, FIX.tool, color],
[String(k.tools), FIX.n, color],
]),
]
}
// 窄面板两行一个
const detail = isRun ? '已跑 ' + ran + ' · ' + idle + ' ' + tool + ' · ' + k.tools + ' 次' : '用时 ' + ran + ' · ' + k.tools + ' 次工具'
return [
line('k-' + k.id, [
[stText, FIX.st, stColor],
[name, width - FIX.st - 1, color],
]),
line('k2-' + k.id, [
['', FIX.st],
[detail, width - FIX.st - 1, stuck ? WARN : DIM],
]),
]
}
const head = wide
? [
line('k-head', [
['状态', FIX.st, DIM],
['描述', descW, DIM],
['时长', FIX.ran, DIM],
['最后动静', FIX.idle, DIM],
['最后工具', FIX.tool, DIM],
['工具', FIX.n, DIM],
]),
]
: []
const body: any[] = [
<Box key="k-top" flexDirection="row" height={1}>
<Text key="k-title" color={ACCENT} bold>
{'子代理'}
</Text>
<Text key="k-sum" color={DIM}>
{padR(' 运行中 ' + running.length + ' · 已结束 ' + ended.length, Math.max(0, width - 6))}
</Text>
</Box>,
]
if (!shown.length) {
body.push(
<Text key="k-none" color={DIM}>
{'这个会话还没有子代理,Esc 关闭'}
</Text>,
)
}
if (running.length) body.push(...head, ...running.flatMap(row))
if (ended.length) {
body.push(
<Text key="k-ended" color={DIM}>
{'已结束 (最近 ' + KEEP_ENDED + ' 个)'}
</Text>,
...(running.length ? [] : head),
...ended.flatMap(row),
)
}
if (shown.length) {
body.push(
<Text key="k-tip" color={DIM}>
{'运行中超过 5 分钟没有工具动作的会标红,Esc 关闭'}
</Text>,
)
}
return (
<Box key="kids" flexDirection="column" width={width}>
{body}
</Box>
)
}usage-hud/hooks/register.tsx lines 2419–2436 · Band
on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
if (layout === 'off' || e.props.hasSurvey) return next(e)
if (e.surface === 'desktop') {
const els: any = $.ui.resolve(e)
return buildDesktop($, els, e.props.bodyColumns ?? 100, !!e.props.isWorking)
}
if (e.surface !== 'terminal') return next(e)
// bodyColumns 已经扣掉引擎右端放 [-] 的 5 格; maxRows = 这条横栏最多能占几行
// v0.16: 终端版这里只画散步道 (面板固定在输入框下方). 按 maxRows 退档:
// >=4: 天空行 + 3 行版; 3: 天空行 + 2 行版; 2: 2 行版 (没有天空行); 1: 1 行版; 0: 不画
const W = e.props.bodyColumns ?? 100
const maxRows = e.props.maxRows ?? 0
const total = crabOn ? Math.min(4, maxRows) : 0
if (total < 1) return next(e)
const sky = total >= 3
const rows = (sky ? total - 1 : total) as Rows
return walkwayView($, $.ui.resolve(e), W, rows, sky, !!e.props.isWorking)
})usage-hud/hooks/register.tsx lines 1195–1268 · Band
async function buildDesktop($: any, els: any, cols: number, working: boolean) {
const { Box, Svg } = els
const s = await snapshot($, working)
// 会在重置前用完 -> "40m 用完" (红色), 否则只写重置倒计时 "1h20m"; tick = 窗口已过比例 (条上的时间刻度)
const limitMeter = (l: Limit | undefined, p: Pace | undefined): DashData['five'] =>
p?.willRunOut && p.runOutIn !== undefined
? { pct: l?.percentUsed, extra: durShort(p.runOutIn) + ' 用完', warn: true, tick: p.elapsedFrac }
: { pct: l?.percentUsed, extra: p?.resetIn !== undefined ? durShort(p.resetIn) : '', tick: p?.elapsedFrac }
const ag = agentsNow ? ` +${agentsNow} 个子代理` : ''
// 客户端只显示到分钟: 每秒变一次会让图片每秒重换一次
const ran = s.now - turnStartedAt
const status: DashData['status'] = working
? { text: toolLabel(currentTool) + (ran >= 60_000 ? ' ' + durShort(ran) : '') + ag, tone: 'work' }
: agentsNow
? { text: agentsNow + ' 个子代理在跑', tone: 'agents' }
: lastTurnMs
? { text: '✓ 上一轮 ' + dur(lastTurnMs) + ',' + lastTurnTools + ' 次工具', tone: 'idle' }
: { text: '✓ 待命', tone: 'idle' }
const top = Object.entries(toolCounts)
.sort((a, b) => b[1] - a[1])
.slice(0, 3)
.map(([t, n]) => shortTool(t) + ' ' + n)
.join(' ')
const counted = tokState === 'ready' || tokState === 'failed'
const data: DashData = {
model: prettyModel(modelId),
effort,
project: project || '--',
branch: branch ? branch + (dirty ? ' *' + dirty : '') : '',
session: dur(s.now - (s.u.startedAt ?? s.now)),
cost: s.u.cost ? '$' + s.u.cost.usd.toFixed(2) : '',
ctx: { pct: s.pct, extra: tok(s.ctxTokens) + ' / ' + tok(s.ctxWindow) },
five: limitMeter(s.five, s.p5),
week: limitMeter(s.week, s.pw),
status,
tools: top,
tokenTotal: counted ? big(tokTotal(s.tk)) : '统计中..',
tokenOutput: counted ? big(s.tk.output) : '',
}
const sc = s.scene
// 可用宽度: 横栏格数 x 每格像素, 减去螃蟹和间距; 太窄就只放一行用量条
lastDesktopCols = cols
const crabScale = 5
const crabW = 16 * crabScale
// 估计的可用宽度; 故意多画 5% + 20 像素, 让客户端总是把它等比缩到正好贴满卡片, 右边缘和卡片对齐
const est = Math.round((cols || 100) * DESKTOP_PX_PER_COL) - crabW - 15
const dashW = Math.max(340, Math.min(1040, Math.round(est * 1.05) + 20))
const compact = layout === 'compact' || est < 380
// 螃蟹直接画在卡片上 (没有底板/边框); 当普通图片显示, SMIL 动画照样会动, 必须给明确宽高
const crab = crabSvg(
{
// 慌张会把睡着的螃蟹叫醒 (和终端版同一套优先级)
mode: sc.celebrating ? 'celebrate' : working ? 'work' : sc.sleeping && mood !== 'panic' ? 'sleep' : 'idle',
kind: sc.kind,
heat: lastPct >= 95 ? 'crit' : lastPct >= 80 ? 'hot' : 'ok',
agents: Math.min(3, agentsNow),
mood,
},
compact ? 3 : crabScale,
)
const crabSize = compact ? { w: 48, h: 21 } : { w: crabW, h: 7 * crabScale }
const dash = dashSvg(data, { compact, width: dashW })
return (
<Box key="hud-d-row" flexDirection="row" alignItems="center" columnGap={2}>
<Box key="hud-d-crab" flexShrink={0}>
<Svg key="crab-svg" source={crab} alt="用量面板的小螃蟹" width={crabSize.w} height={crabSize.h} />
</Box>
{/* 估计的宽度偏大时, 这个容器允许仪表盘等比缩小, 不会被截断 */}
<Box key="hud-d-dash" flexGrow={1} flexShrink={1} minWidth={0} overflow="hidden">
<Svg key="dash-svg" source={dash} alt={`上下文 ${data.ctx.pct ?? '--'}%,5小时 ${data.five.pct ?? '--'}%,本周 ${data.week.pct ?? '--'}%`} />
</Box>
</Box>
)
}Licence text (MIT)
MIT License Copyright (c) 2026 Ronan 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.
How to build this: Pane (panel), Deny a tool call
What its code calls
runs programsreads filesenv varsdrives Claudetool callsrememberscalls tools
What its code shows
Read from the source at commit a19288cf4ae7 on 2026-10-11. 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 read | Every module hooks/hooks.json names was read.usage-hud/hooks/register.tsx |
| Parses | Every file parses as TypeScript or JavaScript.4 files parsed |
| All its code is in the mod | Every import is a file of the mod or the engine's own module; no packages, no require.all its code is in the mod |
| Readable | No 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 open | Network 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 draws | The 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, with its own branch for the desktop |
| Install line | Whether 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 Windows | Whether every program it starts through $.process exists on Windows (tail, date, open, osascript, /usr/… do not).runs no program a Windows PC lacks |
| Network | Whether every fetch names its https host in the code.no network |
| Programs | Whether every program it starts is named in the code and is not a shell, an interpreter or a network tool.usage-hud/hooks/register.tsx:740 a program named at run time; usage-hud/hooks/register.tsx:792 cmd.exe (a shell or interpreter); usage-hud/hooks/register.tsx:795 powershell.exe (a shell or interpreter); usage-hud/hooks/register.tsx:814 cmd.exe (a shell or interpreter); usage-hud/hooks/register.tsx:1094 node (a shell or interpreter) |
| Reads and sends | Whether it both reads something of yours (files, environment variables, the transcript, settings) and reaches outside (the network, an MCP server, another session, telemetry).reads environment variables, files, settings.json and reaches the network |
| Keys in the source | Whether the source holds what looks like an API key or a private key.no keys in the source |
| Licence | An 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 |
| Settings hooks | Hooks declared in hooks/hooks.json or plugin.json beside the module: a command (a shell when it has no args), an HTTP request, an MCP tool or a model prompt at an event. They run outside $.no settings hooks: its function hooks alone |
| Servers it ships | MCP servers (a program, or a URL; a headersHelper is a shell command; a .mcpb bundle is unpacked at run time), LSP servers, monitors (a shell command for the whole session) and bin/ (on the PATH of the Bash tool).ships no MCP or LSP server, no monitor, no bin/ |
| Skills, commands, agents | What its Markdown declares beyond text: allowed-tools granted for the turn, hooks added when a skill is invoked, a command run before Claude reads the skill.no skills, commands, agents or workflows |
| Tools and MCP | Whether every tool it calls through $.tool.call and $.mcp.call is named in the code, and none is a shell (Bash through the tool runs a shell without $.process).command.run: /?; command.run: /reload-plugins |
| Asks of the model | Completions it runs ($.model.complete, fork, classify), subagents it spawns, prompts it submits as you, and the tools, commands and agents it adds.adds command hud |
| Events it hooks | By what a hook there can do: gates (refuse a tool call, a prompt, a setting, another plugin), shapes (what the model reads: the system prompt, tool descriptions, each request), reads (your input, the events of the settings hooks, every event with *), and the rest.gates: command.run (hud), classic.SubagentStop, tool.call, prompt.submit, classic.PermissionRequest · shapes: turn.step · reads: classic.SessionStart, classic.SubagentStart, prompt.edit, classic.Notification · also: session.start, turn.start, turn.complete, ui.render (TurnDuration, Pane, AbovePrompt (+1)) (+2) · timers: clock.after, clock.every |
| Reads, by name | The environment variables and files it names, and whether it reads the transcript, settings.json, the prompt box or the mouse selection.env: OS, USERPROFILE, HOME, CLAUDE_CONFIG_DIR, WSL_DISTRO_NAME (+4); files: /System/Library/CoreServices, a path computed at run time; settings.json |
| Writes, by name | The files and environment variables it names, and whether it changes settings, the prompt box, the clipboard, the conversation (a row the model reads) or another session.writes no files, environment variables, settings or conversation rows |
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 its code (or run claude plugin validate . in its folder), weigh what it reaches, and install the commit you read.
From its marketplace
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 ronanworks/claude-code-mods/plugin install usage-hud@claude-code-mods/reload-pluginsThis installs the marketplace's latest commit, which may not be the one read here (a19288cf4ae7). Compare them before you install. /reload-plugins loads it into a session that is already open.
Try the commit ModsCode read
No marketplace needed. In a terminal, clone the repository, check out the commit read, validate the mod, and load it for one session:
git clone https://github.com/ronanworks/claude-code-modsgit -C claude-code-mods checkout a19288cf4ae7af6d9c99f6e3fa075f06d129d2bfclaude plugin validate claude-code-mods/usage-hudclaude --plugin-dir claude-code-mods/usage-hudThe validate line lists the events the mod hooks and what it asks Claude Code to do, without running it. The last line loads the mod for this session only and writes nothing to your settings. If the author has rewritten history, the commit may no longer exist.
Ask Claude about it
With the ModsCode connector added, Claude can read this mod's code and what it reaches, and build on them. Ask it like this:
Read the ModsCode mod "ronanworks-usage-hud" with its code and make me one like itSearch them from Claude: the MCP connector
Similar mods
- explain-asSumit Paul★ 20
- uploadsBuild Internet★ 18
- ccprogressamigoer★ 14
- flow-scenesRob Macrae★ 11
- laurelsKOZMOS★ 9
- spending-effort-with-jevYaxin Luo★ 6
More from this repository
Badge for your README
If this is your mod, paste this into your README. It links to this page.
[](https://modscode.com/claude-mods/mods/ronanworks-usage-hud/)