AgentSkillsCN

code-review

开展系统的代码评审,不仅关注代码风格的统一,更着重于代码的正确性、安全性与可扩展性。

SKILL.md
--- frontmatter
name: "code-review"
description: "Systematic code review for correctness, security, and growth — not just style enforcement"
applyTo: "**/*review*,**/*PR*,**/*pull*,**/*merge*"

Code Review Skill

Good reviews catch bugs. Great reviews teach the author something.

Review Priority (What Matters Most)

  1. Correctness — Does it do what it's supposed to?
  2. Security — Can it be exploited?
  3. Maintainability — Will the next person understand this?
  4. Performance — Will it scale?
  5. Style — Is it consistent? (ideally enforced by linters, not humans)

3-Pass Review

PassFocusWhat You're Looking ForTime
1. OrientationBig pictureDoes the approach make sense? Is the scope right? Over-engineered?2-3 min
2. LogicDeep readEdge cases, null handling, error paths, concurrency, off-by-one10-15 min
3. PolishSurfaceNaming, duplication, test coverage, docs3-5 min

Pass 1 shortcut: Read the PR description and test names first. They reveal intent faster than code.

Comment Prefixes

PrefixMeaningAuthor Response
[blocking]Must fix before mergeFix it
[suggestion]Better approach existsConsider it, explain if declining
[question]I don't understandClarify (in code, not just in reply)
[nit]Trivial style issueFix if easy, skip if not
[praise]This is well doneAppreciate it

Good vs Bad Comment Examples

BadWhyGood
"This is confusing"Vague, unhelpful"[suggestion] This nested ternary is hard to follow. Consider extracting to a named function like isEligibleForDiscount()."
"Fix this"No context"[blocking] This accepts user input without sanitization. Use escapeHtml() before rendering."
"Why?"Sounds hostile"[question] What's the motivation for the custom sort here vs Array.sort()? Is there a performance concern?"
"LGTM" (on 500-line PR)Rubber stamp"Pass 1: Approach looks right. Pass 2 comments below. Pass 3: naming is clean."

Review Checklist

Security

  • No secrets, tokens, or API keys in code
  • User input validated/sanitized before use
  • Auth checks on protected endpoints
  • No SQL/command injection vectors
  • Sensitive data not logged

Logic

  • Edge cases handled (empty input, null, boundary values)
  • Error paths return meaningful messages
  • Async operations have timeout/cancellation
  • State changes are atomic (no partial updates)
  • All new branches have test coverage

Quality

  • Tests cover the changed behavior, not just the changed lines
  • No debug code (console.log, TODO-hacks)
  • Public API changes documented
  • Backward compatibility considered

Architecture

  • Change is in the right layer (not business logic in the controller)
  • New dependencies justified
  • No unnecessary coupling introduced

Anti-Patterns

Anti-PatternWhat HappensInstead
Rubber-stampBugs shipActually read Pass 1-3
BikesheddingHours on naming, ignore logic bugsSpend 80% on Pass 2
GatekeepingReviewees dread PRsTeach, don't block
Week-long queuePRs go stale, conflicts pile upReview within 4 hours, merge within 24
Style warsTeam frictionAutomate style (ESLint, Prettier, etc.)
Everything-is-blockingAuthor overwhelmedUse prefix system honestly

Review Timing

PR SizeExpected Review TimeIf Larger
< 100 lines< 30 min
100-400 lines30-60 minIdeal size
400+ lines60+ minAsk author to split
1000+ linesDon'tRefuse; request breakdown

Synapses

See synapses.json for connections.