Shows the SSH host, project directory, RAM in use and your 5-hour and 7-day usage limits in a row above the prompt

A Claude Code mod that draws one row above the prompt: the machine you're on, the directory Claude is working in, how much of its RAM is in use, and your 5-hour and 7-day usage limits with the time until each resets.
SSH devbox (192.0.2.10) ~/project RAM ██░░░░░░ 29% 5h █░░░░░░░ 18% ↻ 2h 41m 7d ███████░ 83% ↻ 6d 25m ago

It was made for working in Claude Code over SSH on a small Linux box, where it helps to see at a glance which machine a session is on, whether it is running out of memory, and how close you are to a usage limit.
| Part | Example | Where it comes from |
|---|---|---|
| Host | SSH devbox (192.0.2.10) | /etc/hostname, and the server address (third field) of SSH_CONNECTION. Only the hostname when you're not on SSH. |
| Directory | ~/project | The session's project directory: where Claude started, or where /cd moved it (picked up on the next turn). Your home directory shows as ~. |
| RAM | RAM ██░░░░░░ 29% | MemAvailable and MemTotal in /proc/meminfo, read every 10 s. The bar fills with RAM in use. |
| 5-hour limit | 5h █░░░░░░░ 18% ↻ 2h 41m | The session's usage readings. ↻ is the time until the window resets. |
| 7-day limit | 7d ███████░ 83% ↻ 6d | The same. A day or more out it shows whole days only. |
| Spend limit | spend ██░░░░░░ 25% … | Shown instead of or beside the above when you're behind a Claude apps gateway with a spend limit. |
| Reading age | 25m ago | Shown once the session's last usage reading is 5 minutes old or more. |
The row is sized to fit on one line in a normal-width window (about 110 columns with the example above). In a narrower window, or with a long hostname or directory, it wraps onto a second line.
Every bar, RAM included, uses the same steps:
| Color | Usage bars (% used) | RAM bar (% free) |
|---|---|---|
| green | under 70 % | 30 % or more |
| yellow | 70 % or more | under 30 % |
| orange | 80 % or more | under 20 % |
| red | 90 % or more | under 10 % |
The RAM bar is colored by what's free (strictly below each step), so it changes color where the usage bars do.
Claude Code only learns your usage figures from the API responses a session gets. Each session keeps its own last reading. A session that has been idle for a while still shows the figures from its last reply, even if another session has used more since then.
The band tells you when a reading may be out of date:
25m ago (dim, at the end of the row): the session's last reading is that old. It shows from 5 minutes on. The next reply in that session refreshes it.5h ░░░░░░░░ reset (dim, no percentage): that window's reset time has passed since the reading was taken, so the old percentage no longer applies. The next reply brings the new window's figure.The usage bars appear after the session's first reply. Until then the row shows only the host and RAM.
Claude Code's status line gets the same 5h and 7d figures, and a status line script could draw most of this row. But the Claude desktop app's Code tab doesn't draw custom status lines; only the terminal does. This mod draws above the prompt in both. It can also dim a window past its reset and show how old the reading is, which a status line can't: Claude Code drops a window from the status line's data once it resets, and that data carries no reading time.
rate_limits in the status line docs./etc/hostname and /proc/meminfo. On macOS (and anywhere else those files don't exist) those parts are left out and only the directory and usage bars show. Over SSH into a Mac the host part shows just SSH <server ip>, with no hostname.Install the mod where Claude Code runs:
In the desktop app's SSH sessions, Claude Code runs on the remote host, so the mod goes there too. The band then shows that host's name and RAM.
Don't also install it on the computer running the desktop app. With the mod installed in both places, the band doesn't show in SSH sessions. If you installed it locally, remove that copy first (see Uninstall).
The desktop app puts its own copy of Claude Code on the host the first time you connect, under ~/.claude/remote/ccd-cli/ (one file per version), but not on your PATH. These steps use that copy. Adding the marketplace from GitHub also needs git on the host; if it doesn't have it, see Without git on the host.
CC at the newest version: CC=~/.claude/remote/ccd-cli/$(ls ~/.claude/remote/ccd-cli/ | sort -V | tail -1)
Check it works. This should print a Claude Code version:
"$CC" --version
"$CC" plugin marketplace add RedRoosterKey/claude-code-ssh-usage-band
"$CC" plugin install ssh-usage-band@ssh-usage-band
Set CC again in each new shell. Don't point an alias or symlink at one of the ccd-cli files: the desktop app replaces them when it updates. If the host has its own claude on the PATH, you can use that in place of "$CC".
If step 3 fails with Executable not found in $PATH: "git", either install git on the host (for example sudo apt install git) and run step 3 again, or download the mod with curl and add the folder as a local marketplace. In place of step 3:
mkdir -p ~/ssh-usage-band && curl -fsSL https://github.com/RedRoosterKey/claude-code-ssh-usage-band/archive/refs/heads/main.tar.gz | tar xz --strip-components=1 -C ~/ssh-usage-band
"$CC" plugin marketplace add ~/ssh-usage-band
"$CC" plugin install ssh-usage-band@ssh-usage-band
Claude Code loads the mod straight from ~/ssh-usage-band, so keep that folder. No curl? Use wget -qO- in place of curl -fsSL.
This repository is its own plugin marketplace. In a Claude Code session in a terminal, type:
/plugin install ssh-usage-band --marketplace RedRoosterKey/claude-code-ssh-usage-band
Answer y to add the marketplace, then pick a scope (user scope, the first one offered, loads it in every session). The band shows up in that session straight away.
Or the same from your shell:
claude plugin marketplace add RedRoosterKey/claude-code-ssh-usage-band
claude plugin install ssh-usage-band@ssh-usage-band
/plugin isn't available in the Claude desktop app's Code tab. Install it from a terminal at user scope and it loads in the desktop app's local sessions too.
Clone the repository, then point Claude Code at the folder. For one session:
claude --plugin-dir /path/to/claude-code-ssh-usage-band
For every session, including ones the desktop app starts, add it to the env block of ~/.claude/settings.json (it is not read from a project's settings). Use an absolute path (~ is allowed); separate several folders with :.
{
"env": {
"CLAUDE_CODE_PLUGIN_DIRS": "~/src/claude-code-ssh-usage-band"
}
}
On a remote host: SSH to the host, set CC as in On a remote host, then run:
"$CC" plugin marketplace update ssh-usage-band
"$CC" plugin update ssh-usage-band@ssh-usage-band
If you installed it without git, download it again over the old folder instead:
rm -rf ~/ssh-usage-band && mkdir -p ~/ssh-usage-band && curl -fsSL https://github.com/RedRoosterKey/claude-code-ssh-usage-band/archive/refs/heads/main.tar.gz | tar xz --strip-components=1 -C ~/ssh-usage-band
Then start a new SSH session in the desktop app.
On your computer:
claude plugin marketplace update ssh-usage-band
claude plugin update ssh-usage-band@ssh-usage-band
Then run /reload-plugins in a session, or start a new one.
From a clone: git pull. See Editing the mod for when the change shows up.
On a remote host: SSH to the host, set CC as in On a remote host, then run:
"$CC" plugin uninstall ssh-usage-band@ssh-usage-band
"$CC" plugin marketplace remove ssh-usage-band
If you installed it without git, also delete ~/ssh-usage-band.
On your computer:
claude plugin uninstall ssh-usage-band@ssh-usage-band
claude plugin marketplace remove ssh-usage-band
From a clone: drop the --plugin-dir flag, or remove the folder from CLAUDE_CODE_PLUGIN_DIRS, and start a new session.
.claude-plugin/plugin.json manifest
.claude-plugin/marketplace.json makes this repo a marketplace
hooks/hooks.json names the hooks module
hooks/register.tsx the mod
types/index.d.ts the state contract
tests/band.test.ts tests
claude plugin test .
The tests run against Claude Code's own engine with a mocked clock, environment and filesystem. They need no login and no network, which is also how CI runs them.
claude plugin validate . checks the manifest, the marketplace file and the hooks module the way Claude Code will load them.
Claude Code writes its type declarations into .claude-plugin/types/ each time it loads the mod from a plugin folder (--plugin-dir or CLAUDE_CODE_PLUGIN_DIRS). That folder is generated, so it's in .gitignore. Once it exists:
npx -p typescript tsc -p .
When the mod is loaded from a plugin folder (--plugin-dir or CLAUDE_CODE_PLUGIN_DIRS):
CLAUDE_CODE_PLUGIN_DIR_WATCH=1 is set in the environment or in the env block of ~/.claude/settings.json.claude -p always loads it fresh.A copy installed from the GitHub marketplace doesn't see edits to a clone at all. It changes only through Update.
hooks/register.tsx 249 lines1import { atom, read, update } from 'claude-code'
2import type { Register } from 'claude-code'
3
4import type { Limit, Ram } from '../types'
5
6const limits = atom({ plugin: 'ssh-usage-band', key: 'limits' } as const, [])
7const now = atom({ plugin: 'ssh-usage-band', key: 'now' } as const, 0)
8const host = atom({ plugin: 'ssh-usage-band', key: 'host' } as const, '')
9const dir = atom({ plugin: 'ssh-usage-band', key: 'dir' } as const, '')
10const ram = atom({ plugin: 'ssh-usage-band', key: 'ram' } as const, null)
11// When the session last got a usage reading: each turn's measurement carries the
12// figures from that turn's last API response, so this is the session's last turn.
13const readAt = atom({ plugin: 'ssh-usage-band', key: 'readAt' } as const, 0)
14
15const LABELS: Record<string, string> = {
16 five_hour: '5h',
17 seven_day: '7d',
18 spend_limit: 'spend',
19}
20
21const BAR_WIDTH = 8
22const ORANGE = '#ff8700'
23
24export function bar(percent: number): string {
25 const filled = Math.round((Math.min(100, Math.max(0, percent)) / 100) * BAR_WIDTH)
26 return '█'.repeat(filled) + '░'.repeat(BAR_WIDTH - filled)
27}
28
29export function colorFor(percent: number): string {
30 if (percent >= 90) return 'red'
31 if (percent >= 80) return ORANGE
32 if (percent >= 70) return 'yellow'
33 return 'green'
34}
35
36function span(minutes: number): string {
37 const days = Math.floor(minutes / 1440)
38 const hours = Math.floor((minutes % 1440) / 60)
39 const mins = minutes % 60
40
41 if (days > 0) return `${days}d ${hours}h`
42 if (hours > 0) return `${hours}h ${mins}m`
43 return `${mins}m`
44}
45
46// A window whose reset time has passed: the session's reading of it predates the
47// reset, so its percentage is no longer true until the session's next turn.
48export function hasReset(resetsAt: string | undefined, nowMs: number): boolean {
49 if (!resetsAt || nowMs <= 0) return false
50 return Date.parse(resetsAt) <= nowMs
51}
52
53// A day or more out, whole days are enough and keep the row on one line.
54export function untilReset(resetsAt: string | undefined, nowMs: number): string | undefined {
55 if (!resetsAt) return undefined
56 const ms = Date.parse(resetsAt) - nowMs
57 if (Number.isNaN(ms) || ms <= 0) return undefined
58 const minutes = Math.ceil(ms / 60_000)
59 return minutes >= 1440 ? `↻ ${Math.floor(minutes / 1440)}d` : `↻ ${span(minutes)}`
60}
61
62// Readings younger than this are the session you're working in; no label.
63const AGE_SHOWN_FROM_MS = 5 * 60_000
64
65export function readingAge(readAtMs: number, nowMs: number): string | undefined {
66 if (readAtMs <= 0 || nowMs <= 0) return undefined
67 const ms = nowMs - readAtMs
68 if (ms < AGE_SHOWN_FROM_MS) return undefined
69 return `${span(Math.floor(ms / 60_000))} ago`
70}
71
72const RAM_POLL_MS = 10_000
73
74// Percent of MemTotal that MemAvailable is under. Under 30 % free is over 70 % used,
75// 20 % free is 80 % used, 10 % free is 90 % used: the same yellow, orange and red
76// steps as colorFor, so the RAM bar changes color where the usage bars do.
77const RAM_YELLOW_BELOW = 30
78const RAM_ORANGE_BELOW = 20
79const RAM_RED_BELOW = 10
80
81export function hostLabel(hostname: string, sshConnection: string | undefined): string {
82 // SSH_CONNECTION is "client_ip client_port server_ip server_port".
83 const serverIp = sshConnection?.trim().split(/\s+/)[2]
84 if (!serverIp) return hostname
85 return hostname ? `SSH ${hostname} (${serverIp})` : `SSH ${serverIp}`
86}
87
88// The home directory shortens to ~, the way a shell prompt shows it.
89export function dirLabel(path: string, home: string | undefined): string {
90 const h = home?.replace(/\/+$/, '')
91 if (!h || !path) return path
92 if (path === h) return '~'
93 return path.startsWith(`${h}/`) ? `~${path.slice(h.length)}` : path
94}
95
96export function parseMeminfo(text: string): Ram | null {
97 const kb = (field: string) => Number(new RegExp(`^${field}:\\s+(\\d+) kB$`, 'm').exec(text)?.[1])
98 const totalKb = kb('MemTotal')
99 const availableKb = kb('MemAvailable')
100 if (!(totalKb > 0) || Number.isNaN(availableKb)) return null
101 return { totalKb, availableKb }
102}
103
104export function ramColorFor(availablePercent: number): string {
105 if (availablePercent < RAM_RED_BELOW) return 'red'
106 if (availablePercent < RAM_ORANGE_BELOW) return ORANGE
107 if (availablePercent < RAM_YELLOW_BELOW) return 'yellow'
108 return 'green'
109}
110
111// The bar fills with RAM in use, like the usage bars; the color follows what's free.
112export function ramShown(r: Ram): { usedPercent: number; color: string } {
113 const availablePercent = (r.availableKb / r.totalKb) * 100
114 return {
115 usedPercent: 100 - availablePercent,
116 color: ramColorFor(availablePercent),
117 }
118}
119
120export const register: Register = on => {
121 let home: string | undefined
122
123 on('session.start', async ($, e, next) => {
124 const hostname = await $.fs.read('/etc/hostname').then(
125 text => text.trim(),
126 () => '',
127 )
128 const ssh = await $.env.get('SSH_CONNECTION')
129 await update($, host, () => hostLabel(hostname, ssh))
130
131 // A failed read leaves the directory out; the rest of the band still starts.
132 home = await $.env.get('HOME')
133 const root = await $.session.root().catch(() => '')
134 await update($, dir, () => dirLabel(root, home))
135
136 // Write only when what the band draws changes, so polling doesn't redraw it.
137 let drawn = ''
138 const sampleRam = async () => {
139 let sample: Ram | null = null
140 try {
141 sample = parseMeminfo(await $.fs.read('/proc/meminfo'))
142 } catch {
143 sample = null
144 }
145 const shown = sample ? ramShown(sample) : null
146 const key = shown ? `${Math.round(shown.usedPercent)} ${shown.color}` : ''
147 if (key === drawn) return
148 drawn = key
149 await update($, ram, () => sample)
150 }
151 void sampleRam()
152 $.clock.every(RAM_POLL_MS, () => void sampleRam())
153
154 const usage = await $.session.usage()
155 await update($, limits, () => usage.rateLimits as Limit[])
156 await update($, now, () => 0)
157 if (usage.rateLimits.length > 0) {
158 const t = await $.clock.now()
159 await update($, readAt, () => t)
160 }
161
162 const tick = async () => {
163 const t = await $.clock.now()
164 await update($, now, () => t)
165 }
166 void tick()
167 $.clock.every(60_000, () => void tick())
168
169 return next(e)
170 })
171
172 on('session.measure', async ($, e, next) => {
173 // /cd moves the session's project directory without an event of its own;
174 // each turn's measurement picks it up, and the band redraws only on a change.
175 // A failed read keeps what the band shows and doesn't hold up the usage bars.
176 const root = await $.session.root().catch(() => undefined)
177 if (root !== undefined) {
178 const label = dirLabel(root, home)
179 if (label !== (await read($, dir))) await update($, dir, () => label)
180 }
181
182 // Every measurement carries the current figures, even when only the context
183 // moved, so it refreshes the reading's age; the bars redraw only on a change.
184 if (e.rateLimits.length > 0) {
185 const t = await $.clock.now()
186 if (e.changed.includes('rateLimits')) await update($, limits, () => e.rateLimits as Limit[])
187 await update($, readAt, () => t)
188 await update($, now, () => t)
189 }
190
191 return next(e)
192 })
193
194 on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
195 const current = await read($, limits)
196 const hostText = await read($, host)
197 const dirText = await read($, dir)
198 const mem = await read($, ram)
199 if (e.props.hasSurvey || (current.length === 0 && !hostText && !dirText && !mem)) {
200 return next(e)
201 }
202
203 const nowMs = await read($, now)
204 const age = current.length > 0 ? readingAge(await read($, readAt), nowMs) : undefined
205 const { Box, Text } = $.ui.resolve(e)
206 const shown = mem ? ramShown(mem) : null
207
208 return (
209 <Box flexDirection="row" flexWrap="wrap" columnGap={2}>
210 {hostText ? <Text dimColor>{hostText}</Text> : null}
211 {dirText ? <Text dimColor>{dirText}</Text> : null}
212 {shown ? (
213 <Box key="ram" flexDirection="row" gap={1}>
214 <Text dimColor>RAM</Text>
215 <Text color={shown.color}>{bar(shown.usedPercent)}</Text>
216 <Text bold color={shown.color}>
217 {`${Math.round(shown.usedPercent)}%`}
218 </Text>
219 </Box>
220 ) : null}
221 {current.map(limit => {
222 const label = LABELS[limit.kind] ?? limit.kind
223 if (hasReset(limit.resetsAt, nowMs)) {
224 return (
225 <Box key={limit.kind} flexDirection="row" gap={1}>
226 <Text dimColor>{label}</Text>
227 <Text dimColor>{bar(0)}</Text>
228 <Text dimColor>reset</Text>
229 </Box>
230 )
231 }
232 const reset = nowMs > 0 ? untilReset(limit.resetsAt, nowMs) : undefined
233 return (
234 <Box key={limit.kind} flexDirection="row" gap={1}>
235 <Text dimColor>{label}</Text>
236 <Text color={colorFor(limit.percentUsed)}>{bar(limit.percentUsed)}</Text>
237 <Text bold color={colorFor(limit.percentUsed)}>
238 {`${Math.round(limit.percentUsed)}%`}
239 </Text>
240 {reset ? <Text dimColor>{reset}</Text> : null}
241 </Box>
242 )
243 })}
244 {age ? <Text dimColor>{age}</Text> : null}
245 </Box>
246 )
247 })
248}
249types/index.d.ts 9 lines1export type Limit = { kind: string; percentUsed: number; resetsAt?: string }
2export type Ram = { totalKb: number; availableKb: number }
3
4declare module 'claude-code' {
5 interface PluginState {
6 'ssh-usage-band': { limits: Limit[]; now: number; host: string; dir: string; ram: Ram | null; readAt: number }
7 }
8}
9