GitHub Copilot Review Loop
Drive a pull request from its current review state to one verified clean Copilot cycle. Preserve thread state and require evidence that the final review ran against the latest head commit.
Workflow
- Confirm
gh auth status, the current branch, a clean understanding of the worktree, and the associated open PR.
- Run
scripts/review_state.py from the skill directory. Record head_sha, copilot_review_count, unresolved thread IDs, and the latest Copilot review commit.
- Treat unresolved, non-outdated Copilot threads as actionable unless they are informational, duplicates, incorrect, or conflict with requirements. If the user said to address everything, fix all valid threads; otherwise present a numbered selection.
- Implement the smallest behavior-preserving fixes. Add or update behavioral tests for regressions. Do not resolve threads while tests are failing.
- Run checks proportional to the diff, inspect
git diff --check, commit intentionally, and push the PR branch without force-pushing.
- Reply to each handled thread with the fix commit and verification, then resolve it with GitHub's
resolveReviewThread GraphQL mutation. Do not resolve rejected or ambiguous feedback; explain it instead.
- Re-run
scripts/review_state.py. Confirm the pushed head_sha, zero remaining actionable threads from the cycle, and the current Copilot review count.
- Request Copilot again through GitHub's requested-reviewers API with the special reviewer login
copilot-pull-request-reviewer[bot]. Record the request time, head SHA, and baseline Copilot review count.
- Poll without blocking longer than 60 seconds at a time. A review cycle is complete only when the Copilot review count increases and the newest review targets the recorded head SHA.
- Fetch thread-aware state again. If new actionable comments exist, repeat from step 3. Stop only when the new completed review targets the latest head SHA and adds no actionable comments.
Commands
Inspect state:
python3 "${CODEX_HOME:-$HOME/.codex}/skills/gh-copilot-review-loop/scripts/review_state.py"
Request Copilot review:
gh api --method POST "repos/{owner}/{repo}/pulls/{pr}/requested_reviewers" \
--input - <<'JSON'
{"reviewers":["copilot-pull-request-reviewer[bot]"]}
JSON
Resolve a handled thread:
gh api graphql -f query='mutation($id:ID!){resolveReviewThread(input:{threadId:$id}){thread{isResolved}}}' -f id="$THREAD_ID"
Prefer the installed GitHub connector for PR metadata, replies, and ordinary PR mutations. Use gh api graphql for review-thread resolution and thread-aware state.
Clean-Cycle Gate
Do not claim completion from resolved old threads alone. Require all of the following:
- local and remote branch heads match;
- relevant checks pass;
- every handled thread is resolved or explicitly dispositioned;
- a new Copilot review completed after the last review request;
- that review is anchored to the latest head SHA;
- it produced no new actionable threads.
Report the PR URL, final commit, review-cycle count, resolved threads, verification, and any non-actionable feedback left open.
1---2name: gh-copilot-review-loop3description: Address all actionable GitHub pull-request feedback, push verified fixes, resolve handled threads, request another GitHub Copilot review, and repeat until a completed review cycle produces no new comments. Use for requests such as "address PR comments and re-review until clean," "keep cycling Copilot review," or "fix every review comment and request another review."4---56# GitHub Copilot Review Loop78Drive a pull request from its current review state to one verified clean Copilot cycle. Preserve thread state and require evidence that the final review ran against the latest head commit.910## Workflow11121. Confirm `gh auth status`, the current branch, a clean understanding of the worktree, and the associated open PR.132. Run `scripts/review_state.py` from the skill directory. Record `head_sha`, `copilot_review_count`, unresolved thread IDs, and the latest Copilot review commit.143. Treat unresolved, non-outdated Copilot threads as actionable unless they are informational, duplicates, incorrect, or conflict with requirements. If the user said to address everything, fix all valid threads; otherwise present a numbered selection.154. Implement the smallest behavior-preserving fixes. Add or update behavioral tests for regressions. Do not resolve threads while tests are failing.165. Run checks proportional to the diff, inspect `git diff --check`, commit intentionally, and push the PR branch without force-pushing.176. Reply to each handled thread with the fix commit and verification, then resolve it with GitHub's `resolveReviewThread` GraphQL mutation. Do not resolve rejected or ambiguous feedback; explain it instead.187. Re-run `scripts/review_state.py`. Confirm the pushed `head_sha`, zero remaining actionable threads from the cycle, and the current Copilot review count.198. Request Copilot again through GitHub's requested-reviewers API with the special reviewer login `copilot-pull-request-reviewer[bot]`. Record the request time, head SHA, and baseline Copilot review count.209. Poll without blocking longer than 60 seconds at a time. A review cycle is complete only when the Copilot review count increases and the newest review targets the recorded head SHA.2110. Fetch thread-aware state again. If new actionable comments exist, repeat from step 3. Stop only when the new completed review targets the latest head SHA and adds no actionable comments.2223## Commands2425Inspect state:2627```bash28python3 "${CODEX_HOME:-$HOME/.codex}/skills/gh-copilot-review-loop/scripts/review_state.py"29```3031Request Copilot review:3233```bash34gh api --method POST "repos/{owner}/{repo}/pulls/{pr}/requested_reviewers" \35 --input - <<'JSON'36{"reviewers":["copilot-pull-request-reviewer[bot]"]}37JSON38```3940Resolve a handled thread:4142```bash43gh api graphql -f query='mutation($id:ID!){resolveReviewThread(input:{threadId:$id}){thread{isResolved}}}' -f id="$THREAD_ID"44```4546Prefer the installed GitHub connector for PR metadata, replies, and ordinary PR mutations. Use `gh api graphql` for review-thread resolution and thread-aware state.4748## Clean-Cycle Gate4950Do not claim completion from resolved old threads alone. Require all of the following:5152- local and remote branch heads match;53- relevant checks pass;54- every handled thread is resolved or explicitly dispositioned;55- a new Copilot review completed after the last review request;56- that review is anchored to the latest head SHA;57- it produced no new actionable threads.5859Report the PR URL, final commit, review-cycle count, resolved threads, verification, and any non-actionable feedback left open.