Simple Markdown Files Boost Copilot's Context
A developer found that adding two markdown files, `copilot-instructions.md` and `copilot-prompts.md`, to a project significantly improves GitHub Copilot's contextual awareness in Visual Studio. By explicitly documenting project conventions and goals, the AI tool transformed from 'sometimes helpful' to a 'consistently reliable teammate.'
This technique of using `.github/copilot-instructions.md` is part of a broader practice known as "context engineering," which focuses on shaping and guiding AI assistants to produce more accurate and relevant output. Rather than just prompt engineering for a single query, this provides persistent, repository-wide directives on everything from architectural patterns and naming conventions to preferred libraries and API usage. GitHub Copilot's contextual understanding has evolved significantly from its initial version, which only considered the current file. Later enhancements introduced the "neighboring tabs" technique, which scans all open files in the IDE for relevant code snippets, and "Fill-in-the-Middle" (FIM), allowing the model to consider code both before and after the cursor's position. These markdown instruction files represent a more explicit and developer-controlled method of providing this crucial context. Beyond a single `copilot-instructions.md` file, developers can create a library of reusable `.prompt.md` files stored in a `.github/prompts/` directory. These are on-demand workflows for common tasks like scaffolding a new React component with specific testing patterns or generating release notes, invoked directly within the chat with a slash command. This standardizes repetitive tasks, directly improving developer experience and team consistency. The context provided to Copilot isn't limited to what's explicitly written in these files. The AI also considers "calculated context," where it automatically selects relevant files based on your prompt, and "implicit context" from your currently open and edited files. Mastering the interplay between these implicit and explicit forms of context is key to transforming the tool into a true pair programmer. This structured approach to AI guidance is becoming a core feature of modern development workflows. For engineering leaders, establishing these instruction files is a scalable way to enforce team standards and reduce the friction of onboarding new engineers, who can be guided by the AI on the repository's specific conventions. It treats AI context as a form of version-controlled, shareable documentation. The system is designed to be composable; for instance, a prompt file can be configured to run within the persona of a custom agent, which in turn can reference a set of instruction files. This layering allows for sophisticated, role-based AI assistance, such as a "Security Reviewer" agent that uses specific instructions to check for vulnerabilities. Looking ahead, the concept of context is expanding beyond the codebase. Microsoft is experimenting with "Work IQ," which connects Copilot to organizational knowledge from documents, emails, and meeting transcripts to answer questions about code ownership or original design specs. This aims to address the hard part of development: not writing the code, but understanding the history and decisions behind it.