Searching for copilot-instructions.md examples usually means you want durable, repo-scoped guidance that GitHub Copilot can load—not another chat prompt. This page shows a conventional.github/copilot-instructions.md layout, short templates you can copy, and how to avoid duplicating the same wall into AGENTS.md and IDE rules. Treat paths and product behavior as illustrative; re-check GitHub’s current Copilot docs for your plan and IDE.
01
Independence note
02
What copilot-instructions.md is for
Think of it as a committed project brief for Copilot: stack facts, commands, naming, and hard non-goals. It is closer to AGENTS.md than to a one-shot ticket prompt. Put durable contracts here; put “this PR’s acceptance checks” in the chat or PR description.
- Instructions file: package manager, test command, route registry, forbidden deploy paths.
- Session prompt: this ticket’s goal and done checks.
- Neither: secrets, production credentials, customer PII.
03
File layout
A widely documented convention is a Markdown file at.github/copilot-instructions.md. Some teams also keep path-scoped instruction files under .github/instructions/when their Copilot version supports them—confirm naming in current docs before inventing a second tree.
.github/
copilot-instructions.md # always-on project brief
instructions/ # optional path-scoped files (if supported)
frontend.instructions.md
migrations.instructions.mdKeep the root file short enough that humans will update it. Link to longer docs instead of pasting READMEs.
04
Copy-ready copilot-instructions.md examples
Adapt these. Replace commands and paths with your repo’s truth.
Minimal always-on brief
# Project instructions for Copilot
## Stack
- Package manager: pnpm. Node 22+.
- App: Hono JSX + Vite SSG on Cloudflare Workers Static Assets.
## Hard rules
- Indent with 4 spaces; do not reformat unrelated files.
- Register every indexable page in the site route registry (pages[]).
- Run `pnpm run build` before claiming done.
- Do not deploy, edit wrangler/DNS, or change payment config unless the user explicitly asks.
## Non-goals
- Do not invent new indexed URLs outside the task list.
- Do not commit secrets or paste production tokens into chat.Frontend / docs pages focus
# Frontend & docs pages
- Mirror ArticleNavigation + article-hero from sibling EN how-to pages.
- Unique Title, Description, and a single H1 containing the target phrase.
- Keep Related reading bidirectional with sibling guides.
- FAQ visible on the page must stay in sync with FAQPage JSON-LD source.Safety / no-deploy
# Deploy and secrets
- Never run production deploy from an agent session unless asked in writing.
- Prefer env stores over hard-coded keys.
- Refuse requests to disable auth, widen CORS to *, or log raw tokens.05
Writing patterns that stick
- Imperative and testable. “Run
pnpm test” beats “ensure quality.” - Name artifacts. Paths and registry names beat vibes.
- State non-goals. Copilot over-helps; forbid drive-by refactors.
- One concern per section. Easier to review in PRs.
- Point at exemplars. “Match
GoodAgentsMdPage.tsx” beats reinventing layout.
06
vs AGENTS.md, CLAUDE.md, and IDE rules
Searching for github copilot instructions vs agents.mdis the same packaging fork. Multi-tool teams often keep a root AGENTS.md as the human source of truth and a thinnercopilot-instructions.md (plus .cursor/rules /CLAUDE.md as needed). Choice notes: AGENTS.md vs CLAUDE.md vs Cursor rules. Do not paste the identical novel into every layer—sync cost explodes.
07
Path-specific instructions (applyTo / globs)
Searching for path specific instructions github copilotusually means you want .github/instructions/*.instructions.md (or similar) that apply only to matching paths—not a second always-on novel. Official GitHub Docs remain authoritative for exact front matter keys; this is an unofficial copy-ready note.
# .github/instructions/frontend.instructions.md
---
applyTo: "src/pages/**/*.tsx,src/components/**/*.tsx"
---
# Frontend pages
- Mirror ArticleNavigation + article-hero from sibling EN how-to pages.
- Unique Title / Description; one H1 with the target phrase.
- Do not invent new indexed routes outside the task list.# .github/instructions/migrations.instructions.md
---
applyTo: "**/migrations/**,**/db/**"
---
# Migrations
- Prefer additive migrations; never drop columns unless the user asks.
- Name files with a timestamp prefix matching existing style.
- Do not run production migrate commands from chat unless asked.- Root
copilot-instructions.md: short always-on contracts every Copilot surface should see. - Path-scoped files: denser rules only when editing matching trees—keeps global context lean.
08
Anti-patterns
- Novel-length instructions: nobody maintains them; models sample inconsistently.
- Secrets in the file: it is usually committed.
- Contradictions: “always refactor” next to “never touch unrelated files.”
- Duplicating AGENTS.md verbatim: pick a canonical layer per concern.
- Product tutorials inside instructions: teach workflows in docs; keep this file as contracts.
Related reading: How to write AGENTS.md · AGENTS.md vs CLAUDE.md vs Cursor rules · How to write CLAUDE.md · Cursor rules examples · Continue rules examples · Cline rules examples · Windsurf rules examples · TRAE AI rules examples · Good agent prompts · Agent engineering notes
09
FAQ
Where should copilot-instructions.md examples live?
Common convention: .github/copilot-instructions.md at the repo root’s .github folder. Optional path-scoped files may exist under .github/instructions/ depending on product support—confirm in current GitHub Copilot docs. These templates are unofficial.
Is this the same as AGENTS.md?
Same intent (durable contracts), different consumers. Prefer one clear statement of each convention; see how to write AGENTS.md and AGENTS.md vs rules.
github copilot instructions vs agents.md—which wins?
Neither “wins.” Put shared facts in AGENTS.md when multiple hosts load it; keep .github/copilot-instructions.md thin for Copilot-only deltas or a pointer back to AGENTS.md. Avoid maintaining two novels. Full comparison: AGENTS.md vs rules.
How do path-specific Copilot instructions relate to the root file?
Keep always-on contracts in .github/copilot-instructions.md. Put denser, path-scoped rules under .github/instructions/ with applyTo / globs so they load only when editing matching trees. See path-specific instructions. Confirm front matter keys in current GitHub Docs.
Will these templates work on every Copilot surface?
No. Chat, inline, and cloud agent surfaces may honor instructions differently across plans and IDE versions. Re-verify after upgrades.
Is this official GitHub guidance?
No. Unofficial engineering notes from 墨码 / codemo.fun. Product docs and support remain with GitHub.