GitHub PR代码审查
pr-reviewer
审查 GitHub pull request 的代码质量、安全性与最佳实践。用于自动化 PR 反馈与审批工作流。
- License 许可
- MIT
- 所属仓库
- jmagly/aiwg
- 最近更新
- 2026-11-14
- Stars
- ★ 229
- Forks
- 36
01 前言 Front Matter
- name
- pr-reviewer
- tools
- Read, Write, Bash, Glob, Grep
- namespace
- aiwg
- platforms
- [ "all" ]
- description
- Review GitHub pull requests for code quality, security, and best practices. Use for automated PR feedback and approval workflows.
02 资源文件 1
- 参考文档agents/openai.yaml43 B
03 SKILL.md 正文
PR Reviewer Skill
Purpose
Single responsibility: Review GitHub pull requests for quality, security, and adherence to project standards. (BP-4)
Grounding Checkpoint (Archetype 1 Mitigation)
Before executing, VERIFY:
- [ ] gh CLI is installed and authenticated
- [ ] PR number or URL is valid
- [ ] Repository has review permissions
- [ ] Review criteria are defined
DO NOT submit reviews without understanding the full diff.
Uncertainty Escalation (Archetype 2 Mitigation)
ASK USER instead of guessing when:
- Review scope unclear (security only vs full review)
- Approval authority undefined
- Conflicting with existing reviews
- Breaking changes detected
NEVER approve PRs automatically without user confirmation.
Context Scope (Archetype 3 Mitigation)
| Context Type | Included | Excluded |
|---|---|---|
| RELEVANT | PR diff, commit messages, linked issues | Unrelated files |
| PERIPHERAL | Project standards, CI status | Other PRs |
| DISTRACTOR | Historical PRs | Fork activity |
Workflow Steps
Step 1: Fetch PR Details (Grounding)
# Get PR information
gh pr view <number> --json title,body,author,files,additions,deletions,commits,reviews
# Get diff
gh pr diff <number>
# Check CI status
gh pr checks <number>
Step 2: Analyze Changes
# List changed files
gh pr view <number> --json files --jq '.files[].path'
# Get diff stats
gh pr view <number> --json additions,deletions --jq '"\(.additions) additions, \(.deletions) deletions"'
# Check for sensitive files
gh pr diff <number> | grep -E "(\.env|password|secret|key)" && echo "⚠️ Sensitive patterns detected"
Step 3: Review Categories
Code Quality:
# Check for common issues
gh pr diff <number> | grep -E "(console\.log|debugger|TODO|FIXME)" | head -20
Security:
# Security patterns
gh pr diff <number> | grep -E "(eval\(|innerHTML|dangerouslySetInnerHTML|exec\()" | head -10
Tests:
# Check test coverage
gh pr view <number> --json files --jq '.files[] | select(.path | test("test|spec")) | .path'
Step 4: Submit Review
Comment only:
gh pr review <number> --comment --body "$(cat <<'EOF'
## Code Review
### Summary
[Overview of changes]
### Observations
- Point 1
- Point 2
### Questions
- Question 1?
EOF
)"
Request changes:
gh pr review <number> --request-changes --body "Changes needed: [reason]"
Approve:
gh pr review <number> --approve --body "LGTM! ✅"
Recovery Protocol (Archetype 4 Mitigation)
On error:
- PAUSE - Don't submit partial reviews
- DIAGNOSE - Check error type:
Not found→ Verify PR numberPermission denied→ Check repo accessReview already exists→ Update existingCI pending→ Wait or note in review
- ADAPT - Adjust review scope
- RETRY - With corrected parameters (max 3 attempts)
- ESCALATE - Report issues to user
Checkpoint Support
State saved to: .aiwg/working/checkpoints/pr-reviewer/
checkpoints/pr-reviewer/
├── pr_details.json # PR metadata
├── diff_analysis.json # Change analysis
├── security_scan.json # Security findings
└── review_draft.md # Draft review
Review Template
## Code Review: PR #<number>
### Summary
<Brief overview of the PR purpose and changes>
### Review Checklist
- [ ] Code follows project style guide
- [ ] Tests added/updated for changes
- [ ] Documentation updated if needed
- [ ] No security vulnerabilities introduced
- [ ] CI checks passing
### Observations
#### ✅ Strengths
- Point 1
- Point 2
#### ⚠️ Concerns
- Concern 1 (file:line)
- Concern 2 (file:line)
#### ❓ Questions
- Question about design choice?
### Recommendation
- [ ] Approve
- [ ] Request changes
- [ ] Comment only
### Line Comments
| File | Line | Comment |
|------|------|---------|
| src/foo.ts | 42 | Consider using const |
Common Commands
| Command | Purpose |
|---|---|
gh pr view <n> |
View PR details |
gh pr diff <n> |
View diff |
gh pr checks <n> |
CI status |
gh pr review <n> |
Submit review |
gh pr comment <n> |
Add comment |
gh pr merge <n> |
Merge PR |
References
- GitHub CLI PR commands: https://cli.github.com/manual/gh_pr
- REF-001: Production-Grade Agentic Workflows (BP-4)
- REF-002: LLM Failure Modes (Archetype 2 over-helpfulness)
04 同仓库更多 Skills
plugin-search
Search marketplaces for plugins using configured local manifests and directory caches; rank matching plugins by observed installs, review tier and cache dates without installing or fetching anything
plugin-search
Search marketplaces for plugins using configured local manifests and directory caches; rank matching plugins by observed installs, review tier and cache dates without installing or fetching anything
host-hardening
Read-only system hardening baseline and plan-first host hardening recommendations for SSH, Docker bind addresses, firewall persistence, datastores, exporters and audit retention.
exposure-analysis
Read-only firewall analysis and effective host exposure reconstruction for Docker published ports, UFW bypass, stale rules, CDN scope, IPv6 asymmetry and external probe allowlists.
host-hardening
Read-only system hardening baseline and plan-first host hardening recommendations for SSH, Docker bind addresses, firewall persistence, datastores, exporters and audit retention.
exposure-analysis
Read-only firewall analysis and effective host exposure reconstruction for Docker published ports, UFW bypass, stale rules, CDN scope, IPv6 asymmetry and external probe allowlists.