Copilot code review keeps applying your frontend style guide to Go files — which Copilot instruction files explain it, and how do you scope the guide?
answer
- review reads more than one file
- always-on versus path-matched
- a narrower applyTo glob
- excludeAgent picks one consumer
- head branch, not base
basics
~10 sOn GitHub.com, Copilot code review sends the repository-wide file and any agent files (AGENTS.md, CLAUDE.md, GEMINI.md, REVIEW.md) with every review. Move the guide into a path-specific .instructions.md whose applyTo matches only frontend files.
solid answer
~30 sOn GitHub.com, Copilot code review reads `.github/copilot-instructions.md` for every review, path-specific `.github/instructions/**/*.instructions.md` files whose `applyTo` matches the changed files, agent instructions, and organization instructions. Its docs add that it also reads `CLAUDE.md`, `GEMINI.md` and `REVIEW.md` if they exist. A frontend guide in any always-on file, or in a path-specific file with a glob like `**`, therefore reaches Go reviews. Move it into something like `.github/instructions/frontend.instructions.md` with `applyTo: "**/*.ts,**/*.tsx"`; add `excludeAgent: "cloud-agent"` if only reviews should see it. Review reads instructions from the pull request's head branch, so you can test the fix in the same pull request.
code
markdown · 9 lines---
applyTo: "web/**/*.ts,web/**/*.tsx"
excludeAgent: "cloud-agent"
---
# Frontend review checklist
- Components use PascalCase file names.
- No inline styles; use the design tokens in `web/theme`.
- Every interactive element has an accessible label.go deeper
Recall that Copilot code review reads instruction files from the repository and that path-specific files use an applyTo glob to limit where rules apply.
Explain which files a GitHub.com review reads, why always-on files reach every review, and how applyTo plus excludeAgent narrow both the files and the consumer.
Show the diagnosis order: locate the source file, narrow the glob, pick the consumer with excludeAgent, and verify on the head branch before merging, knowing VS Code reviews ignore path files.
Weigh noisy automated review against reviewer trust; decide which rules belong in always-on files, which in scoped files, and which need real enforcement in CI instead of instructions.
## The symptom and what it tells you Copilot code review leaves comments on a pull request based on the diff and on any **custom instructions** it is given. When it flags a Go file for violating, say, a component naming rule, the review is not confused about the language: some instruction file that carries frontend rules was sent with a review that touched Go code. The fix is to find which file and narrow it. ## What Copilot code review reads on GitHub.com | Source | When it is applied to a review | |---|---| | `.github/copilot-instructions.md` | Every review in the repository | | `.github/instructions/**/*.instructions.md` | When the changed files match the file's `applyTo` | | `AGENTS.md` | Automatically; the code review page describes it at the repository root | | `CLAUDE.md`, `GEMINI.md`, `REVIEW.md` | Read as instructions if they exist | | Organization instructions | Set by organization owners; apply to members' reviews | So a style guide pasted into the repository-wide file, or into an always-read agent file such as `AGENTS.md` or `REVIEW.md`, rides along with every review. A path-specific file can cause the same problem when its glob is too broad, for example `applyTo: "**"`. ## Scoping the guide 1. **Find the source.** Search the always-on files listed above for the frontend rules, and check every `.instructions.md` file's `applyTo`. 2. **Move frontend rules into a path-specific file**, for example `.github/instructions/frontend.instructions.md`, with a glob that matches only frontend code: `applyTo: "**/*.ts,**/*.tsx"` or `"web/**"`. Comma-separated patterns are allowed. 3. **Keep the repository-wide file for rules that are true everywhere**, such as error-handling or security expectations. 4. **Decide which consumer should see the file.** By default both Copilot code review and Copilot cloud agent use a path-specific file. Add `excludeAgent: "cloud-agent"` to keep a review-only checklist away from the agent, or `excludeAgent: "code-review"` for implementation notes that should not become review comments. 5. **Test it in the same pull request.** When reviewing, Copilot reads repository instructions, agent instructions and agent skills from the **head branch**, not the base branch, so the corrected file takes effect on the pull request that changes it, before it is merged. ## A worked example Suppose `.github/copilot-instructions.md` holds three lines about error handling and forty lines of the frontend style guide, and a pull request changes only `cmd/server/main.go`. Every one of those forty lines is sent with the review, so comments about component names on Go code are the expected result, not a malfunction. After the fix: - `.github/copilot-instructions.md` keeps the three error-handling lines that are true for every language. - `.github/instructions/frontend-review.instructions.md` holds the style guide with `applyTo: "web/**/*.ts,web/**/*.tsx"`. - A Go pull request now receives only the error-handling lines; a pull request touching `web/` receives both files. If the comments persist after the move, check the agent files next: a copy of the guide left in `AGENTS.md` or `REVIEW.md` keeps reaching every review. ## What the switches do not do - `excludeAgent` names a **consumer**, not files: `"code-review"` hides the instructions file from reviews; it does not stop Go files from being reviewed. - The repository setting **Use custom instructions when reviewing pull requests** (under the repository's Copilot code review settings, enabled by default) turns off custom instructions for **all** reviews in the repository. It is a blunt diagnostic, not a scoping tool. - Path scoping helps reviews on GitHub.com. According to GitHub's support table, code review run from VS Code reads only the repository-wide file, so a path-specific file does not narrow a review there; VS Code also offers a separate setting, `github.copilot.chat.reviewSelection.instructions`, for reviewing selected code. ## Why this is the cheapest fix Instructions steer reviews but do not enforce anything; Copilot may not follow them identically every time. Scoping keeps each review's prompt relevant: fewer unrelated rules means fewer false comments and less noise for reviewers. Review comments themselves, their types and whether they count toward approvals, belong to the review workflow rather than to the instruction files.
- You fix the glob in a pull request, but your colleague says the change only takes effect after merging. Are they right?No. When reviewing a pull request, Copilot reads repository custom instructions, agent instructions and agent skills from the head branch, the branch with your changes. A corrected .instructions.md therefore applies to the review of the very pull request that changes it, which lets you test the scoping before merging.
- Your team keeps its review checklist in REVIEW.md at the root. What happens to that checklist when Copilot reviews a Go-only pull request?It is still read. Copilot code review's docs say it reads CLAUDE.md, GEMINI.md and REVIEW.md if they exist, without any applyTo scoping. Rules that apply only to some files belong in a path-specific .instructions.md file with a matching glob instead.
- Copilot code review reads only .github/copilot-instructions.md and nothing else.
- excludeAgent: "code-review" stops Copilot from reviewing the matching files.
- Instruction fixes only reach reviews after the pull request is merged into the base branch.
- Without excludeAgent, a path-specific file is read by code review only.
- Turning off custom instructions for reviews is the right way to scope one guide.