ModsCode / Claude Code Mods / Ranking / usage-gauge
usage-gauge
(superseded by rd-ledger) A live cost chip in the prompt footer and a /spend Usage pane: the session's cost, context by category, rate limits, tokens and cache hit per model, subagent share and code changes, without /usage landing in the t…
What it does
- Draws a pane
- Adds /spend
- Watches tool calls and can refuse them
- Hooks session.measure, session.start, turn.complete, turn.step
- 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
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-gauge by Joseph Ayoub (pane), as ModsCode read it from the mod's code:
// https://modscode.com/claude-mods/mods/joseph-ayoub-usage-gauge/
// 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: "Usage" })
on('ui.render', { component: 'Pane', requestId: 'my-pane' }, async ($, e) => {
const { Box, Text, Button } = $.ui.resolve(e)
const label = '…'
const value = '…'
const label2 = '…'
const value2 = '…'
const label3 = '…'
const value3 = '…'
const label4 = '…'
const value4 = '…'
const label5 = '…'
const value5 = '…'
const label6 = '…'
const value6 = '…'
const label7 = '…'
const value7 = '…'
const label8 = '…'
const value8 = '…'
const label9 = '…'
const value9 = '…'
const name = '…'
const name2 = '…'
const name3 = '…'
const PRICE_NOTE = '…'
const line = '…'
const line2 = '…'
const line3 = '…'
const changesLine = '…'
return (
<Box flexDirection="column">
<Box flexDirection="column">
<Box flexDirection="row">
<Box>
<Text wrap="truncate" dimColor>
{label}
</Text>
</Box>
<Box flexGrow={1} justifyContent="flex-end">
<Text wrap="truncate">
{value}
</Text>
</Box>
</Box>
<Box flexDirection="row">
<Box>
<Text wrap="truncate" dimColor>
{label2}
</Text>
</Box>
<Box flexGrow={1} justifyContent="flex-end">
<Text wrap="truncate">
{value2}
</Text>
</Box>
</Box>
<Box flexDirection="row">
<Box>
<Text wrap="truncate" dimColor>
{label3}
</Text>
</Box>
<Box flexGrow={1} justifyContent="flex-end">
<Text wrap="truncate">
{value3}
</Text>
</Box>
</Box>
</Box>
<Box flexDirection="column" marginTop={1}>
<Box flexDirection="row" justifyContent="space-between" alignItems="center">
<Text bold>
Context
</Text>
</Box>
<Box flexDirection="row">
<Box>
<Text wrap="truncate" dimColor>
{label4}
</Text>
</Box>
<Box flexGrow={1} justifyContent="flex-end">
<Text wrap="truncate">
{value4}
</Text>
</Box>
</Box>
<Box flexDirection="row">
<Box>
<Text wrap="truncate" dimColor>
{label5}
</Text>
</Box>
<Box flexGrow={1} justifyContent="flex-end">
<Text wrap="truncate">
{value5}
</Text>
</Box>
</Box>
<Box flexDirection="row">
<Box>
<Text wrap="truncate" dimColor>
{label6}
</Text>
</Box>
<Box flexGrow={1} justifyContent="flex-end">
<Text wrap="truncate">
{value6}
</Text>
</Box>
</Box>
</Box>
<Box flexDirection="column" marginTop={1}>
<Text bold>
Rate limits
</Text>
<Box flexDirection="row">
<Box>
<Text wrap="truncate" dimColor>
{label7}
</Text>
</Box>
<Box flexGrow={1} justifyContent="flex-end">
<Text wrap="truncate">
{value7}
</Text>
</Box>
</Box>
<Box flexDirection="row">
<Box>
<Text wrap="truncate" dimColor>
{label8}
</Text>
</Box>
<Box flexGrow={1} justifyContent="flex-end">
<Text wrap="truncate">
{value8}
</Text>
</Box>
</Box>
<Box flexDirection="row">
<Box>
<Text wrap="truncate" dimColor>
{label9}
</Text>
</Box>
<Box flexGrow={1} justifyContent="flex-end">
<Text wrap="truncate">
{value9}
</Text>
</Box>
</Box>
</Box>
<Box flexDirection="column" marginTop={1}>
<Text bold>
Models
</Text>
<Box flexDirection="column">
<Box flexDirection="row">
<Box>
<Text wrap="truncate">
Model
</Text>
</Box>
<Box justifyContent="flex-end">
<Text wrap="truncate" />
</Box>
<Box justifyContent="flex-end">
<Text wrap="truncate" />
</Box>
<Box justifyContent="flex-end">
<Text wrap="truncate" />
</Box>
</Box>
<Box flexDirection="row">
<Box>
<Text wrap="truncate">
{name}
</Text>
</Box>
<Box justifyContent="flex-end">
<Text wrap="truncate" />
</Box>
<Box justifyContent="flex-end">
<Text wrap="truncate" />
</Box>
<Box justifyContent="flex-end">
<Text wrap="truncate" />
</Box>
</Box>
<Box flexDirection="row">
<Box>
<Text wrap="truncate">
{name2}
</Text>
</Box>
<Box justifyContent="flex-end">
<Text wrap="truncate" />
</Box>
<Box justifyContent="flex-end">
<Text wrap="truncate" />
</Box>
<Box justifyContent="flex-end">
<Text wrap="truncate" />
</Box>
</Box>
<Box flexDirection="row">
<Box>
<Text wrap="truncate">
{name3}
</Text>
</Box>
<Box justifyContent="flex-end">
<Text wrap="truncate" />
</Box>
<Box justifyContent="flex-end">
<Text wrap="truncate" />
</Box>
<Box justifyContent="flex-end">
<Text wrap="truncate" />
</Box>
</Box>
<Box flexDirection="row">
<Box>
<Text wrap="truncate">
Total
</Text>
</Box>
<Box justifyContent="flex-end">
<Text wrap="truncate" />
</Box>
<Box justifyContent="flex-end">
<Text wrap="truncate" />
</Box>
<Box justifyContent="flex-end">
<Text wrap="truncate" />
</Box>
</Box>
<Text dimColor wrap="wrap">
{PRICE_NOTE}
</Text>
</Box>
</Box>
<Box flexDirection="column" marginTop={1}>
<Text bold>
What's contributing
</Text>
<Text>
{line}
</Text>
<Text>
{line2}
</Text>
<Text>
{line3}
</Text>
</Box>
<Box flexDirection="column" marginTop={1}>
<Text bold>
Code changes
</Text>
<Text>
{changesLine}
</Text>
</Box>
<Box marginTop={1}>
<Text dimColor wrap="wrap">
Per-model, per-agent and code figures count from when usage-gauge loaded; the cost is the engine's own, from the sessio…
</Text>
</Box>
<Box flexDirection="row" gap={2} marginTop={1}>
<Button label="Refreshing" hotkey="r" />
<Button label="Close" hotkey="c" role="dismiss" />
</Box>
</Box>
)
})
}
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-gauge/hooks/register.tsx lines 368–527 · Pane
on('ui.render', { component: 'Pane', requestId: PANE }, async ($, e) => {
const { Box, Text, Button } = $.ui.resolve(e)
const v = await readView($)
const isRefreshing = await read($, refreshingRef)
const cols = Math.max(24, Math.floor(e.props.bodyColumns))
const isNarrow = cols < 60
const controls = (
<Box key="controls" flexDirection="row" gap={2} marginTop={1}>
<Button
key="refresh"
label={isRefreshing ? 'Refreshing' : 'Refresh'}
hotkey="r"
dimColor={isRefreshing}
onPress={() => void refresh($, cols).catch(() => undefined)}
/>
<Button key="close" label="Close" hotkey="c" role="dismiss" onPress={() => void $.ui.close({ id: PANE }).catch(() => undefined)} />
</Box>
)
if (!v.usage && v.totals.requests === 0) {
return (
<Box flexDirection="column">
<Text dimColor>Reading usage…</Text>
{controls}
</Box>
)
}
const now = viewNow(v)
const pct = v.usage?.context.percent ?? null
const t = v.totals
// Label left in a fixed column, figure flush with the pane's right edge: the
// value box grows to the rest of the row, so the figures line up on the
// right whatever the pane's width.
type Pair = { key: string; label: string; value: string; isDim?: boolean }
const headline: Pair[] = [
{ key: 'cost', label: 'Cost', value: formatUsd(v.usage?.costUsd ?? null) },
{ key: 'session', label: 'Session', value: formatDuration(sessionMs(v)) },
{ key: 'active', label: 'Active', value: formatDuration(t.activeMs) },
{ key: 'api', label: 'API', value: formatDuration(t.apiMs) },
{ key: 'turns', label: 'Turns', value: formatCount(t.turns) },
{ key: 'requests', label: 'Requests', value: formatCount(t.requests) },
]
if (t.agentTurns > 0) headline.push({ key: 'agent-turns', label: 'Agent turns', value: formatCount(t.agentTurns) })
if (v.usage && !v.usage.hasCost) headline[0] = { key: 'cost', label: 'Cost', value: 'no ledger here', isDim: true }
const context: Pair[] = [{ key: 'window', label: 'Window', value: contextLine(v.usage) }]
const left = untilCompaction(v.breakdown)
if (left !== null) context.push({ key: 'until', label: 'Until compaction', value: formatTokens(left) })
for (const c of categoryRows(v.breakdown, MAX_CATEGORIES)) {
context.push({ key: `cat:${c.name}`, label: c.name, value: `${formatTokens(c.tokens)} · ${formatPercent(c.percent)}`, isDim: c.isDim })
}
const limits: Pair[] = (v.usage?.rateLimits ?? []).map((r, i) => {
const line = rateLine(r, now)
return { key: `rate:${i}`, label: line.label, value: line.value }
})
const labelWidth = isNarrow ? 14 : 20
const pairRows = (pairs: readonly Pair[]) =>
pairs.map(p => (
<Box key={p.key} flexDirection="row">
<Box width={labelWidth}>
<Text wrap="truncate" dimColor>
{p.label}
</Text>
</Box>
<Box flexGrow={1} justifyContent="flex-end">
<Text wrap="truncate" dimColor={p.isDim === true}>
{p.value}
</Text>
</Box>
</Box>
))
const header = (
<Box key="header" flexDirection="column">
{pairRows(headline)}
</Box>
)
// The context fill as a small thin bar at the right of the Context title,
// flush with the pane's edge, so it sits just above the Window figure: on
// the terminal two runs of cells (the track dim); elsewhere a 2 px pill
// SVG that animates from the fill it last drew.
let contextBar
if (e.surface === 'terminal') {
const b = barParts(pct, Math.min(BAR_CELLS, cols - 10))
contextBar = (
<Box key="context-bar" flexDirection="row">
{b.filled !== '' && <Text>{b.filled}</Text>}
{b.track !== '' && <Text dimColor>{b.track}</Text>}
</Box>
)
} else {
const { Svg } = $.ui.resolve(e)
const shown = pct === null ? '--' : `${Math.round(pct)}%`
contextBar = <Svg source={pillSvg(pct, lastBarPercent)} alt={`Context ${shown} used`} width={BAR_WIDTH_PX} height={BAR_HEIGHT_PX} />
lastBarPercent = pct
}
// The model table: columns sized to the body; on a narrow pane only
// output, est. $ and share stay, and on a middling one the least telling
// columns drop until the model name has room.
type Col = { key: string; title: string; width: number; value: (l: ModelLine) => string }
const allCols: Col[] = [
{ key: 'req', title: 'Req', width: 7, value: l => formatCount(l.requests) },
{ key: 'in', title: 'Input', width: 9, value: l => formatTokens(l.input) },
{ key: 'out', title: 'Output', width: 9, value: l => formatTokens(l.output) },
{ key: 'cr', title: 'Cache rd', width: 10, value: l => formatTokens(l.cacheRead) },
{ key: 'cw', title: 'Cache wr', width: 10, value: l => formatTokens(l.cacheWrite) },
{ key: 'hit', title: 'Hit', width: 6, value: l => formatPercent(l.hit) },
// A total with an unpriced model in it is a floor, marked `+`, never a complete figure.
{ key: 'est', title: 'Est. $', width: 11, value: l => (l.estUsd === null ? '--' : `${formatUsd(l.estUsd)}${l.isPartial ? '+' : ''}`) },
{ key: 'share', title: 'Share', width: 7, value: l => (l.share === null ? '--' : formatPercent(l.share)) },
]
let cols2 = isNarrow ? allCols.filter(c => c.key === 'out' || c.key === 'est' || c.key === 'share') : allCols
for (const drop of ['req', 'cw', 'in', 'cr']) {
if (isNarrow || cols - cols2.reduce((s, c) => s + c.width, 0) >= 14) break
cols2 = cols2.filter(c => c.key !== drop)
}
const nameWidth = Math.max(8, cols - cols2.reduce((s, c) => s + c.width, 0))
const { rows: modelRows, total } = modelLines(v.models)
const tableRow = (key: string, name: string, values: string[], isDim: boolean, isBold: boolean) => (
<Box key={key} flexDirection="row">
<Box width={nameWidth}>
<Text wrap="truncate" dimColor={isDim} bold={isBold}>
{name}
</Text>
</Box>
{cols2.map((c, i) => (
<Box key={`${key}:${c.key}`} width={c.width} justifyContent="flex-end">
<Text wrap="truncate" dimColor={isDim} bold={isBold}>
{values[i] ?? ''}
</Text>
</Box>
))}
</Box>
)
const contributing = contributionLines(v.loops)
const section = (title: string) => <Text bold>{title}</Text>
return (
<Box flexDirection="column">
{header}
<Box key="context" flexDirection="column" marginTop={1}>
<Box key="context-title" flexDirection="row" justifyContent="space-between" alignItems="center">
{section('Context')}
{contextBar}
</Box>
{pairRows(context)}
</Box>
<Box key="limits" flexDirection="column" marginTop={1}>
{section('Rate limits')}
{limits.length === 0 ? <Text dimColor>none reported</Text> : pairRows(limits)}
</Box>Licence text (MIT)
MIT License Copyright (c) 2026 Joseph Ayoub 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
drives Claudetool callsremembers
What its code shows
Read from the source at commit 86951e26d68a. 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-gauge/hooks/register.tsx |
| Parses | Every file parses as TypeScript or JavaScript.3 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, the same in both |
| 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.starts no programs |
| 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).reaches nothing outside |
| 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).calls no tool, MCP server or command |
| 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 spend |
| 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: tool.call, command.run (spend) · shapes: turn.step · also: session.start, session.measure, turn.complete, ui.render (PromptHint, SessionMode, Pane) |
| 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.reads no files, environment variables, settings or transcript |
| 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 Joseph-Ayoub/claude-mods/plugin install usage-gauge@joseph-mods/reload-pluginsThis installs the marketplace's latest commit, which may not be the one read here (86951e26d68a). 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/Joseph-Ayoub/claude-modsgit -C claude-mods checkout 86951e26d68a4ca2b7f4f444bb7956e57a43962cclaude plugin validate claude-mods/usage-gaugeclaude --plugin-dir claude-mods/usage-gaugeThe 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 or ChatGPT about it
With ModsCode added as a connector, Claude or ChatGPT can read this mod's code, what it reaches and how its controls are wired, and build on them. Ask it like this:
Read the ModsCode mod "joseph-ayoub-usage-gauge" with its code and make me one like itAdd the ModsCode MCP to Claude or ChatGPT
Similar mods
- blast-radiusdeepseek-ai★ 247,289
- replay-theaterdeepseek-ai★ 247,289
- ruview-liveruvnet★ 97,814
- ruflo-swarmruvnet★ 74,447
- code-modernizationAnthropic★ 37,809
- seo-cockpitAgrici Daniel★ 18,364
More from this repository
- cockpitJoseph Ayoub★ 0
- mem-gaugeJoseph Ayoub★ 0
- merge-laneJoseph Ayoub★ 0
- model-pinJoseph Ayoub★ 0
- rd-ledgerJoseph Ayoub★ 0
- secret-guardJoseph Ayoub★ 0
See all 9 mods in 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/joseph-ayoub-usage-gauge/)