SLOPSHOPPER

context-status

Band above the prompt with the current model, effort, context window usage and the 5-hour and weekly limits

bandstatustimer
v0.4.0no licenseupdated 2026-10-22filip-git-git/claude-context-status/context-status
A shopper browsing a rack in a slop shop
Preview · a replayed session in a sandbox
claude · ~/work/app · context-status
› fix the failing auth test and add an audit log call ⏺ Read(src/auth.ts) ⎿ Read 6 lines ⏺ Update(src/auth.ts) ⎿ Added 2 lines, removed 1 line ⏺ Bash(bun test) ⎿ 3 pass, 1 fail ● Done. refresh now rejects expired claims and logs an audit event. ✻ Worked for 42s · done 4:20 PM Opus 5.5 · ctx █████░░░░░ 49% · 97.4k/200k │ 5h ██░░░ 31% ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── › ? for shortcuts

Draws

Band
Opus 5.5 · ctx █████░░░░░ 49% · 97.4k/200k │ 5h ██░░░ 31%
README

claude-context-status

A Claude Code mod that keeps the current model, its effort level, the context window usage and your 5-hour and weekly limits always visible in a line drawn just above the prompt.

Opus 5.5 · high · ctx ████░░░░░░ 42% · 420k/1M │ 5h █░░░░ 23% 2h14m │ 7d ██░░░ 41% 3d4h

Features

  • Current model: the main-loop model as /model shows it, with ids like claude-opus-5-5 shortened to Opus 5.5.
  • Effort level: low to max. Before the first turn it comes from your settings (modelSettings.<model>.effortLevel, then effortLevel); after each turn it is the effort the request was actually sent with. Models without an effort setting show none.
  • Context usage: a 10-cell bar, the percentage, and tokens used out of the window size (84k/200k, 1M).
  • 5-hour and weekly limits: how much of each window is used, with a 5-cell bar and the time until it resets (45m, 2h14m, 3d4h). Shown on a subscription once Claude Code has a reading; with an API key, or before the first reply, the segments are left out. After a window resets and before the next reading, it shows —.
  • Colors by usage: each bar is green below 80%, yellow from 80%, and red with a compact soon note from 95%. Colors follow your Claude Code theme.
  • No extra API traffic: it only reads figures the session already has.

Before the model's first reply in a session, Claude Code has no usage figure yet, so the line shows ctx — · 200k until then.

The line steps aside while Claude Code shows a survey in the same place. When the terminal is too narrow for the whole line, it drops the token counts first, then the reset countdowns, then the limit bars; the percentages stay.

How it updates

The line is refreshed after every turn, whenever Claude Code measures the session, and every 5 seconds. Mods get no event when you switch models with /model or change the effort, so the 5-second check is what picks up a switch between turns. The same check moves the reset countdowns on, redrawing at most once a minute. The text is only redrawn when it actually changes.

Requirements

Claude Code with mod (function hooks) support. Developed and tested on 2.1.296.

Installation

In Claude Code (2.1.275 or later), run:

/plugin install context-status --marketplace filip-git-git/claude-context-status

Answer y to add the marketplace, then pick a scope (user scope loads it in every session). The line appears right away.

From a local clone

Clone the repository:

git clone https://github.com/filip-git-git/claude-context-status.git

Start Claude Code with the mod folder:

claude --plugin-dir /path/to/claude-context-status/context-status

To load it in every session without the flag, add the folder to CLAUDE_CODE_PLUGIN_DIRS, either in your environment or in the env block of ~/.claude/settings.json:

{
  "env": {
    "CLAUDE_CODE_PLUGIN_DIRS": "/path/to/claude-context-status/context-status"
  }
}

Development

context-status/
├── .claude-plugin/plugin.json      manifest
├── hooks/
│   ├── hooks.json                  points at the hooks module
│   ├── register.tsx                event wiring and the band above the prompt
│   ├── effort-level.ts             which effort level to show
│   ├── rate-limits.ts              5-hour and weekly windows, countdowns
│   ├── status-line.ts              composes the line and fits it to the width
│   └── format-status.ts            pure formatting of the line
├── types/index.d.ts                state contract
└── tests/                        *.test.ts and shared engine stubs

Validate the mod and run the tests:

claude plugin validate context-status
claude plugin test context-status

Thresholds (80% / 95%) and the poll interval (5 s) are constants at the top of format-status.ts and register.tsx.

Source 6 files
hooks/register.tsx 121 lines
1// Draws a band above the prompt: model, effort, context window fill, and the 5-hour and weekly limits.
2import { atom, read, update } from 'claude-code'
3import type { EngineInterface, Register, Timer } from 'claude-code'
4
5import { effortFromSettings, pickEffort } from './effort-level'
6import type { EffortTracker } from './effort-level'
7import { countdownMinute, pickLimits } from './rate-limits'
8import type { RateLimitReading } from './rate-limits'
9import { fitLine } from './status-line'
10import type { Tone } from './status-line'
11import type { ContextFigures, StatusSnapshot } from '../types'
12
13// /model and /effort have no mod event, so a cheap poll catches a switch between turns;
14// it also moves the reset countdowns on, at most once a minute.
15const POLL_MS = 5000
16
17const TONE_COLOR: Record<Exclude<Tone, 'dim' | 'plain'>, string> = {
18  unknown: 'subtle',
19  ok: 'success',
20  warn: 'warning',
21  critical: 'error',
22}
23
24// What session.measure pushes; refresh reads the same from $.session.usage() otherwise.
25type Measured = { context: ContextFigures; rateLimits: readonly RateLimitReading[] }
26
27const snapshot = atom({ plugin: 'context-status', key: 'snapshot' } as const, null)
28
29function isSame(a: StatusSnapshot | null, b: StatusSnapshot): boolean {
30  return a !== null && JSON.stringify(a) === JSON.stringify(b)
31}
32
33// Reads model, effort, usage and limits (all local, free calls); the band redraws only when a figure changed.
34async function refresh($: EngineInterface, tracker: EffortTracker, measured?: Measured): Promise<void> {
35  try {
36    const model = await $.session.model()
37    const settings = await $.settings.read()
38    const effort = pickEffort(tracker, effortFromSettings(settings, model), model)
39    const { context, rateLimits } = measured ?? (await $.session.usage())
40    const limits = pickLimits(rateLimits)
41    const minute = countdownMinute(limits, await $.clock.now())
42    const next: StatusSnapshot = {
43      model,
44      effort,
45      context: { tokens: context.tokens, window: context.window, percent: context.percent },
46      limits,
47      minute,
48    }
49    const previous = await read($, snapshot)
50    if (!isSame(previous, next)) {
51      await update($, snapshot, () => next)
52    }
53  } catch {
54    // Keep the last known figures; a failed read must never break the session.
55  }
56}
57
58function toneProps(tone: Tone): { dimColor?: boolean; color?: string } {
59  if (tone === 'dim') {
60    return { dimColor: true }
61  }
62
63  return tone === 'plain' ? {} : { color: TONE_COLOR[tone] }
64}
65
66export const register: Register = on => {
67  let poll: Timer | undefined
68  const tracker: EffortTracker = {}
69
70  on('session.start', async ($, e, next) => {
71    $.ui.status(undefined) // clears the line version 0.1.0 of this mod pinned
72    await refresh($, tracker)
73    poll?.cancel()
74    poll = $.clock.every(POLL_MS, () => void refresh($, tracker))
75
76    return next(e)
77  })
78
79  // The effort the main loop actually sends, after any downgrade for the model.
80  on('turn.step', async function* ($, e, next) {
81    if (e.agentId === undefined && e.effort !== tracker.fromTurn) {
82      tracker.fromTurn = e.effort
83      await refresh($, tracker)
84    }
85
86    return yield* next(e)
87  })
88
89  on('session.measure', async ($, e, next) => {
90    await refresh($, tracker, e)
91
92    return next(e)
93  })
94
95  on('turn.complete', async ($, e, next) => {
96    const result = await next(e)
97    await refresh($, tracker)
98
99    return result
100  })
101
102  on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
103    const current = await read($, snapshot)
104    if (e.props.hasSurvey || current === null) {
105      return next(e)
106    }
107    const { Box, Text } = $.ui.resolve(e)
108    const pieces = fitLine(current, e.props.bodyColumns)
109
110    return (
111      <Box key="context-status">
112        {pieces.map((piece, index) => (
113          <Text key={`p${index}`} wrap="truncate" {...toneProps(piece.tone)}>
114            {piece.text}
115          </Text>
116        ))}
117      </Box>
118    )
119  })
120}
121
hooks/effort-level.ts 47 lines
1// Works out which reasoning effort to show: the last main-loop request's, or the settings' value.
2
3export type EffortValue = string | number
4
5// What the mod has seen of the effort so far.
6export type EffortTracker = {
7  // The effort the last main-loop model request was sent with.
8  fromTurn?: EffortValue
9  // The settings' value at the previous read, to tell when it changed.
10  lastSettings?: EffortValue
11  // The model the last read was for, to tell when it changed.
12  lastModel?: string
13}
14
15function asEffort(value: unknown): EffortValue | undefined {
16  return typeof value === 'string' || typeof value === 'number' ? value : undefined
17}
18
19// modelSettings["<model id>"].effortLevel wins over the top-level effortLevel.
20export function effortFromSettings(settings: Readonly<Record<string, unknown>>, model: string): EffortValue | undefined {
21  const perModel = settings['modelSettings']
22  if (typeof perModel === 'object' && perModel !== null) {
23    const entry = (perModel as Record<string, unknown>)[model]
24    if (typeof entry === 'object' && entry !== null) {
25      const level = asEffort((entry as Record<string, unknown>)['effortLevel'])
26      if (level !== undefined) {
27        return level
28      }
29    }
30  }
31
32  return asEffort(settings['effortLevel'])
33}
34
35// A turn's value is the truth until the settings or the model change; then the settings speak until the next turn.
36export function pickEffort(tracker: EffortTracker, settingsEffort: EffortValue | undefined, model: string): EffortValue | undefined {
37  if (settingsEffort !== tracker.lastSettings || model !== tracker.lastModel) {
38    if (tracker.lastModel !== undefined) {
39      tracker.fromTurn = undefined
40    }
41    tracker.lastSettings = settingsEffort
42    tracker.lastModel = model
43  }
44
45  return tracker.fromTurn ?? settingsEffort
46}
47
hooks/rate-limits.ts 94 lines
1// Pure handling of the 5-hour and weekly rate-limit windows: picking, mini bar, countdown.
2import type { LimitFigures, LimitWindow } from '../types'
3
4// One window as the engine reports it (SessionRateLimit).
5export type RateLimitReading = { kind: string; percentUsed: number; resetsAt?: string }
6
7export type LimitLabel = '5h' | '7d'
8
9export type LimitSegment = {
10  label: LimitLabel
11  bar: string
12  // "23%", or "—" when the window reset since the reading.
13  percentText: string
14  // undefined when the reading is stale.
15  percent?: number
16  // "2h14m", or '' when the reset time is unknown or passed.
17  reset: string
18}
19
20const MINI_BAR_CELLS = 5
21const MINUTE_MS = 60_000
22
23export function pickLimits(readings: readonly RateLimitReading[]): LimitFigures {
24  const limits: LimitFigures = {}
25  for (const reading of readings) {
26    const window: LimitWindow = { percent: reading.percentUsed }
27    if (reading.resetsAt !== undefined) {
28      window.resetsAt = reading.resetsAt
29    }
30    if (reading.kind === 'five_hour') {
31      limits.fiveHour = window
32    } else if (reading.kind === 'seven_day') {
33      limits.sevenDay = window
34    }
35  }
36
37  return limits
38}
39
40export function formatMiniBar(percent: number): string {
41  const clamped = Math.min(100, Math.max(0, percent))
42  const filled = Math.round(clamped / (100 / MINI_BAR_CELLS))
43
44  return '█'.repeat(filled) + '░'.repeat(MINI_BAR_CELLS - filled)
45}
46
47// 45 min -> "45m", 2 h 14 min -> "2h14m", 3 d 4 h -> "3d4h"; partial minutes round up.
48export function formatCountdown(remainingMs: number): string {
49  const minutes = Math.max(1, Math.ceil(remainingMs / MINUTE_MS))
50  if (minutes < 60) {
51    return `${minutes}m`
52  }
53  if (minutes < 24 * 60) {
54    return `${Math.floor(minutes / 60)}h${String(minutes % 60).padStart(2, '0')}m`
55  }
56
57  return `${Math.floor(minutes / (24 * 60))}d${Math.floor((minutes % (24 * 60)) / 60)}h`
58}
59
60export function describeLimit(label: LimitLabel, window: LimitWindow, nowMs: number): LimitSegment {
61  const resetMs = window.resetsAt === undefined ? Number.NaN : Date.parse(window.resetsAt)
62  if (!Number.isNaN(resetMs) && resetMs <= nowMs) {
63    return { label, bar: formatMiniBar(0), percentText: '—', reset: '' }
64  }
65  const reset = Number.isNaN(resetMs) ? '' : formatCountdown(resetMs - nowMs)
66
67  return {
68    label,
69    bar: formatMiniBar(window.percent),
70    percentText: `${Math.round(window.percent)}%`,
71    percent: window.percent,
72    reset,
73  }
74}
75
76export function describeLimits(limits: LimitFigures | undefined, nowMs: number): LimitSegment[] {
77  const segments: LimitSegment[] = []
78  if (limits?.fiveHour !== undefined) {
79    segments.push(describeLimit('5h', limits.fiveHour, nowMs))
80  }
81  if (limits?.sevenDay !== undefined) {
82    segments.push(describeLimit('7d', limits.sevenDay, nowMs))
83  }
84
85  return segments
86}
87
88// The minute countdowns are measured from, or 0 when no window has a reset time.
89export function countdownMinute(limits: LimitFigures, nowMs: number): number {
90  const counts = limits.fiveHour?.resetsAt !== undefined || limits.sevenDay?.resetsAt !== undefined
91
92  return counts ? Math.floor(nowMs / MINUTE_MS) : 0
93}
94
hooks/status-line.ts 79 lines
1// Composes the band's one line from the snapshot and shortens it to the width it is drawn in.
2import { describeStatus, formatHead, usageLevel } from './format-status'
3import type { StatusLevel } from './format-status'
4import { describeLimits } from './rate-limits'
5import type { LimitSegment } from './rate-limits'
6import type { StatusSnapshot } from '../types'
7
8// How a piece is drawn: dimmed, plain, or in the color of a usage level.
9export type Tone = 'dim' | 'plain' | StatusLevel
10
11export type Piece = { text: string; tone: Tone }
12
13// What a line shows beyond model, context bar and percentages.
14export type Detail = { tokens: boolean; resets: boolean; limitBars: boolean }
15
16// Fullest first; each drops one more detail (FR-15).
17const DETAILS: readonly Detail[] = [
18  { tokens: true, resets: true, limitBars: true },
19  { tokens: false, resets: true, limitBars: true },
20  { tokens: false, resets: false, limitBars: true },
21  { tokens: false, resets: false, limitBars: false },
22]
23
24const MINUTE_MS = 60_000
25
26function usageTone(level: StatusLevel): Tone {
27  return level === 'ok' ? 'plain' : level
28}
29
30function contextPieces(snapshot: StatusSnapshot, detail: Detail): Piece[] {
31  const parts = describeStatus(snapshot.model, snapshot.context, snapshot.effort)
32  const pieces: Piece[] = [{ text: `${formatHead(parts)}ctx `, tone: 'dim' }]
33  if (parts.bar !== '') {
34    pieces.push({ text: `${parts.bar} `, tone: parts.level })
35  }
36  const usage = detail.tokens ? `${parts.percentText} · ${parts.tokensText}` : parts.percentText
37  pieces.push({ text: `${usage}${parts.note}`, tone: usageTone(parts.level) })
38
39  return pieces
40}
41
42function limitPieces(segment: LimitSegment, detail: Detail): Piece[] {
43  const level = usageLevel(segment.percent)
44  const pieces: Piece[] = [{ text: ` │ ${segment.label} `, tone: 'dim' }]
45  if (detail.limitBars) {
46    pieces.push({ text: `${segment.bar} `, tone: level })
47  }
48  pieces.push({ text: segment.percentText, tone: usageTone(level) })
49  if (detail.resets && segment.reset !== '') {
50    pieces.push({ text: ` ${segment.reset}`, tone: 'dim' })
51  }
52
53  return pieces
54}
55
56export function buildLine(snapshot: StatusSnapshot, detail: Detail): Piece[] {
57  const nowMs = (snapshot.minute ?? 0) * MINUTE_MS
58  const limits = describeLimits(snapshot.limits, nowMs)
59
60  return [...contextPieces(snapshot, detail), ...limits.flatMap(segment => limitPieces(segment, detail))]
61}
62
63export function lineText(pieces: readonly Piece[]): string {
64  return pieces.map(piece => piece.text).join('')
65}
66
67// The fullest line that fits in `columns`; the barest one when none does.
68export function fitLine(snapshot: StatusSnapshot, columns: number): Piece[] {
69  let line: Piece[] = []
70  for (const detail of DETAILS) {
71    line = buildLine(snapshot, detail)
72    if (lineText(line).length <= columns) {
73      return line
74    }
75  }
76
77  return line
78}
79
hooks/format-status.ts 105 lines
1// Pure formatting of the indicator: model name, effort, context bar, token counts, usage level.
2import type { ContextFigures } from '../types'
3
4export type StatusLevel = 'unknown' | 'ok' | 'warn' | 'critical'
5
6export type StatusParts = {
7  model: string
8  effort: string
9  bar: string
10  // "42% · 84k/200k" in full; the pieces below are what a narrow line keeps.
11  usage: string
12  // "42%", or "—" before the first measurement.
13  percentText: string
14  // "84k/200k", or just the window ("200k") before the first measurement.
15  tokensText: string
16  // " · compact soon" when critical, else ''.
17  note: string
18  level: StatusLevel
19}
20
21const BAR_CELLS = 10
22const WARN_PERCENT = 80
23const CRITICAL_PERCENT = 95
24
25// "claude-opus-5-5" -> "Opus 5.5"; "claude-sonnet-5-5[1m]" -> "Sonnet 5.5 [1m]"; anything else unchanged.
26export function formatModelName(model: string): string {
27  const match = /^claude-([a-z]+)-(\d+)(?:-(\d+))?(?:-\d{8})?(\[[^\]]+\])?$/i.exec(model.trim())
28  if (match === null) {
29    return model.trim()
30  }
31  const [, family = '', major, minor, suffix] = match
32  const name = family.charAt(0).toUpperCase() + family.slice(1).toLowerCase()
33  const version = minor === undefined ? major : `${major}.${minor}`
34
35  return suffix === undefined ? `${name} ${version}` : `${name} ${version} ${suffix}`
36}
37
38// 950 -> "950", 1500 -> "1.5k", 84000 -> "84k", 1000000 -> "1M".
39export function formatTokens(count: number): string {
40  if (count >= 1_000_000) {
41    return `${trimZero(count / 1_000_000)}M`
42  }
43  if (count >= 1_000) {
44    return `${trimZero(count / 1_000)}k`
45  }
46
47  return String(Math.round(count))
48}
49
50function trimZero(value: number): string {
51  return value >= 100 ? String(Math.round(value)) : String(Number(value.toFixed(1)))
52}
53
54export function formatBar(percent: number): string {
55  const clamped = Math.min(100, Math.max(0, percent))
56  const filled = Math.round(clamped / (100 / BAR_CELLS))
57
58  return '█'.repeat(filled) + '░'.repeat(BAR_CELLS - filled)
59}
60
61export function usageLevel(percent: number | undefined): StatusLevel {
62  if (percent === undefined) {
63    return 'unknown'
64  }
65  if (percent >= CRITICAL_PERCENT) {
66    return 'critical'
67  }
68
69  return percent >= WARN_PERCENT ? 'warn' : 'ok'
70}
71
72export function describeStatus(model: string, context: ContextFigures, effort?: string | number): StatusParts {
73  const head = { model: formatModelName(model), effort: effort === undefined ? '' : String(effort) }
74  const window = formatTokens(context.window)
75  const level = usageLevel(context.percent)
76  if (context.percent === undefined) {
77    return { ...head, bar: '', usage: `— · ${window}`, percentText: '—', tokensText: window, note: '', level }
78  }
79  const used = context.tokens === undefined ? '?' : formatTokens(context.tokens)
80  const note = level === 'critical' ? ' · compact soon' : ''
81
82  return {
83    ...head,
84    bar: formatBar(context.percent),
85    usage: `${context.percent}% · ${used}/${window}${note}`,
86    percentText: `${context.percent}%`,
87    tokensText: `${used}/${window}`,
88    note,
89    level,
90  }
91}
92
93// The indicator as one plain line, e.g. "Opus 5.5 · high · ctx ████░░░░░░ 42% · 84k/200k".
94export function formatStatus(model: string, context: ContextFigures, effort?: string | number): string {
95  const parts = describeStatus(model, context, effort)
96  const bar = parts.bar === '' ? '' : `${parts.bar} `
97
98  return `${formatHead(parts)}ctx ${bar}${parts.usage}`
99}
100
101// "Opus 5.5 · high · ", or "Opus 5.5 · " for a model without effort.
102export function formatHead(parts: StatusParts): string {
103  return parts.effort === '' ? `${parts.model} · ` : `${parts.model} · ${parts.effort} · `
104}
105
types/index.d.ts 24 lines
1// State contract: the last model, effort, context and rate-limit figures the band draws.
2export type ContextFigures = { tokens?: number; window: number; percent?: number }
3
4// One rate-limit window: percent used (0-100) and when it resets (ISO 8601).
5export type LimitWindow = { percent: number; resetsAt?: string }
6
7export type LimitFigures = { fiveHour?: LimitWindow; sevenDay?: LimitWindow }
8
9export type StatusSnapshot = {
10  model: string
11  effort?: string | number
12  context: ContextFigures
13  // Absent in a snapshot an earlier version of the mod stored.
14  limits?: LimitFigures
15  // Minutes since the epoch the countdowns are measured from; 0 when nothing counts down.
16  minute?: number
17}
18
19declare module 'claude-code' {
20  interface PluginState {
21    'context-status': { snapshot: StatusSnapshot | null }
22  }
23}
24