Highlight part of Claude's answer and reply to it. The text goes into your prompt as a quote.

A Claude Code mod for the terminal. Highlight part of Claude's answer, click Reply, and the text goes into your prompt as a quote. You type your reply under it and send.
<img src="docs/reply-light-1.png" alt="A sentence of Claude's answer is highlighted. A row above the prompt reads: Reply to, the sentence, then the buttons Reply and Dismiss." width="100%">
<img src="docs/reply-light-2.png" alt="The prompt holds the sentence as a quote, with a question typed under it." width="100%">
The pictures are from a test terminal, on a made-up project called demo-app.
| You do | The mod does |
|---|---|
| Highlight text with the mouse | Shows a row above the prompt: ↳ Reply to "…" [ Reply ] [ Dismiss ] |
Click Reply | Puts the text in the prompt as a > quote, with a blank line under it for your words. A draft in the prompt stays, and the quote goes under it |
Click Dismiss | Hides the row until you highlight something new. Use it when you highlighted text only to copy it |
| Highlight more text and click again | Adds the next quote under the first one, so one prompt can answer several parts |
| Send the prompt | The row goes away |
The mod never sends a prompt. It puts text in the prompt box, and you send it.
In a Claude Code terminal session:
/plugin install reply --marketplace krishna-goutham-tls/cc-mods
/tui fullscreen turns it on.Dismiss, or send your next prompt, and it goes away.MIT
hooks/register.tsx 117 lines1// reply: highlight part of Claude's answer, click Reply, and the text goes into the
2// prompt as a quote with room under it for your words. Terminal only.
3import { atom, read, update } from 'claude-code'
4import type { EngineInterface, Register } from 'claude-code'
5
6import type { Picked } from '../types'
7import { fillFor, isWorthQuoting, previewOf } from './quote'
8
9/** How often the mod looks for a new highlight. The engine raises no event for one. */
10const POLL_MS = 250
11const REPLY = 'Reply'
12const DISMISS = 'Dismiss'
13
14const picked = atom({ plugin: 'reply', key: 'picked' } as const, null as Picked)
15const done = atom({ plugin: 'reply', key: 'done' } as const, '')
16
17/** Reads the highlight and keeps it in state, so the band shows or hides. */
18const look = async ($: EngineInterface): Promise<void> => {
19 const selected = await $.ui.selection().catch(() => undefined)
20 const text = selected !== undefined && isWorthQuoting(selected.text) ? selected.text : ''
21 const now = await read($, picked)
22
23 if ((now?.text ?? '') === text) {
24 return
25 }
26
27 await update($, picked, (): Picked => (text === '' ? null : { text }))
28
29 if (text === '') {
30 await update($, done, () => '')
31 }
32}
33
34/** Puts the highlight in the prompt as a quote. */
35const reply = async ($: EngineInterface): Promise<void> => {
36 const selected = await $.ui.selection().catch(() => undefined)
37 const text = selected !== undefined && isWorthQuoting(selected.text) ? selected.text : ((await read($, picked))?.text ?? '')
38
39 if (text === '') {
40 return
41 }
42
43 const box = await $.prompt.read().catch(() => ({ text: '', cursor: 0 }))
44 const filled = await $.prompt.fill(fillFor(box.text, text))
45
46 if (filled.isFilled) {
47 await update($, done, () => text)
48 } else {
49 $.ui.toast('The prompt cannot take the quote now. Close the dialog and press Reply again.')
50 }
51}
52
53/** Hides the band until the next highlight, for a highlight made only to copy. */
54const dismiss = async ($: EngineInterface): Promise<void> => {
55 const now = await read($, picked)
56
57 if (now !== null) {
58 await update($, done, () => now.text)
59 }
60}
61
62export const register: Register = on => {
63 let isLooking = false
64
65 on('session.start', async ($, e, next) => {
66 if (e.surface !== 'terminal') {
67 return next(e)
68 }
69
70 $.clock.every(POLL_MS, () => {
71 if (isLooking) {
72 return
73 }
74
75 isLooking = true
76 void look($)
77 .catch(() => undefined)
78 .finally(() => {
79 isLooking = false
80 })
81 })
82
83 return next(e)
84 })
85
86 on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
87 if (e.surface !== 'terminal' || e.props.hasSurvey) {
88 return next(e)
89 }
90
91 const now = await read($, picked)
92
93 if (now === null || now.text === (await read($, done))) {
94 return next(e)
95 }
96
97 const { Box, Text, Button } = $.ui.resolve(e)
98 const { words, lines } = previewOf(now.text)
99 const count = lines > 1 ? ` · ${lines} lines` : ''
100 // "↳ Reply to " before the words; after them the count, two cells, "[ Reply ] [ Dismiss ]", two cells of gap.
101 const room = Math.max(8, e.props.bodyColumns - 11 - count.length - 2 - (REPLY.length + 4) - 1 - (DISMISS.length + 4) - 2)
102 const shown = words.length > room ? `${words.slice(0, room - 1).replace(/\s+$/, '')}…` : words
103
104 return (
105 <Box flexDirection="row" width={e.props.bodyColumns}>
106 <Text color="claude">↳ </Text>
107 <Text color="inactive">Reply to </Text>
108 <Text color="text">“{shown}”</Text>
109 <Text color="inactive">{count} </Text>
110 <Button key="reply" label={REPLY} variant="primary" onPress={() => void reply($).catch(() => undefined)} />
111 <Text> </Text>
112 <Button key="dismiss" label={DISMISS} role="dismiss" dimColor onPress={() => void dismiss($).catch(() => undefined)} />
113 </Box>
114 )
115 })
116}
117hooks/quote.ts 59 lines1// The text work of the mod: no `$` here.
2
3/** The most of a selection that goes into the prompt. */
4export const MAX_QUOTE = 4000
5
6/** A selection as the lines it covers, with blank lines at both ends and trailing spaces gone. */
7const linesOf = (text: string): string[] => {
8 const lines = text.replace(/\r\n?/g, '\n').split('\n').map(line => line.replace(/\s+$/, ''))
9
10 while (lines.length > 0 && lines[0] === '') {
11 lines.shift()
12 }
13
14 while (lines.length > 0 && lines[lines.length - 1] === '') {
15 lines.pop()
16 }
17
18 return lines
19}
20
21/** True when a selection holds something worth a reply. */
22export const isWorthQuoting = (text: string): boolean => linesOf(text).join('').trim() !== ''
23
24/** The selection as a markdown quote: `> ` before each line, `>` alone on a blank one. */
25export const quoteOf = (text: string): string => {
26 const lines = linesOf(text)
27 const all = lines.join('\n')
28 const kept = all.length > MAX_QUOTE ? `${all.slice(0, MAX_QUOTE).replace(/\s+$/, '')} …` : all
29
30 return kept
31 .split('\n')
32 .map(line => (line === '' ? '>' : `> ${line}`))
33 .join('\n')
34}
35
36/**
37 * What goes in the prompt box. An empty box takes the quote and a blank line.
38 * A box with a draft keeps it and gets the quote after a blank line, so
39 * several replies stack in one prompt.
40 */
41export const fillFor = (draft: string, text: string): { text: string; mode: 'replace' | 'append' } => {
42 const quote = quoteOf(text)
43
44 if (draft.trim() === '') {
45 return { text: `${quote}\n\n`, mode: 'replace' }
46 }
47
48 const gap = draft.endsWith('\n\n') ? '' : draft.endsWith('\n') ? '\n' : '\n\n'
49
50 return { text: `${gap}${quote}\n\n`, mode: 'append' }
51}
52
53/** One line for the band: the selection's words on one row, and how many lines it has. */
54export const previewOf = (text: string): { words: string; lines: number } => {
55 const lines = linesOf(text).filter(line => line.trim() !== '')
56
57 return { words: lines.map(line => line.trim()).join(' '), lines: lines.length }
58}
59types/index.d.ts 13 lines1/** The text the person last highlighted with the mouse, as a copy would take it. */
2export type Picked = { text: string } | null
3
4declare module 'claude-code' {
5 interface PluginState {
6 reply: {
7 picked: Picked
8 /** The last highlight replied to or dismissed, so the band hides until the next one. */
9 done: string
10 }
11 }
12}
13