Every tool Claude can use (built-in and MCP) in plain language, how often each was used, and suggestions tailored to the project you are in.

Panels, guardrails and quality-of-life mods for Claude Code: see what fills your context, how fast you burn your plan, and what the agent is running right now, and block the commands you never want run.
<img src="docs/demo-guardrails.gif" alt="guardrails blocking an agent's oc delete all --all before it runs" width="900">
<sub>If a mod saves you from one bad approve, a ⭐ on this repo helps other people find it.</sub>
Claude Code is a black box while it works. You can't see the context window filling up until it compacts away the decision you made an hour ago. You find out you've burned your 5-hour limit when it stops answering. You approve a command, tab away, and come back ten minutes later to find it has been waiting on a second approval the whole time. And most people discover /rewind only after the edit they wanted to undo.
claude-mods is a set of small plugins that open that box. Each mod is a standalone Claude Code plugin built on function hooks, the in-process plugin API: it sees every prompt, tool call and turn as it happens, and it can draw panels, toasts and status lines inside Claude Code itself. Install all eleven or only the ones you want.
They are deliberately boring about tokens. Nine of the eleven never call a model. The two that do (prompt-coach's review and context-keeper's handoff note) say so and are easy to turn off.
| 🧩 mod-manager | One panel (/mods) to install, turn on or off, update, or remove each mod, with presets (Safety only, Essentials, Zero tokens, Everything). Shows when a mod has a newer version. Install this first and pick the rest |
| 🚦 quickbar | One line above the prompt: live context % and a button for every claude-mods panel you have installed. Start here |
| 🧠 context-keeper | What fills your context window, tips to trim it, and checkpoints: a handoff note (goal, decisions, files, TODOs) saved to .claude/checkpoints/ so /clear and /compact stop losing the thread. Archives the raw transcript before every compaction, for zero tokens |
| 📈 usage-meter | 5-hour and 7-day plan-limit bars with reset countdown, burn rate and "full in ~2.3h", session cost, cache hit ratio (and why it's low), tokens-per-turn sparkline (drawn as charts in the desktop app) |
| 🔔 notify | Notification inbox plus native OS notifications (Windows, macOS, Linux) when a long turn ends, a subagent or background task finishes, Claude asks you something, or an approval has been waiting 15s |
| 👀 activity | What Claude is doing this second: thinking, running $ npm test for 0m42s, waiting for YOUR approval, which subagents run, and its todo plan with progress |
| 🛡️ guardrails | Clickable safety rules with presets (Safe defaults, Locked to project, Read-only review): block rm -rf, mass kubectl/oc deletes, terraform destroy, force-push, destructive git, .env and key files, sudo, installs, network; keep Claude inside the project; add your own patterns. Checks scripts the agent wrote before they run, and keeps a weekly log of what it blocked |
| ✍️ prompt-coach | Before a vague prompt is sent, a small fast model suggests a sharper one. You pick Send improved / Send mine / Edit. Never rewrites silently, never touches "yes" or "continue" |
| 🧰 toolbox | Every tool Claude can use (built-in and MCP, grouped by server) in plain language, how often each was used, and suggestions for the project you're in |
| ⌨️ command-hub | The built-in commands you're probably missing, each with when to use it; a searchable list of everything installed; a form to create your own slash command; tips when your prompt matches one ("undo that" → /rewind) |
| 📝 changes | Every file Claude created or edited this session with +/- counts from git, plus one-click why?, summarize all and self-review |
| 🔁 loop-breaker | Notices Claude going in circles (the same command failing 3×, the same code rewritten 3× in a turn), tells you, and tells Claude to stop and rethink |
activity: what Claude is running right now, and the moment it's waiting on you
<img src="docs/demo-activity.gif" alt="activity panel showing thinking, waiting for approval, then completed tool calls" width="900">
context-keeper + usage-meter: what fills the window, a checkpoint saved to disk, plan limits
<img src="docs/demo-context.gif" alt="context panel, writing a checkpoint, then the usage meter" width="900">
prompt-coach: a vague prompt, a suggested rewrite, you choose
<img src="docs/demo-coach.gif" alt="prompt coach suggesting a sharper prompt and sending it" width="900">
command-hub: the built-in commands worth knowing, explained
<img src="docs/demo-commands.gif" alt="command hub listing essential slash commands" width="900">
You ──prompt──▶ ┌──────────────────────────────┐
│ Claude Code engine │
│ │
│ prompt.submit tool.call │
│ turn.start turn.complete│
│ session.compact ui.render │
└──────┬─────────────────▲──────┘
events, in │ │ allow · deny · rewrite
order, live ▼ │ panes · toasts · status
┌──────────────────────────────┐
│ claude-mods (one plugin each)│
│ │
│ guardrails ── may deny ──────┤
│ prompt-coach ─ may ask you ──┤
│ activity · changes · notify │
│ usage-meter · context-keeper │──▶ .claude/checkpoints/
│ toolbox · command-hub ... │──▶ OS notifications
└──────────────────────────────┘
What a mod sees. Each mod registers hooks on engine events. A tool.call hook sits in front of every tool the agent runs (Bash, Edit, MCP tools, subagents) and sees its real arguments before anything executes. That is how activity can show the exact command and guardrails can refuse it.
What it can change. A hook either passes the event on, rewrites it, or answers it itself. Guardrails answers with a denial the model reads ("blocked by the user's guardrails, don't work around it"). Prompt-coach never rewrites on its own: it asks you first, in Claude Code's own question dialog.
What it draws. Panels are ui.render hooks returning a small element tree (Box, Text, Button, Input) that Claude Code draws natively in the terminal and the desktop app. State lives in the engine ($.state), so panels survive a hot reload and redraw only when their data changes.
What it costs. Nothing, for nine of the mods. They read numbers the engine already has ($.session.usage(), $.tool.list(), $.command.list()). The two model calls are opt-out and listed under Honest limits.
Prerequisites: Claude Code 2.1.286 or newer (claude update). Panels dock beside the chat in the desktop app or a terminal ≥ 144 columns wide, and open inline in narrower terminals.
From any terminal:
claude plugin marketplace add mishgoldenberg/claude-mods
claude plugin install mod-manager@claude-mods
(In the Claude Code CLI you can also use /plugin marketplace add mishgoldenberg/claude-mods and the /plugin menu.)
Restart Claude Code. The first session says hello once ("claude-mods ready: /mods to pick your set"). Type /mods: the manager lists every mod with what it does, whether it uses tokens, and whether an update is available. Install, turn on or off, update, or remove each one with a click, or apply a preset:
| Preset | What you get |
|---|---|
| Safety only | guardrails, notify |
| Essentials | guardrails, activity, notify, context-keeper, usage-meter |
| Zero tokens | every mod that never calls a model |
| Everything | all eleven |
Presets turn off what they don't list and never remove anything. Changes apply in your next session.
With quickbar installed, a one-line bar sits above the prompt: live context % and a button for every installed panel. /quickbar (or its ×) hides it; /quickbar again brings it back.
Or just ask Claude: "Install the claude-mods plugins from github.com/mishgoldenberg/claude-mods. Follow its INSTALL-FOR-CLAUDE.md."
The VS Code extension has no /plugin menu, so install from a terminal with the two commands in step 1, then use /mods inside VS Code. Mods need the extension to run Claude Code 2.1.286 or newer.
for m in quickbar context-keeper usage-meter notify activity guardrails prompt-coach toolbox command-hub changes loop-breaker; do
claude plugin install "$m@claude-mods"
done
git clone https://github.com/mishgoldenberg/claude-mods.git
claude --plugin-dir claude-mods/plugins/activity --plugin-dir claude-mods/plugins/guardrails
| Command | Mod | What it does | |||
|---|---|---|---|---|---|
/mods | mod-manager | Install, turn on or off, update, or remove mods; apply a preset | |||
/quickbar | quickbar | Show or hide the launcher above the prompt | |||
/ctx | context-keeper | Open the context panel | |||
/checkpoint | context-keeper | Save a handoff note of this session now | |||
/resume-checkpoint | context-keeper | Load the latest checkpoint into the prompt box (use after /clear) | |||
/meter | usage-meter | Open plan limits, burn rate and cost | |||
/notifications | notify | Open the notification inbox | |||
| `/mute [on\ | off]` | notify | Mute or unmute notifications | ||
/activity | activity | Open the live activity panel | |||
/guard | guardrails | Open the rules panel | |||
| `/guard-preset <safe\ | locked\ | review\ | off>` | guardrails | Apply a preset |
/guard-log [json] | guardrails | What guardrails blocked in the last 7 days | |||
| `/coach [on\ | off]` | prompt-coach | Turn the prompt coach on or off | ||
/tools | toolbox | Open the tools panel and project suggestions | |||
/cmds | command-hub | Open the command hub | |||
/new-command | command-hub | Create your own slash command | |||
/changes | changes | Open the changed-files panel |
Options appear in /config once a mod is installed, or go in ~/.claude/settings.json under pluginConfigs.<mod>.
| Option | Default | Description |
|---|---|---|
warnAt | 70 | Toast a tip when context passes this % |
checkpointAt | 85 | Write a handoff note automatically at this % (0 = off) |
| Option | Default | Description |
|---|---|---|
warnAt | 80 | Toast when a plan window passes this % (a second toast always fires at 95%) |
| Option | Default | Description |
|---|---|---|
minSeconds | 30 | Only notify for turns at least this long |
osNotify | true | Also raise a native OS notification |
approvalWaitSeconds | 15 | Ping when an approval has waited this long (-1 = off) |
| Mod | Option | Default | Description |
|---|---|---|---|
| activity | autoOpen | false | Dock the panel on session start when there is room |
| prompt-coach | enabled | true | Review prompts before sending |
| prompt-coach | model | claude-haiku-4-5 | Reviewer model; small keeps the delay near a second |
| prompt-coach | minChars | 8 | Never review prompts shorter than this |
| loop-breaker | failLimit | 3 | Same failing command this many times in a row |
| loop-breaker | editLimit | 3 | Times the same code is rewritten in one turn (separate edits to different parts of a file never count) |
| Rule | Blocks | In preset |
|---|---|---|
no-rm-rf | rm -rf, rm -fr, Remove-Item -Recurse -Force, rmdir /s | Safe · Locked |
no-mass-delete | kubectl/oc delete --all or -A, delete namespace/project, helm uninstall, terraform destroy | Safe · Locked · Review |
no-force-push | git push --force / -f (--force-with-lease allowed) | Safe · Locked |
no-history-rewrite | git reset --hard, git clean -f, git checkout -- ., branch -D, stash drop, fetch/pull --prune, remote prune | Safe · Locked |
protect-secrets | reading or writing .env*, *.pem, *.key, id_rsa, credentials files | Safe · Locked · Review |
no-sudo | sudo, su -, runas | Safe · Locked · Review |
no-installs | npm i, pip install, cargo add, brew/apt/winget install … | Review |
no-network | WebFetch, WebSearch, curl, wget, Invoke-WebRequest | — |
jail-writes | Write/Edit outside the project folder | — |
jail-all | any file tool outside the project, cd out of it | Locked |
read-only | all edits; shell limited to look-only commands | Review |
Guardrails turns on Safe defaults the first time it loads. /guard-preset off turns everything off.
Whatever the preset, while any rule is on:
Write in this session (and edits after that) is remembered, and when a shell command runs it (bash cleanup.sh, python tools/x.py, ./run, node a.mjs), its code is checked against your enabled rules and patterns first. os.system("rm -rf …") inside a Python file counts.Write/Edit on them, and the obvious shell writes (sed -i, >, tee, cp, mv, rm), are denied with the same "ask the user" message./guard-log prints a summary (/guard-log json for the raw list), and clear wipes it. Commands are cut to 200 characters.Mods run inside Claude Code with your permissions and no sandbox, so this is the right question to ask about any mod, including these. What these ones do:
git diff --numstat (changes), the claude plugin CLI when you open /mods or click in it (mod-manager; only Install, Update and Check for updates go online, through Claude Code's own plugin installer), your OS notification tool (notify), and gh --version to see whether the GitHub CLI exists (toolbox)..claude/checkpoints/ (context-keeper), and a new slash command file when you use the form (command-hub). Settings, and guardrails' 30-day block log, live in Claude Code's own plugin store under ~/.claude. Nothing else.Every mod is a few hundred lines of TypeScript in plugins/<mod>/hooks/register.tsx. Read the ones you install.
rm -rf doesn't block you, except when the text is handed to a shell (bash -c, | sh, powershell -Command), which is checked. For hard guarantees use Claude Code's permission rules and sandboxing; use guardrails to catch the honest mistakes./coach off turns it off.claude-mods/
├── .claude-plugin/
│ └── marketplace.json The marketplace: one entry per mod
├── plugins/
│ ├── activity/
│ │ ├── .claude-plugin/
│ │ │ └── plugin.json Name, description, userConfig options
│ │ ├── hooks/
│ │ │ ├── hooks.json Points at the hooks module
│ │ │ └── register.tsx The mod: hooks, commands, panel
│ │ ├── tests/
│ │ │ └── surfaces.test.tsx The panel draws on every surface (claude plugin test)
│ │ └── types/
│ │ └── index.d.ts Its $.state contract
│ ├── guardrails/ …same shape for every mod
│ └── …
├── docs/
│ └── design.md The shared design spec and kit every mod copies
├── tests/
│ ├── guardrails-rules.test.mjs Every rule against real commands
│ └── design-kit.test.mjs Every mod's kit matches docs/design.md
├── INSTALL-FOR-CLAUDE.md Steps Claude follows when asked to install
└── tsconfig.json Type-checks all mods against the engine API
Add a guardrail rule. Append an entry to RULES in plugins/guardrails/hooks/register.tsx (an id, a title, and a test that returns the offending text) and add cases to tests/guardrails-rules.test.mjs. The panel and presets pick it up automatically.
Add an essential command. One line in ESSENTIALS in plugins/command-hub/hooks/register.tsx. It only shows when that command exists in the user's Claude Code.
Write a new mod. Copy plugins/changes (a small mod with a panel) or plugins/loop-breaker (no UI), rename it everywhere, and add it to marketplace.json. Or ask Claude Code to "make a mod that …": it has a built-in skill for exactly this, with hot reload.
Issues and pull requests are welcome. Start with CONTRIBUTING.md, which has the mod checklist.
npm install
npm run typecheck
npm test
claude plugin validate plugins/<mod>
claude plugin test plugins/<mod>
Every mod follows one design spec, docs/design.md: theme colors only (Claude orange as the single accent), the same pane header, glyphs, hotkeys and empty states, so the set feels like one product in any theme.
Two house rules worth knowing before you write anything, because the validator enforces both:
$ must be top-level function declarations. A closure inside register that receives $ is rejected.$.state key is declared in the mod's types/index.d.ts, under the mod's name.Found a way around guardrails, or another security problem? Please report it privately; see SECURITY.md.
MIT © 2026 Michael Goldenberg
hooks/register.tsx 284 lines1import { atom, read, update } from 'claude-code'
2import type { ElementTable, EngineInterface, Register, RenderChildren } from 'claude-code'
3
4import type { Suggestion, ToolRow } from '../types'
5
6// ── claude-mods kit v1 (docs/design.md): identical in every mod ──
7const TONE = { accent: 'claude', ok: 'success', warn: 'warning', bad: 'error', dim: 'inactive' } as const
8const GLYPH = { on: '●', off: '○', warn: '▲', ok: '✓', fail: '✗' } as const
9type Kit = Pick<ElementTable, 'Box' | 'Text'>
10
11/** Pane header: state glyph, mod name, one-line live status. */
12function header({ Box, Text }: Kit, glyph: string, tone: string, name: string, status: string) {
13 return (
14 <Box gap={1}>
15 <Text color={tone}>{glyph}</Text>
16 <Text bold>{name}</Text>
17 <Text dimColor wrap="truncate-end">{status}</Text>
18 </Box>
19 )
20}
21
22/** A section: a dim label (with optional small controls beside it), then its rows. */
23function section({ Box, Text }: Kit, label: string, rows: RenderChildren, aside?: RenderChildren) {
24 return (
25 <Box flexDirection="column">
26 <Box gap={1}>
27 <Text dimColor>{label}</Text>
28 {aside}
29 </Box>
30 {rows}
31 </Box>
32 )
33}
34
35/** A number right-aligned in a fixed-width cell. */
36function num({ Box, Text }: Kit, value: string, width: number, color?: string) {
37 return (
38 <Box width={width} flexShrink={0} justifyContent="flex-end">
39 <Text color={color}>{value}</Text>
40 </Box>
41 )
42}
43
44/** Empty state: what will show up here, and how to get it. */
45function empty({ Text }: Kit, text: string) {
46 return <Text dimColor>{text}</Text>
47}
48// ── end kit ──
49
50const PANE = 'toolbox'
51const tools = atom({ plugin: 'toolbox', key: 'tools' } as const, [])
52const counts = atom({ plugin: 'toolbox', key: 'counts' } as const, {} as Record<string, number>)
53const suggestions = atom({ plugin: 'toolbox', key: 'suggestions' } as const, [])
54const stack = atom({ plugin: 'toolbox', key: 'stack' } as const, [])
55const filter = atom({ plugin: 'toolbox', key: 'filter' } as const, 'all')
56
57/** Plain-language explanations of the built-in tools, for people new to Claude Code. */
58const EXPLAIN: Record<string, string> = {
59 Bash: 'Runs shell commands (builds, tests, git…)',
60 PowerShell: 'Runs PowerShell commands on Windows',
61 Read: 'Reads files, images, PDFs and notebooks',
62 Write: 'Creates or overwrites a file',
63 Edit: 'Makes exact find-and-replace edits in a file',
64 NotebookEdit: 'Edits Jupyter notebook cells',
65 Glob: 'Finds files by name pattern',
66 Grep: 'Searches file contents (ripgrep)',
67 WebFetch: 'Downloads and reads a web page',
68 WebSearch: 'Searches the web',
69 Agent: 'Starts a subagent for a side task (keeps main context clean)',
70 Task: 'Starts a subagent for a side task (keeps main context clean)',
71 TodoWrite: 'Keeps a visible todo plan for multi-step work',
72 AskUserQuestion: 'Asks you a multiple-choice question',
73 Skill: 'Loads a packaged skill (instructions for a kind of task)',
74 ToolSearch: 'Loads the schemas of deferred tools on demand',
75 EnterPlanMode: 'Switches to plan-first mode',
76 ExitPlanMode: 'Presents a plan for your approval',
77 Monitor: 'Watches a background process for a condition',
78}
79
80const firstSentence = (s: string) => {
81 const line = s.split('\n').find(l => l.trim() !== '')?.trim() ?? ''
82 const cut = line.split(/(?<=\.)\s/)[0] ?? line
83
84 return cut.length > 90 ? `${cut.slice(0, 89)}…` : cut
85}
86
87async function loadTools($: EngineInterface) {
88 const list = await $.tool.list()
89 const rows: ToolRow[] = list.map(t => {
90 const mcp = /^mcp__(.+?)__(.+)$/.exec(t.name)
91 const server = mcp?.[1] ?? ''
92
93 return {
94 name: t.name,
95 group: t.mcp || mcp ? `MCP: ${/^[0-9a-f-]{20,}$/.test(server) ? 'connector' : server}` : 'Built-in',
96 short: EXPLAIN[t.name] ?? firstSentence(t.description),
97 isMcp: t.mcp,
98 }
99 })
100 await update($, tools, () => rows)
101}
102
103async function exists($: EngineInterface, root: string, rel: string) {
104 return $.fs.exists(`${root}/${rel}`).catch(() => false)
105}
106
107/** Looks at the project folder and proposes tools, MCP servers and habits that fit it. */
108async function scan($: EngineInterface) {
109 const root = (await $.session.root()).replace(/\\/g, '/')
110 const has = (rel: string) => exists($, root, rel)
111 const found: string[] = []
112 const out: Suggestion[] = []
113 const toolNames = (await read($, tools)).map(t => t.name.toLowerCase()).join(' ')
114
115 let deps: Record<string, unknown> = {}
116 let scripts: Record<string, unknown> = {}
117 if (await has('package.json')) {
118 found.push('Node')
119 try {
120 const pkg = JSON.parse(await $.fs.read(`${root}/package.json`)) as { dependencies?: Record<string, unknown>; devDependencies?: Record<string, unknown>; scripts?: Record<string, unknown> }
121 deps = { ...pkg.dependencies, ...pkg.devDependencies }
122 scripts = pkg.scripts ?? {}
123 } catch {
124 // unreadable package.json
125 }
126 }
127 const dep = (name: string) => Object.keys(deps).some(d => d === name || d.startsWith(`${name}/`) || d.startsWith(`@${name}/`))
128
129 if (dep('react') || dep('next') || dep('vue') || dep('svelte') || dep('vite') || dep('@angular/core')) found.push('Web UI')
130 if (dep('typescript')) found.push('TypeScript')
131 if ((await has('pyproject.toml')) || (await has('requirements.txt'))) found.push('Python')
132 if (await has('Cargo.toml')) found.push('Rust')
133 if (await has('go.mod')) found.push('Go')
134 if ((await has('Dockerfile')) || (await has('docker-compose.yml')) || (await has('compose.yaml'))) found.push('Docker')
135 if (dep('prisma') || dep('drizzle-orm') || dep('pg') || dep('mongoose') || (await has('prisma/schema.prisma'))) found.push('Database')
136 if (await has('.github/workflows')) found.push('GitHub Actions')
137 const isGit = await has('.git')
138 if (isGit) found.push('git')
139
140 if (!(await has('CLAUDE.md')) && !(await has('.claude/CLAUDE.md'))) {
141 out.push({ id: 'init', title: 'Give Claude a project memory', why: 'No CLAUDE.md here. /init writes one with your build/test commands and conventions, so you stop repeating them.', action: { kind: 'command', value: 'init', label: 'Run /init' } })
142 }
143 if (found.includes('Web UI') && !/browser|playwright|puppeteer|chrome/.test(toolNames)) {
144 out.push({ id: 'browser', title: 'Let Claude see your UI', why: 'Web frontend detected but no browser tool. A browser/Playwright MCP lets Claude click through the app and check its own changes.', action: { kind: 'fill', value: 'Help me set up a browser automation MCP server (e.g. Playwright) for this project so you can check UI changes yourself.', label: 'Ask Claude to set it up' } })
145 }
146 if (found.includes('Database') && !/postgres|sql|supabase|mongo|prisma|neon/.test(toolNames)) {
147 out.push({ id: 'db', title: 'Database access for Claude', why: 'An ORM/DB driver is in this project. A read-only database MCP lets Claude check the real schema and data instead of guessing.', action: { kind: 'fill', value: 'Which database MCP server fits this project? Set up a read-only connection for local development.', label: 'Ask Claude' } })
148 }
149 if (isGit) {
150 const gh = await $.process.run(['gh', '--version']).catch(() => undefined)
151 if (gh === undefined || gh.exitCode !== 0) {
152 out.push({ id: 'gh', title: 'Install the GitHub CLI', why: 'With `gh` Claude can open PRs, read issues and check CI from the terminal.' })
153 }
154 }
155 const testScript = Object.keys(scripts).find(s => /^test/.test(s))
156 if (testScript !== undefined || (await has('pytest.ini')) || (await has('Cargo.toml')) || (await has('go.mod'))) {
157 out.push({ id: 'verify', title: 'Make Claude verify its work', why: 'Tests exist. Telling Claude how to verify (in CLAUDE.md) catches mistakes before you see them.', action: { kind: 'fill', value: `Add a "How to verify changes" section to CLAUDE.md with the exact test${testScript ? ` (npm run ${testScript})` : ''}, lint and type-check commands for this project.`, label: 'Add to CLAUDE.md' } })
158 }
159 if (!(await has('.claude/settings.json'))) {
160 out.push({ id: 'perms', title: 'Fewer permission prompts', why: 'No project settings yet. Allow-listing safe read-only commands (git status, tests) saves a lot of clicking.', action: { kind: 'command', value: 'fewer-permission-prompts', label: 'Scan & suggest' } })
161 }
162 out.push({ id: 'ask', title: 'Ask Claude for a tailored tool review', why: 'Claude reads this project and the tool list above and tells you what is missing or unused.', action: { kind: 'submit', value: 'Look at this project (stack, scripts, CI) and at the tools, MCP servers and skills you currently have. Suggest the 3 most useful additions for this project and anything I have that is unused noise. Be concrete, no setup yet.', label: 'Ask now' } })
163
164 await update($, stack, () => found)
165 await update($, suggestions, () => out)
166}
167
168async function act($: EngineInterface, s: Suggestion) {
169 const action = s.action
170 if (action === undefined) return
171 if (action.kind === 'command') {
172 const available = (await $.command.list()).some(c => c.name === action.value)
173 if (!available) {
174 $.ui.toast(`/${action.value} is not available in this session.`)
175 return
176 }
177 await $.command.run({ command: action.value })
178 } else if (action.kind === 'fill') {
179 await $.prompt.fill({ text: action.value })
180 } else {
181 await $.prompt.submit({ text: action.value })
182 }
183}
184
185export const register: Register = on => {
186 on('session.start', async ($, e, next) => {
187 await $.command.register({ name: 'tools', description: 'See every tool Claude can use, how often it used them, and suggestions for this project' })
188 void loadTools($)
189
190 return next(e)
191 })
192
193 on('command.run', { command: 'tools' }, async $ => {
194 await loadTools($)
195 void scan($)
196 await $.ui.open({ id: PANE, title: 'Tools' })
197
198 return { text: 'Tools panel opened.' }
199 })
200
201 on('tool.call', async ($, e, next) => {
202 await update($, counts, c => ({ ...c, [e.tool]: (c[e.tool] ?? 0) + 1 }))
203
204 return next(e)
205 })
206
207 on('ui.render', { component: 'Pane', requestId: PANE }, async ($, e) => {
208 const { Box, Text, Button } = $.ui.resolve(e)
209 const rows = await read($, tools)
210 const used = await read($, counts)
211 const tips = await read($, suggestions)
212 const found = await read($, stack)
213 const view = await read($, filter)
214
215 const groups = new Map<string, ToolRow[]>()
216 for (const row of rows) {
217 if (view === 'used' && (used[row.name] ?? 0) === 0) continue
218 if (view === 'mcp' && !row.isMcp) continue
219 groups.set(row.group, [...(groups.get(row.group) ?? []), row])
220 }
221 const shortName = (n: string) => n.replace(/^mcp__.+?__/, '')
222
223 const kit = { Box, Text }
224 const usedCount = Object.keys(used).length
225 const shown = [...groups.values()].reduce((n, list) => n + list.length, 0)
226
227 return (
228 <Box flexDirection="column" gap={1}>
229 {header(kit, GLYPH.on, TONE.accent, 'toolbox', rows.length === 0 ? 'reading tools…' : `${rows.length} tools · ${usedCount} used this session`)}
230
231 {section(
232 kit,
233 `For this project${found.length > 0 ? ` (${found.join(', ')})` : ''}`,
234 <Box flexDirection="column">
235 {tips.length === 0 && empty(kit, 'Looking at this project… suggestions appear here in a moment.')}
236 {tips.map(s => (
237 <Box flexDirection="column">
238 <Box gap={1}>
239 <Text color={TONE.accent}>{GLYPH.on}</Text>
240 <Text wrap="truncate-end">{s.title}</Text>
241 {s.action !== undefined && <Button key={`act-${s.id}`} plain label={s.action.label} onPress={() => void act($, s)} />}
242 </Box>
243 <Box paddingLeft={2}>
244 <Text dimColor>{s.why}</Text>
245 </Box>
246 </Box>
247 ))}
248 </Box>,
249 )}
250
251 {section(
252 kit,
253 'Tools',
254 <Box flexDirection="column" gap={1}>
255 {shown === 0 && empty(kit, view === 'used' ? 'No tools used yet this session. Counts go up as Claude works.' : view === 'mcp' ? 'No MCP tools connected. /mcp adds servers (databases, browsers, issue trackers…).' : 'Reading the tool list…')}
256 {[...groups.entries()].map(([group, list]) =>
257 section(
258 kit,
259 `${group} (${list.length})`,
260 list.map(t => (
261 <Box gap={1}>
262 {(used[t.name] ?? 0) > 0 ? num(kit, `${used[t.name]}×`, 5) : num(kit, '·', 5, TONE.dim)}
263 <Text wrap="truncate-end">
264 {shortName(t.name)} <Text dimColor>{t.short}</Text>
265 </Text>
266 </Box>
267 )),
268 ),
269 )}
270 </Box>,
271 <Box gap={1}>
272 {(['all', 'used', 'mcp'] as const).map((v, i) => (
273 <Button key={`f-${v}`} plain hotkey={String(i + 1)} label={view === v ? `[${v}]` : v} onPress={() => void update($, filter, () => v)} />
274 ))}
275 </Box>,
276 )}
277 <Box>
278 <Button key="rescan" hotkey="r" variant="primary" label="Rescan" onPress={() => void loadTools($).then(() => scan($))} />
279 </Box>
280 </Box>
281 )
282 })
283}
284types/index.d.ts 16 lines1export type ToolRow = { name: string; group: string; short: string; isMcp: boolean }
2
3export type Suggestion = { id: string; title: string; why: string; action?: { kind: 'command' | 'fill' | 'submit'; value: string; label: string } }
4
5declare module 'claude-code' {
6 interface PluginState {
7 toolbox: {
8 tools: ToolRow[]
9 counts: Record<string, number>
10 suggestions: Suggestion[]
11 stack: string[]
12 filter: string
13 }
14 }
15}
16