SLOPSHOPPER

file-compare

Compare two small text files by line without editing either.

newpanecommand
A shopper browsing a rack in a slop shop
Preview · a replayed session in a sandbox
claude · ~/work/app · file-compare
│ ┃ File Compare ✕ › fix the failing auth test and add an audit log call │ ┃ File Compare │ ┃ ⏺ Read(src/auth.ts) │ ┃ Compare two small text files by line without ⎿ Read 6 lines │ ┃ editing either. ⏺ Update(src/auth.ts) │ ┃ ⎿ Added 2 lines, removed 1 line │ ┃ Left file: before.txt ⏎ set ⏺ Bash(bun test) │ ┃ ⎿ 3 pass, 1 fail │ ┃ Right file: after.txt ⏎ compare │ ┃ ● Done. refresh now rejects expired claims and logs an audit event. │ ┃ ENOENT: before.txt │ ┃ ✻ Worked for 42s · done 4:20 PM │ ┃ [ Compare again ] │ › /file-compare │ │ ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── › ? for shortcuts

Draws

Pane · File Compare
File Compare Compare two small text files by line without editing either. Left file: before.txt ⏎ set Right file: after.txt ⏎ compare ENOENT: before.txt [ Compare again ]
README

File Compare

Compare two small text files by line without editing either.

Use it when: Check config or fixture differences.

File Compare render preview

Screenshot of this mod's render tree in the fixture preview, with sample data. This is not a capture of the Claude Code application. How previews are made.

Install and open

claude plugin marketplace add whyashthakker/awesome-claude-code-mods
claude plugin install file-compare@awesome-claude-code-mods

Run /reload-plugins in an existing session, then /file-compare. Use Tab and Enter to operate controls; Esc closes the pane. Terminal and Desktop Code tab supported; pane UI is unavailable in claude -p and the VS Code chat panel.

Try the source without installing:

claude --plugin-dir ./mods/file-compare

Access and behavior

Reads two explicitly chosen text files up to 64 KiB each. Positional comparison, not an edit-distance diff.

Module variables reset on hot reload. All display output is bounded; viewers may truncate long content to 9,000 characters. Relative file paths and Git commands use the session working directory.

Verify

Tested with Claude Code 2.1.288. Minimum documented mods version: 2.1.287. The API can change; validate against your installed version.

claude plugin validate mods/file-compare --strict
claude plugin test mods/file-compare

Tests cover plugin commands, pane isolation, both UI surfaces, and the behavior described in tests/register.test.ts. Drawing tests validate element trees; they do not verify pixels painted by the native apps. Validation details.

MIT licensed. No runtime packages or build step required.

Source 2 files
hooks/register.js 48 lines
1import { clean, text, code, row, frame, bar, pretty, bounded, entries, safePath } from './ui.js'
2const ID = "file-compare"
3let left='before.txt',right='after.txt',report=''
4
5async function load($) {
6 try {
7 const a=await $.fs.stat(safePath(left)),b=await $.fs.stat(safePath(right))
8 if(a.size>65536||b.size>65536)throw new Error('Each file must be at most 64 KiB.')
9 const x=(await $.fs.read(left)).split('\n'),y=(await $.fs.read(right)).split('\n')
10 const diff=[]
11 for(let i=0;i<Math.max(x.length,y.length);i++) if(x[i]!==y[i])diff.push((i+1)+': - '+(x[i]??'[missing]')+'\n   + '+(y[i]??'[missing]'))
12 report=diff.length?diff.length+' differing line positions (positional comparison)\n\n'+diff.slice(0,100).join('\n'):'Files are identical.'
13 } catch(error){report=error.message}
14 $.ui.invalidate('ui.render')
15}
16
17export function register(on) {
18  on('session.start', async ($, e, next) => {
19
20    await $.command.register({name:ID, description:"Compare two small text files by line without editing either.", immediate:true, argumentHint:"[path]"})
21    return next(e)
22  })
23  on('command.run', {command:"file-compare"}, async ($, e) => {
24    await load($)
25    await $.ui.open({id:ID,title:"File Compare",focus:true,closeOnEscape:true})
26    return {}
27  })
28
29  on('ui.render', {component:'Pane'}, async ($, e, next) => {
30    if(e.requestId !== ID) return next(e)
31    const E = $.ui.resolve(e)
32    try {
33      const body = await draw($, E)
34      return frame(E,"File Compare","Compare two small text files by line without editing either.",body)
35    } catch(error) {
36      return frame(E,"File Compare",'Unable to inspect this data.',[text(E,error.message,{color:'yellow'}),E.Button({key:'refresh',label:'Refresh',onPress:()=>$.ui.invalidate('ui.render')})])
37    }
38  })
39}
40async function draw($, E) {
41  const refresh = E.Button({key:'refresh',label:'Refresh',hotkey:'r',plain:true,onPress:()=>$.ui.invalidate('ui.render')})
42
43return [E.Input({key:'left',label:'Left file',value:left,submitLabel:'set',onSubmit:async(v)=>{left=v;await load($)}}),
44 E.Input({key:'right',label:'Right file',value:right,submitLabel:'compare',onSubmit:async(v)=>{right=v;await load($)}}),
45 code(E,report),E.Button({key:'refresh',label:'Compare again',onPress:()=>load($)})]
46
47}
48
hooks/ui.js 36 lines
1// Pure UI helpers. No engine access; each plugin contains its own copy.
2export function clean(value, limit = 9000) {
3  return String(value ?? '').replace(/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f-\u009f]/g, '').slice(0, limit)
4}
5export function text(E, value, props = {}) {
6  return E.Text({ ...props, children: [clean(value)] })
7}
8export function code(E, value, language = 'text') {
9  return E.Code({ source: clean(value), language })
10}
11export function row(E, children) {
12  return E.Box({ flexDirection: 'row', columnGap: 2, flexWrap: 'wrap', children })
13}
14export function frame(E, title, subtitle, children) {
15  return E.Box({ flexDirection: 'column', gap: 1, children: [
16    text(E, title, { bold: true, color: 'cyan' }),
17    text(E, subtitle, { dimColor: true }), ...children,
18  ] })
19}
20export function bar(percent, width = 24) {
21  const p = Math.max(0, Math.min(100, Number(percent) || 0))
22  const n = Math.round(p / 100 * width)
23  return '[' + '#'.repeat(n) + '-'.repeat(width - n) + '] ' + p.toFixed(1) + '%'
24}
25export function pretty(value) { return JSON.stringify(value, null, 2) }
26export function bounded(value, max = 9000) {
27  if (value.length > max) throw new Error('Input exceeds ' + max + ' characters. Use a smaller selection.')
28  return value
29}
30export function entries(value) { return value && typeof value === 'object' ? Object.entries(value) : [] }
31export function safePath(value) {
32  const path = value.trim()
33  if (!path || path.startsWith('-') || /[\x00-\x1f]/.test(path)) throw new Error('Enter a path without control characters or leading flags.')
34  return path
35}
36