How to Add Custom GitHub Copilot Instructions
A guide on how to add custom instructions to GitHub Copilot in VS Code to get more specific and relevant suggestions.
You can give GitHub Copilot custom instructions to make its suggestions better for your project. This is useful when you have specific coding styles or rules you want it to follow.
Create the Instructions File
The easiest way is to create a special file in your project that Copilot will read automatically.
- Create a folder named
.github
at the root of your project if it doesn’t exist. - Inside
.github
, create a file namedcopilot-instructions.md
.
Write Your Instructions
Open copilot-instructions.md
and write down your rules using Markdown. You can
tell it about your coding conventions, frameworks you’re using, or anything else
that would help it generate better code.
Here is a simple example:
# Project general coding standards
## Naming Conventions
- Use PascalCase for component names, interfaces, and type aliases.
- Use camelCase for variables, functions, and methods.
## Error Handling
- Use try/catch blocks for async operations.
Copilot will now use these instructions when you ask it for help. You don’t need to repeat these rules every time, as they will be automatically referenced in each GitHub Copilot chat session.