AD SPACE AVAILABLE · BRAND PARTNERS WELCOME

How to Configure Team-Wide Coding Conventions Using GitHub Copilot Custom Instruction Files

Jean-Benoît Doazan · 365Finds Editorial
Indexed 88,650 Wiki articles

Put 365 Wiki to work with your AI

Copy the prompt below, paste it into the AI you already use, then ask your question.

Download full Skill

Try it with the prompt first. If you use 365 Wiki often, install the full 365Wiki Skill so you do not have to paste it again. No regular AI? Gemini or Microsoft Copilot on the web will work.

365Wiki Skill

Prompting GitHub Copilot individually is an exercise in repeating yourself. Every developer on the team asks Copilot to scaffold a controller or write a component, and Copilot responds with whatever paradigm dominated its training distribution that morning. One engineer gets modern React hooks; another gets classes. One gets Vitest mocks; another gets deprecated Jest patterns.

At 365Finds, our stance is unequivocal: treating AI code generation as an uncoordinated free-for-all turns your codebase into an archaeological dig site of competing conventions within three months.

The fix isn't lecturing engineers in code reviews. It is anchoring GitHub Copilot to your repository's architectural ground truths through .github/copilot-instructions.md and path-scoped instruction files. Here is how to configure, structure, and maintain team-wide coding conventions across your repositories, along with the boundaries of what these files can and cannot accomplish.


How GitHub Copilot Discovers and Ranks Instructions

GitHub Copilot does not require external plugins or workspace extensions to ingest repository guidelines. When a developer triggers Copilot Chat, inline generation, or automated code review, Copilot inspects your workspace for instruction files and automatically appends relevant rules into the background context sent to the model.

Copilot resolves instructions through a defined hierarchy of precedence:

Instruction ScopeFile Path or LocationEffective CoveragePrecedence Level
Organization LevelGitHub Web: Organization Settings > Copilot > Custom instructionsAll repositories across the organizationBroad baseline; overridden by repo specifics
Agent / EcosystemAGENTS.md (workspace root or local directories), CLAUDE.mdAutonomous agents and directory-level tool callsIntermediate
Repository-Wide.github/copilot-instructions.md (root directory)Entire repository across all filesHigh; repository standard
Path-Specific.github/instructions/**/*.instructions.mdFiles matching YAML applyTo glob patternsHighest repository specificity
User ProfileIDE local settings / user profile instruction fileIndividual developer machinePersonal preference

When instructions overlap or contain complementary guidance, Copilot blends them. When direct contradictions occur, GitHub Copilot prioritizes narrower scopes over broader organizational baselines.


Step 1: Establish the Repository Baseline (.github/copilot-instructions.md)

The primary mechanism for repository-wide standardization is a single Markdown document located at the root of your project: .github/copilot-instructions.md.

Create the directory and file in your repository:

mkdir -p .github
touch .github/copilot-instructions.md

What Belongs in the File (and What to Cut)

The most common failure mode 365Finds observes in engineering teams is treating this file like an internal wiki or an employee handbook. Large language models suffer from attention dilution: if you feed Copilot 600 lines of polite prose, corporate philosophy, and obvious truisms, it ignores the critical architectural rules you actually care about.

Keep instructions dense, directive, and technical. Structure the file into predictable headings:

# Team Coding Conventions for Core Services

## Architectural & Tech Stack Baselines
- Language runtime: Node.js 22 LTS with TypeScript 5.5 (`strict: true`).
- Framework: Fastify v5. Do not suggest Express or NestJS APIs.
- Database layer: Prisma with PostgreSQL. Always write raw SQL queries via `prisma.$queryRaw` using typed tagged templates.
- State management: Zustand only; do not import Redux or React Context for global state.

## Code Style & Implementation Rules
- Write functional, declarative TypeScript. Class declarations are banned outside of custom Error subclasses.
- Explicit return types: Every exported function must declare an explicit return type.
- Typing restrictions: Never use `any`. Use `unknown` with runtime type narrowing (`zod` schemas).
- Async control flow: Use `async/await` exclusively; never return raw `Promise.then()` chains.
- Early returns: Prefer guard clauses over deeply nested `if/else` branching.

## Error Handling & Observability
- Throw domain-specific exceptions extending `AppError` from `@core/errors`.
- Never use `console.log()` or `console.error()`. Use the shared logger instance (`import { logger } from '@core/logger'`).
- Always attach a `correlationId` to error metadata.

## Testing Standards
- Test runner: Vitest. Do not introduce Jest globals (`jest.fn()`, `jest.spyOn()`).
- Use `@testing-library/react` for UI components. Prefer `findByRole` and `getByRole` selectors over test IDs or CSS selectors.
- Every new API route must include a co-located integration test file: `[name].test.ts`.

Commit this file to your default branch. Once merged, every developer using GitHub Copilot inside this repository automatically benefits from these instructions without touching their local editor settings.


Step 2: Configure Modular Path-Specific Rules (.instructions.md)

Monorepos, polyglot repositories, and full-stack applications quickly outgrow a single instruction file. Imposing React component rules onto Python data pipelines or Go microservices inside the same repository wastes context window tokens and confuses model generation.

To solve this, GitHub Copilot supports scoped instructions under .github/instructions/**/*.instructions.md. These files use YAML frontmatter with an applyTo glob pattern.

Example: Scoping Frontend Rules

Create .github/instructions/web-components.instructions.md:

---
description: "Design system and styling rules for React web components"
applyTo: "apps/web/src/**/*.tsx"
---

# Frontend Component Standards
- Styling: Use Tailwind CSS utility classes. Never create `.module.css` files.
- UI Library: Use Radix UI primitives wrapped in our design tokens (`@ui/components`).
- Component declarations: Export named functions (`export function UserCard()`). Avoid anonymous `export default ()`.
- Accessibility: Ensure all interactive elements include valid `aria-*` attributes and keyboard event handlers.

Example: Scoping Python Test Standards

Create .github/instructions/python-tests.instructions.md:

---
description: "Testing conventions for Python backend services"
applyTo: "services/*/tests/**/*.py"
---

# Python Test Conventions
- Framework: `pytest` with `pytest-asyncio`.
- Fixture management: Reuse shared fixtures defined in `conftest.py`. Do not re-instantiate database connections inside individual test functions.
- Assertion style: Use plain `assert` statements; avoid `unittest.TestCase` assertions (`self.assertEqual`).
- Mocking: Use `unittest.mock.AsyncMock` for external network clients.

When an engineer opens an editor tab inside apps/web/src/components/Modal.tsx, Copilot merges the repository-wide .github/copilot-instructions.md with web-components.instructions.md. When switching to a Python test, the frontend rules drop out of context automatically.


Step 3: Enforce Enterprise-Wide Policies via GitHub Web

If your organization runs hundreds of micro-repositories, manually creating .github/copilot-instructions.md in every new repository creates maintenance drift.

For GitHub Copilot Business and Enterprise subscribers, organization owners can define organization-wide custom instructions:

  1. In GitHub, navigate to your Organization Settings.
  2. In the left sidebar under Copilot, click Custom instructions.
  3. In the text area under Preferences and instructions, enter universal governance constraints:
    • Mandatory internal package registries and private scopes (e.g., Always source utility modules from @myorg/*).
    • Compliance constraints (e.g., Never generate hardcoded API tokens, credentials, or insecure placeholder secrets).
    • Deprecated internal libraries that must never appear in new pull requests.
  4. Click Save changes.

These rules apply silently across every repository belonging to the organization, serving as the foundational tier underneath repository-level files.


Verifying That Copilot Ingests Your Instruction Files

Engineers often ask 365Finds how to prove Copilot is actually reading .github/copilot-instructions.md rather than ignoring it.

  1. Check Context References in VS Code: Open GitHub Copilot Chat (Ctrl+Alt+I or Cmd+Alt+I). Ask a repository question such as: "How should I handle errors in a new service?" Look at the top of the chat response under the Used references dropdown. You will see .github/copilot-instructions.md listed explicitly alongside any workspace context files.
  2. Verify Client Setting: Ensure your workspace or user settings have not disabled instruction reading. In VS Code's settings.json, verify:
    "github.copilot.chat.codeGeneration.useInstructionFiles": true
    
  3. Run a Canary Test: Add an arbitrary, easily verifiable rule to your instructions file, such as:
    - Naming convention: Suffix all boolean helper functions with `IsVerified` or `HasPermission`.
    
    Prompt Copilot Chat to generate a boolean helper. If the generated output adopts the convention without explicit instruction in your prompt, the file is fully operational.

What Instruction Files Can and Cannot Do

At 365Finds, we believe clear expectations prevent costly engineering disappointments. Instruction files are powerful, but their operational role must be understood accurately:

What Instruction Files DoWhat Instruction Files Cannot Do
Shift defaults: Steer probabilistic output toward chosen frameworks, versions, and patterns.Guarantee 100% compliance: LLMs are probabilistic; an edge case or complex prompt can still yield deviations.
Eliminate prompt boilerplate: Remove the need for developers to type "use TypeScript 5 and Vitest" every time.Replace CI linters: Static analysis tools (Biome, ESLint, Ruff) remain mandatory to catch syntax and style errors.
Standardize architecture: Prevent outdated APIs and retired internal libraries from entering greenfield code.Enforce hard runtime security: Instructions reduce accidental vulnerabilities but do not substitute for SAST scanners.

Treat .github/copilot-instructions.md as context engineering for AI pair programming. Treat your CI test suite, ESLint rules, and branch protection policies as the deterministic gatekeepers of production quality.


Maintaining Instruction Files as Living Code

Do not write your instruction file once and forget it. As dependencies upgrade and architectural patterns evolve, obsolete instructions actively degrade Copilot's output quality by anchoring it to outdated standards.

We recommend three concrete team maintenance habits:

In the GitHub Copilot ecosystem, the repository-wide .github/copilot-instructions.md file serves as the baseline, .github/instructions/**/*.instructions.md handles directory-specific overrides via glob matching, and organization-level instructions in GitHub Enterprise establish overarching corporate baselines.

References