AgentSkillsCN

Review Code

审查代码变更或GitHub PR

SKILL.md
--- frontmatter
allowed-tools: Grep, Glob, mcp__acp__Bash, mcp__acp__Read
description: Review code changes or a GitHub PR

Review pull request, ignore possible draft state.

Steps:

  1. Get PR info with mcp__acp__Bash: gh pr view $ARGUMENTS --json title,body,author,headRefName
  2. Checkout the PR branch locally with mcp__acp__Bash: git fetch origin {headRefName} && git checkout {headRefName}
  3. Save the complete diff to a temp file with mcp__acp__Bash: gh pr diff {PR_NUMBER} --repo {owner}/{repo} > /tmp/pr_diff.txt IMPORTANT: Use mcp__acp__Bash directly, NOT the Task tool or any agent.
  4. Read the diff file with mcp__acp__Read: /tmp/pr_diff.txt
  5. Assess diff size:
    • Small (<300 lines): Direct review
    • Medium (300-800 lines): Group by directory, review systematically
    • Large (>800 lines): Enter plan mode, create review strategy, ask user which areas to focus on
  6. First pass: Identify potential issues in the diff
    • Before commenting on any file, verify it exists locally with the path from the diff
    • If a file path doesn't exist, skip that comment and warn
  7. Self-review: For each identified issue, verify it's actually valid:
    • Read the surrounding code context, not just the diff
    • Check if guards, comments, or other code already addresses the concern
    • Ask: Is this a real problem or just pedantic/stylistic?
    • Ask: Would this comment actually help the author?
    • Remove issues that are already handled by existing code
    • Remove issues that are just noise or obvious from context
  8. Present the filtered review to the user in the following format:

Code Review Summary

Overview

[Brief description of changes reviewed]

Strengths

  • [What's done well]

Issues Found

Critical (Must Fix)

  • [File:Line]: [Description] → [Suggested Fix]

Important (Should Fix)

  • [File:Line]: [Description] → [Suggested Fix]

Minor (Nice to Have)

  • [File:Line]: [Description] → [Suggested Fix]

Recommendations

  • [Improvement suggestions]
  1. Clean up: rm /tmp/pr_diff.txt