/icons/vscode-config.svg Copilot Custom Instructions
Category: GitHub Copilot
Overview
Configure GitHub Copilot to use custom instructions, reusable prompts, and project-specific guidelines. This setup allows you to tailor Copilot’s behavior to match your team’s coding standards, architecture patterns, and best practices.
What’s Included
Custom Instructions
- Instruction files enabled: Copilot automatically reads
.github/instructions/*.instructions.md - Instruction location: Configure where VS Code looks for instruction files
- Code generation context: Instructions are automatically added to relevant chat requests
Reusable Prompts
- Prompt files enabled: Create reusable prompts in
.github/prompts/*.md - Prompt location: Configurable prompt file directories
- Quick access: Reference prompts with
#filesyntax in chat
Agent Configuration
- AGENTS.md support: Use
AGENTS.mdin workspace root to define project context - Automatic discovery: Copilot finds and uses agent definitions automatically
Commit & PR Generation
- Custom commit instructions: Add project-specific guidelines for commit messages
- PR description guidelines: Tailor pull request descriptions to your workflow
- Code review instructions: Customize how Copilot reviews your code selections
Setting Up Instructions
1. Create Instruction Files
Create .github/instructions/ directory in your workspace:
mkdir -p .github/instructions
2. Add Instruction Files
Example: .github/instructions/typescript.instructions.md
---
applyTo: "**/*.ts"
---
# TypeScript Standards
- Always use strict mode
- Prefer interfaces over types for object shapes
- Use explicit return types on functions
- No 'any' types without justification
3. Create Reusable Prompts
Example: .github/prompts/test-generation.md
Generate comprehensive unit tests for the selected code including:
- Happy path scenarios
- Edge cases
- Error handling
- Mock external dependencies
Usage Tips
- Scope instructions: Use
applyTofrontmatter to target specific files - Team consistency: Commit instruction files to version control
- Prompt library: Build a library of reusable prompts for common tasks
- Review customization: Add code review criteria specific to your project
Example Instruction Categories
- Code style: Formatting, naming conventions, import order
- Architecture: Component structure, state management patterns
- Testing: Test coverage requirements, testing libraries
- Documentation: JSDoc standards, README templates
- Security: Authentication patterns, data validation
Best For
- Teams with established coding standards
- Projects with specific architectural patterns
- Organizations with compliance requirements
- Developers who want consistent AI behavior across projects
Settings JSON
{
"github.copilot.chat.codeGeneration.useInstructionFiles": true,
"chat.instructionsFilesLocations": {
".github/instructions": true
},
"chat.promptFiles": true,
"chat.promptFilesLocations": {
".github/prompts": true
},
"chat.useAgentsMdFile": true,
"github.copilot.chat.commitMessageGeneration.instructions": [],
"github.copilot.chat.pullRequestDescriptionGeneration.instructions": [],
"github.copilot.chat.reviewSelection.enabled": true,
"github.copilot.chat.reviewSelection.instructions": []
}