explain-this-diff
Skill1 starsChanged 7 months agoMITView on GitHub
Read a git diff and produce a plain-English narrative for a reviewer who wasn't in the original conversation — what changed, why, what's risky, what to spot-check. Use when the diff is non-trivial and the PR description is missing or auto-generated, or when handing context to a reviewer who's joining late.
In this repository50 other files it gives its agents.
- algolia-searchSkill
- audit-tautological-testsSkill
- blame-archaeologySkill
- brevo-emailSkill
- bun-runtimeSkill
- clerk-authSkill
- cloudflare-workersSkill
- dbt-data-modelingSkill
- extract-skill-from-sessionSkill
- fastapi-productionSkill
- find-dead-codeSkill
- find-real-bugSkill
- gdpr-dpiaSkill
- github-actions-ciSkill
- graphql-relaySkill
- grpc-servicesSkill
- hipaa-auditSkill
- india-dpdp-actSkill
- java-8-to-21Skill
- jest-to-vitestSkill
- kubernetes-helmSkill
- mongo-to-postgresSkill
- nextjs-pages-to-appSkill
- node-version-upgradeSkill
- opentelemetry-instrumentSkill
- pci-dss-checklistSkill
- plan-the-rollbackSkill
- python-2-to-3Skill
- razorpay-integrationSkill
- react-native-expoSkill
- scaffold-cli-toolSkill
- scaffold-fullstack-appSkill
- scaffold-go-microserviceSkill
- scaffold-new-appSkill
- scaffold-saas-starterSkill
- sentry-monitoringSkill
- shrink-this-prSkill
- soc2-evidenceSkill
- spec-from-conversationSkill
- stripe-integrationSkill
- supabase-backendSkill
- terraform-patternsSkill
- threat-modeling-strideSkill
- triage-stack-traceSkill
- wcag-accessibility-auditSkill
- webpack-to-viteSkill
- write-adrSkill
- write-commit-messageSkill
- write-pr-descriptionSkill
- write-runbookSkill
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 2 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 39
Test files (signal: the change is tested).
- Distinctive: line 107
Call out the specific risk, not "this is risky."
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Explain This Diff
The reviewer doesn't know what you know. A diff without narrative forces them to reconstruct intent from code, which is slow and error-prone. This skill produces the narrative.
When to use
- Opening a non-trivial PR — generates the description.
- Handing a stale PR to a fresh reviewer mid-week.
- Annotating a long-running feature branch for someone joining the project.
- Code archaeology — explaining a historical commit to current you.
When NOT to use
- Trivial diffs (typo, lint fix) — title is enough.
- Generated code changes (lockfile, generated proto) — note them and skip the body.
The narrative shape
For any diff, produce:
- One-sentence summary — what changes from the user's or developer's perspective.
- Why — motivation. Pull from issue, commit messages, conversation context.
- The interesting bits — design choices a reviewer might question.
- The boring bits — large file moves, generated code, mechanical refactor — call them out and tell the reviewer to skim.
- What to spot-check — specific files or lines worth careful attention.
- What's risky — failure modes worth thinking through.
Skip sections that don't apply. Better short and dense than long and fluffy.
Reading a diff (the algorithm)
- List the file categories — group changes by type:
- Source files (where the actual change lives).
- Test files (signal: the change is tested).
- Generated files (skim only).
- Config / lockfile (note version bumps).
- Docs.
- Identify the "main" change — the file with the most logic-changing lines is usually it.
- Trace its callers — who else changed because of this? Those changes follow from the main change.
- Look for behavior changes —
if/elserearrangements, new branches, default value changes. Highlight. - Look for state changes — schema migrations, config flags, env var additions. These are riskiest.
- Look for what's missing — no test? No error handling? No null check on user input?
Worked example
Diff: 12 files changed, +340 lines / -85 lines.
M apps/api/src/routes/refunds.ts (+95 / -10)
M apps/api/src/services/payments.ts (+40 / -5)
M packages/db/schema.ts (+8 / 0)
A packages/db/migrations/0042_add_remaining_refundable.sql (+12 / 0)
M apps/api/src/services/refunds.test.ts (+120 / -40)
A apps/api/src/services/refunds.fixtures.ts (+50 / 0)
M apps/web/src/app/billing/refunds/page.tsx (+15 / -10)
M README.md (+5 / 0)
M pnpm-lock.yaml (skip)Narrative produced
Summary: Adds partial-refund support to
POST /api/refunds. Previously the endpoint only did full refunds.Why: Customer support has been issuing full refunds for partial requests because the dashboard didn't expose partial. Tracked as #2156.
Main change:
apps/api/src/routes/refunds.ts— accepts optionalamountfield; when present and < payment amount, calls Razorpay withspeed: "optimum"(UPI/IMPS instant). Logic delegated toservices/payments.tswhich validates the amount againstremaining_refundable.DB change:
migrations/0042_add_remaining_refundable.sqladds a generated column onpayments:remaining_refundable bigint GENERATED ALWAYS AS (amount_paise - refunded_paise) STOREDGenerated column = no app code maintains it; Postgres keeps it in sync with
refunded_paise.Tests:
services/refunds.test.tsis mostly rewritten — old tests were happy-path only. New filerefunds.fixtures.tsis the test data builder.UI:
apps/web/.../page.tsx— small change to show partial-refund option when remaining > 0.Skim:
pnpm-lock.yaml(no real dep changes),README.md(one-line note about new endpoint shape).Spot-check:
services/payments.ts:54— the validationif (amount > remaining_refundable)returns 422. Is the error message clear?services/payments.ts:78—speed: "optimum"falls back to"normal"per Razorpay docs; verify the path you'd want for >₹50k refunds (Optimum doesn't always cover those).migrations/0042— generated column isSTORED, so it occupies disk;VIRTUALwould save space but Postgres only supports STORED.Risks:
- If
refunded_paiseis ever updated outside the refund flow (e.g. manual SQL fix),remaining_refundableupdates correctly (Postgres handles it).- Race condition: two simultaneous partial refund requests could both pass validation and over-refund. Mitigation in this PR: row-lock on
paymentsrow in the service. Verify the lock is actually held (search forSELECT ... FOR UPDATE).
A reviewer reading this can review the PR in 10 minutes instead of 30.
What "risk" actually means
Not "could this break?" — every change could break. Specifically:
- Concurrency hazards — what if two requests hit this at the same time?
- Migration / rollback — see
plan-the-rollback. - Data loss — DELETE / UPDATE without WHERE; truncating tables; column drops.
- Performance regression — N+1 introduced; new query without an index; cache invalidated too aggressively.
- Security — input not validated; auth check missing; secret in code.
- Backward compatibility — API contract changes that older clients can't handle.
Call out the specific risk, not "this is risky."
Anti-patterns
- Re-listing every file changed — diff already shows that. Group and summarize.
- Restating diff lines as English — "now the function returns true if X." Useless. The diff says it.
- No "spot-check" section — reviewer has no anchor for where to focus.
- Hedging language ("This might be risky") — be concrete: "Race condition possible because lines 12–18 are not atomic; mitigation needed."
- Skipping the "why" — reviewer can't judge if the approach is right without knowing the goal.
- Including history of what you tried before unless directly informative — past attempts belong in commit messages, not PR explanations.
- No explicit risk callout — reviewer should not have to find the risks.
- Auto-generated bullet list ("Updated foo.ts. Updated bar.ts. ...") — adds zero info.
Verify it worked
- One-sentence summary that a non-author understands.
- Why is concrete (issue link, metric, user report — not "improvement").
- Main change identified by file/section, not "the changes."
- Boring sections (lockfile, generated) are flagged as skim-only.
- Spot-check section has specific file:line references.
- Risks are concrete, not handwaved.
- A reviewer joining cold can review in < 30 min using only the narrative + diff.
- Generated code / mechanical refactor is not explained line by line — flagged for skim.
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.

