fix-pr ยท git:20261008.d56b7ee ยท 2026-10-08 ยท sha256 68ecb48550b5c511
fix-pr git:20261008.d56b7eeA
Immutable. This exact content never changes and is served at /api/v1/blob/68ecb48550b5c511.
---
name: fix-pr
disable-model-invocation: true
description: "Autonomous PR fixing loop - iterates on CI failures and review comments until green"
argument-hint: "[pr-number] (optional - derives from current branch if omitted)"
---
# Fix PR Autonomously
Enter autonomous PR review loop for the current branch's PR. Loops until the PR is merge-ready across ALL criteria, not just CI.
---
## What this does
Drive the current branch's PR to merge-ready across all six criteria, then stop for human
review (this command does not auto-merge).
Use the pr-review-merge skill: it owns the 6 ready criteria, thread-resolution rules, shell
pitfalls, base-sync-first, and the background CI watcher. Pass the current PR number
(`gh pr view --json number --jq '.number'`) and the base branch
(`gh repo view --json defaultBranchRef --jq '.defaultBranchRef.name'`), plus any bot rules
from the project's Marathon Configuration.
---
## Protocol
1. **Autonomous Loop** (DO NOT ask for permission between iterations):
- Sync base branch, check all 6 criteria, fix issues, push
- Report: "Iteration N: Fixed X issues" or "Iteration N: Waiting for CI"
- Loop until all green
2. **Stop when ALL 6 criteria met**:
- Report: "PR #X: All criteria met, ready for human review"
- Include status footer
- STOP
3. **Only ask for help if**:
- Genuinely blocked (ambiguous merge conflict, unclear review feedback)
- After 5+ iterations with no progress
- Need design decision from user
## Example Output
```
๐ Iteration 1: Checking PR #123...
โ ๏ธ Merge conflict with base branch in App.tsx โ resolving (accept both sides)
โ CI: TypeScript errors in user.service.ts
โ CodeRabbit: 2 unresolved threads (missing error handling)
Fixing...
๐ Iteration 2: Checking PR #123...
โ
In sync with base branch
โ
CI passing
โ CodeRabbit: 1 remaining thread (async pattern)
Fixing...
๐ Iteration 3: Checking PR #123...
โ
In sync with base branch
โ
CI passing
โ
All threads resolved
โ
No unaddressed comments
โ
PR #123: All 6 criteria met, ready for your review!
---
## ๐ Current Work
๐ **PR**: #123 - Add payment processing
https://github.com/org/repo/pull/123
๐ **Latest**: All criteria met after 3 iterations
```
## Commands Reference
```bash
# Get PR info
gh pr view --json number,title,statusCheckRollup
# CI failures
gh pr checks <number> --json name,conclusion | jq '.[] | select(.conclusion == "FAILURE")'
# Unresolved threads (GraphQL โ most reliable)
gh api graphql -f query='...'
# Inline comments (REST fallback)
gh api repos/{owner}/{repo}/pulls/<number>/comments | jq '[.[] | select(.user.login | test("bot"; "i"))]'
# Conversation
gh pr view <number> --comments
# Failed CI logs
gh run view <run-id> --log-failed
```
## Important
- **NO permission needed** between iterations - keep looping autonomously
- **Sync base branch FIRST** every iteration - prevents cascade conflicts
- **Stop criteria**: ALL 6 criteria green (not just CI + comments)
- **Max iterations**: 10 (ask for help after that)