ModsCode / Claude Code Mods / Ranking / context-gauge
context-gauge
Context, 5h/7d limits, cost, thinking time, tool timeline and a Stop button above the prompt; a foldable side pane; opt-in auto wrap-up near the limit
What it does
- Draws a band above the prompt, a pane, toasts
- Adds /gauge
- Watches tool calls and can refuse them
- Hooks config.set, session.append, session.measure, session.start and 4 more
- Keeps its own state between turns
Good points
- Starts no processes
- 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 context-gauge by kirishimarisano-rgb (pane, band, toast), as ModsCode read it from the mod's code:
// https://modscode.com/claude-mods/mods/kirishimarisano-rgb-context-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 band above the prompt; what else goes there is drawn under it
on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
const { Box, Text, Button, Svg, Client } = $.ui.resolve(e)
const label = '…'
const dur = '…'
const drawn = '…'
const alt = '…'
const name = '…'
const pill = '…'
const slotLabel = '…'
const outputStyle = '…'
const error = '…'
const dur2 = '…'
const status = '…'
const name2 = '…'
const status2 = '…'
const name3 = '…'
const status3 = '…'
const name4 = '…'
const status4 = '…'
const name5 = '…'
const status5 = '…'
const name6 = '…'
const status6 = '…'
const PHASE = '…'
const dur3 = '…'
const dur4 = '…'
const dur5 = '…'
const tps = '…'
const name7 = '…'
const dur6 = '…'
return (
<Box flexDirection="column">
<Box flexDirection="row" flexWrap="wrap">
<Text>
{label}
{" "}
</Text>
<Text dimColor>
{"wrap-up prompt in "}
{dur}
{" "}
</Text>
<Button label="Cancel" hotkey="c" />
<Text>
{" "}
</Text>
<Button label="Send now" dimColor />
</Box>
<Box flexDirection="row" alignItems="center" gap={2}>
<Box flexGrow={1} flexShrink={1} minWidth={10} overflow="hidden">
<Svg source={`${drawn}`} alt={`${alt}`} />
</Box>
<Box flexDirection="row" alignItems="center" gap={2} flexShrink={0}>
<Box flexDirection="row" gap={1} flexShrink={0}>
<Client module="./slider.tsx" />
<Button label={`⚡ ${name} ⌄`} plain />
</Box>
<Box flexDirection="row" gap={1}>
<Button label="◉" plain dimColor />
<Text>
●
</Text>
<Button label="≡" plain dimColor />
</Box>
<Button label="⚙" plain dimColor />
</Box>
</Box>
<Box flexDirection="column" borderStyle="round" paddingX={1}>
<Box flexDirection="row" gap={2} alignItems="center">
<Svg source={`${pill}`} alt="position none" />
<Button label={`⊘ ${slotLabel}`} plain />
<Button label={`⊘ ${slotLabel}`} plain />
<Button label={`⊘ ${slotLabel}`} plain />
</Box>
<Box flexDirection="row" gap={2}>
<Button label="⚡ Fast on" plain />
<Button label={`Style: ${outputStyle}`} plain dimColor />
<Button label="Edit positions" plain dimColor />
<Button label="✕" plain dimColor />
</Box>
</Box>
<Box flexDirection="column" borderStyle="round" paddingX={1}>
<Box flexDirection="row" gap={2}>
<Text bold>
Claude status & usage
</Text>
<Text>
{`check failed: ${error}`}
</Text>
<Text dimColor>
{"· "}
{dur2}
{" ago"}
</Text>
<Button label="↻ Refresh" plain />
<Button label="✕" plain dimColor />
</Box>
<Box flexDirection="row" flexWrap="wrap" gap={2}>
<Box flexDirection="row">
<Text>
{"● "}
</Text>
<Text dimColor>
{name}
{" "}
{status}
</Text>
</Box>
<Box flexDirection="row">
<Text>
{"● "}
</Text>
<Text dimColor>
{name2}
{" "}
{status2}
</Text>
</Box>
<Box flexDirection="row">
<Text>
{"● "}
</Text>
<Text dimColor>
{name3}
{" "}
{status3}
</Text>
</Box>
</Box>
<Text wrap="truncate">
{`Usage: ${error}`}
</Text>
<Text wrap="truncate">
{"⚠ "}
{name4}
{" ("}
{status4}
)
</Text>
<Text wrap="truncate">
{"⚠ "}
{name5}
{" ("}
{status5}
)
</Text>
<Text wrap="truncate">
{"⚠ "}
{name6}
{" ("}
{status6}
)
</Text>
</Box>
<Box flexDirection="row" flexWrap="wrap">
<Text>
{PHASE}
{" "}
</Text>
<Text>
{dur3}
</Text>
<Text>
{" │ "}
</Text>
<Text dimColor>
{"turn "}
{dur4}
</Text>
<Text dimColor>
{" · think "}
{dur5}
</Text>
<Text dimColor>
{" · "}
{tps}
{" tok/s"}
</Text>
<Text dimColor>
{" · "}
{name7}
{" "}
{dur6}
</Text>
<Text>
{" "}
</Text>
<Button label="■ Stop" hotkey="s" />
<Text>
{" "}
</Text>
<Button label="Panel" dimColor />
<Text>
{" "}
</Text>
<Button label="History" dimColor />
</Box>
{await next(e)}
</Box>
)
})
// the pane: open it with $.ui.open({ id: 'my-pane', title: "History" })
on('ui.render', { component: 'Pane', requestId: 'my-pane' }, async ($, e) => {
const { Box, Button, Text } = $.ui.resolve(e)
const title = '…'
const label = '…'
const a = '…'
const b = '…'
const value = '…'
const note = '…'
const label2 = '…'
const a2 = '…'
const b2 = '…'
const value2 = '…'
const note2 = '…'
const label3 = '…'
const a3 = '…'
const b3 = '…'
const value3 = '…'
const note3 = '…'
const usd = '…'
const k = '…'
const ruleText = '…'
const ruleText2 = '…'
const compactText = '…'
const dur = '…'
const title2 = '…'
const PHASE = '…'
const dur2 = '…'
const dur3 = '…'
const thinkMs = '…'
const respondMs = '…'
const toolMs = '…'
const outTokens = '…'
const name = '…'
const dur4 = '…'
const name2 = '…'
const dur5 = '…'
const name3 = '…'
const dur6 = '…'
const title3 = '…'
const dur7 = '…'
const tps = '…'
const tools = '…'
const dur8 = '…'
const dur9 = '…'
const title4 = '…'
const name4 = '…'
const k2 = '…'
const value4 = '…'
const name5 = '…'
const k3 = '…'
const value5 = '…'
const name6 = '…'
const k4 = '…'
const value6 = '…'
return (
<Box flexDirection="column">
<Box flexDirection="row" justifyContent="space-between">
<Button label="◂ expand" plain dimColor hotkey="f" />
<Button label="⚙ settings" plain dimColor />
</Box>
<Box flexDirection="column">
<Box marginTop={1}>
<Text bold>
{title}
</Text>
</Box>
<Box flexDirection="row">
<Text dimColor>
{label}
</Text>
<Text>
{a}
</Text>
<Text>
{b}
</Text>
<Text>
{" "}
{value}
</Text>
<Text dimColor>
{" "}
{note}
</Text>
</Box>
<Box flexDirection="row">
<Text dimColor>
{label2}
</Text>
<Text>
{a2}
</Text>
<Text>
{b2}
</Text>
<Text>
{" "}
{value2}
</Text>
<Text dimColor>
{" "}
{note2}
</Text>
</Box>
<Box flexDirection="row">
<Text dimColor>
{label3}
</Text>
<Text>
{a3}
</Text>
<Text>
{b3}
</Text>
<Text>
{" "}
{value3}
</Text>
<Text dimColor>
{" "}
{note3}
</Text>
</Box>
</Box>
<Box flexDirection="column" marginTop={1}>
<Text dimColor>
{`$${usd} this session`}
{` · auto-compact at ${k}`}
</Text>
<Text dimColor>
{"wrap-up 5h "}
{ruleText}
{" · 7d "}
{ruleText2}
{" · /compact "}
{compactText}
</Text>
</Box>
<Box flexDirection="row" marginTop={1}>
<Text>
{"wrap-up in "}
{dur}
{" "}
</Text>
<Button label="Cancel" />
</Box>
<Box flexDirection="column">
<Box marginTop={1}>
<Text bold>
{title2}
</Text>
</Box>
<Box flexDirection="row">
<Text>
{PHASE}
{" "}
</Text>
<Text>
{dur2}
</Text>
<Text>
{" "}
</Text>
<Button label="■ Stop" hotkey="s" />
</Box>
<Text dimColor>
{"total "}
{dur3}
{" · think "}
{`${thinkMs}0`}
{" · write"}
{" "}
{`${respondMs}0`}
{" · tools"}
{" "}
{`${toolMs}0`}
</Text>
<Text dimColor>
{k}
{" out"}
{` · ${outTokens} tok/s`}
</Text>
<Box flexDirection="row">
<Text>
{"◌ "}
</Text>
<Text dimColor wrap="truncate">
{name}
</Text>
<Text dimColor>
{" "}
{dur4}
</Text>
</Box>
<Box flexDirection="row">
<Text>
{"◌ "}
</Text>
<Text dimColor wrap="truncate">
{name2}
</Text>
<Text dimColor>
{" "}
{dur5}
</Text>
</Box>
<Box flexDirection="row">
<Text>
{"◌ "}
</Text>
<Text dimColor wrap="truncate">
{name3}
</Text>
<Text dimColor>
{" "}
{dur6}
</Text>
</Box>
</Box>
<Box flexDirection="column">
<Box marginTop={1}>
<Text bold>
{title3}
</Text>
</Box>
<Box flexDirection="row">
<Text>
{"● "}
</Text>
<Text>
{dur7}
</Text>
<Text dimColor>
{` · think ${dur}`}
{` · ${tps} tok/s`}
{` · ${tools} tools`}
{" · stopped"}
</Text>
</Box>
<Box flexDirection="row">
<Text>
{"● "}
</Text>
<Text>
{dur8}
</Text>
<Text dimColor>
{` · think ${dur}`}
{` · ${tps} tok/s`}
{` · ${tools} tools`}
{" · stopped"}
</Text>
</Box>
<Box flexDirection="row">
<Text>
{"● "}
</Text>
<Text>
{dur9}
</Text>
<Text dimColor>
{` · think ${dur}`}
{` · ${tps} tok/s`}
{` · ${tools} tools`}
{" · stopped"}
</Text>
</Box>
</Box>
<Box flexDirection="column">
<Box marginTop={1}>
<Text bold>
{title4}
</Text>
</Box>
<Box flexDirection="row">
<Text dimColor>
{name4}
{" "}
</Text>
<Text>
{k2}
</Text>
<Text dimColor>
{" · "}
{value4}
%
</Text>
</Box>
<Box flexDirection="row">
<Text dimColor>
{name5}
{" "}
</Text>
<Text>
{k3}
</Text>
<Text dimColor>
{" · "}
{value5}
%
</Text>
</Box>
<Box flexDirection="row">
<Text dimColor>
{name6}
{" "}
</Text>
<Text>
{k4}
</Text>
<Text dimColor>
{" · "}
{value6}
%
</Text>
</Box>
</Box>
</Box>
)
})
on('session.start', async ($, e, next) => {
const label = '…'
const WRAP_DELAY_MS = '…'
await $.ui.toast(`${label}: wrap-up prompt in ${WRAP_DELAY_MS}s (cancel above the prompt)`)
await $.ui.toast(`${label}: wrap-up prompt sent`)
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.
context-gauge/hooks/register.tsx lines 1043–1202 · Band
on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
if (e.props.hasSurvey) return next(e)
const m = await read($, meter)
const l = await read($, live)
const w = await read($, wrap)
await read($, tick)
if (!m && !l) return next(e)
const look = await lookOf($)
const now = await $.clock.now()
const { Box, Text, Button } = $.ui.resolve(e)
const Svg = svgOf($, e, look.style)
const sep = <Text color={C.rule}> │ </Text>
const ctx = m ? ctxRatio(m) : 0
const ctxColor = tone(ctx, 0.75, 0.9)
const drawn = m && readings(m, ctx, now, look.style)
const gear = <Button key="settings" label="⚙" plain dimColor onPress={() => openSettings($)} />
const chip = await drawChip($, e)
const status = await read($, serviceStatus)
const statusColor_ = !status || status.error ? C.rule : status.indicator === 'none' ? C.ok : status.indicator === 'minor' ? C.warn : C.hot
const extras = (
<Box flexDirection="row" gap={1}>
<Button key="status" label="◉" plain dimColor onPress={() => update($, isStatusOpen, x => !x)} />
<Text color={statusColor_}>{status ? '●' : '○'}</Text>
<Button key="history" label="≡" plain dimColor onPress={() => openTimeline($)} />
</Box>
)
// What the SVG line may take: the band's cells less the controls beside
// it, at a conservative 8px a cell (a desktop UI font's cell is ~7-8px).
const controlCells =
(chip ? 24 + 2 + (await chipNameLength($)) + 2 : 0) +
8
// Buttons take a little more than their cells on desktop (padding), so
// leave room to spare; the meters shrink and clip, the controls never do.
const meterCells = Math.max(16, e.props.bodyColumns - controlCells - 10)
const stripRoom = meterCells * 6.5
const meterRow =
m && drawn && Svg ? (
<Box flexDirection="row" alignItems="center" gap={2}>
<Box flexGrow={1} flexShrink={1} minWidth={10} overflow="hidden">
<Svg source={strip(drawn, m.usd, look, stripRoom)} alt={alt(drawn, m.usd)} />
</Box>
<Box flexDirection="row" alignItems="center" gap={2} flexShrink={0}>
{chip}
{extras}
{gear}
</Box>
</Box>
) : (
m && (
<Box flexDirection="row" gap={1}>
<Box flexGrow={1} flexShrink={1} minWidth={10} flexDirection="row" overflow="hidden">
{(() => {
const fit = fitTextBand(m, ctx, now, meterCells)
const [c1, c2] = bar(ctx, fit.ctxBar)
return (
<Box flexDirection="row">
<Text color={C.accent}>◆ </Text>
<Text dimColor>ctx </Text>
<Text color={ctxColor}>{c1}</Text>
<Text color={C.rule}>{c2}</Text>
<Text color={ctxColor} bold>
{' '}
{m.percent ?? 0}%
</Text>
{fit.tokens && m.tokens !== undefined && (
<Text dimColor>
{' '}
{k(m.tokens)}/{k(m.isAutoCompact && m.threshold ? m.threshold : m.window)}
</Text>
)}
{fit.delta && m.delta ? (
<Text dimColor>
{' '}
{m.delta > 0 ? '+' : ''}
{k(m.delta)}
</Text>
) : null}
{ctx >= 0.9 && <Text color={C.hot}> ⚠ compacts soon</Text>}
{m.limits
.filter(x => fit.kinds.includes(x.kind))
.map(x => {
const c = tone(x.percent / 100, 0.7, 0.9)
const [a, b] = bar(x.percent / 100, fit.blocks, '▰', '▱')
return (
<Box flexDirection="row">
{sep}
<Text dimColor>{limitLabel(x.kind)} </Text>
<Text color={c}>{a}</Text>
<Text color={C.rule}>{b}</Text>
<Text color={c}> {x.percent}%</Text>
{fit.resets && <Text dimColor> {resetIn(x, now)}</Text>}
</Box>
)
})}
{fit.cost && m.usd !== undefined && (
<Box flexDirection="row">
{sep}
<Text dimColor>${m.usd.toFixed(2)}</Text>
</Box>
)}
</Box>
)
})()}
</Box>
<Box flexDirection="row" gap={1} flexShrink={0}>
{chip}
{extras}
{gear}
</Box>
</Box>
)
)
const running = l && l.tools.find(t => t.ms === null)
const tps = l && l.genMs > 500 ? Math.round(l.outTokens / (l.genMs / 1000)) : null
const phaseNow = l ? now - l.phaseSince : 0
const thinkTotal = l ? l.thinkMs + (l.phase === 'thinking' ? phaseNow : 0) : 0
const liveRow = l && (
<Box flexDirection="row" flexWrap="wrap">
<Text color={C.accent}>{PHASE[l.phase]} </Text>
<Text>{dur(phaseNow)}</Text>
{sep}
<Text dimColor>turn {dur(now - l.startedAt)}</Text>
{thinkTotal > 0 && <Text dimColor> · think {dur(thinkTotal)}</Text>}
{tps !== null && <Text dimColor> · {tps} tok/s</Text>}
{running && <Text dimColor> · {running.name} {dur(now - running.startedAt)}</Text>}
<Text> </Text>
<Button key="stop" label="■ Stop" hotkey="s" onPress={() => stopTurn($)} />
<Text> </Text>
<Button key="pane" label="Panel" dimColor onPress={() => $.ui.open({ id: PANE, title: 'Gauge' })} />
<Text> </Text>
<Button key="timeline" label="History" dimColor onPress={() => openTimeline($)} />
</Box>
)
const wrapRow = w.pending && (
<Box flexDirection="row" flexWrap="wrap">
<Text color={C.hot}>{w.pending.label} </Text>
<Text dimColor>wrap-up prompt in {dur(w.pending.deadline - now)} </Text>
<Button key="wrap-cancel" label="Cancel" hotkey="c" onPress={() => cancelWrap($)} />
<Text> </Text>
<Button key="wrap-now" label="Send now" dimColor onPress={() => fireWrap($)} />
</Box>
)
const picker = await drawInlinePicker($, e)
const statusPanel = await drawStatus($, e)
return (
<Box flexDirection="column">
{wrapRow}
{meterRow}
{picker}
{statusPanel}
{liveRow}
</Box>context-gauge/hooks/register.tsx lines 1504–1544 · Band
async function drawChip($: EngineInterface, e: RenderInput<'AbovePrompt'>) {
const s = await read($, settings)
if (!s.models.isShown) return null
const c = await read($, current)
const isOpen = await read($, isPickerOpen)
const { Box, Button } = $.ui.resolve(e)
const Client =
e.surface === 'terminal' || e.surface === 'desktop'
? ($.ui.resolve(e) as { Client?: ElementConstructor<ClientProps> }).Client
: undefined
const at = activeSlot(c, s.models)
const slot = at === null ? undefined : s.models.slots[at]
const name = slot ? slotLabel(slot) : c.model ? modelLabel(familyOf(c.model) ?? c.model) : 'Model'
const n = s.models.slots.length
return (
<Box flexDirection="row" gap={1} flexShrink={0}>
{Client && (
<Client
key="model-track"
module="./slider.tsx"
props={{
labels: s.models.slots.map(slotLabel),
locked: s.models.slots.map(x => isLocked(x, s.models)),
active: at,
accent: CLAUDE,
compact: true,
rail: (c.theme ?? '').startsWith('light') ? '#dcdce0' : '#3a3b40',
}}
width={(n - 1) * 5 + 3}
/>
)}
<Button
key="model-chip"
label={`${c.fast ? '⚡ ' : ''}${name} ${isOpen ? '⌄' : '›'}`}
plain
dimColor={!isOpen}
onPress={() => update($, isPickerOpen, x => !x)}
/>
</Box>
)
}context-gauge/hooks/register.tsx lines 1561–1592 · Band
async function drawInlinePicker($: EngineInterface, e: RenderInput<'AbovePrompt'>) {
if (!(await read($, isPickerOpen))) return null
const { Box, Button } = $.ui.resolve(e)
const s = await read($, settings)
const c = await read($, current)
const at = activeSlot(c, s.models)
const slots = s.models.slots
const locked = slots.map(x => isLocked(x, s.models))
const Svg = e.surface === 'terminal' ? undefined : ($.ui.resolve(e) as { Svg?: ElementConstructor<SvgProps> }).Svg
return (
<Box flexDirection="column" borderStyle="round" borderColor={C.rule} paddingX={1}>
<Box flexDirection="row" gap={2} alignItems="center">
{Svg && <Svg source={pill(slots.length, at, locked, CLAUDE, 0.5 * SCALE[s.look.size])} alt={`position ${at === null ? 'none' : at + 1}`} />}
{slots.map((x, i) => (
<Button
key={`pick-${i}`}
label={`${locked[i] ? '⊘ ' : ''}${slotLabel(x)}`}
plain
dimColor={i !== at}
onPress={() => applySlot($, i)}
/>
))}
</Box>
<Box flexDirection="row" gap={2}>
<Button key="picker-fast" label={c.fast ? '⚡ Fast on' : '⚡ Fast'} plain dimColor={!c.fast} onPress={() => toggleFast($)} />
<Button key="picker-style" label={`Style: ${c.outputStyle ?? 'default'}`} plain dimColor onPress={() => void setStyle($).then(t => $.ui.toast(t))} />
<Button key="picker-settings" label="Edit positions" plain dimColor onPress={() => update($, settingsTab, () => 'models').then(() => openSettings($))} />
<Button key="picker-close" label="✕" plain dimColor onPress={() => update($, isPickerOpen, () => false)} />
</Box>
</Box>
)
}context-gauge/hooks/register.tsx lines 1617–1673 · Band
async function drawStatus($: EngineInterface, e: RenderInput<'AbovePrompt'>) {
if (!(await read($, isStatusOpen))) return null
const { Box, Text, Button } = $.ui.resolve(e)
const st = await read($, serviceStatus)
const usage = await read($, usageCheck)
const m = await read($, meter)
const now = await $.clock.now()
const colorOf = (status: string) =>
status === 'operational' || status === 'none' ? C.ok : status === 'degraded_performance' || status === 'minor' || status === 'under_maintenance' ? C.warn : C.hot
return (
<Box flexDirection="column" borderStyle="round" borderColor={C.rule} paddingX={1}>
<Box flexDirection="row" gap={2}>
<Text bold>Claude status & usage</Text>
{st ? (
<Text color={st.error ? C.hot : colorOf(st.indicator)}>{st.error ? `check failed: ${st.error}` : st.description || st.indicator}</Text>
) : (
<Text dimColor>not checked yet</Text>
)}
{st && <Text dimColor>· {dur(now - st.at)} ago</Text>}
<Button
key="status-refresh"
label="↻ Refresh"
plain
onPress={async () => {
usageAskedAt = 0
await Promise.all([refreshStatus($), checkUsage($)])
}}
/>
<Button key="status-close" label="✕" plain dimColor onPress={() => update($, isStatusOpen, () => false)} />
</Box>
{st && st.components.length > 0 && (
<Box flexDirection="row" flexWrap="wrap" gap={2}>
{st.components.map(c => (
<Box flexDirection="row">
<Text color={colorOf(c.status)}>● </Text>
<Text dimColor>
{c.name} {COMPONENT_LABEL[c.status] ?? c.status.replace(/_/g, ' ')}
</Text>
</Box>
))}
</Box>
)}
{usage && (
<Text color={usage.error ? C.warn : undefined} dimColor={!usage.error} wrap="truncate">
{usage.error
? `Usage: ${usage.error}`
: `Usage, ${dur(now - usage.at)} ago: ${(m?.limits ?? []).map(x => `${limitLabel(x.kind)} ${x.percent}%`).join(' · ')}`}
</Text>
)}
{st?.incidents.map(i => (
<Text color={i.impact === 'none' || i.impact === 'minor' ? C.warn : C.hot} wrap="truncate">
⚠ {i.name} ({i.status})
</Text>
))}
</Box>
)
}context-gauge/hooks/register.tsx lines 1231–1231 · Pane
on('ui.render', { component: 'Pane', requestId: PANE }, ($, e) => drawGauge($, e, e.props.bodyColumns))context-gauge/hooks/register.tsx lines 1897–2056 · Pane
async function drawGauge($: EngineInterface, e: RenderInput<'Pane' | 'CommandOutput'>, columns: number) {
const { Box, Text, Button } = $.ui.resolve(e)
const m = await read($, meter)
const l = await read($, live)
const hist = await read($, history)
const w = await read($, wrap)
const s = await read($, settings)
const collapsed = await read($, isCollapsed)
const look = await lookOf($)
const Svg = svgOf($, e, look.style)
await read($, tick)
const now = await $.clock.now()
const width = Math.max(12, columns - 2)
const barW = Math.max(6, Math.min(24, width - 18))
const ctx = m ? ctxRatio(m) : 0
const drawn = m && readings(m, ctx, now, look.style)
const head = (title: string) => (
<Box marginTop={1}>
<Text color={C.accent} bold>
{title.toUpperCase()}
</Text>
</Box>
)
const header = (
<Box flexDirection="row" justifyContent="space-between" width={width}>
<Button
key="fold"
label={collapsed ? '◂ expand' : '▸ fold'}
plain
dimColor
hotkey="f"
onPress={() => toggleCollapsed($)}
/>
<Button key="pane-settings" label="⚙ settings" plain dimColor onPress={() => openSettings($)} />
</Box>
)
if (collapsed) {
return (
<Box flexDirection="column">
{header}
<Text color={tone(ctx, 0.75, 0.9)}>ctx {m?.percent ?? 0}%</Text>
{(m?.limits ?? []).map(x => (
<Text color={tone(x.percent / 100, 0.7, 0.9)}>
{limitLabel(x.kind)} {x.percent}%
</Text>
))}
{l && <Text color={C.accent}>{PHASE[l.phase]}</Text>}
</Box>
)
}
// The meters: small SVG bars where the surface draws them, text elsewhere.
const meters =
m && drawn && Svg ? (
<Box marginTop={1}>
<Svg source={stack(drawn, width * 7, look)} alt={alt(drawn, m.usd)} />
</Box>
) : (
m && (
<Box flexDirection="column">
{head('Usage')}
{[
{ label: 'ctx', ratio: ctx, value: `${m.percent ?? 0}%`, note: `${k(m.tokens ?? 0)}/${k(m.window)}`, warn: 0.75 },
...m.limits.map(x => ({
label: limitLabel(x.kind),
ratio: x.percent / 100,
value: `${x.percent}%`,
note: resetIn(x, now),
warn: 0.7,
})),
].map(r => {
const [a, b] = bar(r.ratio, barW)
return (
<Box flexDirection="row">
<Text dimColor>{r.label.padEnd(4)}</Text>
<Text color={tone(r.ratio, r.warn, 0.9)}>{a}</Text>
<Text color={C.rule}>{b}</Text>
<Text color={r.ratio >= 0.9 ? C.hot : undefined}> {r.value.padStart(4)}</Text>
<Text dimColor> {r.note}</Text>
</Box>
)
})}
</Box>
)
)
const summary = m && (
<Box flexDirection="column" marginTop={1}>
<Text dimColor>
{m.usd !== undefined ? `$${m.usd.toFixed(2)} this session` : ''}
{m.isAutoCompact && m.threshold ? ` · auto-compact at ${k(m.threshold)}` : ''}
</Text>
<Text dimColor>
wrap-up 5h {ruleText(s.wrap5h)} · 7d {ruleText(s.wrap7d)} · /compact {compactText(s)}
</Text>
</Box>
)
const turnSection = l && (
<Box flexDirection="column">
{head('This turn')}
<Box flexDirection="row">
<Text color={C.accent}>{PHASE[l.phase]} </Text>
<Text>{dur(now - l.phaseSince)}</Text>
<Text> </Text>
<Button key="pane-stop" label="■ Stop" hotkey="s" onPress={() => stopTurn($)} />
</Box>
<Text dimColor>
total {dur(now - l.startedAt)} · think {dur(l.thinkMs + (l.phase === 'thinking' ? now - l.phaseSince : 0))} · write{' '}
{dur(l.respondMs + (l.phase === 'responding' ? now - l.phaseSince : 0))} · tools{' '}
{dur(l.toolMs + (l.phase === 'tool' ? now - l.phaseSince : 0))}
</Text>
<Text dimColor>
{k(l.outTokens)} out{l.genMs > 500 ? ` · ${Math.round(l.outTokens / (l.genMs / 1000))} tok/s` : ''}
</Text>
{l.tools.slice(-8).map(t => {
const ms = t.ms ?? now - t.startedAt
return (
<Box flexDirection="row">
<Text color={t.ms === null ? C.accent : t.isError ? C.hot : C.ok}>
{t.ms === null ? '◌ ' : t.isError ? '✕ ' : '✓ '}
</Text>
<Text dimColor wrap="truncate">
{t.name.replace(/^mcp__/, '').slice(0, 18).padEnd(18)}
</Text>
<Text dimColor> {dur(ms)}</Text>
</Box>
)
})}
</Box>
)
// Plain numbers: block-glyph sparklines smear together in proportional UI fonts.
const recent = hist.slice(-5).reverse()
const historySection = recent.length > 0 && (
<Box flexDirection="column">
{head('Recent turns')}
{recent.map((r, i) => (
<Box flexDirection="row">
<Text color={i === 0 ? undefined : C.rule}>{i === 0 ? '● ' : '○ '}</Text>
<Text>{dur(r.ms)}</Text>
<Text dimColor>
{r.thinkMs ? ` · think ${dur(r.thinkMs)}` : ''}
{r.tps ? ` · ${r.tps} tok/s` : ''}
{r.tools ? ` · ${r.tools} tools` : ''}
{r.isAborted ? ' · stopped' : ''}
</Text>
</Box>
))}
</Box>
)
// Name, then its tokens and share of the window, on one line: a right-aligned
// column does not survive surfaces that lay text out in proportional fonts.
const breakdown = m && m.categories.length > 0 && (
<Box flexDirection="column">
{head('Context breakdown')}Licence text (MIT)
MIT License Copyright (c) 2026 kirishimarisano-rgb 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
networkdrives Claudetool callsrememberscalls tools
What its code shows
Read from the source at commit d866a4fd879e 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.context-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, 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.https://api.anthropic.com, https://status.claude.com (with the session's own Anthropic credential) |
| 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).reads 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: /model; command.run: /effort; command.run: /fast; command.run: /plugin |
| 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.model.complete, adds command gauge |
| 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: config.set, command.run (gauge), session.append, tool.call · shapes: turn.step · reads: ui.message · also: session.start, session.measure, turn.start, turn.complete (+1) · timers: clock.every, clock.after |
| 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.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.the conversation (a row the model reads); settings (config.set) |
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 kirishimarisano-rgb/Claude-code-usage-context-cost-show/plugin install context-gauge@kirishima-mods/reload-pluginsThis installs the marketplace's latest commit, which may not be the one read here (d866a4fd879e). 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/kirishimarisano-rgb/Claude-code-usage-context-cost-showgit -C Claude-code-usage-context-cost-show checkout d866a4fd879ee6609884a3af57ab2920180772d9claude plugin validate Claude-code-usage-context-cost-show/context-gaugeclaude --plugin-dir Claude-code-usage-context-cost-show/context-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 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 "kirishimarisano-rgb-context-gauge" with its code and make me one like itSearch them from Claude: the MCP connector
Similar mods
- cockpitAndré Servaes★ 0
- links-bartripolskiydigital★ 0
- painel-sessaoguilhermebvdm★ 0
- claudelingoKeisuke Yoda★ 2
- hopAGI Hunt★ 2
- a2a-modAliasgar Khimani★ 1
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/kirishimarisano-rgb-context-gauge/)