Writing custom Instructions for Copilot's Pull Request Code Review #178108
Select Topic AreaQuestion Copilot Feature AreaCopilot in GitHub BodyI am trying to write custom instructions to enhance the GitHub Copilot code review and following the Using GitHub Copilot code review guide. I am getting inconsistent behaviour between the Code Reviews automatically performed by Copilot (doesn't work) and Copilot chat (works), which suggests my issue does not lie with the custom instructions that I have written. Any help appreciated! My TestingI have a simple test case, with the following instructions saved in the When a PR is raised, the code review is automatically triggered (as per our configuration), but the code review does not perform the instructions. I have also tried re-assigning Copilot as a Reviewer and get the same experience. However, if I open Copilot Chat, add the repository and ask "Can you perform a code review of the risk-assessment-test branch", the output includes a detailed code review, with a Risk Assessment section as requested by the instructions. Similarly, asking Copilot to "Can you perform a code review of the PR: " also provides a review with a Risk Assessment section. |
Replies: 6 comments 6 replies
|
I have the same issue. My understanding based on the documentation is that the reviewer should consider the instructions during the PR review process, but it does not. |
|
This behavior is currently expected — GitHub Copilot’s automated PR reviews and Copilot Chat reviews use slightly different models and execution paths, which is why your .github/copilot-instructions.md file works in chat but not during automatic reviews. 🔍 What’s happening Copilot Chat directly references the .github/copilot-instructions.md and applies it dynamically during analysis. Automated PR Reviews (triggered when Copilot is assigned as a reviewer) currently use a cached model context, and don’t always fetch or apply new custom instructions from the repo at runtime. As a result, recent or custom guidance (like your Risk Assessment section) may be ignored in automated runs. ✅ Workarounds Force context refresh: Remove Copilot as a reviewer → wait a few minutes → reassign it. Sometimes forces the model to reload your updated instructions file. Rename and re-save the instructions file to: .github/copilot/INSTRUCTIONS.md Some users report better reliability with this directory-based format. Use Copilot Chat for now for consistent application of custom logic — it always respects your .github/copilot-instructions.md. Track GitHub’s update: The official docs note that “custom instructions support for automatic reviews is rolling out gradually.” Watch the GitHub Copilot Changelog Summary: |
|
Hi @Alex-Burgess! I’m a product manager on Copilot code review, hope I can provide some clarification here. Given that Copilot code review is built for one specific function - to perform code review - it consumes custom instruction files differently from other Copilot products like Copilot chat. Instruction files are primarily used as context for code review; topics like code standards, best practices for your team, language-specific guidelines, security risks to flag, etc. are used to inform the way that Copilot performs a code review. However, asking Copilot code review to deterministically change its behavior with an instruction like “perform a risk assessment” may not work the way you expect it to. I’d like to understand more about what you’re trying to achieve with your instruction file - do you want Copilot code review to label each comment it adds with a risk category? Or just one comment on the PR dedicated to a risk assessment? We are working on adding more documentation and tutorials to clarify the current limitations of custom instructions for Copilot code review. And stay tuned for an upcoming blog post about writing effective instructions files! |
|
As far as I understood, |
|
@ria-gopu It would also be helpful if the copilot reviewer has access to custom or third-party MCP servers to gather context or trigger events. Example, the This is possible to do with custom agents within VS Code but is inconvenient to enforce usage. |
|
Hi @ria-gopu — friendly ping after ~6 months! 👋
^^^ That's from Oct 2025 ;-// Your November blog post helped a lot, but this gap is still the open question here. Thanks! |
Thanks for the details! While custom instruction files may not be able to deterministically influence Copilot code review to consistently leave a risk assessment comment or a "must/should do" comment, the way you're envisioning, we have been exploring solutions around the use case you described. I'm also curious as to whether you've tried the new "Implement suggestion" button, that hands off Copilot code review comments to Copilot coding agent, and whether that has helped with the agent handoff scenario you mentioned?
I'd love to discuss your ideas more - if you're open to scheduling a quick chat, feel free to email me at ria-gopu@github.com.