Skip to content
Back to skills

Code Review

ASecurity

Review a diff, package, or API through one of five lenses — necessity and layering (Russ Cox), honest invariants and costs (BurntSushi), product-versus-library fit (Mitsuhiko), a complexity gate before a design change, or newcomer clarity. Use when asked to review, audit, or polish code, vet a dependency, judge whether a change is too complex, or find what a new hire would not understand. Do NOT use for an adversarial review proven by runs (use interrogate).

  • 4 stars
  • 0 votes
  • 0 copies
  • 7 views
  • Added September 11, 2026
ai-agentspythonrustgojavarubyphpswiftkotlinc++c#

Works with

  • api

Security analysis

A100/100

Pro scans all 10 files and shows the line behind each finding

Scanned December 5, 2026

npx -y skills add wilbeibi/wilbeibi-skills --skill code-review --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Code Review?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Code Review
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/wilbeibi-code-review/badge)](https://www.skillsdirectory.com/skills/wilbeibi-code-review)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: code-review
description: Review a diff, package, or API through one of five lenses — necessity and layering (Russ Cox), honest invariants and costs (BurntSushi), product-versus-library fit (Mitsuhiko), a complexity gate before a design change, or newcomer clarity. Use when asked to review, audit, or polish code, vet a dependency, judge whether a change is too complex, or find what a new hire would not understand. Do NOT use for an adversarial review proven by runs (use interrogate).
---

# code-review

State the problem the code solves in one sentence before reviewing anything. If you cannot, ask — a review of code whose purpose you have guessed at is worse than no review.

Then pick **one** lens and read only that file (`/code-review <lens>` names it directly). They are different methods, not different vocabularies for the same method; running two produces findings that contradict each other on priority.

| The question in front of you | Lens | Read |
|---|---|---|
| Should this exist at all? Is it at the right layer? Does the diff/package/dependency earn its maintenance cost? Asked to "audit", "polish", or "refactor" something | **Russ Cox** | [RUSS-COX.md](RUSS-COX.md) |
| Will it behave as advertised? Can it panic, silently truncate, or cost more than it looks? Are the defaults and error contracts honest? Reviewing a library API or a patch that changes complexity. Asked to break it, or reviewing in place of a test (`test-writing` step 4) | **BurntSushi** | [BURNTSUSHI.md](BURNTSUSHI.md) |
| Is this being held to the right standard? Should the dumb version ship, or does this need to stay stable for years? Reviewing a public interface, a breaking change, or product code that looks over-engineered | **Mitsuhiko** | [MITSUHIKO.md](MITSUHIKO.md) |
| Is a *proposed* change worth its complexity, and which layer owns it? Asked before a substantial design change, or when necessity is contested mid-review | **Complexity** | [COMPLEXITY.md](COMPLEXITY.md) |
| What would a competent engineer who just joined fail to understand? Asked for an onboarding review, a handover check, or what to document first | **Newcomer** | [NEWCOMER.md](NEWCOMER.md) |

Default to **Russ Cox** for an unqualified "review this diff." Reach for the others when the code is a library boundary (BurntSushi), when the product/library call is itself in question (Mitsuhiko), when the change does not exist yet (Complexity), or when the question is comprehension rather than correctness (Newcomer). The Complexity and Newcomer lenses are for explicit requests, not a ceremony before routine edits.

In an established codebase, search for existing primitives before judging anything new — under any lens, the most common real finding is that a helper, interface, or package already does this. Conversely, when a diff establishes or tightens a security, durability, or state invariant on one path, search sibling entrypoints (other handlers, verbs, backends, or platforms) for parallel paths that still bypass it.

For contested designs, reconstruct the author's strongest rationale from the design docs, issues, and review discussion before drafting objections.
Test the user's preferred alternative against the same constraints, including costs it reintroduces.
Report objections that survive this comparison; state what evidence would reverse an unresolved judgment.

## Measure before judging

A model's opinion of how verbose or tangled code is is close to noise (the same judge flips on renamed inputs), so do not form one. Measure instead, then spend judgment only where the measurement points. Run this when the diff was written by an agent, exceeds ~100 lines, or you are in audit mode:

```
python3 scripts/slop.py [BASE] [--scope DIR] [--all]   # working tree vs BASE: HEAD for uncommitted work, main for a branch
```

It wraps [scb-check](https://github.com/gabeorlanski/scb-check) (SlopCodeBench's tool; Python, Rust, JS, TS, Zig, Haskell, C++) and prints: line delta; base-to-head counts for the changed files (split into prod and tests when both change: functions over cyclomatic complexity 10, clone lines, flagged lines, erosion and verbosity ratios); and every clone, complexity, or slop-rule hit that lands on a touched line, as `file:line`. Cross-repo clones need the full scan; if scb-check aborts on a file it cannot parse, the script says so and falls back to the changed files. For Go, Java, C#, Swift, Kotlin, Ruby, PHP and C it uses [lizard](https://github.com/terryyin/lizard) instead: same complexity metric, a weaker token-level clone detector, no slop rules. Lizard's ratios are comparable to the same repo's history, not to scb-check's reference points below.

Reading the output:

- Every line is a lead, not a finding. Open the code. A 10-line function with complexity 15 is dense, not sloppy; a 40-line one with three branches that each re-derive the same state is the finding, and the number is only its evidence.
- Ratios are meaningful for a package, not a diff. On a small diff report the counts and locations; in audit mode use the package ratios as the refactor plan's baseline. SlopCodeBench's reference points: established repos average verbosity 0.15 and erosion 0.31, agent output roughly double both.
- Clone hits are the mechanical form of the "existing primitive" search above. The finding is the pair that will diverge, named on both sides.
- Slop accumulates across sessions because each agent run, reviewer included, starts without memory of the last. The base-to-head counts are the only view of that drift you get; when a package's numbers only ever rise, say so in the summary even if no single hit is a finding.

The script measures local properties only. Whether a boundary holds is a question of who knows what. In audit mode, or when a diff adds a type or module that others will call, take these counts with `rg`, leaving out sites that only construct the type, and reading first the fields with a site outside the type's own package or module:

- **Field knowledge.** For a type with methods of its own, count the places outside those methods that write, take a reference to, index, or call a method on one of its fields, directly or through a getter or setter. Reading a copy does not count. Start each field, and each getter, from `rg -lw0 <Type> . | xargs -0r rg -n '(\.|->)<name>\b'`, which searches only the files that name the type; a caller that never names the type needs the plain search. Report "N places in M modules" once per field.
- **Depth.** Of a module's working functions (wrappers and forwarders excluded), count how many code outside it calls, against how many it keeps to itself. A module that shows as many as it hides costs callers as much to learn as to read.
- **Circles.** Two sibling modules, or two types, that each name the other have no order to be read in. Name both directions as `file:line`.

These counts survive renaming, methods moved to another file, and re-exports, which is why they can stand as evidence. Several leaks from one type are one finding: ask why outsiders need those fields and what operation they are assembling from them, then name the operation the type should own.

Not this skill: writing the commit or PR message (use `write-docs`), building your own understanding of an unfamiliar codebase (use `grok-repo`), or turning a confirmed `Failure` line into the regression that pins it (use `test-writing`).

## Output contract — all lenses

The Complexity lens reports decisions and unresolved tradeoffs rather than findings, and the Newcomer lens uses its own contract (see its file); everything else below applies to them too.

Analyze freely first. This contract governs the final output only — do not begin emitting findings before you have read enough to know which ones matter.

Each finding is one block, most-consequential first:

```
[file:line] <one-line claim — traced | inferred>
  Failure: <concrete inputs or state> → <wrong output, crash, or cost>
  Instead: <one alternative, sketched>
```

- **The failure line is the filter.** A finding that cannot name concrete inputs producing concrete wrong behavior is not a finding — drop it rather than softening it into a suggestion.
- Say `traced` when you followed the path, `inferred` when you reasoned from shape. Never blur the two.
- Sketch the alternative; do not merely point at the problem.
- Close with one line naming coverage and verification limits. Do not repeat the findings in a separate summary.
- Do not nitpick style, naming, or formatting unless it obscures correctness or cost.
- Report only what you found. Never pad toward a count, per axis, per dimension, or per section — a short review of a clean change is the correct output.
- Never emit a numeric quality score or grade, under any lens. Scores are where a model judge is least reliable, and once fed back to the author they become the target.
- A finding must survive renaming every identifier in the diff. If it would vanish, it was about vocabulary, not structure — drop it. (Newcomer is the exception; its subject is names and context.)
- The `Instead:` line must survive the cheapest move that would silence the finding. A getter over the leaked field, a forwarding method, a function split at the threshold, or two files merged into one clears the report and leaves every caller knowing what it knew before. State what callers stop needing to know after the change; if the answer is nothing, it is a mechanical move, not a fix.
- A measurement (complexity, clone size, line count) may appear only in the `Failure` line as evidence. The claim names the tangle or divergence the number points at. "Complexity 18" is not a finding; "three branches each re-derive `refresh`, so changing one silently leaves two behind" is. This is what keeps a threshold from being gamed by splitting a function into fragments that share the same knot.

## Accepting a compromise — all lenses

When the author answers a finding with "I know, but we ship Friday," the reviewer still has to rule.

- **Legitimate**: hard deadlines paired with a documented debt plan; regulatory or compliance requirements; vendor lock-in chosen with eyes open; team-skill constraints paired with training.
- **How to accept one**: document the decision in the code, write a dated paydown plan, minimize the scope of the shortcut, and set a review date. An accepted compromise with no paydown trigger is just a defect with better manners.
- **Never**: security vulnerabilities, data-integrity risks, silent failures, or untested critical paths. These do not have a legitimate deadline exception — say so plainly and leave them ranked at the top.

## Phrasing

Findings land when they carry the analysis, not the verdict. Applies under every lens.

- Instead of "This is too complex": "This has N layers of indirection. Could we solve directly: [sketch]. Benefits: [list]. Tradeoffs: [list]."
- Instead of "Don't add this dependency": "This adds [concrete cost]. Alternative: [sketch]. It preserves [required guarantees] but trades away [capability or maintenance benefit]."
- Instead of "This abstraction is wrong": "For this use case, [direct design] removes [specific coupling]. The tradeoff is [cost or lost guarantee]."
- Instead of "Rewrite this": "Current approach: [analysis]. Maintenance implications: [list]. Alternative: [sketch]. Which fits our long-term goals?"

## Commenting on a colleague's PR

The output contract above is for the user. On a colleague's PR, write for the author and the agent helping them decide what to change.

- **Their agent can read the diff.** Anchor the comment to the relevant lines in the review or with a permalink at the reviewed SHA (`?plain=1` for Markdown lines). Spend the comment on what the diff leaves implicit, such as the invariant at stake, the production condition that triggers a failure, or the tradeoff the author needs to decide.
- **Post only what changes the author's next action.** Praise earns a line when it helps preserve a deliberate choice. A clean change gets a bare approval.
- **Lead with the consequence.** Give the input, timing, or assumption that makes the problem possible and explain what breaks. Name the evidence or remaining uncertainty when it affects the next step. A model check or live test can be cited in a clause. Use numbered steps when the order matters and prose would be harder to follow.
- **Make the next action clear.** Say whether the point needs a fix before merge, a check to resolve uncertainty, or a follow-up. Give the desired behavior or a short direction, with the tradeoff if it affects the choice.
- **Put each point where it can be acted on.** A finding about code that lands in a later PR waits for that PR. A design question on an implementation PR goes to the plan, framed as a question, not a demand.

Write the way you'd leave a note for a colleague. One finding can be a short paragraph. For several, use bullets in order of impact. Use labels when they help the reader scan, and give unfamiliar references a few words of context.

> If the worker exits after it acks the job but before the upload finishes, the queue won't retry and we'll lose the output. Can we wait to ack until the upload succeeds? I'd fix this before merging.

For substantial or contested PR comments, give the draft to a subagent with no context from the review and ask what the author would take away and what would irritate them. Fix what it reports.

Files in this skill

  • BURNTSUSHI-REFERENCE.md13.6 KB
  • BURNTSUSHI.md1.2 KB
  • COMPLEXITY-REFERENCE.md10.1 KB
  • COMPLEXITY.md1.6 KB
  • MITSUHIKO-PRINCIPLES.md6.9 KB
  • MITSUHIKO.md1.7 KB
  • NEWCOMER.md2.3 KB
  • RUSS-COX-REFERENCE.md10.8 KB
  • RUSS-COX.md4.3 KB
  • SKILL.md5.5 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.