Bar above the prompt showing account usage (5h and 7-day limits), context, cost, model, effort and login expiry

A growing collection of mods for Claude Code.
| Mod | What it does |
|---|---|
| agent-squad | Side pane listing the agents at work: nickname, icon, role, status and current activity. /squadra flusso (or a click on an agent) opens a live map in the browser: call graph, timeline, files touched and crucial files. /squadra storico lists past sessions and the files each one changed. A 💬 button on sessions, files and calls puts a question about them in the prompt of the session that did the work (/squadra collega registers the squadra:// link once). Windows only for now |
| token-bar | Bar above the prompt showing account usage (5h and 7-day limits), context, cost, model, effort and login expiry (🔑, read from .credentials.json; absent on macOS, where credentials live in the Keychain). Bars shrink with the terminal width and drop to bare percentages below 90 columns |
The in-app labels are in Italian.
Inside Claude Code:
/plugin marketplace add Lerma4/claude-code-mods
/plugin install agent-squad@claude-code-mods
/plugin install token-bar@claude-code-mods
Then restart Claude Code.
/plugin marketplace update claude-code-mods
Or enable auto-update for this marketplace from the /plugin menu.
The pane works as soon as the plugin is installed. The browser pages and the 💬 buttons need Windows (for now).
/squadra opens it again./squadra flusso, the 🗺 Flusso button in the pane, or a click on an agent's name. It opens in your default browser and updates live./squadra storico, or the 📚 Storico link in the flow page./squadra collega.claude --resume) or pick another open session.squadra link: allow it (tick "always allow" to skip the question next time).| Command | What it does |
|---|---|
/squadra | Opens the pane |
/squadra flusso [name] | Flow map of the session, or of one agent and its subagents |
/squadra storico | Past sessions, the files each one changed, search by file, project or request |
/squadra collega | Registers the squadra:// link for your Windows user (no admin rights) |
/squadra scollega | Removes it |
/squadra pulisci | Clears finished agents from the pane |
/squadra tombola [name] | New random nicknames |
Settings (/plugin → agent-squad → configure): keepSessions, how many recent sessions keep their full flow map (default 20). Older ones keep only the list of files they changed.
What it writes on your machine
%USERPROFILE%\.claude\agent-flow\: the pages, one folder per recent session, the history data. Delete it any time; it is rebuilt./squadra collega only: the key HKCU\Software\Classes\squadra, which runs agent-flow\chiedi.ps1 on a squadra:// link. That script takes only a known session id from the link and puts text in that session's prompt box; /squadra scollega removes the key.Troubleshooting
/squadra collega, then reload the page.hooks/register.tsx 136 lines1import { atom, read, update } from 'claude-code'
2import type { EngineInterface, Register } from 'claude-code'
3
4import type { Snapshot } from '../types'
5
6const snap = atom({ plugin: 'token-bar', key: 'snap' } as const, null)
7
8const LABEL: Record<string, string> = { five_hour: '5h', seven_day: '7gg', spend_limit: 'spesa' }
9// celle della barra in base alla larghezza del terminale; sotto 90 colonne restano solo le percentuali
10const barWidth = (cols: number) => (cols >= 150 ? 14 : cols >= 120 ? 10 : cols >= 90 ? 6 : 0)
11
12// verde < 60, giallo < 85, rosso oltre
13const tone = (p: number) => (p >= 85 ? '#f7768e' : p >= 60 ? '#e0af68' : '#9ece6a')
14
15const bar = (p: number, width: number) => {
16 const n = Math.round((Math.min(100, Math.max(0, p)) / 100) * width)
17 return { on: '█'.repeat(n), off: '░'.repeat(width - n) }
18}
19
20const fmtTokens = (n: number) => (n >= 1e6 ? `${(n / 1e6).toFixed(1)}M` : n >= 1e3 ? `${Math.round(n / 1e3)}k` : `${n}`)
21
22const until = (iso: string | undefined, now: number) => {
23 if (!iso) return ''
24 const m = Math.max(0, Math.round((Date.parse(iso) - now) / 60000))
25 const d = Math.floor(m / 1440)
26 const h = Math.floor((m % 1440) / 60)
27 return d > 0 ? `${d}g ${h}h` : h > 0 ? `${h}h ${m % 60}m` : `${m}m`
28}
29
30const toSnap = (u: {
31 rateLimits: Snapshot['limits']
32 context: { percent?: number; tokens?: number; window: number }
33 cost?: { usd: number }
34}): Snapshot => ({
35 limits: u.rateLimits,
36 contextPercent: u.context.percent,
37 contextTokens: u.context.tokens,
38 contextWindow: u.context.window,
39 usd: u.cost?.usd,
40})
41
42// solo la scadenza del login (refresh token): i token non escono mai da qui. Su macOS le credenziali
43// stanno nel Keychain, il file manca e la chiave non si vede
44const readExpiry = async ($: EngineInterface) => {
45 const dir = (await $.env.get('CLAUDE_CONFIG_DIR')) ?? `${(await $.env.get('HOME')) ?? (await $.env.get('USERPROFILE'))}/.claude`
46 try {
47 const o = JSON.parse(await $.fs.read(`${dir}/.credentials.json`)).claudeAiOauth ?? {}
48 return { refreshExpiresAt: typeof o.refreshTokenExpiresAt === 'number' ? new Date(o.refreshTokenExpiresAt).toISOString() : undefined }
49 } catch {
50 return {}
51 }
52}
53
54export const register: Register = on => {
55 on('session.start', async ($, e, next) => {
56 const u = await $.session.usage()
57 const model = await $.session.model()
58 const expiry = await readExpiry($)
59 await update($, snap, s => ({ ...s, ...toSnap(u), model, ...expiry }))
60
61 return next(e)
62 })
63
64 on('session.measure', async ($, e, next) => {
65 // un nuovo login durante la sessione sposta la scadenza: la rileggo a ogni misura
66 const expiry = await readExpiry($)
67 await update($, snap, s => ({ ...s, ...toSnap(e), ...expiry }))
68
69 return next(e)
70 })
71
72 // modello ed effort reali della richiesta, solo loop principale (non subagenti)
73 on('turn.step', async function* ($, e, next) {
74 if (e.agentId === undefined) {
75 await update($, snap, s => (s ? { ...s, model: e.model, effort: e.effort } : s))
76 }
77
78 return yield* next(e)
79 })
80
81 on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
82 const s = await read($, snap)
83
84 if (e.props.hasSurvey || s === null) return next(e)
85
86 const { Box, Text } = $.ui.resolve(e)
87 const now = await $.clock.now()
88 const width = barWidth(e.viewport?.columns ?? 150)
89 const ctxPct = s.contextPercent ?? (s.contextTokens !== undefined ? (s.contextTokens / s.contextWindow) * 100 : undefined)
90
91 const meters = s.limits.map(l => {
92 const b = bar(l.percentUsed, width)
93 const c = tone(l.percentUsed)
94 const reset = until(l.resetsAt, now)
95
96 return (
97 <Box key={l.kind} gap={1}>
98 <Text bold>{LABEL[l.kind] ?? l.kind}</Text>
99 {width > 0 ? <Text color={c}>{b.on}</Text> : null}
100 {width > 0 ? <Text dimColor>{b.off}</Text> : null}
101 <Text color={c} bold>{`${Math.round(l.percentUsed)}%`}</Text>
102 {reset ? <Text dimColor>{`↻ ${reset}`}</Text> : null}
103 </Box>
104 )
105 })
106
107 return (
108 <Box borderStyle="round" borderColor="#565f89" paddingX={1} flexWrap="wrap" columnGap={3}>
109 <Text bold color="#7aa2f7">⚡</Text>
110 {meters.length > 0 ? meters : <Text dimColor>limiti account non disponibili</Text>}
111 {s.contextTokens !== undefined ? (
112 <Box gap={1}>
113 <Text dimColor>ctx</Text>
114 {ctxPct !== undefined ? <Text color={tone(ctxPct)} bold>{`${Math.round(ctxPct)}%`}</Text> : null}
115 <Text dimColor>{`${fmtTokens(s.contextTokens)}/${fmtTokens(s.contextWindow)}`}</Text>
116 </Box>
117 ) : null}
118 {s.model ? (
119 <Text color="#bb9af7">{`${s.model.replace(/^claude-/, '')}${s.effort !== undefined ? ` · ${s.effort}` : ''}`}</Text>
120 ) : null}
121 {s.usd !== undefined ? <Text dimColor>{`$${s.usd.toFixed(2)}`}</Text> : null}
122 {s.refreshExpiresAt ? (
123 <Box gap={1}>
124 <Text dimColor>🔑</Text>
125 {Date.parse(s.refreshExpiresAt) <= now ? (
126 <Text color="#f7768e" bold>scaduto</Text>
127 ) : (
128 <Text dimColor>{until(s.refreshExpiresAt, now)}</Text>
129 )}
130 </Box>
131 ) : null}
132 </Box>
133 )
134 })
135}
136types/index.d.ts 18 lines1export type Limit = { kind: string; percentUsed: number; resetsAt?: string }
2export type Snapshot = {
3 limits: Limit[]
4 contextPercent?: number
5 contextTokens?: number
6 contextWindow: number
7 usd?: number
8 model?: string
9 effort?: string | number
10 refreshExpiresAt?: string
11}
12
13declare module 'claude-code' {
14 interface PluginState {
15 'token-bar': { snap: Snapshot | null }
16 }
17}
18