一键导入
pr-review-loop
Monitor PR for code review, analyze feedback with AI, implement fixes, and merge when approved with CI green.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Monitor PR for code review, analyze feedback with AI, implement fixes, and merge when approved with CI green.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Argue against proposed actions to test judgment quality. Not "is the code correct" but "should we be doing this at all?" Aligned with robustness, not performance.
Orchestrate Claude Code agent teams for parallel multi-agent collaboration
Learn and integrate new APIs, creating permanent skills for external service access.
Create and update CHANGELOG.md with entries that include AI model/CLI attribution, PRD context, and task references.
Audit decisions for judgment quality, compliance bias, and manipulation vulnerability. Inspired by Anthropic's Project Vend Phase 2 finding that helpfulness training creates exploitable attack surface.
Extract visual style from reference UI screenshot and codify into reusable design system.
| name | pr-review-loop |
| description | Monitor PR for code review, analyze feedback with AI, implement fixes, and merge when approved with CI green. |
| category | quality |
Automate the PR review cycle: wait for review → analyze feedback → implement fixes → push → repeat until approved and CI passes → merge.
Validate PR Exists
gh pr view [PR-number] --json number,state,title,headRefName
Check Initial CI Status
gh pr checks [PR-number] --json name,state,conclusion
Poll for Reviews and Comments
IMPORTANT: Feedback can appear in two places:
APPROVED, CHANGES_REQUESTED, COMMENTED)Both must be checked as reviewers often leave feedback as comments without formal review submission.
# Check formal review state
gh api repos/[owner]/[repo]/pulls/[PR-number]/reviews \
--jq '[.[] | {state: .state, user: .user.login, body: .body, submitted_at}]'
# Check PR conversation comments (CRITICAL - reviewers often use this)
gh pr view [PR-number] --json comments \
--jq '.comments[] | {body: .body, author: .author.login, createdAt}'
Polling Strategy:
APPROVED or CHANGES_REQUESTED state appears, ORStatus Updates:
Timeout Escalation:
# After 480 checks (8 hours)
gh pr comment [PR-number] --body "⏱️ Review polling timeout reached (8 hours).
I've been monitoring this PR for review feedback but haven't received any.
Please notify me when review is complete and I'll resume monitoring.
To resume: Run \`/pr-review-loop [PR-number]\`"
# Log to user
echo "❌ PR #[number] review timeout after 8 hours. Manual intervention needed."
# Exit with status code indicating timeout
exit 124 # Standard timeout exit code
Fetch All Review Feedback
# Get inline review comments (file-specific)
gh api repos/[owner]/[repo]/pulls/[PR-number]/comments \
--jq '[.[] | {path: .path, line: .line, body: .body, user: .user.login, created_at}]'
# Get PR conversation comments (ALREADY fetched in step 3, analyze here)
# Parse for review-like feedback even if not formal review
Analyze Review Comments with AI
For each review/comment, classify as:
| Category | Criteria | Action |
|---|---|---|
| BLOCKING | "must fix", "blocker", "breaks", "security issue", "won't approve until", explicit CHANGES_REQUESTED | Must address before merge |
| IMPORTANT | "should", "please consider", "would be better", suggestions with rationale | Address if reasonable effort |
| NIT | "nit:", "minor:", "optional:", style preferences, typos | Address if trivial, else note |
| QUESTION | Questions about implementation, "why did you...?" | Respond with explanation |
| PRAISE | "LGTM", "nice", "good work", positive feedback | Acknowledge, no action needed |
AI Analysis Prompt:
Analyze this code review comment and classify it:
Comment: "[comment text]"
File: [file path] (line [line number])
Classify as: BLOCKING | IMPORTANT | NIT | QUESTION | PRAISE
Provide:
1. Classification with confidence (high/medium/low)
2. Summary of what's being requested
3. Suggested fix approach (if applicable)
4. Estimated effort (trivial/small/medium/large)
Generate Gap Analysis
Create structured analysis:
## PR #[number] Review Gap Analysis
**Review State:** CHANGES_REQUESTED | COMMENTED | APPROVED
**CI Status:** passing | failing | pending
**Generated:** [timestamp]
### Blocking Issues (Must Fix)
- [ ] [File:line] - [Summary] - [Suggested fix]
### Important Issues (Should Fix)
- [ ] [File:line] - [Summary] - [Suggested fix]
### Nits (Optional)
- [ ] [File:line] - [Summary]
### Questions to Answer
- [ ] [Question] - [Suggested response]
### Verdict
- **Ready to Merge:** No
- **Blocking Count:** N issues
- **Fix Complexity:** [trivial/small/medium/large]
If Blocking Issues Exist → Implement Fixes
For each blocking issue:
a. Read the relevant file
# Context around the issue
sed -n '[start],[end]p' [file-path]
b. Implement the fix
tdd-developerreliability-engineertechnical-plannerc. Run tests to verify fix
bun test [relevant-test-file]
# or
npm test -- --testPathPattern=[pattern]
Commit and Push Fixes
# Verify git state before operations
git status || {
echo "❌ Error: git status failed. Repository may be in bad state."
exit 1
}
# Stage changes
git add [modified-files]
# Verify files were staged
git diff --cached --name-only | grep -q . || {
echo "❌ Error: No files staged. Check if files were modified."
exit 1
}
# Commit with descriptive message
git commit -m "fix(review): address PR feedback
- [Summary of fix 1]
- [Summary of fix 2]
Addresses review comments:
- [Reviewer]: [Brief quote of feedback addressed]
Co-Authored-By: Codex <noreply@anthropic.com>" || {
echo "❌ Error: git commit failed. Check for pre-commit hooks or conflicts."
git status
exit 1
}
# Verify commit succeeded
git log -1 --oneline || {
echo "❌ Error: Could not verify last commit."
exit 1
}
# Push to PR branch
git push origin [branch-name] || {
echo "❌ Error: git push failed. Check network connection and permissions."
echo "Branch may need rebasing if remote has new commits."
git status
exit 1
}
# Verify push succeeded
git fetch origin
LOCAL=$(git rev-parse HEAD)
REMOTE=$(git rev-parse origin/[branch-name])
if [[ "$LOCAL" != "$REMOTE" ]]; then
echo "❌ Warning: Local and remote commits don't match. Push may have failed."
else
echo "✅ Successfully pushed fixes to PR branch"
fi
Add Detailed PR Comment
gh pr comment [PR-number] --body "$(cat <<'EOF'
## Review Feedback Addressed
I've pushed changes to address the review feedback:
### Changes Made
| File | Change | Addresses |
|------|--------|-----------|
| `[file1]` | [Description] | @[reviewer]'s comment about [topic] |
| `[file2]` | [Description] | @[reviewer]'s suggestion to [topic] |
### Fixes Summary
- **Blocking issues resolved:** N/N
- **Important issues resolved:** N/N
- **Nits addressed:** N/N
### Questions Answered
> [Original question]
[Response with explanation]
### CI Status
- Tests: [passing/failing]
- Lint: [passing/failing]
**Ready for re-review.** Please take another look when you have a chance.
EOF
)"
Loop Back to Step 3
Wait for CI to Complete
# Poll CI status
while true; do
STATUS=$(gh pr checks [PR-number] --json state --jq '.[].state' | sort -u)
if [[ "$STATUS" == "SUCCESS" ]]; then
echo "All CI checks passed"
break
elif [[ "$STATUS" == *"FAILURE"* ]]; then
echo "CI failed - analyzing..."
# Fetch failure details and fix
break
fi
sleep 30
done
If CI Fails → Fix and Push
# Get failed check details
gh pr checks [PR-number] --json name,conclusion,detailsUrl \
--jq '.[] | select(.conclusion == "FAILURE")'
fix(ci): [description]Final Readiness Check
All conditions must be true:
APPROVED (or no blocking issues remain)Merge PR
# Squash merge with detailed message
gh pr merge [PR-number] --squash --delete-branch \
--subject "[PR title]" \
--body "$(cat <<'EOF'
[Detailed description of changes]
Reviewed-by: [reviewer(s)]
EOF
)"
Update CHANGELOG.md
After successful merge, update the changelog with the new entry:
# Get merge commit details
MERGE_SHA=$(git rev-parse HEAD)
MERGE_DATE=$(date +%Y-%m-%d)
PR_TITLE="[PR title from PR metadata]"
PR_NUMBER="[PR-number]"
# Detect change type from PR title or labels
# feat: → Added
# fix: → Fixed
# docs: → Documentation
# refactor: → Changed
# test: → Testing
# chore: → Infrastructure
# Update CHANGELOG.md
# Insert new entry under [Unreleased] or create new version section
Changelog format (Keep a Changelog):
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [Unreleased]
### Added
- Feature description from PR #123 (@username, YYYY-MM-DD)
### Fixed
- Bug fix description from PR #124 (@username, YYYY-MM-DD)
### Changed
- Refactor description from PR #125 (@username, YYYY-MM-DD)
## [1.0.0] - YYYY-MM-DD
...
Update logic:
CHANGELOG.md exists, create if not[Unreleased] sectiondocs(changelog): update for PR #[number]Update Task List (if context provided)
[x] completedFinal Summary Comment
# Comment is auto-added by GitHub on merge, but we can add context
gh pr comment [PR-number] --body "$(cat <<'EOF'
## Merged Successfully
- **Merge commit:** [SHA]
- **Review iterations:** N
- **Total fixes:** N blocking, N important, N nits
- **Time to merge:** [duration]
Task list updated. Moving to next phase.
EOF
)"
# Detect conflicts
gh pr view [PR-number] --json mergeable --jq '.mergeable'
# If "CONFLICTING":
# 1. Fetch latest base branch
git fetch origin main
# 2. Rebase PR branch
git checkout [branch-name]
git rebase origin/main
# 3. Resolve conflicts (may need human help for complex conflicts)
# 4. Force push
git push --force-with-lease origin [branch-name]
gh pr checks [PR-number] --rerun[flaky] label and document in PR commentgh pr view [PR-number] --json mergeStateStatus --jq '.mergeStateStatus'
BLOCKED: Missing required reviews or checksBEHIND: Branch needs to be updatedThis skill can be invoked by:
task-processor-auto after creating a PRtask-processor-parallel for each phase PRdev-workflow-orchestrator as part of full pipeline/pr-review-loop [PR-number] commandreference.md for gh CLI patterns