Diff Review (four-principle pre-commit check)
Purpose
Catch the failure modes that make AI-assisted changes risky before they land: unstated wrong
assumptions, needless complexity, sprawling diffs, and "looks done" changes that were never
verified. This skill reviews a concrete diff against four habits and returns a short, actionable
verdict — not a style lecture.
The four principles below distill widely shared guidance on coding with LLMs popularized by
Andrej Karpathy (https://karpathy.ai); the four-point framing is a common community
distillation, not a verbatim quote.
When to use
- Before committing, especially for AI-generated or AI-assisted changes.
- When the user says "review my diff", "karpathy check", "check complexity", "am I overcomplicating
this", or "is this change too big".
- As a final gate after implementing a feature/fix, before opening a PR.
When not to use
- For deep security review (use a dedicated security/secrets review skill).
- For architecture-level decisions across many files (use architecture-review).
- When there is no diff yet — this reviews concrete changes, not ideas.
Procedure
- Get the change. Inspect the actual diff, not the description:
- Staged:
git diff --staged
- Working tree:
git diff
- Last commit:
git show HEAD
Note the number of files, hunks, and net lines changed.
- Principle 1 — Surface assumptions. List the inputs, invariants, and edge cases the change
assumes (nullability, types, ordering, auth state, empty/large inputs, concurrency). For each,
confirm it actually holds in the touched code paths. Flag any unstated assumption that isn't
guaranteed.
- Principle 2 — Keep it simple. Look for complexity the change introduces on its own: new
abstractions/indirection for a single caller, premature generalization, dead branches, clever
one-liners, duplicated logic. Prefer the smallest solution that works; note what could be deleted.
- Principle 3 — Surgical changes. Check that every hunk is required by the task. Flag drive-by
reformatting, unrelated renames, churned imports, and files that didn't need to change. Wide blast
radius = harder review and higher regression risk.
- Principle 4 — Verifiable goal. Identify how this change is proven to work: a test, a command,
an observable output. If there's no verification (or no new/updated test for new behavior), that is
the top finding.
- Verdict. Summarize as keep (ship as-is), keep with nits (minor, non-blocking), or
fix first (blocking issues). List blocking items with the exact file:line and a concrete fix.
Concrete checks
git diff --staged --stat — files and net lines; a "one-line fix" touching 12 files is a red flag.
- New behavior has a matching new/changed test? (search the diff for test files)
- Any
TODO, FIXME, debug print/console.log, commented-out code, or leftover scaffolding in the diff?
- Any new dependency added for a trivial need that the stdlib/existing utils already cover?
- Does the diff reformat lines it didn't functionally change? (whitespace-only hunks)
- Are assumptions about external input validated, or just trusted?
Commands
git diff --staged --stat # blast radius at a glance
git diff --staged # the actual change to review
git show HEAD # review the last commit instead
git diff --staged -- '*.test.*' '*_test.*' '*spec*' # did tests change with the code?
Common issues & anti-patterns
- "It looks right" ≠ verified. No test, no run, no proof → treat as unverified.
- Refactor smuggled into a feature. Keep behavior-preserving refactors in a separate commit.
- Over-abstraction for one caller. YAGNI — inline it until a second caller exists.
- Silent assumption. "It'll always be non-null/sorted/small" without a guard or test.
- Scope creep. The diff fixes three things the task didn't ask for; split them.
Required output
A short report:
- Blast radius: files / hunks / net lines.
- Per principle: ✓ or the specific finding (with
file:line).
- Verdict: keep / keep with nits / fix first.
- Blocking fixes (if any): numbered, each with an exact, minimal fix.
Safety
Read-only review — never amend, commit, reset, or rewrite history as part of this skill. Suggest
fixes; let the author apply them. Do not run formatters or git add/git commit automatically.
1---2name: diff-review3description: Use when reviewing a code change before committing — e.g. the user says "review my diff", "karpathy check", "am I overcomplicating this", "check complexity before I commit", or when finalizing AI-generated code. Audits the staged diff against four principles (surface assumptions, keep it simple, surgical changes, verifiable goal) and returns a keep-or-fix verdict.4---56# Diff Review (four-principle pre-commit check)78## Purpose910Catch the failure modes that make AI-assisted changes risky **before** they land: unstated wrong11assumptions, needless complexity, sprawling diffs, and "looks done" changes that were never12verified. This skill reviews a concrete diff against four habits and returns a short, actionable13verdict — not a style lecture.1415The four principles below distill widely shared guidance on coding with LLMs popularized by16**Andrej Karpathy** (<https://karpathy.ai>); the four-point framing is a common community17distillation, not a verbatim quote.1819## When to use2021- Before committing, especially for AI-generated or AI-assisted changes.22- When the user says "review my diff", "karpathy check", "check complexity", "am I overcomplicating23 this", or "is this change too big".24- As a final gate after implementing a feature/fix, before opening a PR.2526## When not to use2728- For deep security review (use a dedicated security/secrets review skill).29- For architecture-level decisions across many files (use architecture-review).30- When there is no diff yet — this reviews concrete changes, not ideas.3132## Procedure33341. **Get the change.** Inspect the actual diff, not the description:35 - Staged: `git diff --staged`36 - Working tree: `git diff`37 - Last commit: `git show HEAD`38 Note the number of files, hunks, and net lines changed.392. **Principle 1 — Surface assumptions.** List the inputs, invariants, and edge cases the change40 assumes (nullability, types, ordering, auth state, empty/large inputs, concurrency). For each,41 confirm it actually holds in the touched code paths. Flag any unstated assumption that isn't42 guaranteed.433. **Principle 2 — Keep it simple.** Look for complexity the change introduces on its own: new44 abstractions/indirection for a single caller, premature generalization, dead branches, clever45 one-liners, duplicated logic. Prefer the smallest solution that works; note what could be deleted.464. **Principle 3 — Surgical changes.** Check that every hunk is required by the task. Flag drive-by47 reformatting, unrelated renames, churned imports, and files that didn't need to change. Wide blast48 radius = harder review and higher regression risk.495. **Principle 4 — Verifiable goal.** Identify how this change is *proven* to work: a test, a command,50 an observable output. If there's no verification (or no new/updated test for new behavior), that is51 the top finding.526. **Verdict.** Summarize as **keep** (ship as-is), **keep with nits** (minor, non-blocking), or53 **fix first** (blocking issues). List blocking items with the exact file:line and a concrete fix.5455## Concrete checks5657- `git diff --staged --stat` — files and net lines; a "one-line fix" touching 12 files is a red flag.58- New behavior has a matching new/changed test? (search the diff for test files)59- Any `TODO`, `FIXME`, debug `print`/`console.log`, commented-out code, or leftover scaffolding in the diff?60- Any new dependency added for a trivial need that the stdlib/existing utils already cover?61- Does the diff reformat lines it didn't functionally change? (whitespace-only hunks)62- Are assumptions about external input validated, or just trusted?6364## Commands6566```bash67git diff --staged --stat # blast radius at a glance68git diff --staged # the actual change to review69git show HEAD # review the last commit instead70git diff --staged -- '*.test.*' '*_test.*' '*spec*' # did tests change with the code?71```7273## Common issues & anti-patterns7475- **"It looks right" ≠ verified.** No test, no run, no proof → treat as unverified.76- **Refactor smuggled into a feature.** Keep behavior-preserving refactors in a separate commit.77- **Over-abstraction for one caller.** YAGNI — inline it until a second caller exists.78- **Silent assumption.** "It'll always be non-null/sorted/small" without a guard or test.79- **Scope creep.** The diff fixes three things the task didn't ask for; split them.8081## Required output8283A short report:84- **Blast radius:** files / hunks / net lines.85- **Per principle:** ✓ or the specific finding (with `file:line`).86- **Verdict:** keep / keep with nits / fix first.87- **Blocking fixes (if any):** numbered, each with an exact, minimal fix.8889## Safety9091Read-only review — never amend, commit, reset, or rewrite history as part of this skill. Suggest92fixes; let the author apply them. Do not run formatters or `git add`/`git commit` automatically.