SLOPSHOPPER

statusline

A status line as a mod: 5-hour and weekly limits, context, tokens and cost above the prompt; folder, branch, model, session name and id under it.

bandspinnerprocesstimer
v0.2.1Apache-2.0updated 2026-10-12newtonmunene99/claudekit/plugins/statusline
A shopper browsing a rack in a slop shop
Preview · a replayed session in a sandbox
claude · ~/work/app · statusline
› 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 󰓅 5h ━━┃━━━━━ 31% 󰞯 ctx ━━━┃━━ ⟨Claude Code's own drawing⟩ ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── › ? for shortcuts

Draws

Band
󰓅 5h ━━┃━━━━━ 31% ⟨Claude Code's own drawing⟩
README

statusline

A status line as a mod, the same on every install: no statusLine script to set up per machine.

Needs a Claude Code build with mod support (function hooks).

Install

/plugin install statusline --marketplace newtonmunene99/claudekit

On Claude Code older than 2.1.275, add the marketplace first, then install:

/plugin marketplace add https://github.com/newtonmunene99/claudekit
/plugin install statusline@claudekit

Update

/plugin marketplace update claudekit
/plugin update statusline@claudekit
/reload-plugins

From a shell: claude plugin marketplace update claudekit && claude plugin update statusline@claudekit, then restart Claude Code.

Above the prompt

A row of pills, wrapping when the window is narrow:

PillShows
5h5-hour limit: bar, % used, reset time (↻ 19:20)
7dweekly limit: bar, % used, reset day and time (↻ Thu 19:00)
ctxcontext window fill
↑ ↓ ≋this session's input, output and cache-read tokens
$this session's cost at API prices (what /cost shows)

Each pill leads with an icon in a deeper shade of its tint: in the terminal, Nerd Font icons (speedometer, calendar, history clock, upload, download, layers, dollar); elsewhere the plain symbols above. Bars are a thin line with a marker where the fill ends, and turn yellow at 70% and red at 90%. A figure with no reading yet is left out. Token totals count every model request of this session's turns and start at 0 when a session is resumed, so they can run below what the cost covers. Another plugin's band (Conductor's track band) stays, under the pills.

In the desktop app, which draws text in a proportional font, pills are square chips with no bar: caps and line-drawing bars only line up on a terminal's grid.

Terminal pills have round ends by default. Those are Powerline glyphs, which Ghostty bundles; with a font that lacks them, set Pill ends to square and Icons to plain in the config menu (or "ends": "square", "icons": "plain" under pluginConfigs.statusline in settings).

Under the prompt

At the end of the hint line (terminal only): folder (branch✗) · model · name · id. ✗ means git has uncommitted changes; a detached HEAD shows the short commit. The session's name shows when it has one (a /rename shows from the next prompt), then the first 8 characters of the session id.

Once it works for you, remove statusLine from ~/.claude/settings.json.

Writing a mod in claudekit

One mod per plugin, in plugins/<name>/: .claude-plugin/plugin.json (with "types": "./types/index.d.ts" when it keeps $.state), hooks/hooks.json naming ./register.tsx, the module and its pure helpers in hooks/, tests in tests/. Run claude plugin validate plugins/<name> and claude plugin test plugins/<name> before a version bump. A mod that serves one plugin lives inside that plugin (the Conductor HUD lives in conductor).

Two engine rules shape this:

  • A plugin hooks each event once without a matcher, so two mods that both react to turn.complete or a prompt cannot share a plugin cleanly.
  • $ is never passed into a function imported from another file; helpers that take $ are top-level function declarations in the module itself.
Source 4 files
hooks/register.tsx 229 lines
1// The status line, as a mod: usage pills above the prompt and folder ·
2// branch · model · name · id under it. Engine
3// figures are read live while drawing ($.session.usage() is free); events and
4// a timer only ask for a redraw.
5
6import { atom, read, update } from 'claude-code'
7import type { EngineInterface, Register } from 'claude-code'
8
9import { ZERO_TOKENS, addUsage, barSegments, identityText, modelName } from './format'
10import { buildPills } from './pills'
11import type { Icon, Tone } from './pills'
12
13export const tokens = atom({ plugin: 'statusline', key: 'tokens' } as const, ZERO_TOKENS)
14
15// Soft backgrounds like the reference screenshot; bar colours by level.
16const TONE: Record<Tone, string> = {
17  green: '#d9eedf',
18  purple: '#e6def5',
19  grey: '#e6e6e6',
20  red: '#f6dcd6',
21  blue: '#dbe3f6',
22  yellow: '#f6ecd2',
23}
24// A deeper shade of each pill's tint, for its icons.
25const ACCENT: Record<Tone, string> = {
26  green: '#4f8a5c',
27  purple: '#7a5cc4',
28  grey: '#6f6f6f',
29  red: '#c0563f',
30  blue: '#4a64b8',
31  yellow: '#b58a1b',
32}
33const LEVEL = { ok: '#5a9a68', warn: '#c9a227', high: '#c8553d' } as const
34const INK = '#2b2b2b'
35const TRACK = '#bdbdbd'
36
37// Nerd Font icons in the terminal (the same fonts that carry the Powerline
38// caps); plain Unicode elsewhere, where an empty one is left out.
39const ICONS: Record<'nerd' | 'plain', Record<Icon, string>> = {
40  nerd: {
41    limit5h: '\u{F04C5}',
42    limit7d: '\u{F0B67}',
43    context: '\u{F07AF}',
44    reset: '\uEA82',
45    input: '\uF093',
46    output: '\uF019',
47    cache: '\uEBD2',
48    cost: '\uF155',
49  },
50  plain: { limit5h: '', limit7d: '', context: '', reset: '↻', input: '↑', output: '↓', cache: '≋', cost: '$' },
51}
52
53// Boxes have no corner radius, so a terminal pill ends in Powerline half-disc
54// glyphs in its own colour (Ghostty bundles them; a font without them shows
55// boxes, hence the square option). Caps and line-drawing bars need a monospace
56// grid: the desktop draws text in a proportional font, where they come out
57// small, offset and gapped, so other surfaces get square chips with no bar.
58const CAPS = ['', ''] as const
59
60export const identity = atom({ plugin: 'statusline', key: 'identity' } as const, null)
61const title = atom({ plugin: 'statusline', key: 'title' } as const, null)
62
63async function git($: EngineInterface, root: string, args: string[]): Promise<string | null> {
64  try {
65    const { stdout } = await $.process.run(['git', '-C', root, '--no-optional-locks', ...args], { timeoutMs: 3000 })
66    return stdout.trim()
67  } catch {
68    return null
69  }
70}
71
72// Folder, branch (short sha when detached, none outside a repo), dirty mark
73// and model, as the old status line script showed them.
74async function refreshIdentity($: EngineInterface): Promise<void> {
75  const root = await $.session.root()
76  const folder = root.split('/').filter(Boolean).pop() ?? root
77  const model = modelName(await $.session.model())
78  let branch: string | null = null
79  let isDirty = false
80  if ((await git($, root, ['rev-parse', '--is-inside-work-tree'])) === 'true') {
81    const [current, status] = await Promise.all([
82      git($, root, ['branch', '--show-current']),
83      git($, root, ['status', '--porcelain']),
84    ])
85    branch = current || (await git($, root, ['rev-parse', '--short', 'HEAD']))
86    isDirty = Boolean(status)
87  }
88  const text = identityText(folder, branch, isDirty, model, await read($, title), await $.session.id())
89  if (text !== (await read($, identity))) await update($, identity, () => text)
90}
91
92// Git can be slow in a big repo: refresh in the background so no turn waits.
93function refreshIdentityLater($: EngineInterface): void {
94  refreshIdentity($).catch(() => {})
95}
96
97async function noteTitle($: EngineInterface, name: string | undefined): Promise<void> {
98  const next = name?.trim() || null
99  if (next === (await read($, title))) return
100  await update($, title, () => next)
101  refreshIdentityLater($)
102}
103
104function redraw($: EngineInterface): void {
105  $.ui.invalidate('ui.render')
106}
107
108export const register: Register = (on, options) => {
109  const isRound = options.ends !== 'square'
110  const isPlainIcons = options.icons === 'plain'
111
112  // A passed reset time drops off with the clock, not with an event.
113  on('session.start', async ($, e, next) => {
114    const started = await next(e)
115    $.clock.every(30_000, () => redraw($))
116    refreshIdentityLater($)
117    return started
118  })
119
120  on('turn.complete', async ($, e, next) => {
121    const done = await next(e)
122    // A subagent's turn changes nothing the line shows.
123    if (!e.agentId) refreshIdentityLater($)
124    return done
125  })
126
127  // The session's name only arrives on these settings-hook events; a /rename
128  // shows from the next prompt on.
129  on('classic.SessionStart', async ($, e, next) => {
130    await noteTitle($, e.session_title)
131    return next(e)
132  })
133
134  on('classic.UserPromptSubmit', async ($, e, next) => {
135    await noteTitle($, e.session_title)
136    return next(e)
137  })
138
139  // Dim at the end of the engine's own hint line; the terminal draws it,
140  // other surfaces ignore tail for now.
141  on('ui.render', { component: 'PromptHint' }, async ($, e, next) => {
142    const tail = await read($, identity)
143    return tail ? next({ ...e, props: { ...e.props, tail } }) : next(e)
144  })
145
146  on('session.measure', async ($, e, next) => {
147    const measured = await next(e)
148    redraw($)
149    return measured
150  })
151
152  // Every model request, main thread and subagents: the cost figure counts
153  // them all, so the token totals do too. Writing state redraws the band.
154  on('turn.step', async function* ($, e, next) {
155    const result = yield* next(e)
156    const usage = result?.usage
157    if (usage) await update($, tokens, t => addUsage(t ?? ZERO_TOKENS, usage))
158    return result
159  })
160
161  on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
162    if (e.props.hasSurvey) return next(e)
163    const usage = await $.session.usage()
164    const pills = buildPills(usage, await read($, tokens), Date.now())
165    const beneath = await next(e)
166    if (pills.length === 0) return beneath
167    const { Box, Text } = $.ui.resolve(e)
168    const isTerminal = e.surface === 'terminal'
169    const hasCaps = isRound && isTerminal
170    const [left, right] = CAPS
171    const icons = ICONS[isTerminal && !isPlainIcons ? 'nerd' : 'plain']
172    return (
173      // No width on this outer box: the engine refuses its own drawing
174      // (beneath) under a Box with a width, and would drop the whole band.
175      <Box flexDirection="column">
176        <Box flexDirection="row" flexWrap="wrap" gap={1} width={e.props.bodyColumns}>
177          {pills.map(p => (
178            <Box key={p.key} flexDirection="row">
179              {hasCaps && <Text color={TONE[p.tone]}>{left}</Text>}
180              <Box flexDirection="row" gap={1} paddingX={hasCaps ? 0 : 1} backgroundColor={TONE[p.tone]}>
181                {p.parts.map((part, i) => {
182                  const key = `${p.key}-${i}`
183                  const bg = TONE[p.tone]
184                  if (part.kind === 'icon') {
185                    const glyph = icons[part.icon]
186                    return glyph ? (
187                      <Text key={key} color={ACCENT[p.tone]} backgroundColor={bg}>
188                        {glyph}
189                      </Text>
190                    ) : null
191                  }
192                  if (part.kind === 'bar') {
193                    if (!isTerminal) return null
194                    const { filled, empty } = barSegments(part.percent)
195                    return (
196                      <Box key={key} flexDirection="row">
197                        {filled > 0 && (
198                          <Text color={LEVEL[part.level]} backgroundColor={bg}>
199                            {'━'.repeat(filled)}
200                          </Text>
201                        )}
202                        <Text color={INK} backgroundColor={bg} bold>
203                          ┃
204                        </Text>
205                        {empty > 0 && (
206                          <Text color={TRACK} backgroundColor={bg}>
207                            {'━'.repeat(empty)}
208                          </Text>
209                        )}
210                      </Box>
211                    )
212                  }
213                  return (
214                    <Text key={key} color={INK} backgroundColor={bg} bold={part.isBold} dimColor={part.isDim}>
215                      {part.text}
216                    </Text>
217                  )
218                })}
219              </Box>
220              {hasCaps && <Text color={TONE[p.tone]}>{right}</Text>}
221            </Box>
222          ))}
223        </Box>
224        {beneath}
225      </Box>
226    )
227  })
228}
229
hooks/format.ts 76 lines
1// Pure formatting for the usage band and identity line. No `$`, so tests feed
2// it plain values.
3
4import type { UsageTokens } from '../types'
5
6export const ZERO_TOKENS: UsageTokens = { input: 0, output: 0, cacheRead: 0 }
7
8export function shortNumber(n: number): string {
9  if (n < 1_000) return String(Math.round(n))
10  if (n < 1_000_000) return `${(n / 1_000).toFixed(1)}k`
11  return `${(n / 1_000_000).toFixed(2)}M`
12}
13
14const DAYS = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']
15
16// When a limit resets, in local time: "19:20", or "Thu 19:00" with the day
17// for the weekly one. Null when unknown or already past.
18export function resetTime(resetsAt: string | undefined, now: number, isWithDay: boolean): string | null {
19  if (!resetsAt) return null
20  const at = new Date(resetsAt)
21  if (!Number.isFinite(at.getTime()) || at.getTime() <= now) return null
22  const hm = `${String(at.getHours()).padStart(2, '0')}:${String(at.getMinutes()).padStart(2, '0')}`
23  return isWithDay ? `${DAYS[at.getDay()]} ${hm}` : hm
24}
25
26// A thin bar of `width` cells: filled, one marker cell where the fill ends,
27// then the empty track. The marker is always drawn, so 0% still shows a bar.
28export function barSegments(percent: number, width = 8): { filled: number; empty: number } {
29  const room = width - 1
30  const filled = Math.min(room, Math.max(0, Math.round((percent / 100) * room)))
31  return { filled, empty: room - filled }
32}
33
34export function level(percent: number): 'ok' | 'warn' | 'high' {
35  if (percent >= 90) return 'high'
36  if (percent >= 70) return 'warn'
37  return 'ok'
38}
39
40export function addUsage(
41  t: UsageTokens,
42  u: {
43    input_tokens: number
44    output_tokens: number
45    cache_read_input_tokens: number
46    cache_creation_input_tokens: number
47  },
48): UsageTokens {
49  return {
50    input: t.input + u.input_tokens + u.cache_creation_input_tokens,
51    output: t.output + u.output_tokens,
52    cacheRead: t.cacheRead + u.cache_read_input_tokens,
53  }
54}
55
56// "claude-opus-5-5" -> "Opus 5.5"; anything else is returned as given.
57export function modelName(id: string): string {
58  const [, family, major, minor] = /^claude-([a-z]+)-(\d+)-(\d+)/.exec(id) ?? []
59  if (!family || !major || !minor) return id
60  return `${family.charAt(0).toUpperCase()}${family.slice(1)} ${major}.${minor}`
61}
62
63// "<folder> (<branch>[✗]) · <model>[ · <title>] · <id8>": the session's name
64// when it has one, and the id's first 8 characters, enough to find or resume it.
65export function identityText(
66  folder: string,
67  branch: string | null,
68  isDirty: boolean,
69  model: string,
70  title: string | null,
71  sessionId: string,
72): string {
73  const where = branch ? `${folder} (${branch}${isDirty ? '✗' : ''})` : folder
74  return [where, model, title, sessionId.slice(0, 8)].filter(Boolean).join(' · ')
75}
76
hooks/pills.ts 59 lines
1// The band's content as plain data: which pills, in which order, with which
2// parts. The render hook only maps these to elements; icons are named here and
3// drawn per surface there.
4
5import type { UsageTokens } from '../types'
6import { level, resetTime, shortNumber } from './format'
7
8export type Tone = 'green' | 'purple' | 'grey' | 'red' | 'blue' | 'yellow'
9export type Icon = 'limit5h' | 'limit7d' | 'context' | 'reset' | 'input' | 'output' | 'cache' | 'cost'
10export type PillPart =
11  | { kind: 'text'; text: string; isBold?: boolean; isDim?: boolean }
12  | { kind: 'icon'; icon: Icon }
13  | { kind: 'bar'; percent: number; level: 'ok' | 'warn' | 'high' }
14export type PillSpec = { key: string; tone: Tone; parts: PillPart[] }
15
16// The slice of $.session.usage() the band reads.
17export type UsageFigures = {
18  context: { percent?: number }
19  rateLimits: { kind: string; percentUsed: number; resetsAt?: string }[]
20  cost?: { usd: number }
21}
22
23const icon = (name: Icon): PillPart => ({ kind: 'icon', icon: name })
24const text = (value: string, style: { isBold?: boolean; isDim?: boolean } = {}): PillPart => ({
25  kind: 'text',
26  text: value,
27  ...style,
28})
29
30function meter(key: string, mark: Icon, label: string, tone: Tone, percent: number, reset: string | null): PillSpec {
31  const parts: PillPart[] = [
32    icon(mark),
33    text(label, { isDim: true }),
34    { kind: 'bar', percent, level: level(percent) },
35    text(`${Math.round(percent)}%`, { isBold: true }),
36  ]
37  if (reset) parts.push(text('│', { isDim: true }), icon('reset'), text(reset, { isDim: true }))
38  return { key, tone, parts }
39}
40
41export function buildPills(usage: UsageFigures, tokens: UsageTokens, now: number): PillSpec[] {
42  const pills: PillSpec[] = []
43  const limit = (kind: string) => usage.rateLimits.find(r => r.kind === kind)
44  const five = limit('five_hour')
45  const week = limit('seven_day')
46  if (five) pills.push(meter('5h', 'limit5h', '5h', 'green', five.percentUsed, resetTime(five.resetsAt, now, false)))
47  if (week) pills.push(meter('7d', 'limit7d', '7d', 'purple', week.percentUsed, resetTime(week.resetsAt, now, true)))
48  if (usage.context.percent !== undefined) {
49    pills.push(meter('ctx', 'context', 'ctx', 'grey', usage.context.percent, null))
50  }
51  if (tokens.input + tokens.output + tokens.cacheRead > 0) {
52    pills.push({ key: 'in', tone: 'red', parts: [icon('input'), text(shortNumber(tokens.input))] })
53    pills.push({ key: 'out', tone: 'green', parts: [icon('output'), text(shortNumber(tokens.output))] })
54    pills.push({ key: 'cache', tone: 'blue', parts: [icon('cache'), text(shortNumber(tokens.cacheRead))] })
55  }
56  if (usage.cost) pills.push({ key: 'cost', tone: 'yellow', parts: [icon('cost'), text(usage.cost.usd.toFixed(2))] })
57  return pills
58}
59
types/index.d.ts 22 lines
1// State the statusline plugin keeps for a session.
2
3export type UsageTokens = {
4  // Input tokens sent uncached, including those written to the cache.
5  input: number
6  output: number
7  cacheRead: number
8}
9
10declare module 'claude-code' {
11  interface PluginState {
12    statusline: {
13      tokens: UsageTokens
14      // "<folder> (<branch>[✗]) · <model>[ · <title>] · <id8>", or null before
15      // the first reading.
16      identity: string | null
17      // The session's name as the last session start or prompt carried it.
18      title: string | null
19    }
20  }
21}
22