Orchestrate iterative PR review and fix cycle until no critical issues remain
Orchestrates iterative PR review and fix cycles until no critical issues remain.
/plugin marketplace add dapi/claude-code-marketplace/plugin install dev-tools@dapi--max-iterations=NIteratively review and fix PR until no critical/important issues remain.
┌─────────────────────────────────────────────────────────┐
│ ORCHESTRATOR │
│ (maintains minimal state, delegates to subagents) │
└─────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────┐
│ /pr-review-toolkit:review-pr │
│ (Skill - launches 4 agents) │
├─────────────────────────────────────┤
│ ├─ code-reviewer (parallel) │
│ ├─ pr-test-analyzer (parallel) │
│ ├─ silent-failure-hunter(parallel) │
│ └─ comment-analyzer (parallel) │
└─────────────────────────────────────┘
│
▼ (consolidated issues)
┌─────────────────┐
│ Fix Agent │ ──▶ [Loop back to review if issues remain]
│ (subagent) │
└─────────────────┘
│
▼
fixup commit
critical or important severity issues--max-iterations=N (default: 5)iteration = 0.pr-fix-state.json
{
"iteration": 0,
"max_iterations": 5,
"status": "in_progress",
"history": []
}
IMPORTANT: Use Skill tool to invoke /pr-review-toolkit:review-pr — this runs 4 specialized agents in parallel:
Skill tool invocation:
skill: "pr-review-toolkit:review-pr"
Wait for all 4 agents to complete and collect their results.
After review completes, consolidate results into JSON:
{
"issues": [
{
"severity": "critical|important|suggestion|nitpick",
"file": "path/to/file.ts",
"line": 42,
"description": "Brief description of the issue",
"fix_hint": "How to fix it",
"source": "code-reviewer|test-analyzer|silent-failure|comment-analyzer"
}
],
"summary": {
"critical": 0,
"important": 0,
"suggestion": 0,
"nitpick": 0
}
}
Extract only critical and important issues for fixing.
After subagent returns:
critical and important counts{
"iteration": 1,
"history": [
{"iteration": 1, "critical": 2, "important": 3, "action": "review"}
]
}
IF critical == 0 AND important == 0:
status: "success"IF iteration >= max_iterations:
status: "max_iterations_reached"ELSE: Continue to Step 4
Launch Task tool with subagent_type: "general-purpose":
Prompt for subagent:
---
Fix the following PR issues. Apply fixes directly to the files.
ISSUES TO FIX:
{JSON array of critical and important issues from Step 2}
RULES:
1. Fix ONLY the issues listed above
2. Do NOT refactor unrelated code
3. Do NOT add comments explaining fixes
4. After fixing, stage changes: git add -A
5. Create fixup commit: git commit -m "fix: address review feedback (iteration N)"
Output a brief summary of what was fixed.
---
iteration{"iteration": N, "action": "fix", "fixes_applied": X}
File: .pr-fix-state.json (in project root)
{
"iteration": 2,
"max_iterations": 5,
"status": "in_progress|success|max_iterations_reached|error",
"started_at": "2024-01-15T10:30:00Z",
"history": [
{"iteration": 1, "critical": 2, "important": 3, "action": "review"},
{"iteration": 1, "fixes_applied": 5, "action": "fix"},
{"iteration": 2, "critical": 0, "important": 1, "action": "review"},
{"iteration": 2, "fixes_applied": 1, "action": "fix"},
{"iteration": 3, "critical": 0, "important": 0, "action": "review"}
],
"final_result": {
"total_iterations": 3,
"total_fixes": 6,
"remaining_issues": 0
}
}
def fix_pr(max_iterations=5):
state = initialize_state(max_iterations)
for iteration in range(1, max_iterations + 1):
state.iteration = iteration
# Review phase - invoke skill (runs 4 agents in parallel)
review_result = invoke_skill("pr-review-toolkit:review-pr")
# This launches: code-reviewer, pr-test-analyzer,
# silent-failure-hunter, comment-analyzer
issues = consolidate_issues(review_result)
state.history.append({"iteration": iteration, "action": "review", **issues.summary})
# Check stop condition
if issues.critical == 0 and issues.important == 0:
state.status = "success"
save_state(state)
return "Success: No critical/important issues"
# Fix phase (subagent)
fix_result = run_subagent(
type="general-purpose",
prompt=FIX_PROMPT.format(issues=issues.critical_and_important())
)
state.history.append({"iteration": iteration, "action": "fix"})
save_state(state)
state.status = "max_iterations_reached"
save_state(state)
return f"Max iterations reached. Remaining: {issues.summary}"
✅ PR Fix Complete
Iterations: 3
Total fixes applied: 6
Final status: No critical or important issues
History:
[1] Review: 2 critical, 3 important → Fix: 5 issues
[2] Review: 0 critical, 1 important → Fix: 1 issue
[3] Review: 0 critical, 0 important → Done
⚠️ PR Fix Incomplete
Iterations: 5 (max reached)
Remaining: 1 critical, 2 important
History:
[1] Review: 5 critical, 8 important → Fix: 10 issues
...
[5] Review: 1 critical, 2 important → Stopped
Run `/fix-pr` again to continue, or review remaining issues manually.
/fix-prFetch unresolved comments for current branch's PR and fix them
/fix-prFetches and fixes unresolved PR comments by automatically retrieving feedback, addressing reviewer concerns, making targeted code improvements, and streamlining the review process.