Customize Copilot Code Review with AGENTS.md
Use AGENTS.md for shared agent rules, add `.github/copilot-instructions.md` for repository-wide review guidance, and keep path-specific rules in `.github/instructions/*.instructions.md`. Copilot code review reads these from the head branch.
Other people are working this out at the same time: See what people are building
How do I customize Copilot code review with AGENTS.md or setup steps
Use AGENTS.md for shared agent rules, .github/copilot-instructions.md for repository-wide review guidance, and .github/instructions/*.instructions.md for path-specific rules. Copilot code review reads those files from the head branch of the pull request, so the branch you are testing is the branch Copilot uses.
The practical setup is simple. Put broad review rules in .github/copilot-instructions.md, add file or folder specific rules in .github/instructions/, and keep AGENTS.md at the repository root for standing instructions shared across AI tools and agents. GitHub’s docs treat these as separate layers, not duplicate ways to say the same thing.
If you want Copilot code review to check for domain rules, write those rules directly in the instruction files instead of burying them in prose. GitHub recommends short, self-contained statements that point to concrete expectations, like naming conventions, security checks, error handling, or testing requirements. Long essays are harder for the model to apply consistently.
A good repository-wide file is short and specific. For example, .github/copilot-instructions.md can tell Copilot to review backend changes for input validation, ask it to flag missing tests on public APIs, and require comments when a migration changes data shape. GitHub’s own example shows that these instructions apply to all Copilot code reviews in the repository.
Path-specific instructions are for places where the rules change by directory or file type. GitHub documents these under .github/instructions/**/*.instructions.md, and they are useful when the frontend, backend, and infrastructure code all need different review criteria. Keep each file narrow, because broad mixed rules make it harder to know why Copilot raised a comment.
AGENTS.md is the right place when you want a standing contract across AI tools, not just Copilot. GitHub says Copilot code review can use agent instructions from AGENTS.md, and its customization reference lists AGENTS.md as supported on GitHub.com for Copilot code review. That makes it a good place for team-wide conventions that should travel with the repo.
The part people get wrong is putting the important rule in the wrong layer. If a rule only matters for one folder, do not put it in the root file and hope Copilot sorts it out. If a rule must apply to all reviews, do not hide it in a path-specific file. GitHub’s docs separate repository-wide instructions, path-specific instructions, and agent instructions for a reason.
Another common miss is editing the instruction file on the base branch and expecting the current pull request to pick it up. GitHub says Copilot reads repository custom instructions, agent instructions, and skills from the head branch, not the base branch. If you want to test a review-rule change, add it to the feature branch and open or refresh the pull request there.
You can also control whether custom instructions are used at all. GitHub says custom instructions are enabled for Copilot code review by default, and repository settings let you turn them on or off under Copilot, then Code review. If reviews stop reflecting your files, check that setting before rewriting your instructions.
The setup steps are straightforward. First, decide which rules are universal, which are path-specific, and which belong in AGENTS.md. Second, add the files to the repository. Third, open a pull request that changes the same branch content you want reviewed, then ask Copilot for review or enable automatic review if your repository uses it.
When you want automatic review on new pushes, GitHub documents a separate setting in repository ruleset settings to review new pushes. That is useful when you want Copilot to re-check a branch after each update, but it is not the same thing as adding instructions. Instructions change what Copilot reads, while the review setting changes when it runs.
Use examples inside the instruction file when the rule is easy to misread. A short checklist paragraph works better than a vague directive like “be careful with auth.” Say what Copilot should look for, for example missing permission checks, unsafe deserialization, or unvalidated redirects. GitHub’s guidance for customization favors concrete, documented rules over general reminders.
A useful workflow is to start with one repository-wide file, then split out exceptions only when they become noisy. That keeps review behavior predictable and makes it easier to reason about comments. If a folder keeps triggering irrelevant feedback, move the special rule into a path-specific file instead of weakening the main instruction set.
If you already use Copilot cloud agent skills or MCP servers, keep in mind that Copilot code review can use those repository-configured tools when they are relevant to the review. GitHub documents this as part of the code review feature set, so review behavior can reflect both your instructions and whatever agent context the repo exposes.
For a repo that needs a clean baseline, the minimum useful setup is one root AGENTS.md, one .github/copilot-instructions.md, and one or two path-specific instruction files for code that has special rules. That gives you a clear place for shared behavior, a clear place for Copilot-specific review direction, and a clear place for exceptions.
If you want a place to keep the rest of the product workflow in one spot, DevConnect’s site describes its own testing and collaboration flow, and you can use that as a separate reference while you keep GitHub review rules in the repo. The key idea stays the same: put instructions where the tool actually reads them. https://devconnectplatform.com
The inconvenient part is maintenance. Instruction files are code-adjacent documents, so they need review, ownership, and occasional cleanup when the codebase changes. If the rules drift away from the repository’s actual patterns, Copilot starts giving stale comments, and the review file becomes background noise instead of leverage. That is the part teams usually notice late.
A concrete example helps. If your backend forbids raw SQL in request handlers, write that rule once in the backend-specific instructions, then mention the approved query layer and the files it applies to. If your frontend wants no direct API calls from presentation components, put that in the relevant path file, not in the global file.
If Copilot seems to ignore a rule, check four things in order: the file exists on the head branch, the path matches the files under review, custom instructions are enabled for the repository, and the wording is short enough to be operational. That sequence catches most failures without guessing at the model.
The clean rule is this: AGENTS.md sets shared agent behavior, .github/copilot-instructions.md sets repository-wide Copilot review guidance, .github/instructions/*.instructions.md set path-specific review guidance, and the repository setting decides whether custom instructions are active. Write each rule once, in the layer that owns it.
FAQ
Does Copilot code review read AGENTS.md on GitHub.com
Yes. GitHub’s support matrix lists AGENTS.md as supported for Copilot code review on GitHub.com. It also lists repository-wide and path-specific instruction files, so AGENTS.md is one supported layer, not the only one.
Should I put all review rules in AGENTS.md
No. Put shared agent rules there, then use .github/copilot-instructions.md for repository-wide Copilot review guidance and path-specific files for directory-specific rules. GitHub documents those as separate instruction types with different purposes.
Why does Copilot keep commenting on old issues after I changed the file Copilot may re-review from the head branch and can repeat earlier comments, even after they were resolved or downvoted. If the behavior is still wrong, verify the new instructions are on the branch being reviewed and that the repository custom-instructions setting is enabled.
Can I test a new instruction file without merging it first Yes. GitHub says Copilot uses the instructions and skills from the head branch when reviewing a pull request, so you can change the file in the same branch and see the result before merge.
What kind of wording works best in instruction files Short, self-contained statements work best. GitHub recommends documenting patterns and guidelines with references to specs and docs, plus concrete expectations for naming, testing, security, and error handling.
Frequently asked questions
Does Copilot code review read `AGENTS.md` on GitHub.com
Yes. GitHub’s support matrix lists `AGENTS.md` as supported for Copilot code review on GitHub.com, alongside repository-wide and path-specific instruction files.
Should I put all review rules in `AGENTS.md`
No. Use `AGENTS.md` for shared agent rules, `.github/copilot-instructions.md` for repository-wide Copilot review guidance, and path-specific files for exceptions.
Why does Copilot keep commenting on old issues after I changed the file
Copilot can repeat previous comments during re-review, and it reads instructions from the head branch. Check the branch, the repository setting, and the file wording.
Can I test a new instruction file without merging it first
Yes. Copilot reads the instructions from the head branch in the pull request, so you can test changes in the same branch before merge.
What kind of wording works best in instruction files
Short, concrete statements work best. GitHub recommends self-contained rules with specific expectations for testing, security, naming, and error handling.
Know someone stuck on this? Send them the answer.
Sources
Every link here was fetched and confirmed to resolve before this page went live.
- About GitHub Copilot code review - GitHub Docs
- Using GitHub Copilot code review on GitHub - GitHub Docs
- Using custom instructions to unlock the power of Copilot code review - GitHub Docs
- Support for different types of custom instructions - GitHub Docs
- Add custom instructions for Copilot - GitHub Docs
- Customize Copilot - GitHub Docs
Related questions
- Yes, if it runs inside your own network
- GitHub Copilot code review uses both skills and MCP
- GitHub Copilot code review uses branch instructions
Not the question you had?
Ask it. Every source gets fetched and checked before anything goes up, so it takes a day or two, and questions that cannot be answered honestly do not get a page at all.
Everyone here builds with AI, and says so
DevConnect is for developers who use AI and are honest about it. The interesting part is not that the code was generated, it is what you did with it afterwards.