Most engineering leads make the same mistake when trying to get GitHub Copilot to write code like their team: they paste a 40-page corporate coding standard into a single Markdown file, push it to main, and wonder why the AI begins hallucinating compliance or ignoring crucial rules.
At 365Finds, our perspective is unequivocal. Custom instructions are prompt steering wheels, not compiler gates or linter replacements. If you expect a Markdown file to replace ESLint, Prettier, or strict type-checking in CI, you will fail. But when you configure GitHub Copilot's instruction hierarchy correctly—scoping repository-wide guardrails, path-specific rules, and workspace settings—Copilot stops proposing deprecated APIs, abandons outdated testing frameworks, and writes idiomatic code tailored to your exact codebase.
Here is how to configure custom instruction files and workspace rules to enforce real engineering standards across your team.
The Three-Tier Instruction Architecture
GitHub Copilot resolves instructions through a tiered hierarchy. Understanding where each standard belongs prevents instruction bloat and keeps context windows focused.
| Layer | File / Setting Location | Primary Scope | What Belongs Here |
|---|---|---|---|
| Repository-Wide | .github/copilot-instructions.md | Entire repository across Copilot Chat, Edits, and PR reviews | Architecture paradigms, primary runtime versions, dependency bans, error-handling conventions |
| Path-Specific | .github/instructions/*.instructions.md | Targeted glob paths via YAML frontmatter applyTo | Component styling rules, test mock conventions, database migration patterns |
| Workspace Settings | .vscode/settings.json | Local developer IDE or committed team editor profile | Commit message formats, generation toggles, team-specific file instruction paths |
1. Setting Up Repository-Wide Rules: .github/copilot-instructions.md
Create a file named copilot-instructions.md inside your repository's .github/ directory. GitHub Copilot automatically detects this file and injects its contents into the prompt context for any Copilot Chat conversation, multi-file edit session, or automated pull request review within the project.
Keep this file concise—under 100 lines. Focus on high-level architecture, language defaults, and universal project patterns.
# Repository Coding Standards
## Core Architecture & Runtime
- Target Node.js 20+ and TypeScript 5.4+ with strict mode enabled.
- Framework: Next.js 14 App Router. Never generate Pages Router (`pages/`) conventions.
- Data layer: Prisma ORM. Do not write raw SQL queries unless explicitly requested.
## Code Conventions
- Prefer functional components and composable functions. Avoid class-based inheritance.
- Export named functions and constants; avoid default exports.
- Use explicit return types on all exported service functions and public API handlers.
- When handling exceptions, always use our custom `AppError` class from `@/lib/errors`. Never throw raw strings.
## Forbidden Patterns
- Never use the `any` type in TypeScript; use `unknown` and apply runtime type narrowing.
- Do not import `lodash` or `moment`. Use native ECMAScript methods and `date-fns`.
- Never use `console.log` in backend code; use the internal logger `logger.info()` from `@/lib/logger`.
365Finds strongly advises framing instructions as direct, imperative commands rather than conversational advice. Models respond with far higher adherence to "Use native ECMAScript methods" than "We encourage developers to consider modern JavaScript alternatives".
2. Scoping Modular Standards with Path-Specific Instructions
Dumping frontend styling rules, backend database rules, and integration test setup into a single file pollutes Copilot's context window. Frontend engineers do not need Prisma transaction rules, and backend engineers do not need Tailwind CSS utility ordering.
GitHub Copilot resolves this via path-specific instruction files. Place .instructions.md files in .github/instructions/ and define an applyTo glob pattern in the YAML frontmatter.
Example: Backend API Instructions (.github/instructions/api.instructions.md)
---
applyTo: "apps/api/**/*.ts"
---
# API Service Standards
- Validate all incoming HTTP payloads using Zod schemas located in `@/schemas`.
- Always return HTTP responses through the standardized `ApiResponse<T>` envelope.
- Database access must occur through repository classes inside `src/repositories/`. Do not query Prisma directly in controller routes.
- Enforce structured logging with request correlation IDs via `req.context.logger`.
Example: Unit and Integration Test Standards (.github/instructions/tests.instructions.md)
---
applyTo: "tests/**/*.test.ts"
---
# Testing Standards
- Testing runner: Vitest with `@testing-library/react`. Do not write Jest tests.
- Mock external network requests exclusively with MSW (Mock Service Worker).
- Name test suites using the pattern `describe('<ModuleOrHook>', ...)` and test cases using `it('should <expected_behavior> when <state>')`.
- Clean up state inside `afterEach` hooks using our custom `resetTestDb()` helper.
When a developer opens tests/auth/login.test.ts and asks Copilot to generate a test case, Copilot dynamically incorporates both the repository-level instructions and the test-specific instruction file, ignoring irrelevant API or UI guidelines.
3. Configuring Workspace Rules in VS Code (settings.json)
To lock down team-wide behavior at the IDE level, commit workspace configurations inside .vscode/settings.json. This ensures every contributor who clones the repository inherits identical Copilot behavior.
VS Code exposes github.copilot.chat.codeGeneration.instructions and commit message customization:
{
"github.copilot.chat.codeGeneration.useInstructionFiles": true,
"github.copilot.chat.codeGeneration.instructions": [
{
"text": "Always write comments and documentation in US English."
},
{
"file": "./docs/architecture-decisions.md"
}
],
"github.copilot.chat.commitMessageGeneration.instructions": [
{
"text": "Follow Conventional Commits format (feat, fix, refactor, docs, chore). Keep summary line under 72 characters. Reference Jira tickets in format [PROJ-1234] at the start of the commit title."
}
]
}
Developers can inspect and test which instructions are currently active in their workspace by opening the Command Palette (Ctrl+Shift+P / Cmd+Shift+P) and selecting Chat: Open Customizations.
Where Custom Instructions Work—and Where They Fail
At 365Finds, we believe in testing tools against practical engineering realities. Custom instruction files are not magic:
- Copilot Chat, Copilot Edits, and GitHub PR Reviews obey instructions reliably. When Copilot builds a prompt for a chat response or multi-file code refactoring, it loads the relevant Markdown instructions into its system context.
- Inline ghost-text autocomplete does not reliably enforce custom instructions. Inline completions run in tens of milliseconds with strict latency budgets. They rely primarily on open editor tabs, cursor position, and nearest neighbor code snippets, not extensive instruction evaluation.
- Instructions do not replace automated CI checks. Copilot will still occasionally suggest an unapproved library if an external snippet in its pre-training data resembles your code. Linters, compilers, and security scanners remain non-negotiable.
Operational Best Practices for Engineering Leads
- Audit instructions quarterly: Delete rules for deprecated libraries once migrations finish. Lingering rules waste prompt tokens.
- Provide positive structural examples: When demanding a specific pattern, provide a three-line Markdown snippet illustrating the target syntax. Copilot mirrors concrete code examples faster than abstract prose.
- Keep files lean: If
.github/copilot-instructions.mdexceeds 1,000 words, split it into path-specific files usingapplyTo.