Review code changes for security, performance, bugs, and quality. Reviews staged changes, unstaged changes, specific commits, or PR-ready diffs.
复制下面这句话,粘贴给 Claude Code、Codex、Cursor 等 AI 编程工具,它会读取安装说明并在你确认后完成安装。
请阅读 https://ai.atlankj.com/install/asset/gh-review-5c61ff9bcf6f ,按照其中的说明把「review」安装到你(当前 AI 工具)中。执行前先告诉我将运行的命令和写入的位置,等我确认。
查看 AI 将读取的安装说明正在读取 GitHub 原文…
内容来自 GitHub 原始文件,由原作者维护。在 GitHub 查看
The reviewer reads both the diff and the surrounding source files to understand intent and catch issues that only appear in context.
<core_principle> FIND REAL ISSUES, NOT STYLE NITS. Focus on problems that cause bugs, security vulnerabilities, performance degradation, or maintainability pain. Avoid nitpicking formatting or subjective style preferences unless they harm readability. </core_principle>
<analysis_only_rule> THIS SKILL IS READ-ONLY. DO NOT MODIFY CODE.
The purpose is to review and report findings. Making changes during review conflates the reviewer and author roles. Present findings and let the user decide what to act on. </analysis_only_rule>
<working_directory_awareness>
Before running any git command: check whether your dispatch context specifies a working directory (look for "Working directory:" in your initial prompt). If it does and pwd does not match it, prefix every git invocation with -C <that path> (e.g. git -C /path/to/worktree diff --cached). Reviewing the wrong directory's diff is a silent failure mode — the review will look correct but cover the wrong code.
</working_directory_awareness>
<quick_start>
<determine_review_scope>
Parse the user's input to determine what to review:
No arguments - Review staged changes first. If nothing is staged, review unstaged changes.
git diff --cachedgit diffgit show HEADCommit hash argument (e.g., /review abc1234) - Review that specific commit.
git show <hash>File path argument (e.g., /review src/foo.ts) - Review unstaged changes in that file.
git diff -- <path> then fall back to git diff --cached -- <path>"pr" argument (e.g., /review pr) - Review all changes since branching from main.
git diff main...HEADgit diff HEAD~1After obtaining the diff, if it is empty, inform the user that there are no changes to review and stop.
</determine_review_scope>
<gather_context>
Before analyzing the diff:
</gather_context>
<review_categories>
Analyze the changes against each category below. Only report findings that are actually present. Skip categories with no issues.
A. Security Issues (Severity: CRITICAL or HIGH)
B. Performance Concerns (Severity: HIGH or MEDIUM)
C. Bug Risks (Severity: HIGH or MEDIUM)
D. Code Quality (Severity: MEDIUM or LOW)
E. Test Coverage Gaps (Severity: MEDIUM or LOW)
</review_categories>
<format_findings>
For each finding, use this structure:
### [SEVERITY] Category: Brief Title
**File**: `path/to/file.ext` (lines X-Y)
**Issue**: Clear description of the problem.
**Why it matters**: What could go wrong if this is not addressed.
**Suggestion**: How to fix it, with a code snippet if helpful.
Severity levels:
</format_findings>
</quick_start>
<critical_rules>
</critical_rules>
<output_format>
## Code Review: [brief description of what was reviewed]
**Scope**: [staged changes | unstaged changes | commit abc1234 | PR changes from main]
**Files reviewed**: [count] files changed, [additions] additions, [deletions] deletions
---
### Findings
[Findings grouped by severity, highest first. Use the format from <format_findings>.]
---
### Summary
| Severity | Count |
|----------|-------|
| CRITICAL | X |
| HIGH | X |
| MEDIUM | X |
| LOW | X |
### Recommended Actions
1. [Most important action to take]
2. [Next most important action]
3. [...]
If no issues are found:
## Code Review: [brief description]
**Scope**: [what was reviewed]
**Files reviewed**: [count]
No significant issues found. The changes look good to merge.
</output_format>
<decision_gate>
After presenting findings, ALWAYS offer these options:
─────────────────────────────────────────
REVIEW COMPLETE
What would you like to do?
1. **Fix issues** - I'll address the findings starting with the most critical
2. **Save review** - Export findings to a markdown file
3. **Review again** - Re-review with different scope or focus
4. **Discuss a finding** - Ask questions about a specific issue
5. **Other** - Tell me what you need
─────────────────────────────────────────
Wait for user response before taking any action.
This gate is MANDATORY. Never skip it. Never auto-implement fixes.
</decision_gate>