You are reviewing and applying GitHub Copilot's code review feedback. Your job is to:
- •Fetch Copilot's review comments
- •Evaluate each suggestion critically
- •Apply changes that make sense, skip those that don't
- •Resolve the comment threads for applied changes
Step 1: Get PR details
Get the current PR number and repo info:
gh pr view --json number,url,headRefName
Extract the owner and repo from the URL (e.g. https://github.com/owner/repo/pull/123).
Step 2: Fetch Copilot review comments
Use GraphQL to get review threads with full context:
gh api graphql -f query='
query {
repository(owner: "OWNER", name: "REPO") {
pullRequest(number: PR_NUMBER) {
reviewThreads(first: 100) {
nodes {
id
isResolved
path
line
comments(first: 10) {
nodes {
author { login }
body
createdAt
}
}
}
}
}
}
}
'
Filter for threads where the first comment author login contains "copilot" (case-insensitive).
If there are no Copilot comments:
- •Tell the user no Copilot feedback was found
- •Copilot may not have reviewed yet, or had no suggestions
Step 3: Parse Copilot's comment format
Copilot comments typically follow this structure:
In path/to/file.rb: > @@ -21,6 +21,8 @@ def method_name > existing_line > another_line + new_suggested_line [Explanation of the issue and reasoning] Suggested change - old_code_line + new_code_line
For each comment, extract:
- •File path: from the "In path/to/file:" line or the thread's
pathfield - •Line number: from the thread's
linefield - •Explanation: the prose explaining the issue
- •Suggested change: the diff block after "Suggested change" showing
-(remove) and+(add) lines
Step 4: Evaluate each suggestion
Do not blindly apply all suggestions. For each one:
- •Read the relevant file to understand the full context
- •Understand Copilot's reasoning - what problem is it trying to solve?
- •Evaluate critically:
- •Does this suggestion actually improve the code?
- •Is the reasoning sound given the full context?
- •Are there side effects Copilot might have missed?
- •Does it align with the codebase's patterns and conventions?
Apply the change if:
- •The reasoning is sound
- •The fix is correct
- •It improves code quality, performance, or correctness
Skip the change if:
- •The reasoning is flawed or based on incomplete context
- •The suggested code has bugs or issues
- •It conflicts with project conventions
- •The "problem" isn't actually a problem in this context
Step 5: Apply approved changes
For each suggestion you decide to apply:
- •Read the file at the specified path
- •Locate the code matching the
-lines in the suggested change - •Replace it with the
+lines - •Keep track of which thread IDs were addressed
Step 6: Resolve applied comment threads
For each comment thread where you applied the fix, resolve it:
gh api graphql -f query='
mutation {
resolveReviewThread(input: {threadId: "THREAD_NODE_ID"}) {
thread { isResolved }
}
}
'
Use the thread id from the GraphQL query in Step 2.
Step 7: Report to the user
Present a clear summary:
Applied changes:
- •List each file modified
- •Briefly describe what was changed and why
Skipped suggestions:
- •List each suggestion that was not applied
- •Explain why (e.g. "Suggestion assumed X but the code actually does Y")
Next steps:
- •Changes have been applied but not committed
- •User should review with
git diff - •When satisfied, commit and push
Do not commit automatically. Let the user review first.