| name | git-pr-autofix |
| description | Automated PR review-fix loop: request bot reviews, poll for responses, analyze comments, fix code, internal review, push, repeat until no critical issues remain. Use when user says 'autofix PR', 'fix PR reviews', 'PR review loop', or '/git-pr-autofix'. |
/git-pr-autofix
Automated PR review-fix loop. Requests bot reviews, polls for responses, analyzes comments, fixes code, runs internal review, pushes, and repeats until no critical issues remain.
Usage
/git-pr-autofix <PR#>
/git-pr-autofix 1 --max-rounds 5
/git-pr-autofix 1 --reviewers codex,gemini-code-assist
Instructions
When the user invokes this skill:
1. Parse Arguments
PR# (required): Pull request number
--max-rounds N: Maximum review-fix iterations (default: 5)
--reviewers: Comma-separated bot reviewer names (default: codex,gemini-code-assist)
- Detect repo from
gh repo view --json nameWithOwner
2. Pre-flight Checks
Run these checks before entering the loop:
gh pr view <PR#> --json headRefName,state
git status --porcelain
npm test (or equivalent)
If any check fails, report and ask user how to proceed.
3. Enter the Review-Fix Loop
iteration = 0
while iteration < max_rounds:
iteration += 1
## Step A: Request Reviews
Record the current timestamp and latest commit SHA:
REVIEW_REQUEST_TS=$(date -u +%Y-%m-%dT%H:%M:%SZ)
LATEST_SHA=$(git rev-parse --short HEAD)
Post a PR comment mentioning all reviewers with commit context:
gh pr comment <PR#> --body "@reviewer1 @reviewer2 please review (round N, commit ${LATEST_SHA})"
## Step B: Poll for Reviews (background agent)
Launch the `review-collector` agent in the BACKGROUND with:
- repo, pr_number, reviewers list
- after_timestamp: REVIEW_REQUEST_TS from Step A
- stabilization_wait: 60 (seconds to wait after first detection)
- timeout: 600 (10 minutes)
The agent will:
- Poll `gh api` every 30s using jq fromdateiso8601 for exact timestamp filtering
- Wait for ALL reviewers to respond
- After first detection, wait 60s for reviewers to finish posting inline comments
- On timeout: collect whatever exists and return with timeout=true
While waiting, report: "Waiting for reviewers... (polling every 30s)"
If the agent times out or returns incomplete results:
- Ask user: "N명 중 M명만 응답. 계속 대기 / 수동 수집 / 건너뛰기?"
- If user chooses manual collection, run gh api directly and proceed
## Step C: Analyze Comments (agent)
Automatically pipe the review-collector output to the `comment-analyzer` agent:
Input: review-collector's full output (reviews + inline comments)
Also provide: PR scope context (what this PR implements, relevant AC)
Output: categorized list:
- CRITICAL: Must fix now (bugs, security, data corruption)
- WARN: Should fix (performance, reliability, consistency)
- INFO: Nice to have (style, optimization suggestions)
- DEFERRED: Out of scope (different Seed, Phase 2, design change)
For each item: { severity, file, line, summary, fix_description, deferred_reason? }
## Step D: Present to User
Show analysis as a table:
| # | Severity | File | Summary | Action |
|---|----------|------|---------|--------|
| 1 | CRITICAL | cache.ts:82 | Tag escape vulnerability | Fix |
| 2 | WARN | route.ts:150 | Missing inArray filter | Fix |
| 3 | DEFERRED | echoes.ts:311 | Tree pagination redesign | Seed 6 |
Then ask: "N개 수정, M개 보류 예정입니다. 진행할까요?"
- If user says no or wants to adjust: let them modify the plan
- If user approves: proceed to Step E
## Step E: Fix Code
For each approved fix (CRITICAL + WARN):
1. Read the file at the specified location
2. Apply the fix based on the analyzer's fix_description
3. Verify the fix doesn't break anything nearby
After all fixes:
- Run tests: `npm test` (or project test command)
- Run lint: `npx eslint src/` (or project lint command)
- If tests/lint fail, fix before proceeding
## Step F: Internal Review (before push)
Run TWO internal reviews in parallel:
1. **Codex review** (optional, requires codex plugin):
Use `/codex:rescue` skill to review the changes
Focus: bugs, edge cases, security gaps
If not available, skip this step and rely on self-review only
2. **Self-review checklist** (maximum-effort self review):
Check all modified files against:
- [ ] Query performance (indexes, full scans)
- [ ] Serverless safety (no fire-and-forget)
- [ ] Cursor/orderBy consistency
- [ ] Atomicity (transactions where needed)
- [ ] Key design (composite keys, deduplication)
- [ ] Edge cases (empty string, null, empty array)
- [ ] UI↔API state consistency
If internal review finds issues:
- Fix them immediately
- Do NOT push code with known issues
- Re-run tests after fixing
## Step G: Commit + Push
```bash
git add <modified files>
git commit -m "fix: address round N review — X issues (summary)"
git push
```
## Step H: Check Loop Condition
If this round had 0 CRITICAL items → BREAK (done!)
If iteration >= max_rounds → BREAK (warn user)
Otherwise → continue loop (back to Step A)
4. Finalize
After loop exits:
-
Post a final PR comment summarizing ALL deferred items:
## Deferred Items (out of scope for this PR)
| Item | Rationale | When |
|------|-----------|------|
| ... | ... | ... |
-
Report to user:
PR Review Loop Complete
=======================
Rounds: N
Fixed: X issues
Deferred: Y items
Tests: all passing
5. Error Handling
- Review timeout: If reviewers don't respond within 10 min:
- Run gh api directly to collect any partial reviews
- Ask user: "N명 중 M명 응답. 수집된 리뷰로 진행 / 계속 대기 / 취소?"
- If partial reviews exist, offer to proceed with what's available
- Test failure after fix: Report which test failed, attempt auto-fix,
if can't fix ask user
- Max rounds reached: Warn user, show remaining issues, suggest
manual review or scope reduction
Configuration
Create .claude/git-pr-autofix.local.md to customize:
reviewers:
- codex
- gemini-code-assist
max_rounds: 5
poll_interval_seconds: 30
poll_timeout_seconds: 600
test_command: "npm test"
lint_command: "npx eslint src/"