/collab-tools:diff-viewfrom collab-tools
Generates a self-contained HTML code diff (2-way side-by-side or 3-way) with word-level highlighting and optional PNG screenshots for PRs or Slack. Use for shareable visual comparisons of files, pasted code, or git refs.
Ships in collab-tools. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Generates a single self-contained HTML file that renders a rich code diff — dark GitHub-ish theme, line-numbered, syntax-highlighted, with word-level intra-line highlighting on lines that changed. No external dependencies, no network: the diff is computed by a small vanilla-JS pass embedded in the file, which runs on load. The file opens in the user's $EDITOR/browser and can be screenshotted full-page for dropping straight into a GitHub PR description or Slack.
This is a collab-tools skill: like its companions temp-draft and promote-draft, it routes work that doesn't belong in chat (a big visual diff) into a real artifact under /tmp/collab-tools/.
Two modes, auto-detected by how many sources you pass:
Use it when:
/collab-tools:diff-view, or asks to "diff these", "compare side by side", "show this as an HTML diff", "screenshot the diff to share", etc.git diff would be noisy or hard to read.Don't use it for:
git diff is fine.A bundled Node script (scripts/gen-diff.js, zero dependencies — Node built-ins only, no npm install) templates the HTML: it injects the sources, title, column labels, and syntax keyword set, picks the 2-way vs 3-way layout, writes the .html, and optionally drives a headless browser to capture a PNG.
Key properties (carried over from the proven prototype, hardened for arbitrary input):
$vars / keywords / fn-calls). The keyword set is pluggable via --lang or --keywords (defaults to PHP, matching the prototype; js, ts, python, go, ruby, rust, sql, generic are built in, and the language is inferred from the file extension when --lang is omitted).< → <, non-ASCII → \uXXXX). The output file is pure ASCII (so grep/editors don't misflag it as binary) and embedding arbitrary code — including literal </script>, <, >, &, and Unicode — round-trips losslessly. (The prototype used <script type="text/plain"> + textContent, which silently breaks on any of those; this skill fixes that.)You need exactly 2 or 3 sources. Each can come from:
Write to /tmp/collab-tools/<slug>-<role>.<ext>), then pass that path. Keeps chat lean and gives the script a clean file.--git "REF:PATH" (e.g. --git "HEAD~1:src/Foo.php"), which resolves via git show in the current repo. Repeatable; great for "this file before vs after".# Codex: this path resolves under Claude Code; substitute the directory containing this SKILL.md.
SKILL_DIR="${CLAUDE_SKILL_DIR}"
node "$SKILL_DIR/scripts/gen-diff.js" <sourceA> <sourceB> [sourceC] \
--title "Short descriptive title" \
--label "Column A label" --label "Column B label" [--label "Column C label"] \
--lang php \
--screenshot
Useful options (run with -h for the full list):
| Option | Purpose |
|---|---|
--title "..." | Page title / H1. Defaults to a label-derived title. |
--subtitle "..." | Muted one-line description under the title. |
--label "..." | Column header label (repeatable, in column order). Defaults to the file basename. |
--sublabel "..." | Small text under a column label (repeatable). |
--lang <name> | Keyword set: php (default), js, ts, python, go, ruby, rust, sql, generic. Inferred from extension if omitted. |
--keywords "a,b,c" | Explicit keyword list, overrides --lang. |
--note "..." | Footer note (plain text). |
--git "REF:PATH" | Add a source from a git ref (repeatable; takes precedence over positional file args). |
--out PATH | Output HTML path. Defaults to /tmp/collab-tools/<slug>-<YYYY-MM-DD>.html. |
--screenshot | Also render a full-page PNG (best-effort). |
--screenshot-out PATH | PNG path. Defaults to the HTML path with .png. |
--width N | Screenshot width in px (default 1400). |
The script prints HTML: <path> and (with --screenshot) PNG: <path>.
Open the generated HTML the same way temp-draft does — non-blocking, in their editor:
eval "${EDITOR:-vi}" '/tmp/collab-tools/your-diff.html' &
disown 2>/dev/null || true
If the user wants to view rendered rather than edit source, mention they can open the .html in a browser (open <path> on macOS), or just hand them the PNG.
One or two lines: where the HTML landed, and the PNG path if one was produced. Don't paste the HTML or the diff body into chat — the artifact is the deliverable. If the user asked to share it, the PNG is the drag-and-drop target for a PR/Slack.
Capture is best-effort and degrades gracefully; the .html is always produced regardless.
Detection order:
playwright on PATH) — preferred. Gives an exact full-page capture at any height, no guessing.If a screenshot looks clipped/padded and only Chrome was available, suggest installing Playwright (npx playwright install chromium) for exact full-page output, or just open the HTML in a browser.
Two near-identical functions (PHP), screenshot for a PR:
# Codex: this path resolves under Claude Code; substitute the directory containing this SKILL.md.
SKILL_DIR="${CLAUDE_SKILL_DIR}"
node "$SKILL_DIR/scripts/gen-diff.js" /tmp/collab-tools/tag.php /tmp/collab-tools/untag.php \
--title "TagSubscribersByFilter vs UnTagSubscribersByFilter" \
--label "Tag (orig)" --label "UnTag (orig)" --lang php --screenshot
Before / after / extracted-shared (3-way) with sublabels:
# Codex: this path resolves under Claude Code; substitute the directory containing this SKILL.md.
SKILL_DIR="${CLAUDE_SKILL_DIR}"
node "$SKILL_DIR/scripts/gen-diff.js" a.php b.php shared.php \
--title "Tag / UnTag / applyTagOperationByFilter" \
--label "Tag()" --sublabel "original — INSERT path" \
--label "UnTag()" --sublabel "original — DELETE path" \
--label "applyTagOperationByFilter()" --sublabel "new — shared" \
--lang php --screenshot
One file across two git revisions:
# Codex: this path resolves under Claude Code; substitute the directory containing this SKILL.md.
SKILL_DIR="${CLAUDE_SKILL_DIR}"
node "$SKILL_DIR/scripts/gen-diff.js" \
--git "HEAD~1:src/Subscribers.php" --git "HEAD:src/Subscribers.php" \
--title "Subscribers.php — last commit" --label "before" --label "after" --screenshot
\uXXXX escapes and render correctly in the browser./tmp/collab-tools/ (or --out).What SKILL.md sets; muted values are Claude Code's defaults
Use when the user wants a shareable visual diff of code — comparing two versions of a file, two similar functions, or three variants (e.g. before / after / refactored-shared). Triggers on 'diff these', 'side-by-side', 'compare these two/three', 'show the diff as HTML', 'screenshot the diff', or when a plain text/unified diff would be hard to read. Not for applying patches or routine git diffs the user just wants to read in the terminal.
Three short reads, in order
Other plugins' skills for the same job
npx claudepluginhub jtsternberg/claude-plugins --plugin collab-tools3 skills in this plugin
/promote-draftMove a draft out of /tmp/collab-tools/ into its real home, optionally dropping the -draft/-date suffix. Companion to temp-draft; not for arbitrary file moves./temp-draftDraft in a /tmp file opened in the user's $EDITOR instead of pasting into chat; Slack-message drafts use Slack-flavored markup so they paste cleanly.