Out of the box, GitHub Copilot behaves like an enthusiastic, unvetted junior developer who has memorized every random snippet on the internet. It defaults to the statistical average of public GitHub repositories. In practice, that means it suggests outdated React lifecycle methods, uses any whenever TypeScript gets slightly tricky, invents directory conventions that violate your clean architecture, and drafts tests using Jest when your repo migrated to Vitest two years ago.
At 365Finds, we find engineering leaders constantly swinging between two unproductive extremes. Some do nothing, let developers copy-paste whatever the AI outputs, and then complain about technical debt and messy pull requests. Others overcompensate by dumping their company's entire 4,000-word engineering wiki into a root prompt, burning through Copilot's context window and turning suggestions into a sluggish, hallucination-prone mess.
Configuring custom instructions properly does not require an enterprise prompt engineering team. It requires a clear, tiered structure committed directly to your Git repository. Here is how 365Finds structures, writes, and governs repository rules for GitHub Copilot across an active engineering organization.
The Architecture of Repository Instructions
GitHub Copilot does not rely on a single flat prompt. The platform supports a layered instruction hierarchy that allows teams to declare global conventions at the repository root, modular rules for specific subtrees or file types, and directory-level agent directives.
| Instruction Level | Target File Path | Primary Purpose | Evaluation Scope |
|---|---|---|---|
| Global Repository | .github/copilot-instructions.md | Core stack, architecture boundaries, testing philosophy | Loaded across all Copilot Chat, Edits, and PR review interactions |
| Path-Specific | .github/instructions/*.instructions.md | Directory or language rules (e.g., frontend vs. backend) | Filtered via applyTo glob patterns; loaded only for matching files |
| Agent Scoped | AGENTS.md / CLAUDE.md | Multi-step agent workflows and autonomous execution | Nearest ancestor directory takes precedence |
Step 1: Establish the Global Rulebook (.github/copilot-instructions.md)
The entry point for repository-wide configuration is .github/copilot-instructions.md. When present in the default branch, Copilot automatically includes these instructions in the background prompt for Copilot Chat, Copilot Edits, inline code suggestions, and Copilot pull request reviews.
Our recommendation at 365Finds is strict: keep this file under 150 lines. Every sentence you add consumes context tokens that could otherwise hold your project's actual source code. Focus entirely on project identity, strict boundaries, and non-negotiable patterns.
Here is a tested template for .github/copilot-instructions.md that 365Finds recommends for a modern full-stack TypeScript service:
# Repository Instructions for Core Commerce Platform
## 1. Project Tech Stack & Runtime
- Runtime: Node.js 22 LTS, pnpm workspace
- Framework: Next.js 15 (App Router only; no Pages Router conventions)
- Database & ORM: PostgreSQL 16, Prisma ORM
- State & Data Fetching: TanStack Query v5, Server Actions for mutations
## 2. Architecture & File Layout
- Follow Feature-Sliced Design under `src/features/<feature-name>/`.
- Colocate components, hooks, schemas, and tests inside the respective feature folder.
- Do not import directly from another feature's internal folders; use public index exports.
- Shared domain logic lives in `src/shared/`; never put feature-specific logic there.
## 3. TypeScript & Coding Standards
- Strict mode is enabled. Do not use `any`; use `unknown` with type narrowing.
- Prefer functional components and pure utility functions. Avoid class syntax.
- Validate all external input (HTTP requests, server action payloads) using Zod schemas.
- Handle expected domain failures with explicit `Result<T, E>` types; reserve `try/catch` for unexpected infrastructure errors.
## 4. Testing Requirements
- Test runner: Vitest with `@testing-library/react`. Do not import or write Jest tests.
- Colocate tests alongside source files as `*.spec.ts` or `*.spec.tsx`.
- Mock external HTTP boundaries using Mock Service Worker (MSW); do not mock internal helper modules.
## 5. Security & Operational Guardrails
- Never hardcode secrets, credentials, or production tokens in code or test fixtures.
- All database queries must run through Prisma parameterized calls; raw SQL requires explicit approval.
Step 2: Use Path-Specific Instructions for Monorepos (applyTo)
In polyglot repositories or monorepos containing both frontend client apps and Go microservices, a single global instruction file breaks down. Instructing Copilot to "always use Tailwind and functional components" causes bizarre suggestions when an engineer edits a backend database migration or a Terraform module.
GitHub Copilot solves this through path-specific instruction files stored inside .github/instructions/. Each file uses a YAML frontmatter block with an applyTo glob pattern. When an engineer opens or edits a file matching that pattern, Copilot combines the global instructions with the path-specific instructions.
Create .github/instructions/frontend.instructions.md to govern React and CSS conventions:
---
applyTo: "apps/web/**/*.{ts,tsx}"
---
# Frontend UI Guidelines
- Styling: Use Tailwind CSS utility classes exclusively; avoid CSS modules and inline styles.
- State Management: Use local `useState` or URL search params for UI state; use TanStack Query for server state.
- Accessibility: All interactive elements must include explicit `aria-label` attributes and maintain full keyboard navigability.
- Performance: Memoize expensive computations with `useMemo` only when measuring rendering bottlenecks.
Create .github/instructions/database.instructions.md to govern data persistence:
---
applyTo: "packages/database/prisma/**/*"
---
# Database & Migration Conventions
- Schema Changes: All schema additions must include an `@map` attribute matching snake_case database columns.
- Indexes: Every foreign key must have an explicit compound or single-column index.
- Deletions: We enforce soft deletes via a nullable `deleted_at DateTime?` column on domain models.
If a file does not match an applyTo pattern, Copilot skips those tokens entirely. 365Finds considers path-specific instructions the single best mechanism to keep prompts lean while maintaining strict architectural consistency across specialized sub-teams.
Step 3: Stop Teaching Linters to an LLM
One common failure mode we observe across engineering organizations is attempting to turn .github/copilot-instructions.md into an ESLint or Prettier clone. Instructions like "use single quotes", "indent with 2 spaces", or "sort import statements alphabetically" are a waste of context window tokens.
Large language models are probabilistic generators. Linters and AST formatters are deterministic compilers. If an automated tool like Biome, ESLint, or Prettier can format code on pre-commit git hooks or during CI checks, keep it out of Copilot's instruction files. Reserve Copilot's instructions for architectural direction, API deprecations, design patterns, and test methodologies that AST linters cannot enforce.
| Keep in Copilot Instructions | Delegate to Deterministic Tooling (ESLint, Prettier, CI) |
|---|---|
| "Use Server Actions instead of route handlers for mutations" | "Indent using 2 spaces" |
| "Always validate API inputs with Zod schemas" | "Sort import declarations alphabetically" |
"Colocate tests in *.spec.ts using Vitest" | "Require semicolons at statement ends" |
| "Wrap Prisma calls in repository interfaces" | "Ban trailing commas in JSON files" |
Step 4: Version Control and Maintain Instructions as Code
Do not let custom instructions become abandoned markdown documents. When a team migrates from Axios to native fetch, or upgrades an authentication library, Copilot will continue generating the old patterns unless .github/copilot-instructions.md is updated in the same pull request.
At 365Finds, we recommend treating prompt files with the same review rigor as infrastructure-as-code:
- Review Instructions During PRs: When a pull request introduces an architectural shift or replaces a deprecated utility, the PR checklist should verify whether
.github/copilot-instructions.mdor.github/instructions/*.instructions.mdrequires a corresponding update. - Patch Bad AI Suggestions via Commits: When a code reviewer repeatedly catches Copilot generating anti-patterns, the developer should open a PR updating the instruction file with a clear counter-example.
- Audit Token Overhead: Periodically run prompt inspections in your IDE. In Visual Studio Code, open the Command Palette (
Ctrl+Shift+PorCmd+Shift+P) and runChat: Open Customizationsto verify which instruction files are actively registered by the workspace.
Step 5: Enforce Enterprise Policies in GitHub Organization Settings
Repository-level markdown files govern how Copilot writes code, but they do not control what permissions Copilot operates under. Engineering leaders must pair repository instructions with organization-wide governance policies.
In GitHub's organization management portal (Organization Settings -> Copilot -> Policies):
- Public Code Suggestions: Set "Suggestions matching public code" to Blocked. This prevents Copilot from emitting verbatim matches of public open-source code longer than 150 characters, mitigating copyright and IP compliance risks.
- Model Selection Policies: Depending on your enterprise tier, enable multi-model selection (such as Anthropic Claude 3.5 Sonnet alongside OpenAI GPT models) so developers can choose the optimal model for complex refactoring versus quick autocompletion.
- Copilot in Pull Requests: Enable Copilot PR summaries to allow developers to generate initial pull request overviews, which will adhere to your repository's naming conventions and markdown guidelines.
Once .github/copilot-instructions.md is merged into your default branch, Copilot applies it across all team members immediately without requiring local configuration files or IDE reinstallations.