copilot-review-loop
Scannednpx machina-cli add skill xpepper/pr-review-agent-skill/copilot-review-loop --openclawCopilot Review Loop
Purpose
Automate an iterative Copilot-driven review loop: trigger a GitHub Copilot review, address its feedback one comment at a time, then re-trigger Copilot to review again. Repeat up to 2 cycles until all critical issues are resolved.
This is an in-session loop — one long agent context that iterates internally.
It is not the Ralph Wiggum pattern, which is an
external shell loop that spawns a fresh agent session per comment. For that,
see the ralph-wiggum-loop skill instead.
Typical invocations
Users trigger this skill with prompts like:
- "Request a Copilot review on this PR and address the feedback"
- "Trigger a GitHub Copilot review and fix the issues it finds"
- "Run copilot-review-loop on PR #42"
- "Use copilot-review-loop to get and address Copilot's review comments"
Prerequisites
ghCLI (required)gh-copilot-reviewextension (recommended — seereferences/gh-copilot-review-guide.md)
Fallback if not installed:gh extension install ChrisCarini/gh-copilot-reviewgh pr review --request copilotpr-review-loopskill (optional — if installed, the inner loop is delegated to it)- The PR branch must be checked out locally
Process
Step 1 — Pre-flight
Inspect the project for safeguard conventions by checking these files (if they exist):
CLAUDE.md,AGENTS.mdMakefile.github/workflows/README.md
Identify all required safeguards (tests, compilation, linting, formatting, etc.). Run all of them. If any fail, stop immediately and report — do not proceed.
Step 2 — Outer loop (max 2 iterations)
Repeat up to 2 times:
2a. Request Copilot review
Check if gh-copilot-review extension is installed:
gh extension list | grep copilot-review
If installed (preferred):
gh copilot-review [<number> | <url>]
If not installed (fallback):
gh pr review --request copilot
2b. Wait for Copilot to complete
Read references/gh-copilot-review-guide.md for the polling approach.
Record the current count of unresolved copilot[bot] comments before triggering.
Poll every 30 seconds until new comments appear. If no new comments after 10 minutes,
stop and report timeout — do not proceed.
2c. Collect unresolved Copilot comments
Fetch all unresolved comments authored by copilot[bot]. Ignore comments from
human reviewers (those are handled by the pr-review-loop skill).
gh api repos/{owner}/{repo}/pulls/{pr}/comments \
--jq '.[] | select(.user.login == "copilot[bot]")'
Fetch all Copilot comments. Use the count recorded before triggering (step 2b) to identify which are new.
If there are no unresolved Copilot comments, stop — nothing to do.
2d. Address comments — inner loop
If pr-review-loop skill is available:
Invoke the pr-review-loop skill, passing only the Copilot comments collected
in step 2c as the scope. It will handle triage, one-at-a-time fixes, and replies.
If pr-review-loop skill is NOT available:
Follow this process for each comment, one at a time (MUST_FIX first, then SHOULD_FIX):
Triage using the five categories defined in references/triage-guide.md
(MUST_FIX, SHOULD_FIX, PARK, OUT_OF_SCOPE, NEEDS_CLARIFICATION). Read that file before triaging.
For each MUST_FIX and SHOULD_FIX comment:
-
Assess complexity:
- Trivial (rename, small fix): fix directly
- Non-trivial: write plan to
.pr-review/plan-<comment-id>.mdfirst
-
Run safeguards — all must pass before touching code
-
Fix, park, or ask for clarification
- Fix or park as usual.
- If mid-assessment the intent is genuinely ambiguous: post one focused question (see format below), do not resolve the thread, skip steps 4–8, move on.
Clarification question format:
cat > /tmp/pr-review-reply-{comment_id}.md <<'EOF' Thanks for the feedback! Before I make a change, I want to make sure I understand what you're after: <one specific, focused question> EOF jq -n --rawfile body /tmp/pr-review-reply-{comment_id}.md '{body:$body}' > /tmp/pr-review-reply-{comment_id}.json gh api repos/{owner}/{repo}/pulls/{pull_number}/comments/{comment_id}/replies \ --input /tmp/pr-review-reply-{comment_id}.jsonAsk exactly one question. Leave the thread unresolved so the reviewer's answer re-surfaces it.
-
Run safeguards again — all must pass
-
Commit and push:
git add <changed files> git commit -m "<conventional commit describing the fix>" git push -
Reply to the comment — explain fix, deferral, or rejection
-
Resolve the comment on GitHub
-
Delete plan file if one was created:
rm .pr-review/plan-<comment-id>.md
2e. Check stop conditions
Stop iterating if any of:
- No MUST_FIX Copilot comments remain after this pass
- Only OUT_OF_SCOPE or NEEDS_CLARIFICATION Copilot comments remain (awaiting reviewer input)
- This was the 10th iteration
Otherwise continue to the next iteration (back to step 2a).
Step 3 — Summary
Post a final comment on the PR:
## Copilot Review Loop — Summary
Completed N Copilot review cycle(s).
### Fixed
- [commit abc1234] <description> (Copilot comment #<id>)
- ...
### Parked
- <description> — deferred, tracked in #<issue>
- ...
### Rejected
- <description> — <reason>
- ...
### Awaiting Clarification
- Asked Copilot: "<question>" — thread left open (comment #<id>)
- ...
Omit any section that has no entries.
Resumability
This skill can be interrupted and restarted in a fresh context at any point.
On restart:
- Run pre-flight (Step 1)
- Check for an existing
.pr-review/plan-*.md— if found, continue mid-fix from step 2d - Re-fetch unresolved Copilot comments — already-resolved ones won't appear
- Continue the outer loop from the current state
State Directory
.pr-review/ at the repo root (should be gitignored by the project).
plan-<comment-id>.md— plan for the comment currently in progress (deleted after resolution)
Do Not
- Bundle all PR feedback into one large commit
- Make multiple unrelated changes in a single commit
- Push all changes at once without intermediate commits
- Leave Copilot comments unresolved after addressing them
- Proceed to the next Copilot review cycle if MUST_FIX items remain unresolved
Source
git clone https://github.com/xpepper/pr-review-agent-skill/blob/main/copilot-review-loop/SKILL.mdView on GitHub Overview
Copilot Review Loop automates an iterative Copilot-driven review of a PR within a single agent context. It triggers Copilot to review, then addresses its feedback one comment at a time, repeating up to two cycles until critical issues are resolved. It can delegate the inner loop to the pr-review-loop skill or run manual triage when that skill isn't available.
How This Skill Works
It starts with a pre-flight safeguard sweep and ensures gh CLI and the gh-copilot-review extension are available. It then runs an outer loop for up to two iterations: triggering Copilot's review, polling for new copilot[bot] comments, collecting unresolved comments, and addressing them via the inner loop (pr-review-loop if present) or manual triage and fixes when that skill is unavailable.
When to Use It
- You want Copilot to review a PR and address its feedback within the current agent session.
- You prefer automated fixes for Copilot's comments rather than manual edits.
- You have the pr-review-loop skill installed and want it to triage and fix Copilot's feedback one comment at a time.
- You need up to two iterative cycles to resolve critical issues before finalizing the PR.
- You want safeguards (tests, linting, formatting) run prior to iterating and before reporting results.
Quick Start
- Step 1: Ensure prerequisites (gh CLI, gh-copilot-review extension, and local PR checkout) and run pre-flight safeguard checks.
- Step 2: Trigger Copilot review with gh copilot-review [<number> | <url>] (or fallback gh pr review --request copilot) and poll for results.
- Step 3: Collect unresolved copilot[bot] comments and address them via inner loop (pr-review-loop if available) or manual triage; repeat up to two iterations.
Best Practices
- Ensure gh CLI and the gh-copilot-review extension are installed before starting.
- Run the pre-flight safeguard checks (CLAUDE.md, AGENTS.md, Makefile, .github/workflows/, README.md) first.
- Use the inner loop when pr-review-loop is available to handle one-at-a-time fixes.
- Track unresolved copilot[bot] comments and poll every 30 seconds, with a 10-minute timeout for new comments.
- Limit iterations to two cycles and verify all critical issues are resolved before merging.
Example Use Cases
- "Request a Copilot review on this PR and address the feedback"
- "Trigger a GitHub Copilot review and fix the issues it finds"
- "Run copilot-review-loop on PR #42"
- "Use copilot-review-loop to get and address Copilot's review comments"
- If available, delegate to pr-review-loop for the inner triage and fixes