Clawd Meter: your Claude plan usage above the prompt: session and weekly limits, reset countdowns, pace, context fill and limit warnings.

A mod for Claude Code that keeps your session limit, weekly limit and context fill in view, so you never have to dig through settings to find out how much is left.
<img src="assets/usage-band.webp" alt="Clawd Meter above the Claude Code prompt: Clawd the crab, then Session 35%, Week 16% and Context 25% meters with reset countdowns" width="900">
Type this at the prompt of a Claude Code terminal session:
/plugin install usage-band --marketplace Tanish-Dev/claude-usage-band
Answer y to add the marketplace, then pick the user scope. The band appears in that session straight away, and in every session you start afterwards, the desktop app's Code tab included.
| Session limit | How much of the 5-hour window is used, and the time until it resets |
| Weekly limit | How much of the week is used, and the time until it resets |
| Context | How full the current conversation's context window is |
| Colour that means something | Blue, purple and green gradients at rest; a meter turns orange at 75% and red at 90% |
| Pace | Projects where each window will land: on pace for ~57% by reset, or limit in ~1h 20m at this pace. A meter turns orange early if your pace would hit the limit |
| Limit warnings | A toast when a limit crosses 75%, 90% and 95%, once per threshold per window |
| Details view | One row per meter with reset countdowns, token counts, chat length and cost at API rates |
| Memory | Your chosen view and the last limit reading carry over, so a new session shows numbers before its first reply |
In the desktop app, a small pixel crab sits at the start of the band. It blinks, taps its feet, hops, and waves a claw now and then, and it squints once a limit passes 75%.
Hover it and it comments on your actual numbers:
Only 15% of the session limit used. Plenty of room in the shell.
The session limit resets in 24m. Fresh claws incoming.
Context is 82% full (164k of 200k). A /compact would feel nice.
| Command | What it does |
|---|---|
/usage-band | Prints a usage summary and brings a hidden band back |
/usage-band full | Detailed view |
/usage-band compact | One-line view |
/usage-band hide | Hides the band |
The band works in both, with a few differences:
| Desktop app | Terminal | |
|---|---|---|
| Meters, countdowns, warnings, command | Yes | Yes |
| Smooth gradient bars | Yes | Stepped, one shade per segment |
| Clawd and its hover bubble | Yes | No |
The whole mod is one file, hooks/register.tsx.
claude plugin validate .
claude plugin test .
To run a working copy, start a session with claude --plugin-dir <this folder>.
MIT. An unofficial community mod, not affiliated with or endorsed by Anthropic.
hooks/register.tsx 556 lines1import { atom, read, update } from 'claude-code'
2import type { Register } from 'claude-code'
3
4import type { ContextFill, Limit, Mode, Reading } from '../types'
5
6const reading = atom({ plugin: 'usage-band', key: 'reading' } as const, null)
7const mode = atom({ plugin: 'usage-band', key: 'mode' } as const, 'compact')
8const tick = atom({ plugin: 'usage-band', key: 'tick' } as const, 0)
9const alerted = atom({ plugin: 'usage-band', key: 'alerted' } as const, {})
10
11const MINUTE = 60_000
12const HOUR = 60 * MINUTE
13const DAY = 24 * HOUR
14const THRESHOLDS = [75, 90, 95]
15const FILL = '━'
16// Clawd as pixels, for the surfaces that draw them (the terminal has none): a body with two eye holes,
17// two arms and four legs. It blinks, taps its feet, hops and waves a claw now
18// and then, and squints as the limits fill.
19const clawdSvg = (isSquinting: boolean): string => {
20 const body = '#D97757'
21 const move = (values: string, keyTimes: string, dur: string) =>
22 `<animateTransform attributeName="transform" type="translate" values="${values}" keyTimes="${keyTimes}" dur="${dur}" repeatCount="indefinite"/>`
23 const lids = isSquinting
24 ? `<path fill="${body}" d="M4 2h1v1H4zM11 2h1v1h-1z"/>`
25 : `<path fill="${body}" opacity="0" d="M4 2h1v2H4zM11 2h1v2h-1z"><animate attributeName="opacity" values="0;0;1;0" keyTimes="0;0.95;0.975;1" dur="5s" repeatCount="indefinite"/></path>`
26
27 return [
28 '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -1 16 12" width="24" height="18" shape-rendering="crispEdges">',
29 `<g fill="${body}">`,
30 move('0 0;0 0;0 -1;0 0;0 0', '0;0.6;0.66;0.72;1', '4s'),
31 '<path fill-rule="evenodd" d="M2 0h12v9H2zM4 2v2h1V2zM11 2v2h1V2z"/>',
32 lids,
33 '<path d="M0 4h2v2H0z"/>',
34 `<path d="M14 4h2v2h-2z">${move('0 0;0 -1;0 0;0 -1;0 0;0 0', '0;0.04;0.08;0.12;0.16;1', '7s')}</path>`,
35 `<path d="M3 9h1v2H3zM10 9h1v2h-1z">${move('0 0;0 -1;0 0;0 0', '0;0.05;0.1;1', '4s')}</path>`,
36 `<path d="M5 9h1v2H5zM12 9h1v2h-1z">${move('0 0;0 0;0 -1;0 0;0 0', '0;0.1;0.15;0.2;1', '4s')}</path>`,
37 '</g>',
38 '</svg>',
39 ].join('')
40}
41
42// The system palette: each meter's hue as a deep, a middle and a light shade,
43// the fill running through all three; warm ones as a window fills.
44type Hues = readonly [string, string, string]
45const BLUE: Hues = ['#0055D4', '#0A84FF', '#7FE0FF']
46const PURPLE: Hues = ['#7B2FF7', '#BF5AF2', '#FF7AD9']
47const GREEN: Hues = ['#0E9F4F', '#28BD52', '#9BF5C8']
48const INDIGO: Hues = ['#3634A3', '#5E5CE6', '#A5A4FF']
49const ORANGE: Hues = ['#E07800', '#FF9F0A', '#FFD60A']
50const RED: Hues = ['#C81E1E', '#FF453A', '#FF8A80']
51
52// The colour a share of the way through a meter's three shades.
53const blend = (hues: Hues, share: number): string => {
54 const [from, to] = share < 0.5 ? [hues[0], hues[1]] : [hues[1], hues[2]]
55 const part = share < 0.5 ? share * 2 : (share - 0.5) * 2
56 const channel = (hex: string, at: number) => parseInt(hex.slice(at, at + 2), 16)
57 const mix = (at: number) =>
58 Math.round(channel(from, at) + (channel(to, at) - channel(from, at)) * part)
59 .toString(16)
60 .padStart(2, '0')
61
62 return `#${mix(1)}${mix(3)}${mix(5)}`
63}
64
65// The bar where pixels are drawn: the same thin line, its fill a smooth
66// gradient through the meter's shades.
67const lineSvg = (key: string, percent: number, hues: Hues, width: number): string => {
68 const id = key.replace(/[^a-z0-9]/gi, '')
69 const filled = percent <= 0 ? 0 : Math.min(width, Math.max(4, (percent / 100) * width))
70
71 return [
72 `<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="12" viewBox="0 0 ${width} 12">`,
73 `<defs><linearGradient id="g${id}" gradientUnits="userSpaceOnUse" x1="0" y1="0" x2="${Math.max(filled, 1).toFixed(1)}" y2="0">`,
74 `<stop offset="0" stop-color="${hues[0]}"/><stop offset=".5" stop-color="${hues[1]}"/><stop offset="1" stop-color="${hues[2]}"/>`,
75 '</linearGradient></defs>',
76 `<rect x="0" y="4.5" width="${width}" height="3" rx="1.5" fill="#8E8E93" fill-opacity=".3"/>`,
77 filled > 0
78 ? `<rect x="0" y="4.5" width="${filled.toFixed(1)}" height="3" rx="1.5" fill="url(#g${id})"/>`
79 : '',
80 '</svg>',
81 ].join('')
82}
83
84type Meter = {
85 key: string
86 label: string
87 percent: number
88 hues: Hues
89 // The short tail of the one-line view, and the sentence of the detailed one.
90 brief: string
91 detail: string
92}
93
94const windowMs = (kind: string): number | undefined =>
95 kind.startsWith('five_hour') ? 5 * HOUR : kind.startsWith('seven_day') ? 7 * DAY : undefined
96
97const labelOf = (kind: string): string => {
98 if (kind === 'five_hour') return 'Session'
99 if (kind === 'seven_day') return 'Week'
100 if (kind === 'spend_limit') return 'Spend'
101 if (kind.startsWith('seven_day_')) return `Week ${kind.slice(10).replace(/_/g, ' ')}`
102
103 return kind.replace(/_/g, ' ')
104}
105
106const restHues = (kind: string): Hues =>
107 kind === 'context'
108 ? GREEN
109 : kind.startsWith('five_hour')
110 ? BLUE
111 : kind.startsWith('seven_day')
112 ? PURPLE
113 : INDIGO
114
115const huesOf = (kind: string, percent: number, isHot = false): Hues =>
116 percent >= 90 ? RED : percent >= 75 || isHot ? ORANGE : restHues(kind)
117
118const span = (ms: number): string => {
119 const minutes = Math.max(1, Math.round(ms / MINUTE))
120 if (minutes >= 24 * 60) {
121 const hours = Math.round(minutes / 60)
122
123 return hours % 24 === 0 ? `${hours / 24}d` : `${Math.floor(hours / 24)}d ${hours % 24}h`
124 }
125 if (minutes >= 60) {
126 return minutes % 60 === 0 ? `${minutes / 60}h` : `${Math.floor(minutes / 60)}h ${minutes % 60}m`
127 }
128
129 return `${minutes}m`
130}
131
132const tokens = (count: number): string =>
133 count >= 1_000_000
134 ? `${(count / 1_000_000).toFixed(1)}M`
135 : count >= 1000
136 ? `${Math.round(count / 1000)}k`
137 : String(count)
138
139const whole = (percent: number): string => `${Math.round(percent)}%`
140
141// Where the window ends up if the rest of it is spent as fast as its start.
142const pace = (limit: Limit, left: number): { text: string; isHot: boolean } | undefined => {
143 const length = windowMs(limit.kind)
144 if (length === undefined || left <= 0 || limit.percentUsed <= 0) return undefined
145 const elapsed = length - left
146 if (elapsed < length * 0.05) return undefined
147 const rate = limit.percentUsed / elapsed
148 const projected = limit.percentUsed + rate * left
149 if (limit.percentUsed >= 100) return undefined
150 if (projected >= 100) {
151 return { text: `limit in ~${span((100 - limit.percentUsed) / rate)} at this pace`, isHot: true }
152 }
153
154 return { text: `on pace for ~${whole(projected)} by reset`, isHot: false }
155}
156
157const limitMeter = (limit: Limit, now: number): Meter => {
158 const resetsAt = limit.resetsAt === undefined ? NaN : Date.parse(limit.resetsAt)
159 const left = resetsAt - now
160 // A window whose reset has passed is empty until the next reply says otherwise.
161 if (left <= 0) {
162 return {
163 key: limit.kind,
164 label: labelOf(limit.kind),
165 percent: 0,
166 hues: restHues(limit.kind),
167 brief: 'reset',
168 detail: 'window has reset',
169 }
170 }
171 const ahead = pace(limit, left)
172 const resets = Number.isNaN(left) ? '' : `resets in ${span(left)}`
173
174 return {
175 key: limit.kind,
176 label: labelOf(limit.kind),
177 percent: limit.percentUsed,
178 hues: huesOf(limit.kind, limit.percentUsed, ahead?.isHot),
179 brief: Number.isNaN(left) ? '' : span(left),
180 detail: [resets, limit.percentUsed >= 100 ? 'limit reached' : ahead?.text]
181 .filter(part => part !== undefined && part !== '')
182 .join(' · '),
183 }
184}
185
186const contextMeter = (context: ContextFill): Meter | undefined => {
187 if (context.percent === undefined) return undefined
188
189 return {
190 key: 'context',
191 label: 'Context',
192 percent: context.percent,
193 hues: huesOf('context', context.percent),
194 brief: '',
195 detail:
196 context.tokens === undefined
197 ? `of a ${tokens(context.window)} window`
198 : `${tokens(context.tokens)} of ${tokens(context.window)} tokens`,
199 }
200}
201
202const metersOf = (data: Reading, now: number): Meter[] => {
203 const meters = data.limits.map(limit => limitMeter(limit, now))
204 const context = data.context === undefined ? undefined : contextMeter(data.context)
205
206 return context === undefined ? meters : [...meters, context]
207}
208
209const sessionLine = (data: Reading, now: number): string =>
210 [
211 data.startedAt === undefined ? undefined : `This chat ${span(now - data.startedAt)}`,
212 data.costUsd === undefined || data.costUsd <= 0
213 ? undefined
214 : `$${data.costUsd.toFixed(2)} at API rates`,
215 ]
216 .filter(part => part !== undefined)
217 .join(' · ')
218
219const summary = (data: Reading | null, now: number): string => {
220 const meters = data === null ? [] : metersOf(data, now)
221 if (data === null || meters.length === 0) return 'No usage reading yet: it arrives with the first reply.'
222
223 return [
224 ...meters.map(m => `${m.label}: ${whole(m.percent)}${m.detail === '' ? '' : ` (${m.detail})`}`),
225 sessionLine(data, now),
226 ]
227 .filter(line => line !== '')
228 .join('\n')
229}
230
231// What Clawd says when hovered: lines made from the reading itself, so they
232// change as the numbers do.
233const sayings = (data: Reading, now: number): string[] => {
234 const lines: string[] = []
235 for (const limit of data.limits) {
236 const name =
237 limit.kind === 'five_hour'
238 ? 'session'
239 : limit.kind === 'seven_day'
240 ? 'weekly'
241 : labelOf(limit.kind).toLowerCase()
242 const left = limit.resetsAt === undefined ? NaN : Date.parse(limit.resetsAt) - now
243 if (left <= 0) {
244 lines.push(`The ${name} limit just reset. Fresh claws, full tank.`)
245 continue
246 }
247 const percent = limit.percentUsed
248 const used = whole(percent)
249 lines.push(
250 percent >= 100
251 ? `The ${name} limit is spent. Time to bask on a rock.`
252 : percent >= 90
253 ? `${used} of the ${name} limit gone. Pinching every token now.`
254 : percent >= 75
255 ? `${used} of the ${name} limit used. Getting snappy, pace yourself.`
256 : percent >= 50
257 ? `${used} into the ${name} limit. Steady as she scuttles.`
258 : percent >= 25
259 ? `${whole(100 - percent)} of the ${name} limit still free. Cruising sideways.`
260 : `Only ${used} of the ${name} limit used. Plenty of room in the shell.`,
261 )
262 if (Number.isNaN(left)) continue
263 lines.push(
264 left < 30 * MINUTE
265 ? `The ${name} limit resets in ${span(left)}. Fresh claws incoming.`
266 : percent >= 75
267 ? `${span(left)} until the ${name} limit resets. Hang in there.`
268 : `${span(left)} until the ${name} limit resets. No rush.`,
269 )
270 const ahead = pace(limit, left)
271 if (ahead?.isHot === true) {
272 lines.push(`Careful: ${ahead.text} on the ${name} limit. Maybe slow the scuttle.`)
273 } else if (ahead !== undefined) {
274 lines.push(`You are ${ahead.text} on the ${name} limit. Carry on.`)
275 }
276 }
277
278 const context = data.context
279 if (context?.percent !== undefined) {
280 const size =
281 context.tokens === undefined ? '' : ` (${tokens(context.tokens)} of ${tokens(context.window)})`
282 lines.push(
283 context.percent >= 80
284 ? `Context is ${whole(context.percent)} full${size}. A /compact would feel nice.`
285 : context.percent >= 50
286 ? `Context is ${whole(context.percent)} full${size}. Getting cosy in here.`
287 : `Context is ${whole(context.percent)} full${size}. Lots of room to think.`,
288 )
289 }
290 if (data.costUsd !== undefined && data.costUsd > 0) {
291 lines.push(`$${data.costUsd.toFixed(2)} of tokens at API rates this chat. I am not judging.`)
292 }
293 if (data.startedAt !== undefined) {
294 const age = now - data.startedAt
295 lines.push(
296 age >= 2 * HOUR
297 ? `${span(age)} in this chat. Stretch your claws.`
298 : `${span(age)} into this chat. Nice and fresh.`,
299 )
300 }
301
302 return lines.length === 0 ? ['Snip snip.'] : lines
303}
304
305// JSON data only: a field the engine left out is left out, never `undefined`.
306const plain = <T,>(value: T): T => JSON.parse(JSON.stringify(value)) as T
307
308export const register: Register = on => {
309 on('session.start', async ($, e, next) => {
310 await $.command.register({
311 name: 'usage-band',
312 description: 'Show, hide or expand the usage band above the prompt',
313 argumentHint: '[show|hide|compact|full]',
314 immediate: true,
315 })
316
317 const kept = await $.store.get('mode').catch(() => undefined)
318 if (kept === 'compact' || kept === 'full' || kept === 'hidden') {
319 await update($, mode, () => kept)
320 }
321
322 // Rate limits are the account's, so the last session's reading stands in
323 // until this one's first reply; context and cost are this session's alone.
324 const last = (await $.store.get('limits').catch(() => undefined)) as Limit[] | undefined
325 const usage = await $.session.usage().catch(() => undefined)
326 const limits = usage !== undefined && usage.rateLimits.length > 0 ? usage.rateLimits : last
327 await update($, reading, held =>
328 plain<Reading>({
329 limits: limits ?? held?.limits ?? [],
330 context: usage?.context ?? held?.context,
331 costUsd: usage?.cost?.usd ?? held?.costUsd,
332 startedAt: usage?.startedAt ?? held?.startedAt,
333 }),
334 )
335
336 // The countdowns move with the clock, not with a reply.
337 $.clock.every(30_000, () => void update($, tick, n => n + 1))
338
339 return next(e)
340 })
341
342 on('session.measure', async ($, e, next) => {
343 const held = await read($, reading)
344 const limits = e.rateLimits.length > 0 ? e.rateLimits : (held?.limits ?? [])
345 await update($, reading, was =>
346 plain<Reading>({
347 limits,
348 context: { window: e.context.window, tokens: e.context.tokens, percent: e.context.percent },
349 costUsd: e.cost?.usd ?? was?.costUsd,
350 startedAt: was?.startedAt,
351 }),
352 )
353
354 if (e.rateLimits.length > 0) {
355 await $.store.set('limits', plain(e.rateLimits)).catch(() => undefined)
356 }
357
358 // One warning per threshold per window: the key carries the reset, so the
359 // next window warns afresh.
360 const now = await $.clock.now()
361 const seen = await read($, alerted)
362 const nextSeen: Record<string, number> = {}
363 for (const limit of e.rateLimits) {
364 const key = `${limit.kind}@${limit.resetsAt ?? ''}`
365 const before = seen[key] ?? 0
366 const crossed = THRESHOLDS.filter(t => limit.percentUsed >= t).pop() ?? 0
367 nextSeen[key] = Math.max(before, crossed)
368 if (crossed > before) {
369 const meter = limitMeter(limit, now)
370 $.ui.toast(
371 `${meter.label} limit ${whole(limit.percentUsed)} used${meter.detail === '' ? '' : ` · ${meter.detail}`}`,
372 { timeoutMs: 8000 },
373 )
374 }
375 }
376 await update($, alerted, () => nextSeen)
377
378 return next(e)
379 })
380
381 on('command.run', { command: 'usage-band' }, async ($, e) => {
382 const arg = e.args.trim().toLowerCase()
383 const wanted: Mode | undefined =
384 arg === 'hide' || arg === 'off'
385 ? 'hidden'
386 : arg === 'full' || arg === 'details'
387 ? 'full'
388 : arg === 'compact' || arg === 'show' || arg === 'on'
389 ? 'compact'
390 : undefined
391
392 if (arg !== '' && wanted === undefined) {
393 return { text: `Unknown option "${arg}". Use /usage-band show, hide, compact or full.` }
394 }
395
396 // Bare, it reports and brings a hidden band back.
397 const current = await read($, mode)
398 const target = wanted ?? (current === 'hidden' ? 'compact' : current)
399 await update($, mode, () => target)
400 await $.store.set('mode', target).catch(() => undefined)
401
402 if (target === 'hidden') return { text: `Usage band hidden. /usage-band brings it back.` }
403
404 return { text: summary(await read($, reading), await $.clock.now()) }
405 })
406
407 on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
408 const view = await read($, mode)
409 if (e.props.hasSurvey || view === 'hidden') return next(e)
410
411 const data = await read($, reading)
412 const beat = await read($, tick)
413 const now = await $.clock.now()
414 const meters = data === null ? [] : metersOf(data, now)
415 const table = $.ui.resolve(e)
416 const { Box, Button, Text } = table
417 // Pixels where the surface draws them, glyphs on the terminal.
418 const Svg = e.surface !== 'terminal' && 'Svg' in table ? table.Svg : undefined
419
420 const setMode = async (to: Mode) => {
421 await update($, mode, () => to)
422 await $.store.set('mode', to).catch(() => undefined)
423 }
424 const hide = async () => {
425 await setMode('hidden')
426 $.ui.toast(`Usage hidden · /usage-band brings it back`)
427 }
428
429 if (data === null || meters.length === 0) {
430 return (
431 <Box gap={2}>
432 <Text dimColor>Usage appears after the first reply.</Text>
433 <Button key="hide" role="dismiss" dimColor label="Hide" onPress={hide} />
434 </Box>
435 )
436 }
437
438 const columns = e.props.bodyColumns
439 const fullest = Math.max(...meters.map(meter => meter.percent))
440 const lines = sayings(data, now)
441 const saying = lines[(beat + Math.floor(now / 30_000)) % lines.length] ?? ''
442 // Hovering Clawd shows what it has to say in a talk bubble laid over the
443 // meters beside it, so nothing in the band moves. The terminal has no Clawd.
444 const clawd = Svg !== undefined && (
445 <Box key="clawd" position="relative" alignItems="center" flexShrink={0}>
446 <Svg source={clawdSvg(fullest >= 75)} alt="Clawd" width={24} height={18} />
447 <Box
448 position="absolute"
449 top={0}
450 left={4}
451 display="none"
452 hover={{ display: 'flex' }}
453 paddingX={1}
454 >
455 <Text color="claude">
456 {'◂ '}
457 </Text>
458 <Text color="text" wrap="truncate-end">
459 {saying}
460 </Text>
461 </Box>
462 </Box>
463 )
464 const bar = (meter: Meter, width: number) => {
465 const filled =
466 meter.percent <= 0 ? 0 : Math.min(width, Math.max(1, Math.round((meter.percent / 100) * width)))
467
468 if (Svg !== undefined) {
469 const pixels = width * 12
470
471 return (
472 <Svg
473 source={lineSvg(meter.key, meter.percent, meter.hues, pixels)}
474 alt={`${meter.label} ${whole(meter.percent)}`}
475 width={pixels}
476 height={12}
477 />
478 )
479 }
480 // The terminal's fill runs through the meter's shades cell by cell.
481 const cells = Array.from({ length: filled }, (_, at) =>
482 blend(meter.hues, filled === 1 ? 0 : at / (filled - 1)),
483 )
484
485 return (
486 <Text>
487 {cells.map(colour => (
488 <Text color={colour}>{FILL}</Text>
489 ))}
490 <Text color="subtle">{FILL.repeat(width - filled)}</Text>
491 </Text>
492 )
493 }
494
495 if (view === 'compact') {
496 // One line, always: a proportional font draws the bar's glyphs wide, so
497 // the desktop gets fewer of them, and nothing here may wrap.
498 const width = Svg !== undefined ? 5 : columns >= 100 ? 8 : columns >= 72 ? 5 : 0
499
500 return (
501 <Box columnGap={2} flexWrap="nowrap" alignItems="center">
502 {clawd}
503 {meters.map(meter => (
504 <Box gap={1} flexShrink={0} alignItems="center">
505 <Text dimColor wrap="truncate-end">
506 {meter.label}
507 </Text>
508 {width > 0 && bar(meter, width)}
509 <Text bold color={meter.hues[1]}>
510 {whole(meter.percent)}
511 </Text>
512 {meter.brief !== '' && (
513 <Text dimColor wrap="truncate-end">
514 {meter.brief}
515 </Text>
516 )}
517 </Box>
518 ))}
519 <Button key="details" plain dimColor label="Details" onPress={() => setMode('full')} />
520 </Box>
521 )
522 }
523
524 const labelWidth = Math.max(...meters.map(meter => meter.label.length)) + 2
525 const width = Svg !== undefined ? 14 : Math.max(8, Math.min(28, columns - labelWidth - 48))
526 const footer = sessionLine(data, now)
527
528 return (
529 <Box flexDirection="column">
530 {meters.map(meter => (
531 <Box gap={1} alignItems="center">
532 <Box width={labelWidth}>
533 <Text>{meter.label}</Text>
534 </Box>
535 {bar(meter, width)}
536 <Box width={5} justifyContent="flex-end">
537 <Text bold color={meter.hues[1]}>
538 {whole(meter.percent)}
539 </Text>
540 </Box>
541 <Text dimColor wrap="truncate-end">
542 {meter.detail}
543 </Text>
544 </Box>
545 ))}
546 <Box gap={2}>
547 {clawd}
548 {footer !== '' && <Text dimColor>{footer}</Text>}
549 <Button key="compact" dimColor label="Less" onPress={() => setMode('compact')} />
550 <Button key="hide" role="dismiss" dimColor label="Hide" onPress={hide} />
551 </Box>
552 </Box>
553 )
554 })
555}
556types/index.d.ts 24 lines1export type Limit = { kind: string; percentUsed: number; resetsAt?: string }
2
3export type ContextFill = { window: number; tokens?: number; percent?: number }
4
5export type Reading = {
6 limits: Limit[]
7 context?: ContextFill
8 costUsd?: number
9 startedAt?: number
10}
11
12export type Mode = 'compact' | 'full' | 'hidden'
13
14declare module 'claude-code' {
15 interface PluginState {
16 'usage-band': {
17 reading: Reading | null
18 mode: Mode
19 tick: number
20 alerted: Record<string, number>
21 }
22 }
23}
24