GitHub Copilot custom instructions: copilot-instructions.md generator
GitHub Copilot reads repository-wide custom instructions from .github/copilot-instructions.md, and path-specific instructions from .github/instructions/NAME.instructions.md files whose applyTo frontmatter holds glob patterns. Copilot cloud agent, code review and Copilot CLI also read AGENTS.md.
Generate a Copilot instructions file
Where the file goes
.github/copilot-instructions.mdfor repo-wide rules..github/instructions/*.instructions.mdwithapplyTo: "glob,glob"frontmatter for scoped rules.- Agent instruction files (
AGENTS.md,CLAUDE.mdorGEMINI.md) are also read by the Copilot cloud agent, Copilot code review and Copilot CLI. Copilot Chat in VS Code readsAGENTS.md.
How it works
- Repo-wide instructions are added to every Copilot Chat request in the repo.
- Path-specific files are added only when Copilot works on files matching
applyTo; they are additive to the repo-wide file. - Copilot code review can also use these instructions.
- Copilot CLI expands
@pathimport lines in AGENTS.md, CLAUDE.md and copilot-instructions.md. Since v1.0.106 (5 Nov 2026) it follows Markdown code-fence rules: an@line inside a code block is treated as an example, not imported. - Copilot CLI also reads Claude Code rule files in
.claude/rules/as custom instructions.
Tips for a good Copilot instructions
- Keep the repo-wide file short; move language or folder specifics into
.instructions.mdfiles. - Use comma-separated globs in
applyTo, for example"**/*.ts,**/*.tsx". - Put real
@imports on their own line outside code blocks. Copilot CLI ignores@lines inside fenced code, so an import you meant to load can be silently skipped.
Example: Node.js + Express + Prisma + Zod validation
# Copilot instructions - this project
A Node.js + Express + Prisma + Zod validation project.
Stack: Node.js + Express, Prisma, Zod validation.
## Commands
- Dev server: `npm run dev`
- Build: `npm run build`
- Type-check: `npx tsc --noEmit`
- Create and apply migration (dev): `npx prisma migrate dev --name <change>`
- Regenerate client: `npx prisma generate`
- Apply migrations (prod): `npx prisma migrate deploy`
## How to work in this repo
- Read the relevant files before editing. Follow the patterns already in the codebase over these generic rules.
- Make the smallest change that solves the task. Do not refactor or reformat unrelated code.
- Before saying a task is done, run the type-check, lint and tests listed under Commands and fix what you broke.
- If requirements are ambiguous, ask one clear question instead of guessing.
- Never commit secrets, API keys or `.env` files. Use env vars and keep `.env.example` up to date.
- Do not add a new dependency when the standard library or an existing dependency already covers it.
- Ask before adding, removing or upgrading any dependency.
- Ask before changing database schemas, auth, payments or CI configuration.
- Never delete files, drop data or run destructive commands (`rm -rf`, `git push --force`, `DROP TABLE`) without explicit approval.
- Keep each change under ~200 changed lines where possible; split larger work into steps.
---
applyTo: "src/**/*.ts"
---
# Node.js + Express
- Express 5 forwards rejected promises from async handlers to the error middleware; do not wrap every handler in try/catch.
- Have one central error-handling middleware that logs the error and returns a consistent JSON error shape.
- Validate every request body, query and param before using it.
- Use `helmet`, a strict CORS allow-list and rate limiting on public endpoints.
- Read config from env vars once at startup in a typed config module; fail fast if a required var is missing.
- Return correct HTTP status codes (400 validation, 401 unauthenticated, 403 forbidden, 404 not found, 409 conflict).
---
applyTo: "prisma/**,**/*.prisma"
---
# Prisma
- Change the database only through `schema.prisma` + `prisma migrate dev`. Never edit an applied migration.
- Reuse a single PrismaClient instance (cache it on `globalThis` in dev to survive hot reload).
- Use `select` / `include` to fetch only the fields you need.
- Wrap multi-step writes in `prisma.$transaction`.
- Run `npx prisma generate` after schema changes before type-checking.
---
applyTo: "**/*.ts,**/*.tsx"
---
# Zod validation
- Validate all untrusted input (request bodies, form data, env vars, third-party API responses) with a Zod schema at the boundary.
- Derive TypeScript types from schemas with `z.infer<typeof schema>`; do not hand-write duplicate types.
- Use `safeParse` where you need to return validation errors to the user.
FAQ
Where do Copilot instructions go?
In .github/copilot-instructions.md in the repository, plus optional .github/instructions/*.instructions.md files.
Does Copilot read AGENTS.md?
Yes. GitHub calls AGENTS.md, CLAUDE.md and GEMINI.md "agent instructions". The Copilot cloud agent, code review and Copilot CLI read all three, and Copilot Chat in VS Code reads AGENTS.md.
Copilot instructions templates by stack
- Next.js (App Router) + Tailwind CSS v4 + shadcn/ui + Supabase + Zod validation Copilot instructions
- Next.js (App Router) + Tailwind CSS v4 Copilot instructions
- Next.js (App Router) + Tailwind CSS v4 + Prisma + Stripe payments + Zod validation Copilot instructions
- Next.js (App Router) + Tailwind CSS v4 + Drizzle ORM + Clerk auth + Zod validation Copilot instructions
- Next.js (App Router) + Tailwind CSS v4 + shadcn/ui + Vercel AI SDK + Zod validation Copilot instructions
- Next.js (App Router) + Tailwind CSS v4 + Supabase + Stripe payments + Zod validation + Vitest Copilot instructions
- Next.js (App Router) + Tailwind CSS v4 + Firebase Copilot instructions
- Next.js (App Router) + Tailwind CSS v4 + Vitest + Playwright E2E Copilot instructions
- React + Vite + Tailwind CSS v4 + TanStack Query + Vitest + Zod validation Copilot instructions
- React + Vite + Tailwind CSS v4 + Supabase + Zustand Copilot instructions
- React + Vite + Tailwind CSS v4 + Firebase + Vitest Copilot instructions
- Astro + Tailwind CSS v4 Copilot instructions
- SvelteKit (Svelte 5) + Tailwind CSS v4 + Supabase + Zod validation Copilot instructions
- SvelteKit (Svelte 5) + Tailwind CSS v4 + Drizzle ORM + Vitest Copilot instructions
- Nuxt (Vue 3) + Tailwind CSS v4 + Zod validation Copilot instructions
- Nuxt (Vue 3) + Tailwind CSS v4 + Supabase Copilot instructions
- Expo (React Native) + Supabase + Zod validation + Jest Copilot instructions
- Expo (React Native) + TanStack Query + Zustand + Jest Copilot instructions
- Node.js + Express + Prisma + Zod validation + Vitest + Docker Copilot instructions
- Node.js + Express + Drizzle ORM + Zod validation + Docker Copilot instructions
- Python + FastAPI + SQLAlchemy 2 + Alembic + pytest + Docker Copilot instructions
- Python + FastAPI + LLM / agent SDKs (Python) + pytest Copilot instructions
- Python + FastAPI + Supabase + pytest Copilot instructions
- Python (scripts, agents, libraries) + LLM / agent SDKs (Python) + pytest Copilot instructions
- Python + Django + pytest + Docker Copilot instructions
- Python + Django + Tailwind CSS v4 + pytest Copilot instructions
- Ruby on Rails + Tailwind CSS v4 + Docker Copilot instructions
- PHP + Laravel + Tailwind CSS v4 + Stripe payments Copilot instructions
- Go + Docker Copilot instructions
- Rust + Axum + Docker Copilot instructions
- Java + Spring Boot + Docker Copilot instructions
- Flutter (Dart) + Firebase Copilot instructions
- Flutter (Dart) + Supabase Copilot instructions
- Swift + SwiftUI Copilot instructions
- Unity (C#) Copilot instructions
- Godot 4 (GDScript) Copilot instructions
- Phaser (TypeScript web games) + Vitest Copilot instructions
- React + Vite + Tailwind CSS v4 + shadcn/ui + Zod validation + Vitest Copilot instructions
- Next.js (App Router) + Tailwind CSS v4 + Drizzle ORM + Supabase + Zod validation Copilot instructions
- SvelteKit (Svelte 5) + Tailwind CSS v4 + Vercel AI SDK + Zod validation Copilot instructions
- Expo (React Native) + Firebase + Zod validation + Jest Copilot instructions
- Next.js (App Router) + Tailwind CSS v4 + shadcn/ui + Clerk auth + Prisma + Stripe payments + Zod validation Copilot instructions
- Astro + Tailwind CSS v4 + shadcn/ui Copilot instructions
- Ruby on Rails + Tailwind CSS v4 + Stripe payments + Docker Copilot instructions
- Nuxt (Vue 3) + Tailwind CSS v4 + Vercel AI SDK + Zod validation Copilot instructions
- Chrome Extension (MV3) + Tailwind CSS v4 + Zustand + Vitest Copilot instructions
Official docs: GitHub Copilot custom instructionsCustom instructions supportCopilot CLI changelog. Last reviewed 2026-11-11.