Custom instructions for GitHub Copilot
- https://docs.github.com/en/copilot/how-tos/custom-instructions/adding-repository-custom-instructions-for-github-copilot
MyProject
├── .git
│ ├── branches
│ ├── COMMIT_EDITMSG
│ ...
├── .github
│ ├── copilot-instructions.md
│ └── instructions
│ ├── javascript.instructions.md
│ ├── landing-page.instructions.md
│ ├── markdown.instructions.md
│ ├── mongodb.instructions.md
│ ├── nextjs.instructions.md
│ ├── react.instructions.md
│ └── tailwindcss.instructions.md
Type of instructions files
https://code.visualstudio.com/docs/copilot/customization/custom-instructions#_type-of-instructions-files
VS Code supports multiple types of Markdown-based instructions files. If you have multiple types of instructions files in your project, VS Code combines and adds them to the chat context, no specific order is guaranteed.
-
A single
.github/copilot-instructions.mdfile- Automatically applies to all chat requests in the workspace
- Stored within the workspace
-
One or more
.instructions.mdfiles- Conditionally apply instructions based on file type or location by using glob patterns
- Stored in the workspace or user profile
-
One or more
AGENTS.mdfiles- Useful if you work with multiple AI agents in your workspace
- Automatically applies to all chat requests in the workspace or to specific subfolders (experimental)
- Stored in the root of the workspace or in subfolders (experimental)
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.
To reference specific context in your instructions, such as files or URLs, you can use Markdown links.
Using a single .github/copilot-instructions.md file
# MardkdownWhen working with markdown files, do the following:- Use reference link instead of inline link.- Don't add link in the headers.
Using one or more .instructions.md files
You can split copilot-instructions.md into multiple files. Create a .github/instructions folder and place your instructions files there. GitHub Copilot will automatically load all *.instructions.md files in that folder.
You can name the instructions file anything you like, such as javascript.instructions.md, as long as you place it in the .github/instructions folder.
Important guidelines:
-
Do not reference other files or locations - keep all necessary information within the instructions file itself, since the "pre-prompt" does not collect resources externally.
-
When working with multiple files:
-
Do not duplicate content or list items more than once, as this will cause the AI to malfunction.
-
Do not include conflicting rules; conflicting instructions will lead to unpredictable results.
-
Do keep instructions concise and clear, avoiding ambiguity. Leaving decisions open to the AI can result in unreliable and inconsistent outputs due to inherent randomness.
-