We often treat AI coding assistants like GitHub Copilot as simple search engines: we ask a question, get an answer, and move on. But the most powerful way to use GitHub Copilot isn't to ask better questions, it's to give it a better memory. Think of it as VS Code AI customisation for your projects.
The One File That Makes Copilot 10x Smarter (And How to Automate It)
We often treat AI coding assistants like GitHub Copilot as simple search engines: we ask a question, get an answer, and move on. But the most powerful way to use GitHub Copilot isn't to ask better questions, it's to give it a better memory. Think of it as VS Code AI customisation for your projects.
VS Code allows you to create a 'brain' for your project using a simple markdown file called copilot-instructions.md. This file acts as a permanent context layer, ensuring every suggestion Copilot makes is aware of your architecture, tech stack, and little quirks. These are GitHub Copilot custom instructions.
The catch? Writing this documentation is tedious.
Here is the 'Meta-Prompt' hack to set this up in 30 seconds.
The Concept: 'Self-Documentation'
Instead of manually writing out your project's rules, we are going to use the AI to analyse the codebase and write its own instruction manual. It’s a technique called 'Context Bootstrapping'.
Think of it as teaching Copilot about your project's culture and unwritten rules, so it can act more like a senior developer who already knows the codebase. You aren't just teaching the AI; you are asking the AI to teach itself about you. This is how to improve AI coding assistant context.
Step 1: Create the File
In the root of your project, create a folder and file path: .github/copilot-instructions.md
(Note: You may need to enable 'Use Instruction Files' in your VS Code settings. This can be found under File > Preferences > Settings, then search for 'Copilot Instructions'.)
Step 2: The 'God Prompt'
Open your Copilot Chat (or Edits) window. We need a prompt that forces the AI to look at the 'Big Picture' architecture, workflows, and hidden conventions rather than just file syntax.
Copy and paste this prompt (based on the excellent workflow from the VS Code docs):
Analyse this codebase to generate or update
.github/copilot-instructions.mdfor guiding AI coding agents.Focus on discovering the essential knowledge that would help an AI agent be immediately productive in this codebase. Consider aspects like:
The 'Big Picture' Architecture: 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: Patterns that differ from common practices (e.g., 'we use Zod for validation, not Joi').
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/**,README.md}(do one glob search).Guidelines:
If
.github/copilot-instructions.mdexists, merge intelligently preserve valuable content while updating outdated sections.Write concise, actionable instructions (~20-50 lines).
Include specific examples from the codebase when describing patterns.
Avoid generic advice ('write tests') focus on THIS project's specific approaches.
Document only discoverable patterns, not aspirational practices.
Step 3: Refine and Save
The AI will generate a markdown file summarising your project. Read it. This is critical because the AI might hallucinate a pattern you don't actually follow (e.g., 'Always use TypeScript interfaces' when you actually use types).
Once you save this file, every future chat session will invisibly read this 'System Prompt' before answering you.
Here's a simple example of what your copilot-instructions.md file might look like:
# Project Conventions
* We use snake_case for all variable names.
* API endpoints should always return JSON.
* Error handling is done using try/catch blocks.
Why This Works
This transforms Copilot from a generic coding tool into a specialised team member.
Onboarding: It’s essentially an automated onboarding doc for robots.
Consistency: It stops the AI from using libraries you haven't installed.
Portability: You can check this file into Git, so your entire team gets the same 'smart' Copilot experience instantly.
Stop repeating yourself in every prompt. Let the AI read the manual.
Troubleshooting and Common Issues
Copilot isn't respecting the instructions: Ensure the 'Use Instruction Files' setting is enabled and that the file is located in the correct directory (
.github/copilot-instructions.md). Try restarting VS Code.The generated instructions are inaccurate: Carefully review the generated file and correct any inaccuracies. Refine the 'God Prompt' to guide the AI towards more accurate analysis.
The instructions are too generic: Add more specific examples and project-specific details to the 'God Prompt'. Encourage the AI to focus on the unique aspects of your codebase.
Advanced Configuration: Targeting Specific Directories
For more granular control, you can configure the applyTo property within your copilot.settings.json file. This allows you to specify which files or directories the custom instructions should apply to.
For example, if you only want the instructions to apply to files within the src directory, your copilot.settings.json would look like this:
{
"useInstructionFiles": true,
"applyTo": "src/**"
}This ensures that Copilot only considers the instructions when working on files under the src directory, providing more focused and relevant suggestions.
Hopefully, this guidance will help you get the most out of your AI coding assistant, transforming it from a simple tool into a powerful and personalised extension of your development workflow. Good luck!
