agentleFS
lintangknittolintangknitto/agent-skills/skills/code-review-and-quality/SKILL.md

code-review-and-quality

Skill0 starsChanged 2 months agoMITView on GitHub

Conducts multi-axis code review. Use before merging any change, when reviewing code written by yourself/another agent/a human, or when you need to assess code quality across multiple dimensions before it enters the main branch. This is the review methodology itself — a reviewer agent should invoke it rather than inventing its own checklist.

45 other projects use a version of this, 37 of them edited.

Adopted by

Most recently taken up by

Used with

Projects with it also use constraint-driven-development, code-simplification and 9 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • vinvcnSkill

    constraint-driven-development

    把一个项目的质量线确立为书面契约,并阻止 agent 悄悄降低它。通过访谈确定用户在意哪些维度,当用户心里没有数字时提供合理的默认阈值,把一切记录进 CONSTRAINTS.md,并盯住 diff 中质量线被削弱的迹象——新增的 @ts-ignore 或 eslint-disable 抑制注释、被跳过或删除的测试、被剥掉的断言、未实现的 stub、被调低的阈值。当没有任何质量线被写下来时使用;当用户说 "set up constraints" 或 "define our standards" 时;当用户希望把他们在意的维度——无障碍性、Web 性能、覆盖率——设置成被强制执行的约束时;当 agent 为了变绿不断静默检查或跳过测试时;当你需要一个覆盖率或性能阈值却不知道该选什么数字时;或者当 agent 写下的代码超出任何人会读的体量时。

    Also in 4 projects that use this

  • az9713Skill

    code-simplification

    Simplifies code for clarity. Use when refactoring code for clarity without changing behavior. Use when code works but is harder to read, maintain, or extend than it should be. Use when reviewing code that has accumulated unnecessary complexity.

    Also in 31 projects that use this

  • borhen68Skill

    observability-and-instrumentation

    Instruments code so production behavior is visible and diagnosable. Use when adding logging, metrics, tracing, or alerting. Use when shipping any feature that runs in production and you need evidence it works. Use when production issues are reported but you can't tell what happened from the available data.

    Also in 12 projects that use this

  • az9713Skill

    deprecation-and-migration

    Manages deprecation and migration. Use when removing old systems, APIs, or features. Use when migrating users from one implementation to another. Use when deciding whether to maintain or sunset existing code.

    Also in 19 projects that use this

  • mycelium-hqSkill

    doubt-driven-development

    Use when correctness matters more than speed: about to commit non-trivial code, make an architectural call under uncertainty, work in unfamiliar code, or assert what the compiler cannot check (''this is safe'', ''thread-safe'', ''this scales'', ''matches the spec''). Strongest on high-stakes surfaces (production deploys, security-sensitive logic, data migrations, irreversible operations) and when the user asks to sanity-check, red-team, double-check, or get a second opinion on a decision.

    Also in 18 projects that use this

  • galandoSkill

    source-driven-development

    Version-aware, source-driven development — fetch official docs before writing framework code

    Also in 21 projects that use this

The file

We split this skill into the rules it gives an agent

12 rules. 7 are common, 5 are distinctive, and 0 are very specific to this project.

  • 7

    Common

    Most of the 42 edited versions we read keep these.

  • 5

    Distinctive

    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
  1. Common:

    Before merging any PR or change

    line 34
  2. Common:

    After completing a feature implementation

    line 35
  3. Common:

    When another agent or model produced code you need to evaluate

    line 36
  4. Common:

    When refactoring existing code

    line 37
  5. Common:

    After any bug fix (review both the fix and the regression test)

    line 38
  6. Distinctive:

    When you flag a structural problem, propose the move — not just the problem.

    line 136
  7. Distinctive:

    Reuse the canonical helper: instead of a bespoke near-duplicate.

    line 146
  8. Distinctive:

    Prefer the remedy that removes moving pieces over one that spreads the same complexity around.

    line 152
  9. Distinctive:

    Do tests exist? Do they test behavior, not implementation details?

    line 186
  10. Distinctive:

    After reviewing a refactor or implementation change, check for orphaned code.

    line 228
  11. Common:

    Rule: prefer standard library and existing utilities over new dependencies.

    line 251
  12. Common:

    No regression tests with bug fix PRs

    line 329

“Common” is measured: kept by at least 6 in 10 of the 42 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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Code Review and Quality

Overview

Multi-dimensional code review with quality gates. Every change gets reviewed before merge — no exceptions. Review covers five axes: correctness, readability, architecture, security, and performance.

The approval standard: Approve a change when it definitely improves overall code health, even if it isn't perfect. Perfect code doesn't exist — the goal is continuous improvement. Don't block a change because it isn't exactly how you would have written it. If it improves the codebase and follows the project's conventions, approve it.

When to use

  • Before merging any PR or change
  • After completing a feature implementation
  • When another agent or model produced code you need to evaluate
  • When refactoring existing code
  • After any bug fix (review both the fix and the regression test)

The five-axis review

1. Correctness

Does the code do what it claims to do?

  • Does it match the spec or task requirements?
  • Are edge cases handled (null, empty, boundary values)?
  • Are error paths handled (not just the happy path)?
  • Does it pass all tests? Are the tests actually testing the right things?
  • Are there off-by-one errors, race conditions, or state inconsistencies?

2. Readability & simplicity

Can another engineer (or agent) understand this code without the author explaining it?

  • Are names descriptive and consistent with project conventions? (No temp, data, result without context)
  • Is the control flow straightforward (avoid nested ternaries, deep callbacks)?
  • Is the code organized logically (related code grouped, clear module boundaries)?
  • Are there any "clever" tricks that should be simplified?
  • Could this be done in fewer lines? (1000 lines where 100 suffice is a failure)
  • Are abstractions earning their complexity? (Don't generalize until the third use case)
  • Would comments help clarify non-obvious intent? (But don't comment obvious code.)
  • Are there dead code artifacts: no-op variables (_unused), backwards-compat shims, or // removed comments?
  • Is a new conditional bolted onto an unrelated flow? That's a design smell, not a nit — push the logic into its own helper, state, or policy instead of tangling an existing path.
  • Do repeated conditionals on the same shape appear? They signal a missing model or dispatcher. A "temporary" branch is usually permanent debt.

3. Architecture

Does the change fit the system's design?

  • Does it follow existing patterns or introduce a new one? If new, is it justified?
  • Does it maintain clean module boundaries?
  • Is there code duplication that should be shared?
  • Are dependencies flowing in the right direction (no circular dependencies)?
  • Is the abstraction level appropriate (not over-engineered, not too coupled)?
  • Does this refactor reduce complexity or just relocate it? Count the concepts a reader must hold to follow the change. If a "cleaner" version leaves that count unchanged, it isn't cleaner — prefer the restructuring that makes whole branches, modes, or layers disappear over one that re-centralizes the same logic. Prefer deleting an abstraction to polishing it.
  • Is feature-specific logic leaking into a shared or general-purpose module? Keep logic in its owning layer, reuse the existing canonical helper instead of a near-duplicate, and don't normalize architectural drift.
  • Are type boundaries explicit? Question gratuitous any/unknown/ optional/casts and silent fallbacks that paper over an unclear invariant — making the boundary explicit often makes the surrounding control flow simpler.

4. Security

For detailed guidance, see references/security-checklist.md. Does the change introduce vulnerabilities?

  • Is user input validated and sanitized?
  • Are secrets kept out of code, logs, and version control?
  • Is authentication/authorization checked where needed?
  • Are SQL queries parameterized (no string concatenation)?
  • Are outputs encoded to prevent XSS?
  • Are dependencies from trusted sources with no known vulnerabilities?
  • Is data from external sources (APIs, logs, user content, config files) treated as untrusted?
  • Are external data flows validated at system boundaries before use in logic or rendering?

5. Performance

For detailed profiling guidance, see references/performance-checklist.md. Does the change introduce performance problems?

  • Any N+1 query patterns?
  • Any unbounded loops or unconstrained data fetching?
  • Any synchronous operations that should be async?
  • Any unnecessary re-renders in UI components?
  • Any missing pagination on list endpoints?
  • Any large objects created in hot paths?

Structural remedies

When you flag a structural problem, propose the move — not just the problem. A review that only says "this is complex" leaves the author guessing. Reach for a named restructuring:

  • Replace a chain of conditionals with a typed model or an explicit dispatcher.
  • Collapse duplicate branches into a single clearer flow.
  • Separate orchestration from business logic so each reads on its own.
  • Move feature-specific logic out of a shared module into the package that owns the concept.
  • Reuse the canonical helper instead of a bespoke near-duplicate.
  • Make a type boundary explicit so downstream branching disappears.
  • Delete a pass-through wrapper that adds indirection without clarifying the API.
  • Extract a helper, or split a large file into focused modules.

Prefer the remedy that removes moving pieces over one that spreads the same complexity around.

Change sizing

~100 lines changed   → Good. Reviewable in one sitting.
~300 lines changed   → Acceptable if it's a single logical change.
~1000 lines changed  → Too large. Split it.

Watch file size, not just diff size. A small diff can still push a file past a healthy boundary — around 1000 total lines in a single file is a common inspection signal, not a hard cap. When a change materially grows an already-large file, ask whether to extract helpers, subcomponents, or modules first, before piling more on. Decompose, then add.

What counts as "one change": A single self-contained modification that addresses one thing, includes related tests, and keeps the system functional after submission.

Separate refactoring from feature work. A change that refactors existing code and adds new behavior is two changes — flag it as such. Small cleanups (variable renaming) can be included at reviewer discretion.

Review process

Step 1 — Understand the context

What is this change trying to accomplish? What spec/task does it implement? What's the expected behavior change?

Step 2 — Review the tests first

Do tests exist? Do they test behavior, not implementation details? Are edge cases covered? Would they catch a regression?

Step 3 — Review the implementation

Walk each changed file through the five axes above.

Step 4 — Categorize findings

Label every comment with its severity so the author knows what's required vs. optional:

PrefixMeaningAuthor action
(no prefix)Required changeMust address before merge
Critical:Blocks mergeSecurity vulnerability, data loss, broken functionality
Nit:Minor, optionalAuthor may ignore — formatting, style preferences
Optional: / Consider:SuggestionWorth considering but not required
FYIInformational onlyNo action needed

Lead with what matters. Order findings by leverage: correctness and security first, then structural regressions and missed simplifications, then everything else. Don't bury a real issue under cosmetic nits — a few high-conviction comments beat a long list.

Step 5 — Verify the verification

What tests were run? Did the build pass? Was it tested manually? Are there screenshots for UI changes? Is there a before/after comparison?

Check reported evidence, don't re-run the full suite yourself. Answer these from what's already reported — CI status, results the author/session already stated, existing screenshots/reports. A quick sanity typecheck or build is fine if it's cheap. But don't execute the full test suite or a browser/E2E pass as part of review — that's the expensive verification pass this pipeline runs separately (/qa), deliberately kept out of every review invocation. If no evidence of verification exists at all, say so as a finding ("not verified") rather than running the suite yourself to find out.

Dead code hygiene

After reviewing a refactor or implementation change, check for orphaned code. List anything now unreachable or unused explicitly, and ask before recommending deletion — don't silently assume it's safe to remove.

Honesty in review

  • Don't rubber-stamp. "LGTM" without evidence of review helps no one.
  • Don't soften real issues. "This might be a minor concern" when it's a bug that will hit production is dishonest.
  • Quantify problems when possible. "This N+1 query will add ~50ms per item in the list" is better than "this could be slow."
  • Push back on approaches with clear problems. Sycophancy is a failure mode in reviews.
  • Comment on code, not people.

Dependency discipline

Part of code review is dependency review:

Before adding any dependency: does the existing stack already solve this? How large is it? Is it actively maintained? Any known vulnerabilities? Is the license compatible?

Rule: prefer standard library and existing utilities over new dependencies. Every dependency is a liability.

Upgrading a dependency is a code change like any other — read the changelog (not just the version number), upgrade one dependency per change, let the tests decide, mind the transitive graph (review the lockfile diff, not just the manifest), and never hand-edit the lockfile.

The review checklist

## Review: [PR/Change title]

### Context
- [ ] I understand what this change does and why

### Correctness
- [ ] Change matches spec/task requirements
- [ ] Edge cases handled
- [ ] Error paths handled
- [ ] Tests cover the change adequately

### Readability
- [ ] Names are clear and consistent
- [ ] Logic is straightforward
- [ ] No unnecessary complexity

### Architecture
- [ ] Follows existing patterns
- [ ] No unnecessary coupling or dependencies
- [ ] Appropriate abstraction level
- [ ] Refactors reduce complexity rather than relocate it
- [ ] No feature logic in shared modules; file stays within a healthy size

### Security
- [ ] No secrets in code
- [ ] Input validated at boundaries
- [ ] No injection vulnerabilities
- [ ] Auth checks in place
- [ ] External data sources treated as untrusted

### Performance
- [ ] No N+1 patterns
- [ ] No unbounded operations
- [ ] Pagination on list endpoints

### Verification
- [ ] Tests pass
- [ ] Build succeeds
- [ ] Manual verification done (if applicable)

### Verdict
- [ ] **Approve** — Ready to merge
- [ ] **Approve with comments** — Non-blocking issues noted
- [ ] **Changes requested** — Issues must be addressed

Common rationalizations

RationalizationReality
"It works, that's good enough"Working code that's unreadable, insecure, or architecturally wrong creates debt that compounds.
"I wrote it, so I know it's correct"Authors are blind to their own assumptions. Every change benefits from another set of eyes.
"We'll clean it up later"Later never comes. The review is the quality gate — use it.
"AI-generated code is probably fine"AI code needs more scrutiny, not less. It's confident and plausible, even when wrong.
"The tests pass, so it's good"Tests are necessary but not sufficient. They don't catch architecture, security, or readability problems.
"The refactor makes it cleaner"Relocating complexity isn't reducing it. If the reader still holds the same number of concepts, the structure didn't improve.
"It's only a small addition to this file"Small diffs still push files past a healthy size and bolt branches onto unrelated flows.
"It's just a version bump"A bump is a behavior change you didn't write. Read the changelog.
"I'll upgrade everything in one PR to save time"A bulk bump that breaks the build hides which package did it.

Red flags

  • PRs merged without any review
  • Review that only checks if tests pass (ignoring other axes)
  • "LGTM" without evidence of actual review
  • Security-sensitive changes without security-focused review
  • Large PRs that are "too big to review properly" (recommend splitting)
  • No regression tests with bug fix PRs
  • Review comments without severity labels
  • Accepting "I'll fix it later" as a substitute for fixing it now
  • A refactor that moves code around without reducing the number of concepts a reader must hold
  • A change that grows an already-large file instead of decomposing it
  • New conditionals scattered into unrelated code paths (a missing abstraction)
  • A bespoke helper that duplicates an existing canonical one
  • A bulk "bump dependencies" PR with no changelog review
  • A hand-edited or uncommitted lockfile change

Verification (before handing back a verdict)

  • All Critical issues are resolved or explicitly called out as blocking
  • All Required (no-prefix) changes are resolved or explicitly deferred with justification
  • Tests pass, build succeeds
  • The verification story is documented (what changed, how it was verified)
  • Dependency upgrades were reviewed against their changelog, isolated per package, with the lockfile diff reviewed

See also

  • references/security-checklist.md — deeper OWASP-style checklist for the security axis
  • references/performance-checklist.md — profiling and optimization checklist for the performance axis

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.