What are Custom Instructions?
Custom instructions are markdown files that provide context-aware guidance to GitHub Copilot. They automatically apply coding standards, best practices, and project-specific conventions when working with files that match specific patterns.Instructions help GitHub Copilot understand your project’s conventions without needing to repeat them in every prompt.
How Instructions Work
Instructions use file pattern matching to automatically activate when you’re working with specific file types. When an instruction file matches your current context, its guidelines are applied to Copilot’s suggestions.Example Flow
- You open a file:
components/Button.tsx - Copilot checks for instructions that match
**/*.tsx - The React and TypeScript instructions automatically apply
- Copilot generates code following your project’s React patterns
Instruction File Format
Every instruction file follows a standard format with YAML frontmatter and markdown content.Required Frontmatter
A clear, concise description of the instruction’s purpose. Must be wrapped in single quotes.
File patterns that trigger this instruction. Supports glob patterns and comma-separated values.
File Content
After the frontmatter, write your instructions in markdown. Include:- Coding standards - Naming conventions, formatting rules
- Best practices - Recommended patterns and approaches
- Project structure - How to organize code and files
- Common patterns - Reusable code examples
- Testing guidelines - How to write and structure tests
Understanding applyTo Patterns
TheapplyTo field uses glob patterns to match files. Here are common patterns:
Single File Extension
Single File Extension
Multiple Extensions
Multiple Extensions
Specific File Types
Specific File Types
All Files
All Files
Infrastructure as Code
Infrastructure as Code
Pattern Matching Rules
**- Matches any directory at any level*- Matches any characters except directory separator*.ext- Matches files with specific extension- Multiple patterns are comma-separated
Real-World Examples
C# Development Instructions
React Development Instructions
Accessibility Instructions
Installation and Usage
Using VS Code Install Buttons
Most instructions in the Awesome GitHub Copilot repository include install buttons:Manual Installation
You can also manually add instructions to your project:Global Instructions
For workspace-wide instructions, use the special file:Best Practices for Writing Instructions
Be Specific
Provide concrete examples and clear rules rather than vague guidelines
Stay Focused
Keep instructions relevant to the file types they target
Use Examples
Include code snippets showing the preferred patterns
Explain Why
Include rationale for important decisions and patterns
Structure Your Instructions
Good instructions typically include:- Project Context - Technology stack, versions, frameworks
- Development Standards - Architecture, patterns, conventions
- Code Style - Formatting, naming, organization
- Testing Guidelines - How to write and structure tests
- Security & Performance - Important considerations
- Examples - Real code showing preferred patterns
Common Use Cases
Framework-Specific Standards
Framework-Specific Standards
Apply React, Angular, Vue, or other framework best practices automatically when working with those files.
Language Conventions
Language Conventions
Enforce language-specific patterns like C# naming conventions, Python PEP 8 compliance, or Java code style.
Infrastructure as Code
Infrastructure as Code
Guide Terraform, Bicep, or CloudFormation generation with security and maintainability standards.
Testing Patterns
Testing Patterns
Ensure consistent test structure, naming, and coverage requirements across your codebase.
Accessibility Requirements
Accessibility Requirements
Apply WCAG compliance and accessibility best practices to UI code automatically.
Security Standards
Security Standards
Enforce security patterns, input validation, and OWASP guidelines in your code.
Next Steps
Browse the Catalog
Explore available instructions organized by technology
Create Your Own
Learn how to create custom instructions for your projects