agentleFS
dotnetdotnet/dev-proxy/.github/skills/pr-review-loop/SKILL.md

pr-review-loop

Skill851 starsChanged 21 months agoMITView on GitHub

This skill should be used when the user asks to "open a PR", "submit a PR", "get a review", "address review comments", "drive the PR through review", or says the code work is done and ready for review in the Dev Proxy repository. Opens a pull request to dotnet/dev-proxy main with the gh CLI, requests a GitHub Copilot code review, and repeats fix-and-re-review rounds until a stop condition is met. Never merges.

  • Commits and pushes

20 other projects use a version of this.

Adopted by

Most recently taken up by

The file

Show its rules and text

We split this skill into the rules it gives an agent

13 rules. 0 are common, 9 are distinctive, and 4 are very specific to this project.

  • 0

    Common

    Most of the 18 edited versions we read keep these.

  • 9

    Distinctive

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Stop the loop and report to the user when any of these is true:

    line 27
  2. Distinctive:

    Check whether a pull request from the branch to main is already open:

    line 66
  3. Distinctive:

    Run the same commands to re-request a review in later rounds.

    line 109
  4. Very specific:

    If REVIEW is empty or checks are still pending, stop (stop condition 5).

    line 139
  5. Very specific:

    If CI failed, read the logs (gh run view <run-id> --repo "$UPSTREAM" --log-failed) and fix the cause together with the review comments in …

    line 141
  6. Distinctive:

    If the review has no new inline comments, its body reports no findings you haven't addressed, and CI is green, stop (stop condition 1).

    line 145
  7. Distinctive:

    Verify each claim against the code before acting on it.

    line 168
  8. Distinctive:

    If a fix needs a decision from a human, stop (stop condition 4) and ask.

    line 175
  9. Very specific:

    After you push the fixes (Step 6), reply to every thread.

    line 177
  10. Distinctive:

    When you decline a suggestion, reply with the reason and leave the thread unresolved, so that a maintainer can decide.

    line 191
  11. Very specific:

    Commit with a message that describes the fixes, and push: git push origin "$BRANCH"

    line 202
  12. Distinctive:

    If nothing changed in this round, stop (stop condition 6)

    line 204
  13. Distinctive:

    When the loop stops, report to the user:

    line 209

“Common” is measured: kept by at least 6 in 10 of the 18 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

PR Review Loop

Open a pull request, get a Copilot code review, address the feedback, and repeat until the review comes back clean or a stop condition is hit.

Guardrails

These stay with a human. Never:

  • Merge, close, or approve the pull request, or enable auto-merge
  • Change repository settings, rulesets, branch protection, secrets, or release and deployment workflows
  • Force-push over someone else's commits or rewrite the history of the base branch
  • Dismiss reviews, or resolve threads you didn't address

Stop Conditions

Stop the loop and report to the user when any of these is true:

  1. Clean review: the latest Copilot review of the current head commit has no new inline comments and its body reports no unaddressed findings, CI is green, and every earlier thread and review-body finding is resolved or has your reply
  2. Round limit: 20 review rounds have been completed
  3. Repeated CI failure: the same CI check fails 3 times in a row with the same error
  4. Stuck: a fix needs a decision from a human (design choice, behavior change, scope change). Ask; don't guess
  5. Timeout: Copilot hasn't submitted a review, or CI hasn't finished, 30 minutes after the review was requested
  6. Nothing left to review: a round produced only advisory comments that you declined, so no code changed

Prerequisites

  • gh CLI 2.87 or newer (adds gh pr edit --add-reviewer @copilot), signed in (gh auth status) with access to the fork and to dotnet/dev-proxy
  • Remotes: upstream points to dotnet/dev-proxy, origin points to your fork
  • Work is committed on a feature branch (not main)

Set these once and reuse them in the commands below:

UPSTREAM=dotnet/dev-proxy
FORK_OWNER=$(gh api user --jq .login)
BRANCH=$(git branch --show-current)

Process

Step 1: Verify Locally

Restore in locked mode (like CI, so stale lock files fail instead of being updated), then build and run the tests. Fix any failures before you continue.

dotnet restore DevProxy.sln --locked-mode
dotnet build DevProxy.sln --no-restore
dotnet test DevProxy.sln

Skip this step for documentation-only changes.

Step 2: Open the Pull Request

Check whether a pull request from the branch to main is already open:

PR=$(gh pr list --repo "$UPSTREAM" --head "$BRANCH" --base main --state open \
  --json number,headRepositoryOwner \
  --jq ".[] | select(.headRepositoryOwner.login==\"$FORK_OWNER\") | .number")

If PR is set, reuse it. Unresolved inline threads from earlier rounds come up again in Step 5, but findings that Copilot reported only in a review body don't. Before continuing, read the bodies of the earlier Copilot reviews and the PR comments, which hold your earlier replies to such findings:

gh pr view "$PR" --repo "$UPSTREAM" --json reviews,comments \
  --jq '(.reviews[] | select(.author.login=="copilot-pull-request-reviewer") | {submittedAt, body}),
        (.comments[] | {author: .author.login, body})'

Address every body finding that has neither a fix nor a reply, as described at the end of Step 5. Then push any new commits (git push origin "$BRANCH") and continue with Step 3.

Otherwise, rebase on the latest upstream main and push the branch to the fork. Only rebase a branch that hasn't been pushed yet. Once it's published, don't rewrite its history; if it needs upstream changes, merge upstream/main instead.

git fetch upstream main
git rebase upstream/main
git push -u origin "$BRANCH"

Open the pull request against upstream main. Describe what changed and why, and reference the issue it closes (Closes #123):

gh pr create --repo "$UPSTREAM" --base main --head "$FORK_OWNER:$BRANCH" \
  --title "<title>" --body-file <path-to-description.md>
PR=$(gh pr view "$FORK_OWNER:$BRANCH" --repo "$UPSTREAM" --json number --jq .number)

Step 3: Request a Copilot Review

Record the request time first, so that an earlier review of the same commit isn't mistaken for the new one:

REQUESTED_AT=$(date -u +%Y-%m-%dT%H:%M:%SZ)
gh pr edit "$PR" --repo "$UPSTREAM" --add-reviewer "@copilot"

Run the same commands to re-request a review in later rounds. Each request counts as one round.

Step 4: Wait for CI and the Review

Poll CI and the review together every 60 seconds, for up to 30 minutes after the request (stop condition 5). The loop ends when CI has finished and Copilot submitted a review of the current head commit after REQUESTED_AT:

HEAD_SHA=$(git rev-parse HEAD)
REVIEW=""
for i in $(seq 1 30); do
  REVIEW=$(gh api graphql -F owner=dotnet -F name=dev-proxy -F pr="$PR" -f query='
  query($owner:String!,$name:String!,$pr:Int!){
    repository(owner:$owner,name:$name){
      pullRequest(number:$pr){
        reviews(last:50){
          nodes{ author{login} submittedAt commit{oid} comments{totalCount} body }
        }
      }
    }
  }' --jq "[.data.repository.pullRequest.reviews.nodes[]
    | select(.author.login==\"copilot-pull-request-reviewer\" and .commit.oid==\"$HEAD_SHA\" and .submittedAt > \"$REQUESTED_AT\")]
    | last // empty")
  PENDING=$(gh pr checks "$PR" --repo "$UPSTREAM" --json bucket --jq '[.[] | select(.bucket=="pending")] | length')
  [ -n "$REVIEW" ] && [ "$PENDING" = "0" ] && break
  sleep 60
done
echo "$REVIEW"
gh pr checks "$PR" --repo "$UPSTREAM"

If REVIEW is empty or checks are still pending, stop (stop condition 5).

If CI failed, read the logs (gh run view <run-id> --repo "$UPSTREAM" --log-failed) and fix the cause together with the review comments in Step 5. Track how many times in a row each check failed with the same error (stop condition 3).

comments.totalCount is the number of new inline comments in that round. Also read the review body: Copilot lists some findings, such as issues it missed in code that didn't change since the last review, only in the body and not as inline comments. Treat those like inline comments.

If the review has no new inline comments, its body reports no findings you haven't addressed, and CI is green, stop (stop condition 1).

Step 5: Address Each Comment

List unresolved review threads. --paginate fetches all pages, so threads from earlier rounds don't hide new ones:

gh api graphql --paginate -F owner=dotnet -F name=dev-proxy -F pr="$PR" -f query='
query($owner:String!,$name:String!,$pr:Int!,$endCursor:String){
  repository(owner:$owner,name:$name){
    pullRequest(number:$pr){
      reviewThreads(first:100,after:$endCursor){
        pageInfo{ hasNextPage endCursor }
        nodes{
          id isResolved path line
          comments(first:20){ nodes{ databaseId author{login} body } }
        }
      }
    }
  }
}' --jq '.data.repository.pullRequest.reviewThreads.nodes[] | select(.isResolved|not)'

Verify each claim against the code before acting on it. Reviewers can be wrong. Then classify it:

TypeExamplesAction
BlockingIncorrect behavior, security issue, data loss, crash, missing test for new or fixed behaviorFix it
AdvisoryNaming, style, wording, optional refactoring, speculative concernsFix it if it's an improvement, otherwise reply explaining why not

If a fix needs a decision from a human, stop (stop condition 4) and ask.

After you push the fixes (Step 6), reply to every thread. Use the databaseId of the first comment in the thread:

gh api -X POST "repos/$UPSTREAM/pulls/$PR/comments/<databaseId>/replies" \
  -f body="Fixed in <sha>: <one line summary>"

Resolve the threads you fixed:

gh api graphql -f id=<thread-id> -f query='
mutation($id:ID!){ resolveReviewThread(input:{threadId:$id}){ thread{ isResolved } } }'

When you decline a suggestion, reply with the reason and leave the thread unresolved, so that a maintainer can decide.

Findings that appear only in the review body have no thread. Address them in one PR comment:

gh pr comment "$PR" --repo "$UPSTREAM" --body "<finding>: fixed in <sha> / not changed because <reason>"

Step 6: Push and Repeat

  1. For code changes, run Step 1 again
  2. Commit with a message that describes the fixes, and push: git push origin "$BRANCH"
  3. Reply to and resolve the threads (Step 5)
  4. If nothing changed in this round, stop (stop condition 6)
  5. Otherwise go back to Step 3

Step 7: Report

When the loop stops, report to the user:

  • Pull request URL
  • Number of rounds and which stop condition ended the loop
  • Comments fixed, comments declined with reasons, and anything that needs a human decision
  • Final CI status

The pull request stays open for a maintainer to review and merge.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.