GITHUBCOPILOTINSTRUCTIONSMD(5)GITHUBCOPILOTINSTRUCTIONSMD(5)

NAME

.github/copilot-instructions.md — instruction file for GitHub Copilot

SYNOPSIS

.github/copilot-instructions.md

.github/instructions/*.instructions.md

METADATA

FORMATMarkdown
FILENAME.github/copilot-instructions.md
CASE SENSITIVENo
TOOLGitHub Copilot
ENCODINGUTF-8
GIT COMMITTEDYes
MAX SIZE8KB
SINCEGitHub Copilot (2024)

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

├──Code Style & Conventions
Language-specific style rules, naming conventions, and formatting preferences for Copilot to follow.
├──Project Context
Brief overview of the project's architecture, key dependencies, and patterns. Helps Copilot generate contextually appropriate code.
└──Testing Preferences
Test framework, assertion style, mocking patterns, and coverage expectations.

ANNOTATED EXAMPLE

.github/copilot-instructions.md
markdown
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>
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

Gotchas
&cross;WRONG Placing the file at the project root as copilot-instructions.md
&check;RIGHT It must be at .github/copilot-instructions.md

GitHub Copilot looks specifically in the .github/ directory for this file, consistent with where other GitHub configuration files live (workflows, issue templates, etc.).

&cross;WRONG Expecting instructions to apply to GitHub.com web Copilot Chat
&check;RIGHT copilot-instructions.md primarily targets VS Code / IDE Copilot; AGENTS.md is for GitHub's hosted agents

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.

&cross;WRONG Including sensitive information or secrets
&check;RIGHT This file is committed to version control — keep it public-safe

Like all files in the .github directory, copilot-instructions.md is part of the repository and visible to anyone with read access.

&cross;WRONG Writing extremely detailed, multi-page instructions
&check;RIGHT Keep it focused on the most impactful conventions

The file content competes with code context for Copilot's limited context window. Dense, focused instructions outperform sprawling docs.

&cross;WRONG Duplicating rules already enforced by linters or formatters
&check;RIGHT Focus on semantic rules that tools can't enforce

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.

USED BY

SIMILAR FILES

AGENTS.mdAgents Instruction File
CLAUDE.mdClaude Memory File
.cursorrulesCursor Rules (Legacy)

COMPARISONS

agentconfig.ing2026-03-16GITHUBCOPILOTINSTRUCTIONSMD(5)