A Mod Tools button in the prompt footer that opens a panel for picking the model and effort, showing or hiding mod panes, and switching your installed mods on…

A Claude Code mod that puts a ◆ Mod Tools ▾ button at the bottom right of the prompt footer. Click it to open a small control panel above the prompt:
╭──────────────────────────────────────────────────────────────╮
│ ◆ M O D T O O L S Opus 5.5 · High │
│ │
│ MODEL Haiku 4.5 Sonnet 5.5 [Opus 5.5] Fable 5.1 │
│ EFFORT Low Medium [High] XHigh Max │
│ │
│ M O D S All on All off Show Enabled │
│ │
│ ○ Buffer Pane text snippets pane ○ Off │
│ ● Clean View simple checklist ● On │
│ ● Flightdeck agent dashboard [● Shown ] ● On │
│ ● Pinboard decisions, tasks & links pa ○ Hidden ● On │
│ ● Secret Redactor hides secrets & PII ● On │
│ ● Usage Pane plan limits & session us ○ Hidden ● On │
╰──────────────────────────────────────────────────────────────╯
───────────────────────────────────────────── Mod Control Panel ─
/model with its full ID; Opus keeps the 1M context window)./effort). Haiku doesn't use effort, so the row says so.hooks/hooks.json loads function-hook modules) gets an On/Off switch. Plugins that aren't mods, such as Codex, aren't listed, and neither is Mod Tools itself.claude plugin enable|disable <id> --scope user, then /reload-plugins./simple on|off. If the Clean View plugin is disabled, its switch enables it./flightdeck open|close, /usage-pane open|close). A mod that's switched off, or that has no pane, leaves the cell empty.paneOpen value in its $.state, and Mod Tools reads it.When a session starts with a person at the prompt, Mod Tools opens the mod panes for you, in this tab order: Flightdeck, Pinboard, Buffer pane, Usage. Tabs sit in the order their panes opened, so Mod Tools runs the four show commands one at a time and waits for each before the next.
launched flag in $.state survives the reload), and neither does /clear.Colors come from your Claude Code theme, so the panel follows whatever theme you've picked in /config.
If you can't click the footer, type /tools to open or close the panel.
claude plugin marketplace add jidhra/claude-mods
claude plugin install mod-tools@claude-mods --scope user
Or, inside Claude Code: /plugin install mod-tools --marketplace jidhra/claude-mods.
claude plugin validate .
claude plugin test .hooks/register.tsx 8 lines1import type { Register } from 'claude-code'
2
3import { registerModTools } from './mod-tools'
4
5export const register: Register = on => {
6 registerModTools(on)
7}
8hooks/mod-tools.tsx 532 lines1import { atom, read, update } from 'claude-code'
2import type { ConfigRow, EngineInterface, On } from 'claude-code'
3
4import type { ModToolsMod } from '../types'
5
6const COMMAND = 'tools'
7const FALLBACK_COMMAND = 'mod-tools'
8const TITLE = '◆ M O D T O O L S'
9const FOOTER_LABEL = 'Mod Tools'
10const RULE_LABEL = ' Mod Control Panel ─'
11const LABEL_CELLS = 8
12const MODS_HEADING = 'M O D S'
13
14type Engine = EngineInterface
15
16type ModelChoice = {
17 id: string
18 label: string
19 family: string
20 hasEffort: boolean
21}
22
23type EffortChoice = {
24 value: string
25 label: string
26}
27
28/** The models the panel offers, in the order drawn. Opus keeps the 1M context window. */
29export const MODELS: readonly ModelChoice[] = [
30 { id: 'claude-haiku-4-5-20251001', label: 'Haiku 4.5', family: 'haiku', hasEffort: false },
31 { id: 'claude-sonnet-5-5', label: 'Sonnet 5.5', family: 'sonnet', hasEffort: true },
32 { id: 'claude-opus-5-5[1m]', label: 'Opus 5.5', family: 'opus', hasEffort: true },
33 { id: 'claude-fable-5-1', label: 'Fable 5.1', family: 'fable', hasEffort: true },
34]
35
36export const EFFORTS: readonly EffortChoice[] = [
37 { value: 'low', label: 'Low' },
38 { value: 'medium', label: 'Medium' },
39 { value: 'high', label: 'High' },
40 { value: 'xhigh', label: 'XHigh' },
41 { value: 'max', label: 'Max' },
42]
43
44const isOpenAtom = atom({ plugin: 'mod-tools', key: 'isOpen' } as const, false)
45const modelAtom = atom({ plugin: 'mod-tools', key: 'model' } as const, null)
46const effortAtom = atom({ plugin: 'mod-tools', key: 'effort' } as const, null)
47const modsAtom = atom({ plugin: 'mod-tools', key: 'mods' } as const, [])
48const launchedAtom = atom({ plugin: 'mod-tools', key: 'launched' } as const, false)
49const cleanViewAtom = atom({ plugin: 'clean-view', key: 'cleanViewEnabled' } as const, true)
50
51/** Each mod with a pane publishes whether it is open; the engine lists a plugin's panes only to that plugin. */
52const flightdeckOpenAtom = atom({ plugin: 'flightdeck', key: 'paneOpen' } as const, false)
53const usagePaneOpenAtom = atom({ plugin: 'usage-pane', key: 'paneOpen' } as const, false)
54
55type PaneCommand = { command: string; args: string }
56
57/** The mods that have a pane: where Show reads whether it is open, and the commands that show and hide it. */
58export const PANES: Readonly<Record<string, { show: PaneCommand; hide: PaneCommand }>> = {
59 flightdeck: { show: { command: 'flightdeck', args: 'open' }, hide: { command: 'flightdeck', args: 'close' } },
60 'usage-pane': { show: { command: 'usage-pane', args: 'open' }, hide: { command: 'usage-pane', args: 'close' } },
61}
62
63/** The panes opened at session start, left to right as their dock tabs read. Usage opens only when asked. */
64export const LAUNCH_ORDER = ['flightdeck'] as const
65
66async function readPaneOpen($: Engine): Promise<Record<string, boolean>> {
67 return {
68 flightdeck: await read($, flightdeckOpenAtom),
69 'usage-pane': await read($, usagePaneOpenAtom),
70 }
71}
72
73/** The bare plugin name: `pinboard@claude-mods` → `pinboard`. */
74const baseName = (id: string) => id.split('@')[0] ?? id
75
76async function setShown($: Engine, mod: ModToolsMod, isShown: boolean) {
77 const pane = PANES[baseName(mod.id)]
78 if (pane === undefined) {
79 return
80 }
81 await $.command.run(isShown ? pane.show : pane.hide)
82}
83
84/**
85 * Opens the mod panes in LAUNCH_ORDER, once per session. Tabs sit in the order their panes
86 * opened, so each command is awaited before the next. A reload fires session.start again;
87 * the flag lives in $.state, which outlasts the module, so the panes are not opened twice.
88 */
89async function launchPanes($: Engine) {
90 if (await read($, launchedAtom)) {
91 return
92 }
93 await update($, launchedAtom, () => true)
94 const paneOpen = await readPaneOpen($)
95 for (const name of LAUNCH_ORDER) {
96 if (paneOpen[name]) {
97 continue
98 }
99 // A mod that is disabled or not installed has no command: skip it, open the rest
100 await $.command.run(PANES[name]!.show).catch(() => undefined)
101 }
102}
103
104// Cells of the two switch columns, so every row's buttons line up under their headings
105const SHOW_CELLS = 10
106const ENABLED_CELLS = 8
107
108/** Clean View stays loaded when switched off: its row runs /simple instead of disabling the plugin. */
109export const CLEAN_VIEW_ID = 'clean-view@claude-mods'
110const SELF_ID = 'mod-tools@claude-mods'
111
112/** Short captions for the mods this panel knows; any other mod shows its name alone. */
113const CAPTIONS: Readonly<Record<string, string>> = {
114 'clean-view': 'simple checklist',
115 flightdeck: 'agent dashboard & pinboard',
116 'usage-pane': 'plan limits & session usage pane',
117 'secret-redactor': 'hides secrets & PII',
118}
119
120/** `clean-view@claude-mods` → `Clean View`. */
121export function modName(id: string): string {
122 return (id.split('@')[0] ?? id)
123 .split(/[-_]/)
124 .filter(word => word !== '')
125 .map(word => word[0]!.toUpperCase() + word.slice(1))
126 .join(' ')
127}
128
129type ListedPlugin = { id: string; enabled: boolean; installPath: string }
130
131/** A mod is a plugin whose hooks/hooks.json loads function-hook modules; classic-hook plugins (Codex) are not. */
132async function isMod($: Engine, installPath: string): Promise<boolean> {
133 try {
134 const manifest = asRecord(JSON.parse(String(await $.fs.read(`${installPath}/hooks/hooks.json`))))
135
136 return Array.isArray(manifest.modules) && manifest.modules.length > 0
137 } catch {
138 return false
139 }
140}
141
142/** Lists the installed mods (not this one) from `claude plugin list --json`. */
143async function refreshMods($: Engine) {
144 let listed: ListedPlugin[]
145 try {
146 const { exitCode, stdout } = await $.process.run(['claude', 'plugin', 'list', '--json'])
147 if (exitCode !== 0) {
148 return
149 }
150 listed = JSON.parse(stdout) as ListedPlugin[]
151 } catch {
152 return
153 }
154
155 const mods: ModToolsMod[] = []
156 for (const plugin of listed) {
157 if (plugin.id !== SELF_ID && (await isMod($, plugin.installPath))) {
158 mods.push({ id: plugin.id, name: modName(plugin.id), enabled: plugin.enabled })
159 }
160 }
161 mods.sort((a, b) => a.name.localeCompare(b.name))
162 await update($, modsAtom, () => mods)
163}
164
165/** Enables or disables each plugin, then reloads once. Returns false if a switch failed (its error is toasted). */
166async function switchPlugins($: Engine, ids: readonly string[], isOn: boolean): Promise<boolean> {
167 let isOk = true
168 for (const id of ids) {
169 const { exitCode, stderr, stdout } = await $.process.run(['claude', 'plugin', isOn ? 'enable' : 'disable', id, '--scope', 'user'])
170 if (exitCode !== 0) {
171 isOk = false
172 $.ui.toast(`${modName(id)}: ${(stderr || stdout).trim().split('\n')[0] ?? 'could not switch'}`)
173 }
174 }
175 if (ids.length > 0) {
176 await refreshMods($)
177 await $.command.run({ command: 'reload-plugins', args: '' })
178 }
179
180 return isOk
181}
182
183async function setMod($: Engine, mod: ModToolsMod, isOn: boolean) {
184 if (mod.id === CLEAN_VIEW_ID && mod.enabled) {
185 await setCleanView($, isOn)
186 return
187 }
188 if (await switchPlugins($, [mod.id], isOn)) {
189 $.ui.toast(`${mod.name}: ${isOn ? 'On' : 'Off'}`)
190 }
191}
192
193async function setAllMods($: Engine, isOn: boolean) {
194 const mods = await read($, modsAtom)
195 const cleanView = mods.find(mod => mod.id === CLEAN_VIEW_ID)
196 // Clean View switches by /simple; it is only enabled as a plugin when All on finds it disabled.
197 const ids = mods
198 .filter(mod => mod.enabled !== isOn && (mod.id !== CLEAN_VIEW_ID || isOn))
199 .map(mod => mod.id)
200 if (cleanView?.enabled && !isOn) {
201 await setCleanView($, false)
202 }
203 await switchPlugins($, ids, isOn)
204 if (cleanView !== undefined && isOn) {
205 await setCleanView($, true)
206 }
207 $.ui.toast(isOn ? 'All mods on' : 'All mods off')
208}
209
210/** Finds which offered model a model name (an id, an alias, a /config value) is. */
211export function modelFor(name: string | null): ModelChoice | null {
212 if (name === null) {
213 return null
214 }
215 const lower = name.toLowerCase()
216
217 return MODELS.find(model => lower.includes(model.family)) ?? null
218}
219
220export function effortFor(name: string | null): EffortChoice | null {
221 if (name === null) {
222 return null
223 }
224 const lower = name.toLowerCase()
225
226 return EFFORTS.find(effort => effort.value === lower) ?? null
227}
228
229function findRow(rows: readonly ConfigRow[], name: 'model' | 'effort'): ConfigRow | undefined {
230 const matches = (text: string) => (name === 'model' ? /^model$/i.test(text) : /effort/i.test(text))
231
232 return rows.find(row => row.provider.plugin === 'engine' && (matches(row.key) || matches(row.label)))
233}
234
235function asText(value: unknown): string | null {
236 return typeof value === 'string' && value !== '' ? value : null
237}
238
239function asRecord(value: unknown): Record<string, unknown> {
240 return typeof value === 'object' && value !== null ? (value as Record<string, unknown>) : {}
241}
242
243/** The effort settings hold for a model: its own `modelSettings` entry, else the global `effortLevel`. */
244function savedEffort(settings: Record<string, unknown>, model: string | null): string | null {
245 const choice = modelFor(model)
246 if (choice !== null) {
247 const perModel = asRecord(settings.modelSettings)
248 const bareId = choice.id.replace('[1m]', '')
249 const key = bareId in perModel ? bareId : Object.keys(perModel).find(name => modelFor(name)?.family === choice.family)
250 const effort = key === undefined ? null : asText(asRecord(perModel[key]).effortLevel)
251 if (effort !== null) {
252 return effort
253 }
254 }
255
256 return asText(settings.effortLevel)
257}
258
259async function readSettings($: Engine): Promise<Record<string, unknown>> {
260 try {
261 return asRecord(await $.settings.read())
262 } catch {
263 return {}
264 }
265}
266
267/** Reads the session's model from `/config` (or settings) and its effort from `/config` or settings. */
268async function refresh($: Engine) {
269 let model: string | null = null
270 let effort: string | null = null
271 try {
272 const rows = await $.config.list()
273 model = asText(findRow(rows, 'model')?.value)
274 effort = asText(findRow(rows, 'effort')?.value)
275 } catch {
276 // The settings below are the fallback.
277 }
278
279 const settings = await readSettings($)
280 model ??= asText(settings.model)
281 effort ??= savedEffort(settings, model)
282
283 if (model !== null) {
284 await update($, modelAtom, () => model)
285 }
286 if (effort !== null) {
287 await update($, effortAtom, () => effort)
288 }
289}
290
291async function chooseModel($: Engine, model: ModelChoice) {
292 await update($, modelAtom, () => model.id)
293 await $.command.run({ command: 'model', args: model.id })
294 const effort = savedEffort(await readSettings($), model.id)
295 if (effort !== null) {
296 await update($, effortAtom, () => effort)
297 }
298 $.ui.toast(`Model: ${model.label}`)
299}
300
301/** Sets effort through its `/config` row where this build has one, else `/effort`. */
302async function chooseEffort($: Engine, effort: EffortChoice) {
303 await update($, effortAtom, () => effort.value)
304 const row = findRow(await $.config.list(), 'effort')
305 const fits = row !== undefined && !row.isLocked && (row.kind === 'text' || (row.options ?? []).includes(effort.value))
306 const answer = fits ? await $.config.set({ key: row.key, value: effort.value }).catch(() => undefined) : undefined
307 if (answer === undefined || answer.deny !== undefined) {
308 await $.command.run({ command: 'effort', args: effort.value })
309 }
310 $.ui.toast(`Effort: ${effort.label}`)
311}
312
313async function setCleanView($: Engine, isOn: boolean) {
314 await $.command.run({ command: 'simple', args: isOn ? 'on' : 'off' })
315}
316
317async function setOpen($: Engine, isOpen: boolean) {
318 await update($, isOpenAtom, () => isOpen)
319 if (isOpen) {
320 await refresh($)
321 await refreshMods($)
322 }
323}
324
325async function toggleFromCommand($: Engine) {
326 const isOpen = !(await read($, isOpenAtom))
327 await setOpen($, isOpen)
328
329 return isOpen ? 'Mod Tools is open above the prompt.' : 'Mod Tools is closed.'
330}
331
332export function registerModTools(on: On) {
333 on('session.start', async ($, e, next) => {
334 try {
335 await $.command.register({ name: COMMAND, description: 'Open or close Mod Tools' })
336 } catch {
337 await $.command.register({ name: FALLBACK_COMMAND, description: 'Open or close Mod Tools' })
338 }
339
340 await refresh($)
341 await refreshMods($)
342
343 const started = await next(e)
344 // Not awaited: command.run waits for the session to go idle
345 if (e.isInteractive) {
346 void launchPanes($).catch(() => undefined)
347 }
348
349 return started
350 })
351
352 on('command.run', { command: 'tools' }, async $ => ({ text: await toggleFromCommand($) }))
353 on('command.run', { command: 'mod-tools' }, async $ => ({ text: await toggleFromCommand($) }))
354
355 on('turn.start', async ($, e, next) => {
356 if (await read($, isOpenAtom)) {
357 await refresh($)
358 }
359
360 return next(e)
361 })
362
363 on('ui.render', { component: 'SessionMode' }, async ($, e) => {
364 const { Box, Text, Button } = $.ui.resolve(e)
365 const isOpen = await read($, isOpenAtom)
366
367 return (
368 <Box flexDirection="row" gap={2}>
369 {e.props.modes.length > 0 && <Text dimColor>{e.props.modes.join(' & ')}</Text>}
370 <Button
371 key="open"
372 plain
373 label={`◆ ${FOOTER_LABEL} ${isOpen ? '▴' : '▾'}`}
374 onPress={() => setOpen($, !isOpen)}
375 />
376 </Box>
377 )
378 })
379
380 on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
381 if (e.props.hasSurvey || !(await read($, isOpenAtom))) {
382 return next(e)
383 }
384
385 const { Box, Text, Button } = $.ui.resolve(e)
386 const below = await next(e)
387 const width = Math.max(32, e.props.bodyColumns)
388 const model = modelFor(await read($, modelAtom))
389 const effort = effortFor(await read($, effortAtom))
390 const hasEffort = model === null || model.hasEffort
391 const isCleanViewOn = await read($, cleanViewAtom)
392 const mods = await read($, modsAtom)
393 const paneOpen = await readPaneOpen($)
394 // A mod reads On when its plugin is enabled; Clean View also needs /simple on.
395 const isOn = (mod: ModToolsMod) => mod.enabled && (mod.id !== CLEAN_VIEW_ID || isCleanViewOn)
396 const summary = [model?.label ?? 'Default model', hasEffort ? (effort?.label ?? 'Default effort') : null]
397 .filter(part => part !== null)
398 .join(' · ')
399
400 const modelRow = MODELS.map(choice =>
401 choice.family === model?.family ? (
402 <Text backgroundColor="claude" color="inverseText" bold>
403 {` ${choice.label} `}
404 </Text>
405 ) : (
406 <Button key={`model:${choice.family}`} plain label={` ${choice.label} `} onPress={() => chooseModel($, choice)} />
407 ),
408 )
409
410 const effortRow = hasEffort ? (
411 EFFORTS.map(choice =>
412 choice.value === effort?.value ? (
413 <Text backgroundColor="permission" color="inverseText" bold>
414 {` ${choice.label} `}
415 </Text>
416 ) : (
417 <Button key={`effort:${choice.value}`} plain label={` ${choice.label} `} onPress={() => chooseEffort($, choice)} />
418 ),
419 )
420 ) : (
421 <Text dimColor> {model?.label} doesn't use an effort setting</Text>
422 )
423
424 const modRow = (mod: ModToolsMod) => {
425 const isModOn = isOn(mod)
426 const caption = CAPTIONS[baseName(mod.id)]
427 const hasPane = mod.enabled && PANES[baseName(mod.id)] !== undefined
428 const isShown = paneOpen[baseName(mod.id)] === true
429
430 return (
431 <Box key={`row:${mod.id}`} flexDirection="row" justifyContent="space-between" gap={2}>
432 <Box flexDirection="row" gap={1} flexShrink={1}>
433 <Text color={isModOn ? 'success' : 'inactive'}>{isModOn ? '●' : '○'}</Text>
434 <Text bold>{mod.name}</Text>
435 {caption !== undefined && (
436 <Text dimColor wrap="truncate-end">
437 {caption}
438 </Text>
439 )}
440 </Box>
441 <Box flexDirection="row" flexShrink={0}>
442 <Box width={SHOW_CELLS} flexShrink={0}>
443 {hasPane &&
444 (isShown ? (
445 <Box backgroundColor="success">
446 <Button key={`show:${mod.id}`} plain label=" ● Shown " onPress={() => setShown($, mod, false)} />
447 </Box>
448 ) : (
449 <Button key={`show:${mod.id}`} plain label=" ○ Hidden " onPress={() => setShown($, mod, true)} />
450 ))}
451 </Box>
452 <Box width={ENABLED_CELLS} flexShrink={0}>
453 {isModOn ? (
454 <Box backgroundColor="success">
455 <Button key={`mod:${mod.id}`} plain label=" ● On " onPress={() => setMod($, mod, false)} />
456 </Box>
457 ) : (
458 <Button key={`mod:${mod.id}`} plain label=" ○ Off " onPress={() => setMod($, mod, true)} />
459 )}
460 </Box>
461 </Box>
462 </Box>
463 )
464 }
465
466 const panel = (
467 <Box flexDirection="column" width={width}>
468 <Box flexDirection="column" borderStyle="round" borderColor="subtle" paddingX={1}>
469 <Box flexDirection="row" justifyContent="space-between" gap={2}>
470 <Text color="claude" bold wrap="truncate-end">
471 {TITLE}
472 </Text>
473 <Text wrap="truncate-end">{summary}</Text>
474 </Box>
475
476 <Box flexDirection="row" marginTop={1}>
477 <Box width={LABEL_CELLS} flexShrink={0}>
478 <Text dimColor>MODEL</Text>
479 </Box>
480 <Box flexDirection="row" flexWrap="wrap" flexShrink={1}>
481 {modelRow}
482 </Box>
483 </Box>
484 <Box flexDirection="row">
485 <Box width={LABEL_CELLS} flexShrink={0}>
486 <Text dimColor>EFFORT</Text>
487 </Box>
488 <Box flexDirection="row" flexWrap="wrap" flexShrink={1}>
489 {effortRow}
490 </Box>
491 </Box>
492
493 <Box key="heading:mods" flexDirection="row" justifyContent="space-between" gap={2} marginTop={1} marginBottom={1}>
494 <Box flexDirection="row" gap={2} paddingLeft={2} flexShrink={1}>
495 <Text dimColor>{MODS_HEADING}</Text>
496 {mods.length > 0 && (
497 <Box flexDirection="row" gap={1}>
498 <Button key="mods:allOn" plain label=" All on " onPress={() => setAllMods($, true)} />
499 <Button key="mods:allOff" plain label=" All off " onPress={() => setAllMods($, false)} />
500 </Box>
501 )}
502 </Box>
503 {mods.length > 0 && (
504 <Box flexDirection="row" flexShrink={0}>
505 <Box width={SHOW_CELLS} flexShrink={0}>
506 <Text dimColor> Show</Text>
507 </Box>
508 <Box width={ENABLED_CELLS} flexShrink={0}>
509 <Text dimColor> Enabled</Text>
510 </Box>
511 </Box>
512 )}
513 </Box>
514 {mods.length > 0 ? mods.map(modRow) : <Text dimColor>No other mods installed</Text>}
515 </Box>
516 <Text dimColor wrap="truncate-end">
517 {'─'.repeat(Math.max(0, width - RULE_LABEL.length))}
518 {RULE_LABEL}
519 </Text>
520 </Box>
521 )
522
523 // No size props on this wrapper: the engine refuses its own band node under a sized Box.
524 return (
525 <Box flexDirection="column">
526 {panel}
527 {below}
528 </Box>
529 )
530 })
531}
532types/index.d.ts 20 lines1export type ModToolsModel = string | null
2
3export type ModToolsEffort = string | null
4
5/** An installed mod the panel can switch: its plugin id, display name and whether the plugin is enabled. */
6export type ModToolsMod = { id: string; name: string; enabled: boolean }
7
8declare module 'claude-code' {
9 interface PluginState {
10 'mod-tools': {
11 isOpen: boolean
12 model: ModToolsModel
13 effort: ModToolsEffort
14 mods: ModToolsMod[]
15 /** True once this session's panes were opened in launch order. */
16 launched: boolean
17 }
18 }
19}
20