SLOPSHOPPER

collapse-diffs

Hides the diff under successful Edit and Write tool rows and under Bash commands that change files

rows
v0.2.0MITupdated 2026-10-14Zimoholdijk/collapse-diffs
A shopper browsing a rack in a slop shop
README

collapse-diffs

A Claude Code mod that hides the diff under successful Edit and Write tool rows. The row itself (Update(src/auth.ts), Write(src/new.ts)) stays as it is.

Bash commands that change files (sed -i, a heredoc, a script that writes files) get the same treatment: the diff under the row is replaced by one line per file with its line counts, and the command's own output still shows.

● Bash(sed -i 's/a/b/' src/auth.ts && node gen.js)
  ⎿  Updated src/auth.ts +1 -1
  ⎿  Created gen/out.ts +40

Still shown as normal:

  • a call that errored, with its error text
  • a change held for review instead of written
  • any result the mod doesn't recognise

Works on every Claude Code surface: the terminal, VS Code and the desktop app.

Because the diff is hidden, the transcript no longer shows what an edit changed. Review changes with git diff, especially when edits are auto-accepted.

Install

/plugin marketplace add Zimoholdijk/plugins
/plugin install collapse-diffs@zimoholdijk

It's listed in Zimoholdijk/plugins, the catalog of my plugins.

Note

This mod uses Claude Code's early-access plugin API, which can change between releases. If diffs start showing again after an update, the API has likely moved.

Develop

Load your checkout instead of the installed copy, so edits show after /reload-plugins: add the folder to CLAUDE_CODE_PLUGIN_DIRS in the env block of ~/.claude/settings.json (or start a session with claude --plugin-dir <folder>).

claude plugin validate .
claude plugin test .
npx tsc -p .

tsconfig.json extends the types Claude Code writes to .claude-plugin/types/ when it first loads the mod, so load it once before running tsc.

Source 1 files
hooks/register.tsx 122 lines
1import type { Register } from 'claude-code'
2
3// The gutter the engine opens a line beneath a tool row with.
4const GUTTER = '  ⎿  '
5
6// A written change: an object with a patch, not held for review.
7const isWritten = (output: unknown) =>
8  typeof output === 'object' &&
9  output !== null &&
10  Array.isArray((output as { structuredPatch?: unknown }).structuredPatch) &&
11  (output as { staged?: boolean }).staged !== true
12
13type EditDiff = {
14  files: { filePath: string; hunks?: { lines?: string[] }[]; created?: true; deleted?: true }[]
15  moreFiles?: number
16}
17
18// A Bash output without the per-file diff of the files its command changed
19// (sed -i, a heredoc, a generator script), and those files with the lines
20// added and removed. Files past the diff's cap stay as an emptied diff, so the
21// engine still counts them.
22export const withoutFileDiffs = (output: unknown) => {
23  const diff = (output as { bashEditDiff?: EditDiff } | null)?.bashEditDiff
24  if (typeof output !== 'object' || output === null || !Array.isArray(diff?.files) || diff.files.length === 0) {
25    return { output, changedFiles: [] }
26  }
27  const { bashEditDiff: _, ...rest } = output as { bashEditDiff: EditDiff }
28  return {
29    output: diff.moreFiles ? { ...output, bashEditDiff: { ...diff, files: [] } } : rest,
30    changedFiles: diff.files.map(file => {
31      const changed = (file.hunks ?? []).flatMap(hunk => hunk.lines ?? [])
32      return {
33        path: file.filePath,
34        change: file.created === true ? 'Created' : file.deleted === true ? 'Deleted' : 'Updated',
35        added: changed.filter(line => line.startsWith('+')).length,
36        removed: changed.filter(line => line.startsWith('-')).length,
37      }
38    }),
39  }
40}
41
42// A Bash output that printed nothing and that the engine marks no other way
43// (interrupted, backgrounded, an image, saved to a file).
44const isSilent = (output: unknown) => {
45  const result = output as Record<string, unknown>
46  return (
47    !('bashEditDiff' in result) &&
48    result.interrupted !== true &&
49    !result.isImage &&
50    result.backgroundTaskId === undefined &&
51    result.persistedOutputPath === undefined &&
52    [result.stdout, result.stderr].every(s => typeof s !== 'string' || s.trim() === '')
53  )
54}
55
56// `path` relative to `root` when it is inside it.
57const shortPath = (path: string, root: string) => {
58  const dir = root.endsWith('/') ? root : `${root}/`
59  return path.startsWith(dir) ? path.slice(dir.length) : path
60}
61
62export const register: Register = on => {
63  for (const tool of ['Edit', 'Write']) {
64    on('ui.render', { component: 'ToolResult', props: { tool } }, ($, e, next) => {
65      if (e.props.isErrored || !isWritten(e.props.output)) {
66        return next(e)
67      }
68      const { Box } = $.ui.resolve(e)
69      return <Box />
70    })
71  }
72
73  // A Bash row that changed files lists each beneath it as
74  // `Updated src/a.ts +1 -1` in place of the diff. The row is handed the
75  // output without the diff, as an expanded group's row draws it inline.
76  on('ui.render', { component: 'ToolUse', props: { tool: 'Bash' } }, async ($, e, next) => {
77    const { output, changedFiles } = withoutFileDiffs(e.props.output)
78    if (e.props.isRunning || changedFiles.length === 0) {
79      return next(e)
80    }
81    const root = await $.session.root()
82    const { Box, Text } = $.ui.resolve(e)
83    return (
84      <Box flexDirection="column">
85        {await next({ ...e, props: { ...e.props, output } })}
86        {changedFiles.map(file => (
87          <Box key={`${file.change}:${file.path}`}>
88            <Text dimColor>{GUTTER}</Text>
89            <Text>
90              {file.change} {shortPath(file.path, root)}
91              {[
92                { text: ` +${file.added}`, color: 'success' as const, isShown: file.added > 0 },
93                { text: ` -${file.removed}`, color: 'error' as const, isShown: file.removed > 0 },
94              ]
95                .filter(side => side.isShown)
96                .map(side => (
97                  <Text key={side.color} color={side.color}>
98                    {side.text}
99                  </Text>
100                ))}
101            </Text>
102          </Box>
103        ))}
104      </Box>
105    )
106  })
107
108  // The result beneath it draws the command's output without the diff, and
109  // nothing when the changed files, already on the row, were all it had.
110  on('ui.render', { component: 'ToolResult', props: { tool: 'Bash' } }, ($, e, next) => {
111    const { output, changedFiles } = withoutFileDiffs(e.props.output)
112    if (changedFiles.length === 0) {
113      return next(e)
114    }
115    if (!e.props.isErrored && isSilent(output)) {
116      const { Box } = $.ui.resolve(e)
117      return <Box />
118    }
119    return next({ ...e, props: { ...e.props, output } })
120  })
121}
122