A curated list of awesome custom instructions for GitHub Copilot to enhance your coding experience.
GitHub Copilot is an AI pair programmer that helps you write better code. Custom instructions allow you to tailor Copilot's behavior to your specific needs and preferences.
Custom instructions allow you to enhance GitHub Copilot's responses by providing persistent context about your development preferences and requirements. These instructions automatically apply to all interactions with Copilot, eliminating the need to repeat context in every query. They can be configured for specific purposes:
- Code Generation: Define coding style preferences, naming conventions, and implementation patterns
- Test Generation: Specify testing frameworks and methodologies
- Code Review: Set criteria and focus areas for code analysis
- Commit Messages: Define commit message format and content requirements
Custom instructions are applied automatically in Chat view, Quick Chat, and Inline Chat, making them a powerful tool for maintaining consistency across your development workflow.
- Open VS Code settings.json file
- Configure custom instructions using
github.copilot.chat.codeGeneration.instructions
- Instructions can be defined directly in settings or referenced from external files
Example settings.json configuration:
"github.copilot.chat.codeGeneration.instructions": [
{
"text": "Always add a comment: 'Generated by Copilot'."
},
{
"text": "In TypeScript always use underscore for private field names."
},
{
"file": "code-style.md"
}
]
Example code-style.md:
Always use React functional components.
Always add comments.
Note:
- Instructions can be defined at User or Workspace level
- You can specify language-specific instructions
- External files can be referenced using the
file
property - Multiple instructions can be combined in a single configuration
- Create a
.github/copilot-instructions.md
file at the root of your workspace
mkdir -p .github
touch .github/copilot-instructions.md
-
Enable instruction files in VS Code settings:
- Set
github.copilot.chat.codeGeneration.useInstructionFiles
totrue
- Set
-
Add your custom instructions to the file using Markdown format
Note:
- Instructions can be written as single paragraphs or separated by blank lines
- Whitespace between instructions is ignored
- The file works in both VS Code and Visual Studio
- If you have instructions in both settings and the file, Copilot will combine them
Tip: In VS Code's Explorer view, you can create the folder and file in one step by typing the full path as the file name.
Contributions are welcome! To add a new custom instruction:
- Fork this repository
- Create a new markdown file in the appropriate category under
instructions/
- Follow the template in
TEMPLATE.md
- Add your entry to the README.md
- Submit a pull request
Please ensure your contribution is original and includes:
- Clear description of the instruction's purpose
- Example usage
- Any relevant context or limitations
- Proper formatting and organization