Interactive PR Reviews with GitHub Copilot in VS Code¶
Strict code review standards - like mandatory reviews and conversation resolution - are vital for preventing technical debt, but they often introduce major bottlenecks. The current GitHub Web and UI-focused review process necessitates not only distracting context switching but also significant manual labor. Constantly toggling between the browser to read comments and the IDE to fix code breaks flow and encourages developers to skim feedback rather than engaging with it deeply.
The solution isn't to lower standards, but to improve the workflow. This post demonstrates how to handle Pull Request reviews entirely within VS Code, using GitHub Copilot to interactively fetch comments, propose fixes, and resolve threads via the GitHub CLI. By keeping the entire cycle inside the editor, you can validate changes locally and resolve feedback faster - without ever opening a browser.
Why Code Reviews in VS Code Matter¶
While switching between browser and editor is distracting, the deeper problem lies in the limitations of web-based reviews.
When reviewing suggestions in a browser, developers are often limited to accepting them "as-is" - bundled and committed without local validation. You cannot easily run tests, check type safety, or iterate on the logic without manually copying code back to your local environment. This makes it difficult to improve upon a suggestion or validate its impact on the broader codebase.
Furthermore, the administrative burden of strict "Reply and Resolve" policies is significant. To comply with these standards, a developer must:
- Switch to the IDE to implement the fix and verify it.
- Commit the changes.
- Switch back to the browser to look up the comment thread.
- Draft a reply summarizing the change (often needing to hunt for the specific commit hash for traceability).
- Manually mark the thread as resolved.
Developers need a workflow that doesn't just keep them in VS Code, but brings the entire lifecycle of assessment, iteration, and documented resolution directly into the workspace. By automating the summaries and resolution steps, you can remove the manual labor while achieving better traceability and accountability.
Automating Code Reviews with Copilot and VS Code¶
The goal is a workflow that keeps you in the IDE throughout the entire review process. Here is an effective setup:
How It Works¶
- Retrieve Comments: Copilot fetches all inline review comments using the GraphQL API, presenting them in a structured summary with file paths and line numbers.
- Iterate Comments One by One: You work through the feedback sequentially.
- Visual Context: Copilot shows you the exact code in question.
- Interactive Discussion: You discuss the validity of the comment.
- Proposed Solution: Copilot suggests a specific code fix.
- Approve and Implement: Once you approve the fix (and only then), Copilot applies the changes to your local files.
- Automated Reply & Resolution: Copilot commits the change, replies to the comment thread with the commit hash ("Fixed in commit abc1234"), and marks the thread as resolved in GitHub.
Tool Selection: GitHub CLI vs Pull Request Extension vs MCP Server¶
This workflow leverages the GitHub CLI (gh) and GraphQL API. While other tools offer GitHub integration, they typically lack the necessary mutation capabilities to programmatically resolve review threads - a critical requirement for fully automating this cycle:
- GitHub Pull Request Extension for VS Code: Excellent for reviewing diffs, but does not expose an API for Copilot to programmatically resolve threads or navigate the "reply-and-resolve" loop autonomously.
- GitHub MCP Server: Provides useful context gathering but currently lacks the mutation capabilities required to mark conversation threads as
resolvedvia the API.
The GitHub CLI + GraphQL combination proved to be the only robust method to fetch thread IDs and programmatically execute the resolveReviewThread mutation, establishing the "resolve" step as an automated part of the coding cycle rather than a manual administrative chore. Additionally, using gh allows reusing the developer's existing authentication seamlessly, eliminating the need to configure extra tokens or expose credentials directly to Copilot agents.
Key Principles for Success¶
To make this workflow effective, we recommend adhering to a few core guidelines in the Copilot instructions:
- Interactive & Collaborative: Copilot never acts autonomously. It proposes a solution and waits for your explicit "okay" before changing code or updating GitHub.
- Traceability: Every reply includes the specific commit hash where the fix resides.
- Micro-Focus: We resolve one comment completely before moving to the next, preventing cognitive overload.
Important
One technical hurdle involves the GitHub CLI's default pager (see gh config: pager), which can swallow output during automation. We solve this by prepending GH_PAGER=cat to our API calls. This ensures output is captured correctly without modifying the user's global gh configuration, preserving their preferred pager for normal CLI use.
Getting Started¶
To adopt this workflow, simply copy the instructions in the appendix below into your Copilot custom instructions (or save them as a reference file in your workspace). These instructions provide Copilot with the exact GraphQL queries and process steps needed to manage PR reviews interactively.
Appendix: Copilot Instructions¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 | |

