Engineering teams adopting GitHub Copilot quickly discover an annoying paradox: the AI writes code fast, but it generates whatever pattern was most common on the open web five years ago. Outdated JavaScript idioms, legacy ORM patterns, deprecated testing libraries, and chaotic directory placements creep into pull requests. Reviewers end up spending more time correcting AI-generated stylistic drifts than catching architectural bugs.
GitHub Copilot addresses this through repository-level custom instructions. By placing structured configuration files directly in your Git repository, your engineering organization can automatically feed project-specific constraints, framework choices, and architectural boundaries into Copilot's context window.
365Finds has analyzed how engineering teams configure these instructions in production. Our view is straightforward: repository instructions are steering mechanisms, not security gates. They dramatically reduce review friction when kept concise and concrete, but trying to turn an instructions file into a full deterministic linter will fail every time.
The Instruction Architecture: Where Rules Live
GitHub Copilot supports three distinct tiers of repository instruction files. Understanding how Copilot prioritizes and combines these files prevents prompt bloat and conflicting rules.
| Scope | File Path | When Copilot Applies It | Best Used For |
|---|---|---|---|
| Repository-Wide | .github/copilot-instructions.md | Automatically injected into every Copilot Chat query, code completion request, and review session across the repo | Global tech stack definitions, banned libraries, project-wide error handling contracts |
| Path-Specific | .github/instructions/*.instructions.md | Injected only when the developer edits or asks about files matching the specified glob pattern | Frontend vs. backend boundaries, database migration rules, unit vs. e2e testing standards |
| Agent-Level | AGENTS.md (or root CLAUDE.md, GEMINI.md) | Consumed by autonomous coding agents and deep review workflows | Tool execution instructions, repository build scripts, environment setup prerequisites |
1. Setting Up Global Instructions (.github/copilot-instructions.md)
The baseline mechanism is a single Markdown file located at the root of your project: .github/copilot-instructions.md.
Whenever an engineer opens a workspace containing this file in VS Code, Visual Studio, JetBrains IDEs, or interacts with GitHub Copilot on GitHub.com, Copilot silently prepends these instructions to the model prompt behind the scenes.
To initialize it:
- Create the
.githubdirectory in your repository root. - Add a
copilot-instructions.mdfile. - Commit and push the file to your default branch.
2. Path-Specific Instructions for Monorepos and Polyglot Projects
A major flaw in early Copilot setups was instruction leakage: frontend React rules would confuse Copilot when an engineer worked on backend Go microservices in the same repository.
GitHub resolves this through modular instructions located inside .github/instructions/. Each file must use YAML frontmatter with the applyTo key:
---
applyTo: "apps/web/**/*.tsx"
---
# Web Client Instructions
- Use Next.js 15 App Router conventions; never suggest Pages Router APIs.
- Prefer React Server Components. Mark client components explicitly with 'use client'.
- Style components strictly using Tailwind CSS utility classes; avoid inline styles.
If an engineer asks Copilot to modify apps/web/components/Navbar.tsx, Copilot merges the global .github/copilot-instructions.md with this specific web instruction file. If they open an API route in apps/api/**/*.go, the web instructions are omitted entirely.
A Production-Grade .github/copilot-instructions.md Template
At 365Finds, we strongly recommend structuring your repository instruction file into four concise operational buckets. Avoid vague aspirational statements like "Write clean, readable code"—large language models already assume they write clean code. Focus instead on concrete technical prohibitions and prescriptive defaults.
# Repository Instructions: Payment Platform Service
## Core Tech Stack & Constraints
- Runtime: Node.js 22 LTS with TypeScript 5.6 (strict mode enabled).
- Framework: Fastify (do NOT generate Express.js code).
- Database & ORM: PostgreSQL with Prisma ORM.
## Architectural & Code Conventions
- Validation: Always use Zod schemas for incoming request validation and environment parsing. Do not use Joi or Yup.
- Async Control: Use native async/await. Avoid raw Promise chains (.then/.catch).
- Typing: Never use 'any'. If a type is genuinely unknown, use 'unknown' with type narrowing.
- Error Handling: Throw custom domain errors extending 'AppError' (found in `src/errors`). Never swallow exceptions silently.
## Testing Standards
- Test Framework: Vitest.
- Mocking: Use Vitest built-in mocks (`vi.fn()`, `vi.spyOn()`); do not import Jest.
- Pattern: Co-locate unit tests next to source files using the `.spec.ts` suffix.
## Security & Privacy Non-Negotiables
- Never hardcode API keys, secrets, or bearer tokens in code or mock fixtures.
- Mask PII (emails, phone numbers, card numbers) in all logger outputs (`req.log.info`).
How 365Finds Evaluates Repository Instructions
Engineering leaders often ask us whether adding custom instructions genuinely moves the needle on code velocity and pull request throughput. The answer depends entirely on how disciplined the team is about keeping the file focused.
The Clear Advantages
- Elimination of Deprecated APIs: Copilot loves defaulting to what it saw most frequently in training data (like older versions of React or deprecated ORM methods). Explicitly declaring "Use Zustand 5, do not use Redux" stops stale suggestions immediately.
- Frictionless Library Enforcement: When our engineers tested repos with and without explicit instructions, the instructed Copilot consistently chose the designated utility library (e.g.,
date-fnsovermoment, or nativefetchoveraxios), saving multiple review cycles per PR. - Zero Client Configuration Required: Once merged into the repository, every engineer on the team gets the benefits automatically without needing to install custom editor extensions or configure local IDE settings.
The Real Constraints and Trade-Offs
- Context Window Overhead: Every line in
.github/copilot-instructions.mdconsumes input tokens on every single chat exchange. If you paste a 40-page corporate coding standard, you dilute the model's attention and crowd out the developer's actual prompt context. - Soft Nudges, Not Compilers: GitHub Copilot follows instructions probabilistically, not deterministically. An instruction file will reduce off-standard code by 70% to 80%, but it will still occasionally produce banned syntax if the surrounding file context heavily suggests it.
- Merge Conflicts and Maintenance Burden: The instruction file must be treated like live production code. If your team upgrades from Node 18 to Node 22 or migrates from Jest to Vitest, someone must update
.github/copilot-instructions.mdin the exact same PR.
Operational Playbook: Making It Work in Engineering Teams
To make repository instructions stick across dozens or hundreds of developers, 365Finds advises engineering organizations to adopt three operational practices:
- Keep the Global File Under 1,500 Tokens: Cap
.github/copilot-instructions.mdat roughly 100 to 150 lines. If a rule can be caught by ESLint, Biome, Prettier, or a compiler flag, let the tooling handle it. Use Copilot instructions for architectural decisions, preferred libraries, and pattern selection that static analysis cannot express easily. - Assign Instruction Ownership to Tech Leads: Place
.github/copilot-instructions.mdunder aCODEOWNERSfile entry. Only tech leads or architects should approve changes to prevent individual developers from introducing personal pet preferences into the shared team prompt. - Run Instructions in Tandem with GitHub Copilot Code Review: In repository settings under
Settings > Copilot > Code Review, ensure Copilot's automated PR reviewer is enabled. Copilot Code Review reads the same repository instructions, meaning it will actively check incoming pull requests against the standards you defined in the markdown file before human reviewers even open the diff.
When path-specific instruction files and global instructions overlap, GitHub Copilot concatenates the global file first and then appends the path-matched instructions directly before the user prompt in the final context payload.