What this thread does
The problem
One big instructions file means the code reviewer, the cloud agent and chat all read the same rules, including ones that only make sense for one folder or one job. GitHub's docs describe how to split them.
The layers
- Repository-wide:
.github/copilot-instructions.md(Markdown). - Path-specific:
NAME.instructions.mdfiles in.github/instructions/(subfolders allowed). Each starts with frontmatter containingapplyToand glob patterns, for example for TypeScript files. If a repository-wide file also exists, both apply. - Agent instructions:
AGENTS.mdanywhere in the repo; the nearest one in the tree wins. A singleCLAUDE.mdorGEMINI.mdin the root can be used instead. - Keep a file away from one feature: add
excludeAgentto the frontmatter with"code-review"or"cloud-agent". Without it both features read the file.
Where they apply and in what order
Path-specific instructions work for the cloud agent and code review on GitHub.com. In Copilot Chat on github.com attach the repository; a used instructions file shows in the references list. For code review, Copilot reads instructions from the pull request's head branch, not the base, and the feature can be switched on or off under Settings, Copilot, Code review. Priority is personal, then repository, then organization instructions, but all relevant sets are sent, so avoid contradictions. The docs state no code-review length limit; their only size advice is to keep a generated onboarding file under about two pages. The page does not describe the CLI or IDE behavior, so check their own guides.
Practical split
Put language- or folder-specific style in .instructions.md with a tight applyTo; put review-only checks ("flag missing tests for public functions") in a file with excludeAgent: "cloud-agent"; put build and test commands in AGENTS.md. Test on a throwaway PR and check the references list.
Related: teach-ai-code-reviewer-your-team-rules, agents-md-one-instructions-file-for-all-agents.
Sources
- GitHub docs "Add repository custom instructions" (<https://docs.github.com/en/copilot/how-tos/configure-custom-instructions/add-repository-instructions>), read directly. Checked: the three layers, applyTo and excludeAgent values, both files applying together, AGENTS.md nearest wins, CLAUDE.md or GEMINI.md in the root, path-specific support limited to the cloud agent and code review on GitHub.com, the head-branch rule, the code review toggle, the priority order, the References list, and that the two-page advice appears only in the onboarding prompt.
- Not checked here, CLI and IDE behaviour (the page does not cover it), the related threads named, and the practical split at the end (my suggestion, untested).
Started from a post by @GitHub, packaged by the editor. Original post