iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more
To give GitHub Copilot durable context about a codebase, add guidance to the repository: use .github/copilot-instructions.md for repository-wide rules, .github/instructions/ for rules tied to matching paths, and AGENTS.md for agent guidance where the relevant Copilot surface supports it. These mechanisms are specific to GitHub Copilot—not a universal standard for coding assistants—and support differs across IDEs and features.
What repository context can Copilot use?
GitHub documents three instruction-file approaches. They differ mainly in scope, so a project can use broad guidance for the whole repository and narrower rules for particular parts of it.
| File or location | Intended scope | How to use it |
|---|---|---|
.github/copilot-instructions.md |
Repository-wide | Put guidance here when it should apply broadly across the codebase. |
.github/instructions/*.instructions.md |
Matching paths | Use instruction files with an applyTo pattern to target relevant files or folders. |
AGENTS.md |
AI-agent guidance | Use for agent instructions in environments that support this file type; GitHub documents nearest-file precedence in its repository-instructions guidance. |
For the documented IDE workflow, GitHub says repository-wide and matching path-specific instructions are both used when relevant. That behavior should not be assumed for every Copilot feature or environment; consult GitHub’s custom-instruction support matrix before relying on a particular combination.
Recommended Free Tools
How should you organize instructions for different folders?
Keep generally applicable conventions in .github/copilot-instructions.md. Add a *.instructions.md file under .github/instructions/ when a subset of the repository needs distinct guidance, and define an applyTo pattern for the paths it covers. For example, a project might keep broad architecture and validation guidance in the repository-wide file while a targeted file describes conventions for one folder. This is an organizational example, not a promise that every Copilot surface applies both files.
#1 Best Overall
GitHub’s IDE documentation explains the path-specific setup and combined use with repository instructions in its guide to adding repository instructions in your IDE. Check the support matrix for the IDE and Copilot feature your team actually uses.
What belongs in useful project guidance?
GitHub’s project-improvement tutorial recommends instructions that orient Copilot to the codebase and its working practices. Include concrete, current details that help someone make and validate a change:
- What the software does: a concise summary of the product or service and the repository’s purpose.
- How the repository is organized: identify important directories and what belongs in them.
- How to build and validate changes: list the applicable build, formatting, linting, and test practices.
- Contribution and merge requirements: state required checks or project-specific contribution expectations.
- Technical principles: document architectural constraints and conventions that materially affect implementation choices.
Before adding new rules, inspect what is already in place and confirm it is accurate. GitHub presents these items as practical guidance, not as a guarantee of better results. Its tutorial, Using GitHub Copilot cloud agent to improve a project, provides the underlying checklist.
Does every Copilot feature support the same files?
No. GitHub’s support documentation distinguishes among Copilot experiences, including GitHub.com Copilot Chat, cloud agent, code review, and IDE or other environments. File types and behavior can vary by surface. The documentation does not support treating one setup as a universal configuration for all of them.
Rank #3
Use the official support matrix to verify the file types for the specific product surface and environment you plan to use. Recheck it when changing IDEs or workflows because documented availability can change.
Do custom instructions guarantee that Copilot follows project rules?
No. GitHub explains that custom instructions are added to relevant requests, but Copilot may not follow them in exactly the same way every time because AI behavior is nondeterministic. Instructions provide context; they do not guarantee exact adherence, eliminate errors, or replace review and validation. GitHub states this limitation in About customizing GitHub Copilot responses.
Rank #4
Keep guidance focused and check generated changes through the project’s normal build, tests, review, and other relevant validation steps.
When do agents or MCP servers fit?
Instruction files are one part of project customization, not a complete answer to every integration need. GitHub’s customization overview also describes specialized agents and MCP server configuration for selected cloud-agent and code-review use cases. MCP servers can provide Copilot cloud agent and code review with access to external tools and data in supported contexts. Their availability and setup depend on the feature, so consult GitHub’s Copilot customization overview rather than assuming they apply everywhere.
Quick Recap
Best Value
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

