| title | Adding repository custom instructions | ||
|---|---|---|---|
| shortTitle | Add repository instructions | ||
| intro | Create repository custom instructions files that give {% data variables.product.prodname_copilot_short %} additional context on how to understand your project and how to build, test and validate its changes. | ||
| versions |
|
||
| topics |
|
||
| contentType | how-tos |
This version of this article is for using repository custom instructions with the {% data variables.product.prodname_copilot %} CLI. Click the tabs above for instructions on using custom instructions in other environments.
{% data variables.product.prodname_copilot %} supports three types of repository custom instructions.
-
Repository-wide custom instructions, which apply to all requests made in the context of a repository.
These are specified in a
copilot-instructions.mdfile in the.githubdirectory of the repository. See Creating repository-wide custom instructions. -
Path-specific custom instructions, which apply to requests made in the context of files that match a specified path.
These are specified in one or more
NAME.instructions.mdfiles within or below the.github/instructionsdirectory in the repository. See Creating path-specific custom instructions.If the path you specify matches a file that {% data variables.product.prodname_copilot_short %} is working on, and a repository-wide custom instructions file also exists, then the instructions from both files are used. You should avoid potential conflicts between instructions as {% data variables.product.prodname_copilot_short %}'s choice between conflicting instructions is non-deterministic.
-
Agent instructions are used by AI agents.
{% data reusables.copilot.custom-instructions-agents %}
Alternatively, you can use a single
CLAUDE.mdorGEMINI.mdfile stored in the root of the repository.
-
In the root of your repository, create a file named
.github/copilot-instructions.md.Create the
.githubdirectory if it does not already exist. -
Add natural language instructions to the file, in Markdown format.
Whitespace between instructions is ignored, so the instructions can be written as a single paragraph, each on a new line, or separated by blank lines for legibility.
{% data reusables.copilot.custom-instructions-path %}
{% data reusables.copilot.custom-instructions-note %}