explain-diff
Skill0 starsChanged 26 days agoMITView on GitHub
Generate a rich HTML explanation of a git diff — background, intuition, code walkthrough, four review sections (duplication, complexity delta, pattern precedent with blame authors, responsibility boundaries), and an interactive quiz — saved to ~/.claude/diff-explanations/. Use when the user types /explain-diff [<ref>].
16 other projects use a version of this.
Adopted by
Most recently taken up by
- eugenelim/agent-ready-repotheir own version, first seen Nov 8, 2026
- jorgenschaefer/skillstheir own version, first seen Nov 1, 2026
- lucaslimafons/skillstheir own version, first seen Nov 1, 2026
- OlliTapio/claude_skillstheir own version, first seen Oct 26, 2026
- SwiftyJunnos/skillstheir own version, first seen Oct 20, 2026
- CheckPickerUpper/skillstheir own version, first seen Oct 13, 2026
Other versions16 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 16
- claesbackman/AI-research-feedback★ 523same name
- eugenelim/agent-ready-repo★ 28same name
- CheckPickerUpper/skills★ 9same name
- flpbalada/fb-skills★ 8same name
- yogan/agent-skills★ 2same name
- arturlimaaa/skills★ 1same name
- aryankeluskar/skills★ 1same name
- lucaslimafons/skills★ 1same name
- SwiftyJunnos/skills★ 1same name
- tyom/skills★ 1same name
6 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository13 other files it gives its agents.
- arch-reviewSkill
- explainSkill
- find-sessionSkill
- prep-compactSkill
- prep-prSkill
- prune-commentsSkill
- remove-commentsSkill
- resume-planSkill
- review-pr-comments-loopSkill
- review-pr-commentsSkill
- runbookSkill
- session-review-loopSkill
- session-reviewSkill
The file
We split this skill into the rules it gives an agent
12 rules. 0 are common, 8 are distinctive, and 4 are very specific to this project.
0
Common
Most of the 15 edited versions we read keep these.
8
Distinctive
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 16
No argument: default to main...HEAD (changes on the current branch since it diverged from main).
- Distinctive: line 24
If the diff is empty, tell the user and stop.
- Very specific: line 41
Read ~/.claude/skills/shared/review-checks.md and follow its Evidence section for the diff from step 1.
- Distinctive: line 56
Use the Write tool to write a single self-contained HTML file to the output path.
- Very specific: line 83
Before/after code blocks side by side (flex-direction: row.
- Distinctive: line 93
Write in the style of Martin Kleppmann: clear, precise, builds intuition before detail.
- Distinctive: line 95
Keep code snippets short — enough to illustrate the point, not the full function.
- Distinctive: line 102
Data shape: Do not hard-code the option order in the HTML.
- Distinctive: line 122
Every option of one question must be within about 20% of the others in word count.
- Distinctive: line 123
Write all four options first, then trim the longest and expand the shortest until they match.
- Very specific: line 124
Put the reason the answer is correct in the why field, not in the option text.
- Distinctive: line 126
Use the same grammar for all four options: if one starts with a verb, all start with a verb.
“Common” is measured: kept by at least 6 in 10 of the 15 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
explain-diff
Generate a structured, educational explanation of a git diff and write it as a self-contained HTML file. No dependencies required.
Steps
1. Determine the diff ref
- With argument (e.g.
/explain-diff main..feature/auth): use the provided git ref exactly. - No argument: default to
main...HEAD(changes on the current branch since it diverged from main).
git rev-parse --show-toplevel
git branch --show-current
git diff <ref> --statIf the diff is empty, tell the user and stop.
2. Get the diff
git diff <ref>
git diff <ref> --name-onlySkip generated files, lock files, migration files, and .snap files.
3. Read surrounding context
For each changed file (up to 8 files), use the Read tool to read the full file. Note the file's role in the system and how the changed lines fit into the larger context. Never explain from the diff alone.
4. Gather evidence for the review sections
Read ~/.claude/skills/shared/review-checks.md and follow its Evidence section for the diff from step 1. Collect the evidence now, before you write the page.
5. Derive slug and output path
- Slug: branch name with
/,_, spaces replaced by-, lowercased, truncated to 40 chars. If on main or detached HEAD, derive a 3-word kebab-case summary from the changes. - Output path:
~/.claude/diff-explanations/<repo>_<YYYY-MM-DD>_<slug>.html
Each run always creates a new file — never overwrite an existing one.
mkdir -p ~/.claude/diff-explanations6. Write the HTML file
Use the Write tool to write a single self-contained HTML file to the output path. The file must have no external dependencies — all CSS and JS inline.
Structure
The page has eight sections. Sections 1–3 are the main explanation. Sections 4–7 are the review sections: one per table in the Tables section of review-checks.md, in the same order, always present, even when a section has no finding. Section 8 is the quiz.
- Background — 2–4 sentence overview of the changed code's role, what it does before and after, and why the change matters.
- Intuition — The key concept driving the change, explained simply. Include a concrete toy example showing the effect of the change, rendered as a before/after code comparison.
- Code Walkthrough — One entry per changed file (logical order: data model → service → API → UI, not diff order). Each entry has: file path, one-sentence role, plain-English explanation of what changed and why, and a before/after code block where relevant.
- Duplication Check — whether existing code overlaps what the diff adds.
- Complexity Delta — what the diff adds and removes in locks, abstractions, and indirection, with the net verdict.
- Pattern Precedent — where else the repo uses the main pattern of the diff, with blame authors and dates.
- Responsibility Boundaries — which layer and which repo owns each part of the changed behavior.
- Quiz — 5 multiple-choice questions testing genuine comprehension. Each question has 4 options. Clicking an option reveals whether it is correct and shows a one-sentence explanation. Only one reveal per question. See Quiz construction below — the answer must not be guessable from its position or its length.
Design
- Clean, readable design with a neutral light background and good typography.
- Page width:
.pagestarts atwidth: 860px; max-width: calc(100vw - 4rem); margin: 0 auto. A fixed drag handle (.resize-handle, 6px wide,cursor: ew-resize) is positioned at the right edge of.pagevia JS. Dragging it adjustspage.style.width; the new width is persisted inlocalStorage. The handle turns indigo on hover/drag. Onwindow resize, reposition the handle. Multiply mouse delta by 2 (since the centered page expands symmetrically) and clamp between 400px andwindow.innerWidth - 64. - Syntax-highlighted code blocks: dark background (
#1e1e1e), monospace font, appropriate token colors (keywords blue, strings green, comments grey, types teal). Apply highlighting via a small inline JS function — no external libraries. - Before/after code blocks side by side (
flex-direction: row; flex-wrap: wrap), each sideflex: 1 1 300px. Eachpreblock usesoverflow-x: autoso long lines scroll horizontally rather than wrapping. - Quiz options styled as clickable buttons, built by JS from the shuffled option data (see Quiz construction). On click: correct answer turns green with a checkmark, wrong answers turn red with an ✗. Explanation appears below. Disable all options after one is chosen.
- Section headers use a clear visual hierarchy. Use a subtle left border or colored rule to distinguish sections.
- Give the four review sections a different left-border color from the main explanation, and put a small "Review" label above the first one, so the reader sees where the explanation ends.
- Review tables: full width, zebra rows,
font-size: 0.9em, file:line cells in monospace. Wrap each table in a container withoverflow-x: auto. - Flags (as the Flags section of
review-checks.mddefines them) get an amber badge. A section with no flags shows a grey "No findings" badge next to its header. <title>set to the explanation title.<meta name="description">set to a one-line summary.
Content guidelines
- Write in the style of Martin Kleppmann: clear, precise, builds intuition before detail.
- Define any jargon inline in parentheses the first time it appears.
- Keep code snippets short — enough to illustrate the point, not the full function.
- Quiz questions should test genuine comprehension, not trivia. Medium difficulty. At least one question must come from the review sections.
Quiz construction
A reader must not be able to pick the answer without understanding the change. Two tells give the answer away: the position of the correct option, and its length. Remove both.
Data shape. Do not hard-code the option order in the HTML. Emit each question as data, with the options in authoring order and the correct one marked by a flag:
const QUIZ = [
{
question: "...",
options: [
{ text: "...", correct: true, why: "..." },
{ text: "...", correct: false, why: "..." },
{ text: "...", correct: false, why: "..." },
{ text: "...", correct: false, why: "..." }
]
}
];Shuffle at render time. On page load, shuffle each question's options with a Fisher-Yates shuffle before you build the buttons. Derive the A–D letter from the shuffled index, never from the authoring order. Because the correct option carries a flag, the shuffle cannot break the scoring.
Length parity. The shuffle fixes position. It does not fix length, so you must write the options to the same size:
- Every option of one question must be within about 20% of the others in word count.
- Write all four options first, then trim the longest and expand the shortest until they match.
- Put the reason the answer is correct in the
whyfield, not in the option text. Thewhyfield is only shown after the click, so it cannot leak the answer. - Give every wrong option a real claim about the code. Do not write a short wrong option that is obviously a placeholder.
- Use the same grammar for all four options: if one starts with a verb, all start with a verb.
Check before you save. For each question, count the words of each option and compare. If one option is the longest in more than two of the five questions, rewrite it.
7. Report
Tell the user:
- The full path to the saved file
- How to open it:
open <path> - The review-check summary line (see Summary line in
review-checks.md)
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

