AgentSkillsCN

code-review

审查代码变更的正确性、潜在风险、回归问题及测试覆盖率。当被要求“审查代码”“进行代码评审”“检查我的更改”,或收到差异对比、PR 或补丁以获取反馈时使用。

SKILL.md
--- frontmatter
name: code-review
description: Review code changes for correctness, risk, regressions, and test coverage. Use when asked to "review", "code review", "check my changes", or when a diff/PR/patch is provided for feedback.

Code Review

Goals

  • Find correctness bugs, edge cases, security issues, and behavior regressions.
  • Flag missing or inadequate tests and suggest targeted additions.
  • Keep feedback concrete, actionable, and tied to files/lines when possible.

Workflow

  1. Identify the scope: files touched, feature intent, and expected behavior.
  2. Read the diff first; then inspect surrounding code for context.
  3. Focus on high-risk areas: input validation, error handling, concurrency, resource cleanup, and boundary conditions.
  4. Check API contracts, data schemas, and invariants for violations or mismatches.
  5. Validate tests: coverage of new paths, failure cases, and backward compatibility.

Output Format

  • Start with findings ordered by severity (blocker, high, medium, low).
  • For each finding, include: file path, location hint, impact, and recommended fix.
  • If no issues are found, state that explicitly and note any remaining risk or untested paths.

Practical Heuristics

  • Prefer small, surgical changes over large rewrites when proposing fixes.
  • If a finding depends on assumptions, state them clearly.
  • If the intent is ambiguous, ask one focused question.

If Tests Are Available

  • Recommend the smallest test that proves the fix.
  • Mention whether the current tests would fail before the fix and pass after.