A pane for answering the question rounds of the grilling / grill-me skill

A pane for answering the question rounds of the grilling skill (and its /grill-me shortcut).
When one of Claude's replies holds questions in the skill's format, the mod opens a pane with each question, its recommendation and an answer field. On send, your answers become your next prompt:
**Q1** - <title>: <your answer>
**Q2** - <title>: I accept the recommendation
/plugin install grill-answer --marketplace kguidonimartins/claude-mods
❓ **Q1** - **<title>**: <body>
➡️ <recommendation>
---
Only the main conversation is read, never a subagent's. A reply without this format opens nothing.
| Key / command | Action |
|---|---|
ctrl+x tab or click | gives the pane the keyboard (the cursor goes to the first pending field) |
Enter in a field | saves the answer and jumps to the next pending field |
Tab / arrows | walk between fields and buttons |
1–9 | accepts question N's recommendation (with the focus on a button) |
a | accepts the recommendation of every pending question |
s | sends the answers |
p | takes the round to the prompt box, to finish long answers there (with the focus on a button) |
Esc | hands the keyboard back to the prompt |
/grill-answer | reopens the pane for the last round |
A pane that opens on its own only shows from 144 columns; below that, use /grill-answer. Text typed without Enter is sent too. Mobile has no text field: only the accept buttons.
The answer field is one line and shows the start of a long text, not where you are typing. For a long answer, leave the field with Tab (what you typed stays) and press p, or click [ edit in prompt ]: the round, with the answers given so far and the pending ones left blank after :, is added after the prompt box's draft, where it wraps, takes newlines and opens in $EDITOR with ctrl+g. The pane closes; /grill-answer reopens it with the answers kept.
claude --plugin-dir plugins/grill-answer # loads it for this session only
claude plugin validate plugins/grill-answer
claude plugin test plugins/grill-answer
tsc -p plugins/grill-answer # once the mod has loaded at least oncehooks/register.tsx 247 lines1import { atom, read, update } from 'claude-code'
2import type { EngineInterface, Register } from 'claude-code'
3
4import type { GrillRound } from '../types'
5import { composeAnswers, parseRound } from './parse'
6
7const PANE = 'grill-answer'
8const ACCEPT = 'I accept the recommendation'
9
10const round = atom({ plugin: 'grill-answer', key: 'round' } as const, null)
11const answers = atom({ plugin: 'grill-answer', key: 'answers' } as const, {})
12
13// Drafts typed without Enter: kept here so a keystroke does not redraw.
14const drafts = new Map<number, string>()
15
16function openPane($: EngineInterface, questions: number) {
17 return $.ui.open({
18 id: PANE,
19 title: `Grill: ${questions} question(s)`,
20 focus: true,
21 rows: Math.min(40, 6 + questions * 6),
22 // The answer field is one line: the wider the dock, the more of it shows.
23 columns: 100,
24 })
25}
26
27function setAnswer($: EngineInterface, n: number, text: string) {
28 return update($, answers, all => ({ ...all, [n]: text }))
29}
30
31// After Enter, moves the cursor to the next pending field (or to "send").
32async function focusNext(
33 $: EngineInterface,
34 current: GrillRound,
35 given: Record<string, string>,
36 after: number,
37) {
38 const order = [
39 ...current.questions.filter(q => q.n > after),
40 ...current.questions.filter(q => q.n < after),
41 ]
42 const next = order.find(q => !given[q.n]?.trim() && !drafts.get(q.n)?.trim())
43 const key = next === undefined ? 'send' : `answer-${next.n}`
44 try {
45 const moved = await $.ui.focus({ requestId: PANE, key })
46 if (moved.deny !== undefined) $.ui.log(`grill-answer: focus did not move (${moved.deny})`)
47 } catch (error) {
48 $.ui.log(`grill-answer: focus did not move (${String(error)})`)
49 }
50}
51
52// The saved answers plus the drafts typed without Enter.
53async function collect($: EngineInterface) {
54 const given = { ...(await read($, answers)) }
55 for (const [n, draft] of drafts) {
56 if (!given[n]?.trim() && draft.trim()) given[n] = draft
57 }
58
59 return given
60}
61
62async function send($: EngineInterface, current: GrillRound) {
63 const given = await collect($)
64
65 drafts.clear()
66 await update($, round, () => null)
67 await update($, answers, () => ({}))
68 $.ui.status(undefined)
69 await $.ui.close({ id: PANE })
70 await $.prompt.submit({
71 text: composeAnswers(current.questions, given),
72 asUser: true,
73 })
74}
75
76// Long answers: the round goes to the prompt box, which wraps and takes
77// newlines. The round stays saved, so /grill-answer reopens it.
78async function editInPrompt($: EngineInterface, current: GrillRound) {
79 const given = await collect($)
80 const box = await $.prompt.read()
81 const gap = box.text.trim() === '' || box.text.endsWith('\n\n') ? '' : '\n\n'
82
83 const filled = await $.prompt.fill({
84 text: gap + composeAnswers(current.questions, given, ''),
85 mode: 'append',
86 })
87 if (!filled.isFilled) {
88 $.ui.toast('grill: the prompt box did not take the answers')
89 return
90 }
91
92 drafts.clear()
93 await update($, answers, () => given)
94 $.ui.status(undefined)
95 await $.ui.close({ id: PANE })
96}
97
98export const register: Register = on => {
99 on('session.start', async ($, e, next) => {
100 await $.command.register({
101 name: 'grill-answer',
102 description: 'Open the pane to answer the last grilling round',
103 })
104
105 return next(e)
106 })
107
108 on('command.run', { command: 'grill-answer' }, async $ => {
109 const current = await read($, round)
110 if (current === null) {
111 return { text: 'No grilling round pending.' }
112 }
113
114 await openPane($, current.questions.length)
115
116 return { text: 'Grilling pane opened.' }
117 })
118
119 on('turn.complete', async ($, e, next) => {
120 const isMain = e.agentId === undefined && e.reason === 'answer'
121 const questions = isMain ? parseRound(e.answer) : []
122
123 if (questions.length > 0) {
124 drafts.clear()
125 await update($, round, () => ({ id: e.turnId, questions }))
126 await update($, answers, () => ({}))
127 $.ui.status(`grill: ${questions.length} question(s) — /grill-answer`)
128
129 const opened = await openPane($, questions.length)
130 if (!opened.isPlaced) {
131 $.ui.toast('grill: /grill-answer to answer the questions')
132 }
133 }
134
135 return next(e)
136 })
137
138 on('ui.render', { component: 'Pane', requestId: PANE }, async ($, e) => {
139 const elements = $.ui.resolve(e)
140 const { Box, Text, Button, Markdown } = elements
141 // mobile has no Input: there only the recommendation can be accepted.
142 const Input = 'Input' in elements ? elements.Input : undefined
143 const current = await read($, round)
144 const given = await read($, answers)
145
146 if (current === null) {
147 return <Text dimColor>No grilling round pending.</Text>
148 }
149
150 const pending = current.questions.filter(q => !given[q.n]?.trim())
151
152 return (
153 <Box flexDirection="column" gap={1}>
154 {!e.props.isFocused && (
155 <Text color="yellow">
156 Pane has no keyboard: ctrl+x tab (or click) to answer.
157 </Text>
158 )}
159 {current.questions.map(q => {
160 const answer = given[q.n]
161
162 return (
163 <Box key={`q${q.n}`} flexDirection="column">
164 {/* accept sits by the title so the answer field gets the whole row */}
165 <Box flexDirection="row" gap={1}>
166 <Box flexGrow={1}>
167 <Text bold>
168 Q{q.n} · {q.title}
169 </Text>
170 </Box>
171 <Button
172 key={`accept-${q.n}`}
173 label="accept"
174 hotkey={q.n < 10 ? String(q.n) : undefined}
175 dimColor={answer === ACCEPT}
176 onPress={() => setAnswer($, q.n, ACCEPT)}
177 />
178 </Box>
179 {q.body !== '' && (
180 <Markdown dimColor text={q.body.slice(0, 2000)} />
181 )}
182 {q.recommendation !== '' && (
183 <Text color="green">➡ {q.recommendation}</Text>
184 )}
185 {Input !== undefined && (
186 <Input
187 key={`answer-${q.n}`}
188 label="› "
189 placeholder="type, then Enter to save"
190 submitLabel="save"
191 autoFocus={q === pending[0] ? true : undefined}
192 value={answer ?? drafts.get(q.n) ?? ''}
193 onInput={(value: string) => drafts.set(q.n, value)}
194 onSubmit={async (value: string) => {
195 await setAnswer($, q.n, value)
196 await focusNext($, current, { ...given, [q.n]: value }, q.n)
197 }}
198 />
199 )}
200 {answer !== undefined && answer.trim() !== '' && (
201 <Text dimColor>✔ {answer}</Text>
202 )}
203 </Box>
204 )
205 })}
206 <Box flexDirection="row" gap={1}>
207 <Button
208 key="accept-all"
209 label={`accept pending (${pending.length})`}
210 hotkey="a"
211 onPress={() =>
212 update($, answers, all => {
213 const next = { ...all }
214 for (const q of current.questions) {
215 if (!next[q.n]?.trim() && !drafts.get(q.n)?.trim()) {
216 next[q.n] = ACCEPT
217 }
218 }
219 return next
220 })
221 }
222 />
223 <Button
224 key="send"
225 label="send answers"
226 variant="primary"
227 hotkey="s"
228 onPress={() => send($, current)}
229 />
230 <Button
231 key="edit-in-prompt"
232 label="edit in prompt"
233 hotkey="p"
234 onPress={() => editInPrompt($, current)}
235 />
236 <Button
237 key="dismiss"
238 label="close"
239 role="dismiss"
240 onPress={() => $.ui.close({ id: PANE })}
241 />
242 </Box>
243 </Box>
244 )
245 })
246}
247hooks/parse.ts 52 lines1import type { GrillQuestion } from '../types'
2
3// One round of the grilling skill:
4// ❓ **Q1** - **<title>**: <body>
5//
6// ➡️ <recommendation>
7//
8// ---
9const HEAD = /^\*\*Q(\d+)\*\*\s*[-–—:]\s*\*\*(.+?)\*\*\s*:?\s*/
10const ARROW = /^\s*➡️?\s*/m
11
12export const parseRound = (answer: string): GrillQuestion[] => {
13 const questions: GrillQuestion[] = []
14
15 for (const chunk of answer.split(/^\s*❓️?\s*/m).slice(1)) {
16 const head = HEAD.exec(chunk)
17 if (head === null) continue
18
19 const rest = chunk.slice(head[0].length)
20 const arrow = ARROW.exec(rest)
21 const body = arrow === null ? rest : rest.slice(0, arrow.index)
22 const recommendation =
23 arrow === null ? '' : rest.slice(arrow.index + arrow[0].length)
24
25 questions.push({
26 n: Number(head[1]),
27 title: head[2]!.trim(),
28 body: tidy(body),
29 recommendation: tidy(recommendation),
30 })
31 }
32
33 return questions
34}
35
36// Cuts the `---` separator and whatever follows the last question.
37const tidy = (text: string) => text.split(/^\s*---\s*$/m)[0]!.trim()
38
39// `pending` fills a question with no answer: a marker when sent, '' when the
40// round goes to the prompt box to be completed there.
41export const composeAnswers = (
42 questions: GrillQuestion[],
43 answers: Record<string, string>,
44 pending = '(no answer yet)',
45): string => {
46 const lines = questions.map(
47 q => `**Q${q.n}** - ${q.title}: ${answers[q.n]?.trim() || pending}`,
48 )
49
50 return lines.join('\n\n')
51}
52types/index.d.ts 18 lines1export type GrillQuestion = {
2 n: number
3 title: string
4 body: string
5 recommendation: string
6}
7
8export type GrillRound = { id: string; questions: GrillQuestion[] }
9
10declare module 'claude-code' {
11 interface PluginState {
12 'grill-answer': {
13 round: GrillRound | null
14 answers: Record<string, string>
15 }
16 }
17}
18