SLOPSHOPPER

tldr

While switched on, after each long reply a small model picks the sentences you must not skip (decisions, warnings, questions for you, failures, things to do)…

bandrowscommandmodeltimer
★ 1v0.3.0MITupdated 2026-10-21samuelbfernandes/moddeck/mods/tldr
A shopper browsing a rack in a slop shop
Preview · a replayed session in a sandbox
claude · ~/work/app · tldr
› fix the failing auth test and add an audit log call ⏺ 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 › /tldr ⎿ tldr: tldr · off · colour green ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── › ? for shortcuts
README

tldr

Install (Claude Code 2.1.287 or later): /plugin install tldr --marketplace samuelbfernandes/moddeck

What it does

Long replies are easy to skim past the one line that mattered. While tldr is on, each long reply (800 characters or more) goes once to a small model (Haiku), which:

  • picks the sentences you must not skip (a question asked of you, a decision made for you, a warning, a failure, a required action, a number you need), copied word for word. Those sentences are drawn bold inside the reply, so they stand out while you scroll; in the desktop app the paragraph that holds one is also tinted (green by default, /tldr color to change it). Code is never touched.
  • writes a box above the prompt: TL;DR (two or three sentences), ⚑ Needs you, → Next. ▾ folds it to one line, ✕ puts it away until the next long reply.
  • does not repeat itself: a ⚑ Needs you or → Next point already shown earlier in the session is left out of the box (and the small model is told which ones to skip). /clear forgets them.

The call runs after the turn has ended, so nothing waits on it, and nothing is added to the conversation.

Modes

  • highlight: only the must-read sentences are marked in the reply. No box.
  • summary (the default): the marks, plus the TL;DR box above the prompt.

Colour

In the desktop app the paragraph holding a must-read sentence is tinted. /tldr color <name> picks the tint: red, yellow, olive, green (default), blue, purple or plum. The colours are estimated by eye from a screenshot; check them on your screen.

Use

  • /tldr highlight · /tldr summary: turn it on in that mode. /tldr on keeps the mode you last chose; /tldr off turns it off.
  • /tldr (status) shows the mode. The moddeck side bar has the same choice as a dropdown (off, highlight, summary) under Prompt helpers.
  • Setting minChars (default 800): shorter replies are left alone.

Cost

One Haiku call per long reply: the reply (up to about 24,000 characters) in, at most 700 tokens out. Off by default.

Limits

  • A small model can miss a sentence or pick a dull one; a must-read sentence it paraphrased instead of copying is dropped (only exact sentences are marked).
  • Marks cover the last 40 picked sentences of the session and go away after /clear.
  • Not verified live: the marks and the box in a real session, and in the desktop app.

Credit

The idea (a summary box with "you should know" and "what to do next") comes from claude-mod-tldr by alzerapradisa and mystique by wellavelino; no code was copied.

Source 3 files
hooks/register.tsx 245 lines
1// tldr: while switched on, after each long reply a small model (Haiku) picks the sentences the reader must not skip and
2// sums the reply up. The sentences are marked inside the reply (in bold) wherever the transcript draws them, and a
3// box above the prompt shows Summary, Needs you and Next. One model call per long reply, run after the turn has ended,
4// so nothing waits on it; nothing is added to the conversation. Off until `/tldr on` or the moddeck switch.
5// FAIL OPEN: if anything here fails, the reply is drawn as it was and the box stays empty.
6import { atom, read, update } from 'claude-code'
7import type { EngineInterface, Register } from 'claude-code'
8
9import type { TldrDigest, TldrMode } from '../types'
10import { HIGHLIGHT_COLORS, HIGHLIGHT_DEFAULT, SYSTEM, addMarks, addSeen, dropSeen, isHighlightColor, markText, parseDigest, promptFor, splitBlocks, type HighlightColor } from './lib'
11
12type Dollar = EngineInterface
13
14const COMMAND = 'tldr'
15const MODES: readonly TldrMode[] = ['highlight', 'summary']
16const isOff = atom({ plugin: 'tldr', key: 'isOff' } as const, true)
17const mode = atom({ plugin: 'tldr', key: 'mode' } as const, 'summary' as TldrMode)
18const color = atom({ plugin: 'tldr', key: 'color' } as const, HIGHLIGHT_DEFAULT as HighlightColor)
19const digest = atom({ plugin: 'tldr', key: 'digest' } as const, null as TldrDigest | null)
20const marks = atom({ plugin: 'tldr', key: 'marks' } as const, [] as string[])
21const seen = atom({ plugin: 'tldr', key: 'seen' } as const, [] as string[]) // needs and next points already shown this session
22const isFolded = atom({ plugin: 'tldr', key: 'isFolded' } as const, false)
23
24async function isOn($: Dollar): Promise<boolean> {
25  try {
26    return (await $.store.get('on')) === true
27  } catch {
28    return false
29  }
30}
31
32/** The highlight colour the reader last chose (green by default). */
33async function colorOf($: Dollar): Promise<HighlightColor> {
34  try {
35    const c = await $.store.get('color')
36    return isHighlightColor(c) ? c : HIGHLIGHT_DEFAULT
37  } catch {
38    return HIGHLIGHT_DEFAULT
39  }
40}
41
42/** `/tldr color <name>`: the tint of the paragraphs that hold a must-read sentence. */
43async function setColor($: Dollar, word: string): Promise<string> {
44  if (!isHighlightColor(word)) return `tldr · colour "${word.slice(0, 20)}" is not one of ${Object.keys(HIGHLIGHT_COLORS).join(', ')}`
45  try {
46    await $.store.set('color', word)
47    await update($, color, () => word)
48  } catch {
49    return 'tldr · that did not work, nothing changed'
50  }
51  return `tldr · highlight colour · ${word}`
52}
53
54/** The mode the reader last chose (summary by default). */
55async function modeOf($: Dollar): Promise<TldrMode> {
56  try {
57    const m = await $.store.get('mode')
58    return MODES.find(x => x === m) ?? 'summary'
59  } catch {
60    return 'summary'
61  }
62}
63
64async function flip($: Dollar, to: boolean): Promise<string> {
65  try {
66    if (to) await $.store.set('on', true)
67    else await $.store.delete('on')
68    await update($, isOff, () => !to)
69    if (!to) await update($, digest, () => null)
70  } catch {
71    return 'tldr · that did not work, nothing changed'
72  }
73  return to ? `tldr · on · ${MODE_TEXT[await modeOf($)]}` : 'tldr · off'
74}
75
76/** `highlight` or `summary`: turns tldr on in that mode (the switch and the dropdown both use it). */
77async function setMode($: Dollar, to: TldrMode): Promise<string> {
78  try {
79    await $.store.set('mode', to)
80    await $.store.set('on', true)
81    await update($, mode, () => to)
82    await update($, isOff, () => false)
83  } catch {
84    return 'tldr · that did not work, nothing changed'
85  }
86  return `tldr · on · ${MODE_TEXT[to]}`
87}
88
89const MODE_TEXT: Record<TldrMode, string> = {
90  highlight: 'highlight: must-read sentences are marked in the reply, no box',
91  summary: 'summary: must-read sentences are marked, and a box above the prompt sums the reply up (one Haiku call each)',
92}
93
94/** One small-model call over the reply; the digest and its must-read sentences replace the last ones. */
95async function digestReply($: Dollar, reply: string): Promise<void> {
96  try {
97    const r = await $.model.complete({ model: 'haiku', system: SYSTEM, prompt: promptFor(reply, await read($, seen)), maxTokens: 700, timeoutMs: 60_000 })
98    if (!r.isAnswered) return
99    const parsed = parseDigest(r.text, reply)
100    if (parsed === undefined) return
101    // A point flagged in an earlier reply is not shown again.
102    const before = await read($, seen)
103    const d = { ...parsed, needs: dropSeen(parsed.needs, before), next: dropSeen(parsed.next, before) }
104    await update($, seen, list => addSeen(list, [...d.needs, ...d.next]))
105    await update($, digest, () => d)
106    await update($, isFolded, () => false)
107    if (d.mustRead.length > 0) await update($, marks, list => addMarks(list, d.mustRead))
108  } catch {
109    // fail open: no box this time
110  }
111}
112
113export const register: Register = (on, options) => {
114  const minChars = typeof options.minChars === 'number' && options.minChars >= 200 ? options.minChars : 800
115
116  on('session.start', async ($, e, next) => {
117    try {
118      const isOnNow = await isOn($) // the switch and its mode outlive the session
119      const modeNow = await modeOf($)
120      const colorNow = await colorOf($)
121      await update($, isOff, () => !isOnNow)
122      await update($, mode, () => modeNow)
123      await update($, color, () => colorNow)
124    } catch {
125      // reads as off
126    }
127    try {
128      await $.command.register({ name: COMMAND, description: 'Mark what you must not skip in long replies: /tldr [highlight|summary|on|off]', argumentHint: '[highlight|summary|on|off]', immediate: true })
129    } catch {
130      // the side bar switch still works
131    }
132    return next(e)
133  })
134
135  on('command.run', { command: COMMAND }, async ($, e) => {
136    const word = e.args.trim().toLowerCase()
137    if (word === 'on' || word === 'off') return { text: await flip($, word === 'on') }
138    if (word === 'highlight' || word === 'summary') return { text: await setMode($, word) }
139    if (word.startsWith('color')) return { text: await setColor($, word.slice('color'.length).trim()) }
140    if (word === '' || word === 'status') return { text: ((await isOn($)) ? `tldr · on · ${MODE_TEXT[await modeOf($)]}` : 'tldr · off') + ` · colour ${await colorOf($)}` }
141    return { text: `tldr · unknown word "${e.args.trim().slice(0, 30)}" · use /tldr highlight, /tldr summary, /tldr color <name>, /tldr on or /tldr off` }
142  }).catch(() => ({ text: 'tldr · that did not work, nothing changed' }))
143
144  // A long answer of the main conversation: digest it once the turn is over (a timer, so the turn never waits).
145  on('turn.complete', async ($, e, next) => {
146    const r = await next(e)
147    try {
148      if (e.agentId === undefined && e.reason === 'answer' && !e.isAborted && e.answer.length >= minChars && (await isOn($))) {
149        const reply = e.answer
150        $.clock.after(1, () => void digestReply($, reply))
151      }
152    } catch {
153      // fail open
154    }
155    return r
156  })
157
158  // /clear starts a new conversation: its marks and box go with the old one.
159  on('session.end', async ($, e, next) => {
160    if (e.reason === 'clear') {
161      await update($, digest, () => null).catch(() => undefined)
162      await update($, marks, () => [])
163      await update($, seen, () => []).catch(() => undefined).catch(() => undefined)
164    }
165    return next(e)
166  })
167
168  // The reply itself: each must-read sentence in bold, so it stands out while scrolling.
169  on('ui.render', { component: 'AssistantMessage' }, async ($, e, next) => {
170    if (!(await isOn($))) return next(e)
171    const list = await read($, marks)
172    const marked = markText(e.props.text, list)
173    if (marked === undefined) return next(e)
174    // The terminal draws the rewritten markdown (in bold). The app also tints each paragraph holding a must-read
175    // sentence pale yellow: the reply is drawn here paragraph by paragraph, the marked ones on the tint.
176    if (e.surface !== 'desktop') return next({ ...e, props: { ...e.props, text: marked } })
177    const { Box, Markdown } = $.ui.resolve(e)
178    const tint = HIGHLIGHT_COLORS[await read($, color)]
179    return (
180      <Box key="tldr-reply" flexDirection="column" gap={1}>
181        {splitBlocks(marked).map((block, i) =>
182          list.some(m => block.includes(`**${m}**`)) ? (
183            <Box key={`tldr-p${i}`} backgroundColor={tint}>
184              <Markdown text={block} />
185            </Box>
186          ) : (
187            <Markdown key={`tldr-p${i}`} text={block} />
188          ),
189        )}
190      </Box>
191    )
192  }).catch(($, e, next) => next(e))
193
194  // The box above the prompt: Summary, Needs you, Next; ▾ folds it to one line, ✕ puts it away until the next reply.
195  on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
196    const d = await read($, digest)
197    if (d === null || !(await isOn($)) || (await read($, mode)) !== 'summary' || e.props.hasSurvey) return next(e)
198    const { Box, Button, Text } = $.ui.resolve(e)
199    const folded = await read($, isFolded)
200    const head = (
201      <Box key="tldr-head" columnGap={1}>
202        <Button key="tldr:fold" plain onPress={() => void update($, isFolded, f => !f)}>
203          <Text bold color="suggestion">{folded ? '▸ TL;DR' : '▾ TL;DR'}</Text>
204        </Button>
205        <Box flexGrow={1} flexShrink={1}>
206          <Text wrap={folded ? 'truncate-end' : 'wrap'}>{d.summary}</Text>
207        </Box>
208        <Button key="tldr:close" plain onPress={() => void update($, digest, () => null)}>
209          <Text dimColor>✕</Text>
210        </Button>
211      </Box>
212    )
213    const line = (key: string, label: string, items: string[], color?: string) =>
214      items.length > 0 && (
215        <Box key={key} columnGap={1}>
216          <Text bold color={color}>{label}</Text>
217          <Box flexShrink={1}>
218            <Text wrap="wrap">{items.join(' · ')}</Text>
219          </Box>
220        </Box>
221      )
222    const box = (
223      <Box key="tldr-box" flexDirection="column" borderStyle="round" borderColor="inactive" paddingX={1}>
224        {head}
225        {!folded && (line('tldr-needs', '⚑ Needs you', d.needs, 'warning') as never)}
226        {!folded && (line('tldr-next', '→ Next', d.next) as never)}
227      </Box>
228    )
229    let below: unknown
230    try {
231      below = await next(e)
232    } catch {
233      below = undefined
234    }
235    return below !== null && typeof below === 'object' ? (
236      <Box key="tldr-band" flexDirection="column">
237        {box}
238        {below as never}
239      </Box>
240    ) : (
241      box
242    )
243  }).catch(($, e, next) => next(e))
244}
245
hooks/lib.ts 129 lines
1// tldr: pure helpers. The prompt to the small model, reading its answer, and marking the must-read sentences in a reply.
2import type { TldrDigest } from '../types'
3
4export const MAX_SEEN = 30 // flagged points remembered, so the box does not repeat itself
5export const MAX_MARKS = 40 // sentences kept for marking, across recent replies
6export const MAX_REPLY_CHARS = 24_000 // what the small model is shown of a very long reply
7export const MARK = '⚑'
8/**
9 * The tint behind a paragraph that holds a must-read sentence, in the app. The colours are the ones of the highlighter
10 * sample (estimated by eye from the screenshot); green is the default. As #RRGGBBAA, at 30% opacity.
11 */
12export const HIGHLIGHT_COLORS = {
13  red: '#FF5C5C4D',
14  yellow: '#FFE0664D',
15  olive: '#A8A82A4D',
16  green: '#66BB6A4D',
17  blue: '#6F7CFF4D',
18  purple: '#9C6BD64D',
19  plum: '#5C1F5C4D',
20} as const
21export type HighlightColor = keyof typeof HIGHLIGHT_COLORS
22export const HIGHLIGHT_DEFAULT: HighlightColor = 'green'
23export const HIGHLIGHT = HIGHLIGHT_COLORS[HIGHLIGHT_DEFAULT]
24export const isHighlightColor = (v: unknown): v is HighlightColor => typeof v === 'string' && v in HIGHLIGHT_COLORS
25
26export const SYSTEM = [
27  'You help a busy reader skim a coding assistant\'s reply.',
28  'Answer with JSON only: {"summary": string, "needs": string[], "next": string[], "mustRead": string[]}.',
29  'summary: two or three plain sentences on what was done or found.',
30  'needs: decisions, questions, warnings or failures that need the reader (empty if none). Short, concrete.',
31  'next: what happens next or what the reader should do (at most 3).',
32  'mustRead: at most 5 sentences the reader must not skip, COPIED WORD FOR WORD from the reply (a question asked of them, a decision made for them, a warning, a failure, a required action, a number they need). No paraphrase.',
33].join('\n')
34
35export const promptFor = (reply: string, seen: readonly string[] = []): string =>
36  (seen.length > 0 ? `Already flagged to the reader earlier (leave these out of needs and next):\n${seen.slice(0, 10).map(s => `- ${s}`).join('\n')}\n\n` : '') +
37  `The reply:\n\n${reply.length > MAX_REPLY_CHARS ? `${reply.slice(0, MAX_REPLY_CHARS)}\n[cut]` : reply}`
38
39const squash = (s: string): string => s.toLowerCase().replace(/[^\p{L}\p{N}]+/gu, ' ').trim()
40
41/** The items not flagged before (compared without case or punctuation). */
42export const dropSeen = (items: readonly string[], seen: readonly string[]): string[] => {
43  const known = new Set(seen.map(squash))
44  return items.filter(s => !known.has(squash(s)))
45}
46
47/** Newest first, no repeats, at most MAX_SEEN. */
48export const addSeen = (list: readonly string[], fresh: readonly string[]): string[] => {
49  const keys = new Set(fresh.map(squash))
50  return [...fresh, ...list.filter(s => !keys.has(squash(s)))].slice(0, MAX_SEEN)
51}
52
53const strings = (v: unknown, max: number): string[] =>
54  Array.isArray(v) ? v.filter((x): x is string => typeof x === 'string' && x.trim() !== '').map(x => x.trim()).slice(0, max) : []
55
56/** The model's JSON (it may wrap it in a fence); mustRead keeps only sentences found in the reply as written. */
57export function parseDigest(raw: string, reply: string): TldrDigest | undefined {
58  const body = raw.slice(raw.indexOf('{'), raw.lastIndexOf('}') + 1)
59  let v: Record<string, unknown>
60  try {
61    v = JSON.parse(body) as Record<string, unknown>
62  } catch {
63    return undefined
64  }
65  const summary = typeof v.summary === 'string' ? v.summary.trim() : ''
66  if (summary === '') return undefined
67  const mustRead = strings(v.mustRead, 5)
68    .map(s => s.replace(/^[-*>\s]+/, '').replace(/\*\*/g, ''))
69    .filter(s => s.length >= 12 && reply.includes(s))
70  return { summary, needs: strings(v.needs, 5), next: strings(v.next, 3), mustRead }
71}
72
73/** Newest first, no repeats, at most MAX_MARKS. */
74export const addMarks = (list: readonly string[], fresh: readonly string[]): string[] =>
75  [...fresh, ...list.filter(s => !fresh.includes(s))].slice(0, MAX_MARKS)
76
77/**
78 * The block's markdown with each must-read sentence bolded. A sentence inside a code fence or inline code is
79 * left alone, so code stays exact; so is one already bold. Undefined when nothing changes.
80 */
81export function markText(text: string, marks: readonly string[]): string | undefined {
82  if (marks.length === 0) return undefined
83  let out = text
84  let changed = false
85  for (const m of marks) {
86    let from = 0
87    for (;;) {
88      const at = out.indexOf(m, from)
89      if (at < 0) break
90      const isMarked = out.slice(Math.max(0, at - 2), at) === '**'
91      if (isInCode(out, at) || isMarked) {
92        from = at + m.length
93        continue
94      }
95      const wrapped = `**${m}**`
96      out = out.slice(0, at) + wrapped + out.slice(at + m.length)
97      from = at + wrapped.length
98      changed = true
99    }
100  }
101  return changed ? out : undefined
102}
103
104/** Inside a ``` fence or a `span` on its line. */
105function isInCode(text: string, at: number): boolean {
106  const before = text.slice(0, at)
107  if ((before.match(/^```/gm) ?? []).length % 2 === 1) return true
108  const line = before.slice(before.lastIndexOf('\n') + 1)
109  return (line.match(/`/g) ?? []).length % 2 === 1
110}
111
112/** The reply cut at blank lines into paragraphs, never inside a ``` fence, so each can be drawn (and tinted) on its own. */
113export function splitBlocks(text: string): string[] {
114  const out: string[] = []
115  let cur: string[] = []
116  let inFence = false
117  for (const line of text.split('\n')) {
118    if (/^```/.test(line)) inFence = !inFence
119    if (!inFence && line.trim() === '' && cur.length > 0) {
120      out.push(cur.join('\n'))
121      cur = []
122      continue
123    }
124    if (!(line.trim() === '' && cur.length === 0)) cur.push(line)
125  }
126  if (cur.length > 0) out.push(cur.join('\n'))
127  return out
128}
129
types/index.d.ts 35 lines
1/** What the small model made of the last long reply. */
2export type TldrDigest = {
3  /** Two or three plain sentences. */
4  summary: string
5  /** Decisions, questions or warnings that need the reader. */
6  needs: string[]
7  /** What happens next, or what the reader should do. */
8  next: string[]
9  /** Sentences copied word for word from the reply that must not be skipped; each one is marked in the transcript. */
10  mustRead: string[]
11}
12
13/** What the reader sees while on: the must-read sentences only, or those plus the TL;DR box above the prompt. */
14export type TldrMode = 'highlight' | 'summary'
15
16declare module 'claude-code' {
17  interface PluginState {
18    tldr: {
19      /** True while off (it ships off). The persisted switch is `$.store` 'on'; mirrored for the moddeck side bar. */
20      isOff: boolean
21      /** The mode while on (`summary` ships as the default). Persisted as `$.store` 'mode'; mirrored for the moddeck side bar. */
22      mode: TldrMode
23      /** The tint of the paragraphs that hold a must-read sentence in the app (green by default). Persisted as `$.store` 'color'. */
24      color: 'red' | 'yellow' | 'olive' | 'green' | 'blue' | 'purple' | 'plum'
25      /** The last long reply's digest; null before the first one, after /clear, or once dismissed. */
26      digest: TldrDigest | null
27      /** Must-read sentences of this session's recent replies, marked wherever the transcript draws them. */
28      marks: string[]
29      seen: string[]
30      /** The box above the prompt is folded to one line. */
31      isFolded: boolean
32    }
33  }
34}
35