Advanced Iterate Pr
Comprehensive skill designed for iterate, until, passes, need. Includes structured workflows, validation checks, and reusable patterns for sentry.
Advanced Iterate PR
A pull request iteration skill for systematically reviewing, refining, and improving pull requests through structured feedback cycles, automated checks, and collaborative workflows.
When to Use
Choose Advanced Iterate PR when:
- Iterating on pull request feedback from code reviewers
- Managing complex PR review cycles with multiple rounds of changes
- Automating PR quality checks and ensuring all feedback is addressed
- Tracking review comments and their resolution status across iterations
Consider alternatives when:
- Creating a new PR from scratch — use standard git workflow
- Performing one-time code review — use a code review tool
- Managing release branches — use a release management tool
Quick Start
# View all review comments on current PR gh pr view --comments gh pr checks # Address review feedback and push updates git add -p # Stage specific changes addressing feedback git commit -m "fix(auth): address review feedback on token validation - Add null check for expired tokens per @reviewer comment - Extract validation logic into separate function - Add unit tests for edge cases" git push
import subprocess import json import re class PRIterator: def __init__(self, pr_number): self.pr_number = pr_number self.comments = [] self.resolved = [] self.pending = [] def fetch_comments(self): """Fetch all review comments from GitHub""" result = subprocess.run( ["gh", "api", f"repos/:owner/:repo/pulls/{self.pr_number}/comments"], capture_output=True, text=True ) self.comments = json.loads(result.stdout) self._categorize_comments() def _categorize_comments(self): for comment in self.comments: if comment.get("resolved", False): self.resolved.append(comment) else: self.pending.append(comment) def create_iteration_checklist(self): """Generate a checklist from pending review comments""" checklist = [] for c in self.pending: checklist.append({ "file": c.get("path", ""), "line": c.get("line", 0), "reviewer": c["user"]["login"], "comment": c["body"][:200], "addressed": False }) return checklist def push_iteration(self, message): """Commit and push with iteration tracking""" iteration = len(self.get_iterations()) + 1 full_message = f"review(iteration-{iteration}): {message}" subprocess.run(["git", "add", "-A"]) subprocess.run(["git", "commit", "-m", full_message]) subprocess.run(["git", "push"]) def get_iterations(self): """Count previous iteration commits""" result = subprocess.run( ["git", "log", "--oneline", "--grep=review(iteration"], capture_output=True, text=True ) return result.stdout.strip().split("\n") if result.stdout.strip() else [] def summarize_changes(self): """Summarize what was changed in this iteration""" result = subprocess.run( ["git", "diff", "--stat", "HEAD~1"], capture_output=True, text=True ) return { "pending_comments": len(self.pending), "resolved_comments": len(self.resolved), "changes": result.stdout.strip() }
Core Concepts
PR Iteration Workflow
| Phase | Actions | Tools |
|---|---|---|
| Review Received | Read all comments, categorize by priority | gh pr view --comments |
| Plan Changes | Create checklist from feedback | Custom scripts |
| Implement | Make targeted changes per comment | Editor + git |
| Verify | Run tests, lint, type check | CI pipeline |
| Respond | Reply to each comment with resolution | gh pr comment |
| Push | Push iteration with descriptive commit | git push |
| Request Re-review | Notify reviewers of updates | gh pr edit --add-reviewer |
Automated PR Quality Gates
#!/bin/bash # pr-quality-check.sh — Run before requesting re-review echo "=== PR Quality Check ===" # Check all CI passes gh pr checks --fail-fast || { echo "CI checks failing"; exit 1; } # Verify no unresolved conversations pending=$(gh api "repos/:owner/:repo/pulls/$1/comments" \ --jq '[.[] | select(.resolved == false)] | length') if [ "$pending" -gt 0 ]; then echo "Warning: $pending unresolved review comments" fi # Check for fixup commits that need squashing fixups=$(git log --oneline origin/main..HEAD | grep -c "fixup\|squash") if [ "$fixups" -gt 0 ]; then echo "Warning: $fixups fixup commits need squashing before merge" fi # Verify branch is up to date with base git fetch origin main behind=$(git rev-list HEAD..origin/main --count) if [ "$behind" -gt 0 ]; then echo "Branch is $behind commits behind main — rebase recommended" fi echo "=== Quality Check Complete ==="
Configuration
| Option | Description | Default |
|---|---|---|
pr_number | Pull request number to iterate on | Auto-detect from branch |
base_branch | Base branch for comparison | "main" |
auto_resolve | Mark comments resolved after push | false |
squash_fixups | Auto-squash fixup commits before merge | true |
require_all_resolved | Block merge if comments unresolved | true |
notify_reviewers | Auto-request re-review after push | true |
iteration_prefix | Commit message prefix for iterations | "review" |
max_iterations | Warning threshold for iteration count | 5 |
Best Practices
- Address all review comments explicitly by replying to each one with what you changed or why you disagree — silent pushes leave reviewers wondering if their feedback was seen or ignored
- Group related changes into single iteration commits rather than making one commit per comment; this keeps the history clean and makes re-review faster for the reviewer
- Rebase onto the latest base branch before pushing iteration updates to avoid merge conflicts that complicate the review and to ensure your changes work with the latest codebase
- Use fixup commits during iteration then squash them before merging so the final commit history is clean while the review process maintains a clear trail of what changed per iteration
- Set a reasonable iteration limit — if a PR requires more than 3-4 rounds of review, it may be too large or the requirements may be unclear; consider splitting the PR or scheduling a synchronous discussion
Common Issues
Review fatigue after multiple iterations: Each iteration round takes reviewer energy and context-switching time. Minimize iterations by thoroughly self-reviewing before requesting the first review, addressing all comments in a single batch, and having a clear conversation about disagreements rather than going back and forth.
Losing track of which comments are addressed: In large PRs with 20+ comments, it is easy to miss some. Create a local checklist from all pending comments, check them off as you address each one, and reference the comment in your commit message so reviewers can verify quickly.
Merge conflicts accumulating between iterations: Long-running PRs diverge from main as other changes merge. Rebase at the start of each iteration cycle, resolve conflicts once, and push the updated branch. If conflicts are frequent, it signals the PR should be merged sooner or split into smaller pieces.
Reviews
No reviews yet. Be the first to review this template!
Similar Templates
Full-Stack Code Reviewer
Comprehensive code review skill that checks for security vulnerabilities, performance issues, accessibility, and best practices across frontend and backend code.
Test Suite Generator
Generates comprehensive test suites with unit tests, integration tests, and edge cases. Supports Jest, Vitest, Pytest, and Go testing.
Pro Architecture Workspace
Battle-tested skill for architectural, decision, making, framework. Includes structured workflows, validation checks, and reusable patterns for development.