Usage meters, model, effort, context window and git branch in one line under the prompt

My personal Claude Code mods. Each one is tuned for my own setup and taste: the macOS + Google Chrome stack, a gruvbox palette and the layout of my terminal. They are shared as they are. Use them, fork them, but expect to change them to fit your setup.
One directory per mod.
| Mod | Description | ||
|---|---|---|---|
| yt-music | YT Music in Chrome under the prompt: track, time, play/pause, previous and next | ||
| session-info | Usage meters, model, effort, context window and git branch in one line under the prompt | ||
| cc-model-router | Routes each prompt to Haiku, Sonnet or Opus by how hard it is; opus: style prefixes and `/router on\ | off\ | status` |
osascript, so Chrome needs "Allow JavaScript from Apple Events" turned on (View → Developer). It reads the first tab open on music.youtube.com.git in the session's working directory. Colors are hard-coded gruvbox.~/.claude/cc-model-router/decisions.jsonl. Pairs with session-info, which then shows the routed model and effort./plugin marketplace add cybertron288/claude-mods
/plugin install yt-music@ravi-mods
/plugin install session-info@ravi-mods
/plugin install cc-model-router@ravi-modshooks/register.tsx 172 lines1import { atom, read, update } from 'claude-code'
2import type { EngineInterface, Register } from 'claude-code'
3
4import type { Info, Meter } from '../types'
5
6const infoAtom = atom({ plugin: 'session-info', key: 'info' } as const, null)
7
8const windowLabel = (tokens: number): string =>
9 tokens >= 1_000_000 ? `${tokens / 1_000_000}M` : `${Math.round(tokens / 1000)}k`
10
11// `five_hour` reads as `5h`, `seven_day` as `7d`; any other kind as its own name.
12const limitLabel = (kind: string): string => {
13 const name = kind.toLowerCase()
14
15 return name.includes('five') ? '5h' : name.includes('seven') || name.includes('week') ? '7d' : name.replace(/_/g, ' ')
16}
17
18// Centred thick bars (▬); the empty track is the same glyph drawn muted so the fill stands out.
19const bar = (percent: number, width = 8): { filled: string; empty: string } => {
20 const filled = Math.round((percent / 100) * width)
21
22 return { filled: '▬'.repeat(filled), empty: '▬'.repeat(width - filled) }
23}
24
25// Gruvbox, to match the skin.
26const COLORS = { accent: '#fabd2f', warn: '#fe8019', err: '#fb4934', model: '#8ec07c', effort: '#d3869b', window: '#83a598', branch: '#b8bb26', router: '#fabd2f', muted: '#928374' }
27
28// Each meter keeps its own hue until it runs high; then warn and err take over.
29const METER_COLORS: Record<string, string> = { ctx: '#4bb6e5', '5h': '#cc57de', '7d': '#35cd7b' }
30
31const meterColor = (label: string, percent: number): string =>
32 percent >= 95 ? COLORS.err : percent >= 80 ? COLORS.warn : (METER_COLORS[label] ?? COLORS.accent)
33
34// The last effort a model request carried; none before the first.
35let effort: string | null = null
36
37// The effort `/effort` set, as the /config menu holds it: for the first turn, before any
38// model request has said which effort it ran at.
39async function configuredEffort($: EngineInterface): Promise<string | null> {
40 const rows = await $.config.list().catch(() => [])
41 const row = rows.find(r => /effort/i.test(r.key) || /effort/i.test(r.label))
42
43 return row === undefined || row.value === null || row.value === undefined || row.value === '' ? null : String(row.value)
44}
45
46type Routed = { model: string; effort: string | null }
47
48// cc-model-router's current pick, when that mod is loaded and on. Read untyped so session-info loads without it.
49async function routed($: EngineInterface): Promise<Routed | null> {
50 const read = await $.state.get({ plugin: 'cc-model-router', key: 'router' } as never).catch(() => null)
51 const state = read?.value as { isOn?: unknown; decision?: { model?: unknown; effort?: unknown } | null } | undefined
52 const model = state?.isOn === true ? state.decision?.model : undefined
53
54 return typeof model === 'string' ? { model, effort: typeof state?.decision?.effort === 'string' ? state.decision.effort : null } : null
55}
56
57async function refresh($: EngineInterface): Promise<void> {
58 const [sessionModel, router, usage, git] = await Promise.all([
59 $.session.model(),
60 routed($),
61 $.session.usage(),
62 $.process.run(['git', 'branch', '--show-current']).catch(() => null),
63 ])
64 const branch = git !== null && git.exitCode === 0 ? git.stdout.trim() || null : null
65 const status = branch === null ? null : await $.process.run(['git', 'status', '--porcelain']).catch(() => null)
66 const dirty = status !== null && status.exitCode === 0 && status.stdout.trim() !== ''
67 const meters: Meter[] = [
68 ...(usage.context.percent == null ? [] : [{ label: 'ctx', percent: usage.context.percent }]),
69 ...usage.rateLimits.map(limit => ({ label: limitLabel(limit.kind), percent: limit.percentUsed })),
70 ].map(meter => ({ ...meter, percent: Math.max(0, Math.min(100, Math.round(meter.percent))) }))
71 const prev = await read($, infoAtom)
72 // A reload resets the module's `effort`; the last one shown lives on in session state.
73 const shownEffort = router?.effort ?? effort ?? (await configuredEffort($)) ?? prev?.effort ?? null
74 const next: Info = { model: router?.model ?? sessionModel, effort: shownEffort, window: usage.context.window || null, branch, dirty, meters, isRouted: router !== null }
75
76 if (JSON.stringify(prev) !== JSON.stringify(next)) {
77 await update($, infoAtom, () => next)
78 }
79}
80
81export const register: Register = on => {
82 on('session.start', async ($, e, next) => {
83 const result = await next(e)
84 await refresh($)
85
86 return result
87 })
88
89 on('turn.step', async function* ($, e, next) {
90 if (e.effort !== undefined) {
91 effort = String(e.effort)
92 }
93
94 return yield* next(e)
95 })
96
97 // The router picks a model as the prompt is submitted; show it as the turn begins.
98 on('turn.start', async ($, e, next) => {
99 const result = await next(e)
100
101 if (e.agentId === undefined) {
102 await refresh($)
103 }
104
105 return result
106 })
107
108 on('turn.complete', async ($, e, next) => {
109 const result = await next(e)
110 await refresh($)
111
112 return result
113 })
114
115 on('session.measure', async ($, e, next) => {
116 const result = await next(e)
117 await refresh($)
118
119 return result
120 })
121
122 // One line under the prompt hint: usage meters and model on the left, the branch at the right edge.
123 on('ui.render', { component: 'PromptHint' }, async ($, e, next) => {
124 const info = await read($, infoAtom)
125 const theirs = await next(e)
126
127 if (info === null) {
128 return theirs
129 }
130
131 const { Box, Text } = $.ui.resolve(e)
132 const parts = [
133 { text: info.model, color: COLORS.model },
134 info.effort === null ? null : { text: info.effort, color: COLORS.effort },
135 info.window === null ? null : { text: `${windowLabel(info.window)} ctx`, color: COLORS.window },
136 ].filter((part): part is { text: string; color: string } => part !== null)
137
138 return (
139 <Box flexDirection="column">
140 {theirs}
141 <Box width="100%" justifyContent="space-between">
142 <Box>
143 {info.meters.map(meter => (
144 <Text key={meter.label}>
145 <Text color={COLORS.muted}>{`${meter.label} `}</Text>
146 <Text color={meterColor(meter.label, meter.percent)}>{bar(meter.percent).filled}</Text>
147 <Text color={COLORS.muted}>{bar(meter.percent).empty}</Text>
148 <Text color={COLORS.muted}>{` ${meter.percent}% `}</Text>
149 </Text>
150 ))}
151 {parts.map(part => (
152 <Text key={part.text}>
153 <Text color={COLORS.muted}>{'· '}</Text>
154 <Text color={part.color}>{`${part.text} `}</Text>
155 </Text>
156 ))}
157 </Box>
158 <Box flexDirection="column" alignItems="flex-end">
159 {info.isRouted ? <Text color={COLORS.router}>{`⑂ routed to ${info.model}`}</Text> : null}
160 {info.branch === null ? null : (
161 <Text>
162 <Text color={COLORS.branch}>{`⎇ ${info.branch}`}</Text>
163 {info.dirty ? <Text color={COLORS.warn}>{'*'}</Text> : null}
164 </Text>
165 )}
166 </Box>
167 </Box>
168 </Box>
169 )
170 })
171}
172types/index.d.ts 10 lines1export type Meter = { label: string; percent: number }
2
3export type Info = { model: string; effort: string | null; window: number | null; branch: string | null; dirty: boolean; meters: Meter[]; isRouted: boolean }
4
5declare module 'claude-code' {
6 interface PluginState {
7 'session-info': { info: Info | null }
8 }
9}
10