Home › Rules › copilot-instructions.md examples
copilot-instructions.md examples: 7 copy-paste GitHub Copilot instruction files
Short answer: create a file called .github/copilot-instructions.md in your repo and write plain-English instructions in it: what the project is, the tools it uses, how to build and test it, and your rules. Copilot adds it to requests made in that repository automatically. For rules that only apply to some files, add .github/instructions/NAME.instructions.md files with an applyTo line. Copy one of the examples below and edit the details.
The 3 kinds of Copilot instruction files
| File | Where | Applies to |
|---|---|---|
| Repository-wide | .github/copilot-instructions.md | Every request in this repository |
| Path-specific | .github/instructions/NAME.instructions.md (name must end in .instructions.md) | Only files matching its applyTo pattern. If the repo-wide file also exists, both are used |
| Agent instructions | AGENTS.md anywhere (the nearest one wins), or a single CLAUDE.md or GEMINI.md in the root | AI agents, like Copilot cloud agent |
Repository-wide examples
GitHub's advice: keep instructions short, self-contained statements that apply to most requests, because the file is sent with every chat message. Cover what the project is, your coding standards, and the tools and versions you use.
1. Next.js + Supabase web app
# Project overview
A habit tracker web app for beginners. Users sign up, add habits and tick them off each day.
Built with Next.js (App Router), TypeScript, Tailwind CSS and Supabase (database and auth).
## How to work in this repo
- Work in small steps. After each change, tell me how to test it in the browser.
- Ask before changing the database schema, auth or anything to do with payments.
- Never put secret keys in front-end code. Only NEXT_PUBLIC_ variables may be used in the browser.
- Explain errors in plain English before fixing them.
## Coding standards
- TypeScript for all new files. Function components only.
- Reuse components in src/components before creating new ones.
- Use Tailwind classes. No inline styles.
## Build and test
- Install: npm install
- Run locally: npm run dev
- Check before committing: npm run lint and npm run build
2. Python script
# Project overview
A Python script that reads a CSV of orders and emails a daily summary.
Python 3.12. Dependencies are in requirements.txt.
## Rules
- Keep it as a simple script. No classes unless I ask.
- Read settings and passwords from environment variables, never hard-code them.
- Every function gets a one-line docstring in plain English.
- Print clear messages when something goes wrong, saying which row or file caused it.
## Run and test
- Install: pip install -r requirements.txt
- Run: python main.py --dry-run (prints the email instead of sending it)
- Test: pytest
3. Simple landing page (no build step)
# Project overview
A one-page landing site for a local dog-grooming business. Plain HTML, Tailwind via CDN, no build step.
## Rules
- Keep everything in index.html and styles.css. Don't add a framework.
- Mobile first: every section must look right at 375px wide.
- Every image needs alt text. Use one h1 on the page.
- The contact form posts to the existing form service URL. Don't change it.
- Keep the page fast: no new scripts or fonts without asking.
Want one for your exact project type? The free rules generator writes a Copilot instructions file (or AGENTS.md, CLAUDE.md or a Cursor rule) in a few clicks.
Path-specific examples (.instructions.md)
Start the file with an applyTo line that says which files it covers. Separate several patterns with commas. **/*.ts means every .ts file in every folder; src/**/*.py means every .py file inside src.
4. Tests
---
applyTo: "**/*.test.ts,**/*.test.tsx"
---
- Use Vitest and React Testing Library, the same as the existing tests.
- Test what the user sees and does, not internal state.
- One behavior per test, with a name that reads like a sentence.
- Never delete or skip a failing test to make the suite pass. Tell me instead.
5. Database migrations
---
applyTo: "supabase/migrations/**"
---
- Every migration must be safe to run once on a database that already has real users.
- Never drop a table or column, or turn off row-level security, without saying so in plain English first.
- Every new table gets row-level security turned on, with a policy so users can only see their own rows.
6. React components
---
applyTo: "src/components/**/*.tsx"
---
- One component per file, named the same as the file.
- Keep components under 150 lines; split anything bigger.
- Buttons and links need a visible focus style and a clear label.
7. Code review only
---
applyTo: "**"
excludeAgent: "cloud-agent"
---
When reviewing a pull request, check these first:
- Secret keys, tokens or passwords in the code or in front-end environment variables.
- Database changes that remove data or turn off row-level security.
- New pages with no title tag or meta description.
- Error messages that would confuse a non-technical user.
excludeAgent: "cloud-agent" means only Copilot code review uses this file; excludeAgent: "code-review" does the opposite. Leave it out and both use it. Copilot code review reads instructions from the branch with your changes, so you can test edits to them in the same pull request.
Where each file works
Support depends on where you use Copilot. From GitHub's support table:
| Where | copilot-instructions.md | .instructions.md | AGENTS.md |
|---|---|---|---|
| Copilot Chat on GitHub.com | Yes | No | No |
| Copilot cloud agent | Yes | Yes | Yes (also CLAUDE.md, GEMINI.md) |
| Copilot code review on GitHub.com | Yes | Yes | Yes |
| Copilot Chat in VS Code | Yes | Yes | Yes |
| Copilot Chat in Visual Studio | Yes | Yes | No |
Check GitHub's support table (in the sources) for JetBrains, Xcode, Eclipse and the Copilot CLI.
copilot-instructions.md vs AGENTS.md
If you only use Copilot, .github/copilot-instructions.md works in the most places. If you also use Cursor, Codex or Claude Code, an AGENTS.md in the root is read by all of them, and Copilot's agent and VS Code read it too. Many people keep both with the same core rules. GitHub's docs ask you to avoid conflicting instructions across files. On GitHub.com, when several apply, the order is: your personal instructions, then path-specific, then copilot-instructions.md, then AGENTS.md, then your organization's. More: every rules file format and AGENTS.md vs CLAUDE.md.
Tips that actually help
- Write the build and test commands down. GitHub's own generator prompt focuses on these, so Copilot doesn't have to guess and fail.
- Avoid instructions GitHub says may not work, like "follow the style guide in another repo", "answer like a friendly colleague", or strict length limits on every answer.
- Let Copilot write the first draft. On GitHub you can ask Copilot cloud agent (at github.com/copilot/agents) to create the file for you as a pull request, using a prompt from GitHub's docs. Then trim it.
- Check it's being used. In Copilot Chat, open the list of references at the top of a reply and look for
.github/copilot-instructions.md. - Copilot may not follow them perfectly every time. GitHub says so itself. Short, specific rules get followed most.
Best value
Get all 5 kits for $25 with 30% off: code WELCOME30 at checkout (through Nov 30, 2026)
An instructions file tells Copilot how to code. The kits tell it what to build and in what order, with copy-paste prompts and stop-and-test checkpoints: a small game, a Discord bot, an email-triage agent, an MVP, or a cleanup of messy code.
Get all 5 kits for $25 → See what's in each kit
$25 instead of $39 for the five kits bought separately; WELCOME30 takes 30% off that at checkout ($17.50). Instant download from Gumroad. 7-day refund, no questions asked.
Related
- Every rules file format (AGENTS.md, CLAUDE.md, .mdc, Copilot)
- Free rules file generator
- Cursor rules examples (10 copy-paste .mdc rules)
- CLAUDE.md examples
- Vibe coding security checklist
Sources
- GitHub docs: Adding repository custom instructions for GitHub Copilot
- GitHub docs: Custom instructions for GitHub Copilot
- GitHub docs: Support for different types of custom instructions
- agents.md
Checked Oct 20, 2026. These tools change often; if something here no longer matches, tell us at [email protected].