GitHub Copilot Configuration

copilot-instructions.md Guide

Configure GitHub Copilot with custom instructions. Learn how to set up repository-wide rules, path-specific instructions, and organization standards.

Understanding copilot-instructions.md

copilot-instructions.md is a Markdown file where you define custom coding standards, rules, and best practices that GitHub Copilot should follow across your repository. It helps Copilot generate code that matches your project's conventions and requirements.

With the largest market share among AI coding tools, GitHub Copilot's custom instructions feature gives you control over how Copilot understands your codebase and generates suggestions.

How to Set Up

  1. Create a .github directory in your repository root if it doesn't exist
  2. Create a file named copilot-instructions.md
  3. Add natural language instructions in Markdown format
  4. Commit and push to your repository

copilot-instructions.md Format

The instructions file uses Markdown format. Here's a recommended structure:

.github/copilot-instructions.md
# Project Coding Standards

## Language & Framework
- This is a TypeScript React project using Next.js 14
- Use App Router patterns, not Pages Router
- Target ES2022 JavaScript features

## Code Style
- Use functional components with hooks
- Prefer named exports over default exports
- Use TypeScript strict mode - no 'any' types
- Use arrow functions for component definitions

## Naming Conventions
- Components: PascalCase (UserProfile.tsx)
- Hooks: camelCase with 'use' prefix (useAuth.ts)
- Utils: camelCase (formatDate.ts)
- Constants: SCREAMING_SNAKE_CASE

## State Management
- Use React Query for server state
- Use Zustand for client state
- Avoid prop drilling beyond 2 levels

## Testing
- Write unit tests for utility functions
- Use React Testing Library for components
- Mock external dependencies

## Documentation
- Add JSDoc comments to exported functions
- Include usage examples in complex utilities

Path-Specific Instructions

For language-specific or directory-specific rules, create .instructions.md files with YAML frontmatter:

.github/python.instructions.md
---
applyTo: "**/*.py"
---

# Python Code Standards

- Use Python 3.11+ features
- Follow PEP 8 style guidelines
- Use type hints for all function parameters and returns
- Use dataclasses or Pydantic for data models
- Prefer pathlib over os.path
- Use f-strings for string formatting
- Write docstrings in Google style format
.github/api.instructions.md
---
applyTo: "src/api/**/*"
---

# API Development Standards

- Use RESTful conventions
- Return proper HTTP status codes
- Validate all input data
- Handle errors gracefully with try/except
- Log all API errors
- Use async/await for database operations

Priority Order

Copilot combines instructions from multiple sources with this priority:

  1. Personal instructions — Highest priority (your individual settings)
  2. Repository instructions — Project-level rules in .github/
  3. Organization instructions — Org-wide standards (enterprise)

All relevant instructions are combined and provided to Copilot. Avoid conflicting instructions across levels.

Best Practices

  • Keep instructions short and self-contained — Each statement should add context without depending on other statements
  • Use path-specific files for language rules — Don't mix Python and TypeScript rules in one file
  • Be specific about versions — Mention framework versions to prevent outdated suggestions
  • Verify with references — Check that your instructions appear in Copilot Chat references
  • Update regularly — Keep instructions in sync with project evolution

Related Guides

CLAUDE.mdCLAUDE.md Guide.cursorrulesCursor Rules GuideComparisonCompare All Tools

Frequently Asked Questions

Manage Your copilot-instructions.md Visually

ClaudeMDEditor lets you browse, edit, and organize copilot-instructions.md files across all your projects. Plus it handles CLAUDE.md, .cursorrules, and more.

Claude CodeCursorCopilotWindsurfGeminiCodexAider
Get ClaudeMDEditor — $13

One-time purchase for macOS Tahoe (26+)