NAME
.github/copilot-instructions.md — instruction file for GitHub Copilot
SYNOPSIS
.github/copilot-instructions.md
.github/instructions/*.instructions.md
METADATA
DESCRIPTION
.github/copilot-instructions.md is GitHub's repository-level configuration file for GitHub Copilot in IDE environments (VS Code, JetBrains, Neovim). When Copilot generates completions or responds to chat prompts, it incorporates these instructions as additional system context.
The file lives in the .github/ directory alongside other GitHub-specific configuration like Actions workflows and issue templates. The base file uses plain Markdown with no special syntax.
Copilot also supports scoped instructions via `.github/instructions/*.instructions.md` files. Each scoped file uses YAML frontmatter with an `applyTo` glob pattern to target specific file types or directories. This enables different conventions for different parts of the codebase (e.g., React components vs. API routes vs. test files).
Note the distinction between copilot-instructions.md (for IDE-based Copilot) and AGENTS.md (for GitHub's agentic AI features like Copilot Workspace). For full coverage, repositories may want both files.
STRUCTURE
ANNOTATED EXAMPLE
1# Copilot Instructions
2
3## Language & Framework
4This is a Python 3.12 project using FastAPI with SQLAlchemy 2.0 (async).
5We use Pydantic v2 for validation and Alembic for migrations.
6
7## Code Style
8- Use type hints on all function signatures
9- Prefer `async def` for route handlers and database operations
10- Use dependency injection via FastAPI's `Depends()` system
11- Name variables descriptively: `user_repository` not `ur`
12- Keep functions under 30 lines; extract helpers for complex logic
13
14## Architecture Patterns
15- Repository pattern for all database access (`app/repositories/`)
16- Service layer for business logic (`app/services/`)
17- Route handlers should only validate input, call services, format output
18- Use Pydantic models for all API request/response schemas
19
20## Error Handling
21- Raise domain-specific exceptions from `app/exceptions.py`
22- Never catch bare `Exception` — always catch specific types
23- Return RFC 7807 Problem Details JSON for all API errors
24
25## Testing
26- Use pytest with pytest-asyncio for async test support
27- Factory Boy for test fixtures (`tests/factories/`)
28- Every endpoint needs at least: happy path, validation error, not found
29- Use `httpx.AsyncClient` for integration tests, not TestClient
30
31---
32
33## Scoped Instructions (.github/instructions/react.instructions.md)
34
35```markdown
36---
37applyTo: "src/components/**/*.tsx"
38---
39- Use functional components with TypeScript interfaces for props
40- Prefer named exports over default exports
41- Use Tailwind CSS utility classes for styling
42- Keep components under 150 lines
43```
SPECIAL DIRECTIVES
applyTo: <glob>YAML frontmatter field in scoped instruction files (.github/instructions/*.instructions.md). Specifies a glob pattern that determines which files the instructions apply to. Example: `applyTo: '**/*.tsx'` makes the instructions active only when Copilot works on TSX files.
COMMON MISTAKES
GitHub Copilot looks specifically in the .github/ directory for this file, consistent with where other GitHub configuration files live (workflows, issue templates, etc.).
The copilot-instructions.md file is read by the Copilot extension in VS Code, JetBrains, and other IDEs. GitHub's server-side agents (Copilot Workspace, etc.) primarily use AGENTS.md.
Like all files in the .github directory, copilot-instructions.md is part of the repository and visible to anyone with read access.
The file content competes with code context for Copilot's limited context window. Dense, focused instructions outperform sprawling docs.
If ESLint or Prettier already enforce formatting, don't repeat those rules. Focus on architectural patterns, naming conventions, and design decisions that linters can't capture.