SLOPSHOPPER

approvals

A pane on the right listing the decisions Claude needs from you, each with its recommendation and Approve / Chat buttons

paneguardcommandprompttool
v0.1.0MITupdated 2026-10-16dbroadhurst/claude-mod-approvals
A shopper browsing a rack in a slop shop
Preview · a replayed session in a sandbox
claude · ~/work/app · approvals
│ ┃ Approvals ✕ › fix the failing auth test and add an audit log call │ ┃ Nothing waiting for you │ ⏺ Read(src/auth.ts) │ ⎿ Read 6 lines │ ⏺ Update(src/auth.ts) │ ⎿ Added 2 lines, removed 1 line │ ⏺ Bash(bun test) │ ⎿ 3 pass, 1 fail │ │ ● Done. refresh now rejects expired claims and logs an audit event. │ │ ✻ Worked for 42s · done 4:20 PM │ │ › /approvals │ ⎿ approvals: Approvals pane opened. │ │ ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── › ? for shortcuts

Draws

Pane · Approvals
Nothing waiting for you
README

approvals — a Claude Code mod

A pane beside the chat that lists the decisions Claude needs from you. Each one is condensed to two lines, a title and Claude's recommendation, so the list is easy to scroll:

3 waiting for you

1. Capsule sky [AD-Q1]
✓ "Race under the lights": the track's own sky, no painted glow
[ Approve ]  Chat  more
  • Approve settles it and tells Claude to go ahead with its recommendation.
  • Chat puts Re [id] <title>: in your prompt box so you can answer in your own words.
  • more opens the reasoning and the alternatives in place.
  • Decided items fold into a ▸ Decided (n) row.

Claude adds items itself: the mod gives it three tools (ask, resolve, list) and a short instruction to use them whenever it puts a decision to you with a recommendation. If you answer in chat instead of pressing Approve, Claude marks the item settled.

The list is kept per project and survives restarts. The pane opens by itself when something is waiting; /approvals shows or hides it.

Install

At the prompt of a Claude Code terminal session:

/plugin install approvals --marketplace dbroadhurst/claude-mod-approvals

Answer y to add the marketplace, then choose a scope (user scope loads it in every session).

Where the pane shows

In the fullscreen layout with a terminal at least 110 columns wide, the pane docks beside the transcript (144 columns when it opens by itself). Narrower, or on the main-screen layout, it sits above the prompt.

Notes

  • Built on Claude Code's function-hooks plugin API (Claude Code 2.1.294), which is early access and may change between releases.
  • Develop from a clone with claude --plugin-dir <path>; check with claude plugin validate . and claude plugin test ..

MIT licensed.

Source 2 files
hooks/register.tsx 235 lines
1import { atom, read, update } from 'claude-code'
2import type { EngineInterface, Register } from 'claude-code'
3
4import type { Approval, Board } from '../types'
5
6// One board of decisions per project, kept across sessions in $.store.
7const PANE = 'approvals'
8const TITLE = 'Approvals'
9const board = atom({ plugin: 'approvals', key: 'board' } as const, { root: '', items: [] })
10const expanded = atom({ plugin: 'approvals', key: 'expanded' } as const, [])
11
12const MAX_RESOLVED = 30
13const storeKey = (root: string) => `board:${root}`
14
15const GUIDE = [
16  'Approvals pane (the `approvals` plugin): the person sees the decisions you need from them in a pane beside the chat, each with Approve and Chat buttons.',
17  '- Whenever you put a decision to the person with a recommendation, also call `mcp__approvals__ask` with a short id (the design-doc id if there is one), a title of a few words, and the recommendation condensed to one line (about 100 characters). Put the reasoning in `why` and the other options in `alternatives`, a line each.',
18  '- When the person answers in chat (approves, picks another option, or drops it), call `mcp__approvals__resolve` with the id and the outcome in a few words.',
19  '- A prompt starting "Approved [id]" came from the pane\'s Approve button: act on the recommendation as given. "Re [id]" is the person discussing it.',
20  '- When you point the person to a decision, give its number on the pane (its position in `mcp__approvals__list`, checked just before) and its id, e.g. "approval #2 `db-choice`".',
21].join('\n')
22
23const pending = (b: Board) => b.items.filter(i => i.status === 'pending')
24const oneLine = (s: string | undefined, max: number) => {
25  const t = (s ?? '').replace(/\s+/g, ' ').trim()
26  return t.length > max ? `${t.slice(0, max - 1)}…` : t
27}
28
29// Applies `fn` to the board, keeps the decided list bounded and persists it.
30async function change($: EngineInterface, fn: (items: Approval[]) => Approval[]): Promise<Board> {
31  let saved: Board = { root: '', items: [] }
32  await update($, board, prev => {
33    const items = fn(prev.items)
34    const open = items.filter(i => i.status === 'pending')
35    const done = items
36      .filter(i => i.status !== 'pending')
37      .sort((a, b) => (b.resolvedAt ?? 0) - (a.resolvedAt ?? 0))
38      .slice(0, MAX_RESOLVED)
39    saved = { root: prev.root, items: [...open, ...done] }
40    return saved
41  })
42  await $.store.set(storeKey(saved.root), saved.items)
43  return saved
44}
45
46async function settle($: EngineInterface, id: string, status: Approval['status'], outcome: string): Promise<Board> {
47  const now = await $.clock.now()
48  return change($, items => items.map(i => (i.id === id ? { ...i, status, outcome, resolvedAt: now } : i)))
49}
50
51async function openPane($: EngineInterface) {
52  return $.ui.open({ id: PANE, title: TITLE })
53}
54
55export const register: Register = on => {
56  on('session.start', async ($, e, next) => {
57    const root = await $.session.root()
58    const items = ((await $.store.get(storeKey(root))) as Approval[] | undefined) ?? []
59    await update($, board, () => ({ root, items }))
60
61    await $.command.register({
62      name: 'approvals',
63      description: 'Show or hide the pane of decisions waiting for you',
64    })
65    await $.tool.register({
66      name: 'ask',
67      description:
68        'Adds (or updates, by id) a decision the person needs to make to their Approvals pane, with your recommendation condensed to one line. Call it whenever you put a decision to them with a recommendation.',
69      inputSchema: {
70        type: 'object',
71        properties: {
72          id: { type: 'string', description: 'Short id, e.g. the design-doc decision id (K7) or a slug' },
73          title: { type: 'string', description: 'A few words naming the decision' },
74          recommendation: { type: 'string', description: 'Your recommendation in one line, about 100 characters' },
75          why: { type: 'string', description: 'The reasoning, one or two lines' },
76          alternatives: { type: 'string', description: 'The other options, one line' },
77        },
78        required: ['id', 'title', 'recommendation'],
79      },
80      isDeferred: false,
81    })
82    await $.tool.register({
83      name: 'resolve',
84      description:
85        'Marks a decision on the Approvals pane as settled once the person has answered it in chat (approved, another option chosen, or dropped).',
86      inputSchema: {
87        type: 'object',
88        properties: {
89          id: { type: 'string' },
90          outcome: { type: 'string', description: 'What was decided, a few words' },
91        },
92        required: ['id', 'outcome'],
93      },
94      isDeferred: false,
95    })
96    await $.tool.register({
97      name: 'list',
98      description: 'Lists the decisions still waiting on the Approvals pane.',
99      isDeferred: false,
100    })
101
102    if (items.some(i => i.status === 'pending')) void openPane($)
103
104    return next(e)
105  })
106
107  on('prompt.compose', async ($, e, next) => {
108    const composed = await next(e)
109    return {
110      ...composed,
111      sections: [...composed.sections, { id: 'approvals:guide', text: GUIDE, scope: 'session' as const }],
112    }
113  })
114
115  on('command.run', { command: 'approvals' }, async $ => {
116    const isOpen = (await $.ui.panes()).some(p => p.id === PANE)
117    if (isOpen) {
118      await $.ui.close({ id: PANE })
119      return { text: 'Approvals pane closed.' }
120    }
121    await openPane($)
122    return { text: 'Approvals pane opened.' }
123  })
124
125  on('tool.call', { tool: 'mcp__approvals__ask' }, async ($, e) => {
126    const input = e as unknown as Partial<Approval>
127    const id = oneLine(input.id, 40)
128    if (!id || !input.title || !input.recommendation) {
129      return { deny: 'approvals: id, title and recommendation are required.' }
130    }
131    const now = await $.clock.now()
132    const item: Approval = {
133      id,
134      title: oneLine(input.title, 80),
135      recommendation: oneLine(input.recommendation, 300),
136      why: input.why ? oneLine(input.why, 600) : undefined,
137      alternatives: input.alternatives ? oneLine(input.alternatives, 600) : undefined,
138      status: 'pending',
139      askedAt: now,
140    }
141    const saved = await change($, items => [...items.filter(i => i.id !== id), item])
142    void openPane($)
143    return { result: `Added ${id} to the Approvals pane (${pending(saved).length} waiting).` }
144  })
145    .catch(() => ({ deny: 'approvals: the ask tool failed.' }))
146
147  on('tool.call', { tool: 'mcp__approvals__resolve' }, async ($, e) => {
148    const { id, outcome } = e as unknown as { id: string; outcome: string }
149    const b = await read($, board)
150    if (!b.items.some(i => i.id === id)) return { result: `No decision ${id} on the pane.` }
151    const saved = await settle($, id, 'resolved', oneLine(outcome, 120))
152    return { result: `Resolved ${id}. ${pending(saved).length} still waiting.` }
153  })
154    .catch(() => ({ deny: 'approvals: the resolve tool failed.' }))
155
156  on('tool.call', { tool: 'mcp__approvals__list' }, async $ => {
157    const open = pending(await read($, board))
158    const text = open.length
159      ? open.map(i => `${i.id}: ${i.title} → ${i.recommendation}`).join('\n')
160      : 'Nothing waiting.'
161    return { result: text }
162  })
163    .catch(() => ({ deny: 'approvals: the list tool failed.' }))
164
165  on('ui.render', { component: 'Pane', requestId: PANE }, async ($, e) => {
166    const { Box, Text, Button } = $.ui.resolve(e)
167    const b = await read($, board)
168    const open = b.items.filter(i => i.status === 'pending').sort((x, y) => x.askedAt - y.askedAt)
169    const done = b.items.filter(i => i.status !== 'pending')
170    const shown = new Set(await read($, expanded))
171    const width = Math.max(20, (e.props.bodyColumns ?? 40) - 2)
172
173    const toggle = (key: string) =>
174      update($, expanded, list => (list.includes(key) ? list.filter(k => k !== key) : [...list, key]))
175
176    const approve = async (i: Approval) => {
177      await settle($, i.id, 'approved', 'approved as recommended')
178      void $.prompt.submit({ text: `Approved [${i.id}] ${i.title}: go with your recommendation (${i.recommendation}).` })
179    }
180    const chat = async (i: Approval) => {
181      await $.prompt.fill({ text: `Re [${i.id}] ${i.title}: `, mode: 'replace' })
182    }
183
184    return (
185      <Box flexDirection="column" gap={1}>
186        <Text bold>
187          {open.length === 0 ? 'Nothing waiting for you' : `${open.length} waiting for you`}
188        </Text>
189        {open.map((i, n) => {
190          const isOpen = shown.has(i.id)
191          return (
192            <Box key={`item-${i.id}`} flexDirection="column">
193              <Text bold wrap="truncate-end">
194                {n + 1}. {i.title} <Text dimColor>[{i.id}]</Text>
195              </Text>
196              <Text color="green" wrap={isOpen ? 'wrap' : 'truncate-end'}>
197                ✓ {isOpen ? i.recommendation : oneLine(i.recommendation, width * 2)}
198              </Text>
199              {isOpen && i.why && <Text dimColor wrap="wrap">Why: {i.why}</Text>}
200              {isOpen && i.alternatives && <Text dimColor wrap="wrap">Or: {i.alternatives}</Text>}
201              <Box flexDirection="row" gap={1}>
202                <Button key={`approve-${i.id}`} variant="primary" label="Approve" onPress={() => approve(i)} />
203                <Button key={`chat-${i.id}`} label="Chat" onPress={() => chat(i)} />
204                {(i.why || i.alternatives || i.recommendation.length > width) && (
205                  <Button key={`more-${i.id}`} dimColor plain label={isOpen ? 'less' : 'more'} onPress={() => toggle(i.id)} />
206                )}
207              </Box>
208            </Box>
209          )
210        })}
211        {done.length > 0 && (
212          <Box key="history" flexDirection="column">
213            <Button
214              key="history-toggle"
215              dimColor
216              plain
217              label={`${shown.has('#history') ? '▾' : '▸'} Decided (${done.length})`}
218              onPress={() => toggle('#history')}
219            />
220            {shown.has('#history') &&
221              done.map(i => (
222                <Text key={`done-${i.id}`} dimColor wrap="truncate-end">
223                  {i.status === 'approved' ? '✓' : '•'} {i.title} [{i.id}]{i.outcome ? `: ${i.outcome}` : ''}
224                </Text>
225              ))}
226            {shown.has('#history') && (
227              <Button key="clear" dimColor plain label="clear history" onPress={() => change($, items => items.filter(x => x.status === 'pending'))} />
228            )}
229          </Box>
230        )}
231      </Box>
232    )
233  })
234}
235
types/index.d.ts 22 lines
1export type ApprovalStatus = 'pending' | 'approved' | 'chat' | 'resolved'
2
3export type Approval = {
4  id: string
5  title: string
6  recommendation: string
7  why?: string
8  alternatives?: string
9  status: ApprovalStatus
10  askedAt: number
11  resolvedAt?: number
12  outcome?: string
13}
14
15export type Board = { root: string; items: Approval[] }
16
17declare module 'claude-code' {
18  interface PluginState {
19    approvals: { board: Board; expanded: string[] }
20  }
21}
22