A pane summarising the remaining todos, each with Do, Chat, Defer and Delete

A pane beside the chat that summarises the remaining todos, two lines each, so the list is easy to scroll:
3 to do · 1 deferred
1. Play-test Harbour Lights [hl-playtest]
You, before Wed 14 Oct (first screenshot session)
[ Do ] Chat Defer Delete more
Re [id] <title>: in your prompt box so you can talk it through.▸ Deferred (n) list, where you can restore or delete it.▸ Done (n).Claude keeps the list itself: the mod gives it three tools (add, done, list) and a short instruction to add work that remains and mark it done when finished.
The list is kept per project and survives restarts. The pane opens by itself when something is left; /todos shows or hides it.
At the prompt of a Claude Code terminal session:
/plugin install todos --marketplace dbroadhurst/claude-mod-todos
Answer y to add the marketplace, then choose a scope. To turn it on for one project only, add this to the project's .claude/settings.json:
{
"extraKnownMarketplaces": {
"claude-mod-todos": { "source": { "source": "github", "repo": "dbroadhurst/claude-mod-todos" } }
},
"enabledPlugins": { "todos@claude-mod-todos": true }
}
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.
claude --plugin-dir <path>; check with claude plugin validate . and claude plugin test ..MIT licensed.
hooks/register.tsx 277 lines1import { atom, read, update } from 'claude-code'
2import type { EngineInterface, Register } from 'claude-code'
3
4import type { Todo, TodoList, TodoOwner, TodoStatus } from '../types'
5
6// One list of todos per project, kept across sessions in $.store.
7const PANE = 'todos'
8const TITLE = 'Todos'
9const list = atom({ plugin: 'todos', key: 'list' } as const, { root: '', items: [] })
10const expanded = atom({ plugin: 'todos', key: 'expanded' } as const, [])
11
12const MAX_DONE = 30
13const storeKey = (root: string) => `list:${root}`
14
15const GUIDE = [
16 'Todos pane (the `todos` plugin): the person sees the remaining todos in a pane beside the chat, each with Do, Chat, Defer and Delete; a todo for the person has Done instead of Do.',
17 '- Keep it current: when work remains (for the person or for you), call `mcp__todos__add` with a short id, a title of a few words, a one-line summary (who, what, by when) and `for` ("you" when the person must do it). Adding an existing id updates it.',
18 '- When a todo is finished, call `mcp__todos__done` with its id and a few words on the outcome.',
19 '- A prompt starting "Do [id]" came from the Do button: start that todo now. "Re [id]" is the person discussing it.',
20 '- The person marks their own todos finished with the Done button; `mcp__todos__list` shows what is still open.',
21 '- When you point the person to a todo, give its number on the pane (its position in `mcp__todos__list`, checked just before) and its id, e.g. "todo #3 `fix-login`".',
22].join('\n')
23
24const isOpen = (t: Todo) => t.status === 'open' || t.status === 'doing'
25const oneLine = (s: string | undefined, max: number) => {
26 const t = (s ?? '').replace(/\s+/g, ' ').trim()
27 return t.length > max ? `${t.slice(0, max - 1)}…` : t
28}
29
30// Applies `fn` to the list, keeps the done history bounded and persists it.
31async function change($: EngineInterface, fn: (items: Todo[]) => Todo[]): Promise<TodoList> {
32 let saved: TodoList = { root: '', items: [] }
33 await update($, list, prev => {
34 const items = fn(prev.items)
35 const live = items.filter(t => t.status !== 'done')
36 const done = items
37 .filter(t => t.status === 'done')
38 .sort((a, b) => b.changedAt - a.changedAt)
39 .slice(0, MAX_DONE)
40 saved = { root: prev.root, items: [...live, ...done] }
41 return saved
42 })
43 await $.store.set(storeKey(saved.root), saved.items)
44 return saved
45}
46
47async function setStatus($: EngineInterface, id: string, status: TodoStatus, note?: string): Promise<TodoList> {
48 const now = await $.clock.now()
49 return change($, items => items.map(t => (t.id === id ? { ...t, status, note: note ?? t.note, changedAt: now } : t)))
50}
51
52async function openPane($: EngineInterface) {
53 return $.ui.open({ id: PANE, title: TITLE })
54}
55
56export const register: Register = on => {
57 on('session.start', async ($, e, next) => {
58 const root = await $.session.root()
59 const items = ((await $.store.get(storeKey(root))) as Todo[] | undefined) ?? []
60 await update($, list, () => ({ root, items }))
61
62 await $.command.register({
63 name: 'todos',
64 description: 'Show or hide the pane of remaining todos',
65 })
66 await $.tool.register({
67 name: 'add',
68 description:
69 'Adds (or updates, by id) a remaining todo on the Todos pane, with a one-line summary. Use it whenever work remains for the person or for you.',
70 inputSchema: {
71 type: 'object',
72 properties: {
73 id: { type: 'string', description: 'Short id or slug' },
74 title: { type: 'string', description: 'A few words naming the todo' },
75 summary: { type: 'string', description: 'One line: who, what, by when (about 100 characters)' },
76 detail: { type: 'string', description: 'Optional extra context, a line or two' },
77 for: {
78 type: 'string',
79 enum: ['you', 'claude'],
80 description: '"you" when the person must do it (the pane shows Done instead of Do); "claude" (the default) when you will',
81 },
82 },
83 required: ['id', 'title'],
84 },
85 isDeferred: false,
86 })
87 await $.tool.register({
88 name: 'done',
89 description: 'Marks a todo on the Todos pane as finished.',
90 inputSchema: {
91 type: 'object',
92 properties: {
93 id: { type: 'string' },
94 note: { type: 'string', description: 'The outcome, a few words' },
95 },
96 required: ['id'],
97 },
98 isDeferred: false,
99 })
100 await $.tool.register({
101 name: 'list',
102 description: 'Lists the todos on the Todos pane that are still open, doing or deferred.',
103 isDeferred: false,
104 })
105
106 if (items.some(isOpen)) void openPane($)
107
108 return next(e)
109 })
110
111 on('prompt.compose', async ($, e, next) => {
112 const composed = await next(e)
113 return {
114 ...composed,
115 sections: [...composed.sections, { id: 'todos:guide', text: GUIDE, scope: 'session' as const }],
116 }
117 })
118
119 on('command.run', { command: 'todos' }, async $ => {
120 const isUp = (await $.ui.panes()).some(p => p.id === PANE)
121 if (isUp) {
122 await $.ui.close({ id: PANE })
123 return { text: 'Todos pane closed.' }
124 }
125 await openPane($)
126 return { text: 'Todos pane opened.' }
127 })
128
129 on('tool.call', { tool: 'mcp__todos__add' }, async ($, e) => {
130 const input = e as unknown as Partial<Todo> & { for?: TodoOwner }
131 const id = oneLine(input.id, 40)
132 if (!id || !input.title) return { deny: 'todos: id and title are required.' }
133 const now = await $.clock.now()
134 const saved = await change($, items => {
135 const old = items.find(t => t.id === id)
136 const item: Todo = {
137 id,
138 title: oneLine(input.title, 80),
139 summary: input.summary ? oneLine(input.summary, 300) : old?.summary,
140 detail: input.detail ? oneLine(input.detail, 600) : old?.detail,
141 owner: input.for === 'you' || input.for === 'claude' ? input.for : old?.owner,
142 status: old && old.status !== 'done' ? old.status : 'open',
143 addedAt: old?.addedAt ?? now,
144 changedAt: now,
145 }
146 return old ? items.map(t => (t.id === id ? item : t)) : [...items, item]
147 })
148 void openPane($)
149 return { result: `Added ${id} (${saved.items.filter(isOpen).length} to do).` }
150 })
151 .catch(() => ({ deny: 'todos: the add tool failed.' }))
152
153 on('tool.call', { tool: 'mcp__todos__done' }, async ($, e) => {
154 const { id, note } = e as unknown as { id: string; note?: string }
155 const l = await read($, list)
156 if (!l.items.some(t => t.id === id)) return { result: `No todo ${id} on the pane.` }
157 const saved = await setStatus($, id, 'done', note ? oneLine(note, 120) : undefined)
158 return { result: `Done ${id}. ${saved.items.filter(isOpen).length} left.` }
159 })
160 .catch(() => ({ deny: 'todos: the done tool failed.' }))
161
162 on('tool.call', { tool: 'mcp__todos__list' }, async $ => {
163 const live = (await read($, list)).items.filter(t => t.status !== 'done')
164 const text = live.length
165 ? live.map(t => `${t.id} (${t.status}${t.owner === 'you' ? ', for the person' : ''}): ${t.title}${t.summary ? ` — ${t.summary}` : ''}`).join('\n')
166 : 'Nothing left to do.'
167 return { result: text }
168 })
169 .catch(() => ({ deny: 'todos: the list tool failed.' }))
170
171 on('ui.render', { component: 'Pane', requestId: PANE }, async ($, e) => {
172 const { Box, Text, Button } = $.ui.resolve(e)
173 const l = await read($, list)
174 const live = l.items.filter(isOpen).sort((x, y) => x.addedAt - y.addedAt)
175 const deferred = l.items.filter(t => t.status === 'deferred')
176 const done = l.items.filter(t => t.status === 'done')
177 const shown = new Set(await read($, expanded))
178 const width = Math.max(20, (e.props.bodyColumns ?? 40) - 2)
179
180 const toggle = (key: string) =>
181 update($, expanded, keys => (keys.includes(key) ? keys.filter(k => k !== key) : [...keys, key]))
182 const remove = (id: string) => change($, items => items.filter(t => t.id !== id))
183
184 const doIt = async (t: Todo) => {
185 await setStatus($, t.id, 'doing')
186 void $.prompt.submit({ text: `Do [${t.id}] ${t.title}${t.summary ? `: ${t.summary}` : ''}` })
187 }
188 const chat = async (t: Todo) => {
189 await $.prompt.fill({ text: `Re [${t.id}] ${t.title}: `, mode: 'replace' })
190 }
191
192 const header = [
193 live.length === 0 ? 'Nothing left to do' : `${live.length} to do`,
194 deferred.length ? `${deferred.length} deferred` : '',
195 ]
196 .filter(Boolean)
197 .join(' · ')
198
199 return (
200 <Box flexDirection="column" gap={1}>
201 <Text bold>{header}</Text>
202 {live.map((t, n) => {
203 const isMore = shown.has(t.id)
204 return (
205 <Box key={`item-${t.id}`} flexDirection="column">
206 <Text bold wrap="truncate-end">
207 {t.status === 'doing' ? '▶ ' : `${n + 1}. `}
208 {t.title} <Text dimColor>[{t.id}]</Text>
209 </Text>
210 {t.summary && (
211 <Text dimColor wrap={isMore ? 'wrap' : 'truncate-end'}>
212 {isMore ? t.summary : oneLine(t.summary, width * 2)}
213 </Text>
214 )}
215 {isMore && t.detail && <Text dimColor wrap="wrap">{t.detail}</Text>}
216 <Box flexDirection="row" gap={1}>
217 {t.owner === 'you' ? (
218 <Button key={`done-${t.id}`} variant="primary" label="Done" onPress={() => setStatus($, t.id, 'done')} />
219 ) : (
220 <Button key={`do-${t.id}`} variant="primary" label={t.status === 'doing' ? 'Doing' : 'Do'} onPress={() => doIt(t)} />
221 )}
222 <Button key={`chat-${t.id}`} label="Chat" onPress={() => chat(t)} />
223 <Button key={`defer-${t.id}`} label="Defer" onPress={() => setStatus($, t.id, 'deferred')} />
224 <Button key={`delete-${t.id}`} dimColor label="Delete" onPress={() => remove(t.id)} />
225 {(t.detail || (t.summary ?? '').length > width) && (
226 <Button key={`more-${t.id}`} dimColor plain label={isMore ? 'less' : 'more'} onPress={() => toggle(t.id)} />
227 )}
228 </Box>
229 </Box>
230 )
231 })}
232 {deferred.length > 0 && (
233 <Box key="deferred" flexDirection="column">
234 <Button
235 key="deferred-toggle"
236 dimColor
237 plain
238 label={`${shown.has('#deferred') ? '▾' : '▸'} Deferred (${deferred.length})`}
239 onPress={() => toggle('#deferred')}
240 />
241 {shown.has('#deferred') &&
242 deferred.map(t => (
243 <Box key={`deferred-${t.id}`} flexDirection="row" gap={1}>
244 <Text dimColor wrap="truncate-end">
245 {t.title} [{t.id}]
246 </Text>
247 <Button key={`restore-${t.id}`} dimColor plain label="restore" onPress={() => setStatus($, t.id, 'open')} />
248 <Button key={`drop-${t.id}`} dimColor plain label="delete" onPress={() => remove(t.id)} />
249 </Box>
250 ))}
251 </Box>
252 )}
253 {done.length > 0 && (
254 <Box key="done" flexDirection="column">
255 <Button
256 key="done-toggle"
257 dimColor
258 plain
259 label={`${shown.has('#done') ? '▾' : '▸'} Done (${done.length})`}
260 onPress={() => toggle('#done')}
261 />
262 {shown.has('#done') &&
263 done.map(t => (
264 <Text key={`done-${t.id}`} dimColor wrap="truncate-end">
265 ✓ {t.title} [{t.id}]{t.note ? `: ${t.note}` : ''}
266 </Text>
267 ))}
268 {shown.has('#done') && (
269 <Button key="clear" dimColor plain label="clear done" onPress={() => change($, items => items.filter(x => x.status !== 'done'))} />
270 )}
271 </Box>
272 )}
273 </Box>
274 )
275 })
276}
277types/index.d.ts 25 lines1export type TodoStatus = 'open' | 'doing' | 'deferred' | 'done'
2
3/** Who does it: the person, or Claude (the default). */
4export type TodoOwner = 'you' | 'claude'
5
6export type Todo = {
7 id: string
8 title: string
9 summary?: string
10 detail?: string
11 owner?: TodoOwner
12 status: TodoStatus
13 addedAt: number
14 changedAt: number
15 note?: string
16}
17
18export type TodoList = { root: string; items: Todo[] }
19
20declare module 'claude-code' {
21 interface PluginState {
22 todos: { list: TodoList; expanded: string[] }
23 }
24}
25