If you are not using custom instructions with GitHub Copilot, than this post will maybe help to finally get started. Writing your own set of custom instructions can be a challenge and although multiple examples are available, it still can be a challenge coming up with the right set of instructions.
But what if we can let GitHub Copilot create the instructions for us? Let’s find out how…
Why custom instructions?
Custom instructions in GitHub Copilot can significantly improve your coding experience and productivity in several key ways:
- Code quality and consistency Custom instructions help ensure Copilot generates code that follows your specific style guidelines, naming conventions, and architectural patterns. Instead of getting generic suggestions, you'll receive code that matches your project's existing standards and practices.
- Context awareness By providing instructions about your tech stack, frameworks, and project structure, Copilot can make more relevant suggestions. For example, telling it you're using TypeScript with React and specific libraries will result in more accurate completions.
- Reduced manual editing Well-crafted instructions mean less time spent modifying Copilot's suggestions. The AI will generate code closer to what you actually need, reducing the back-and-forth of tweaking suggestions to fit your requirements.
- Domain-specific knowledge If you work in specialized domains (healthcare, finance, government), custom instructions can incorporate industry-specific practices, compliance requirements, or domain terminology that generic AI responses might miss.
- Personal preferences You can specify preferences for things like error handling patterns, logging approaches, testing methodologies, or even whether you prefer functional or object-oriented programming styles.
- Project-specific context Instructions can include information about your current project's goals, constraints, or unique requirements that would be impossible for Copilot to infer from code alone.
The time invested in setting up thoughtful custom instructions typically pays off quickly through more accurate, useful, and immediately applicable code suggestions.
Let GitHub Copilot create custom instructions
To generate custom instructions, you need to take the following steps:
- Open your solution or project in VS Code
- Click on to the Settings icon above the GitHub Copilot Chat window:
- Select Generate Instructions from the context menu:
- Copilot generates the following prompt and starts working on it:
Analyze this codebase to generate or update `.github/copilot-instructions.md` for guiding AI coding agents.
Focus on discovering the essential knowledge that would help an AI agents be immediately productive in this codebase. Consider aspects like:
- The "big picture" architecture that requires reading multiple files to understand - major components, service boundaries, data flows, and the "why" behind structural decisions
- Critical developer workflows (builds, tests, debugging) especially commands that aren't obvious from file inspection alone
- Project-specific conventions and patterns that differ from common practices
- Integration points, external dependencies, and cross-component communication patterns
Source existing AI conventions from `**/{.github/copilot-instructions.md,AGENT.md,AGENTS.md,CLAUDE.md,.cursorrules,.windsurfrules,.clinerules,.cursor/rules/**,.windsurf/rules/**,.clinerules/**,README.md}` (do one glob search).
Guidelines (read more at https://aka.ms/vscode-instructions-docs):
- If `.github/copilot-instructions.md` exists, merge intelligently - preserve valuable content while updating outdated sections
- Write concise, actionable instructions (~20-50 lines) using markdown structure
- Include specific examples from the codebase when describing patterns
- Avoid generic advice ("write tests", "handle errors") - focus on THIS project's specific approaches
- Document only discoverable patterns, not aspirational practices
- Reference key files/directories that exemplify important patterns
Update `.github/copilot-instructions.md` for the user, then ask for feedback on any unclear or incomplete sections to iterate.
- After analyzing the codebase, you get your instructions file. Don't forget to review and tweak it further.
- Thank you Copilot!
More information
Configure custom instructions for GitHub Copilot - GitHub Docs
GitHub Copilot - Custom Instructions
Finding inspiration for good custom instructions for GitHub Copilot
Custom instructions when using GitHub Copilot
Context is key–Add instructions to your copilot-instructions.md file