Telling an AI assistant to stop writing boilerplate or to use your specific project conventions on every single prompt is exhausting. At 365Finds, we find that default GitHub Copilot output often leans toward generic, lowest-common-denominator code patterns—antiquated syntax, missing types, or test suites written in frameworks your repository abandoned two years ago.
Visual Studio Code and GitHub Copilot provide concrete mechanisms to pin down coding style, architectural boundaries, and workflow conventions directly in your workspace. You do not need complex prompt engineering before every question. You need clean configuration files committed alongside your source code.
Here is how to configure repository-wide rules, task-specific hooks, and granular path instructions in VS Code.
The Foundation: Repository-Wide Rules via .github/copilot-instructions.md
The cleanest and most portable way to establish project rules is the repository-level instruction file. Whenever you open a workspace in VS Code, GitHub Copilot Chat automatically indexes this file and injects its rules into the background context of conversations and code-generation actions.
Setup Steps
- In the root of your project directory, create a
.githubfolder if it does not already exist. - Inside that folder, create a file named
copilot-instructions.md. - Write direct, imperative rules using standard Markdown.
- Commit the file to Git so every teammate inherits the same baseline.
Alternatively, you can open the Command Palette (Ctrl+Shift+P on Linux/Windows, Cmd+Shift+P on macOS) and run Chat: Open Customizations to manage instruction files visually through VS Code's Agent Customizations editor.
What an Effective Instruction File Looks Like
365Finds recommends keeping this file sharp and prescriptive. Copilot is an LLM, not an infinite context sponge. Dumping an entire 40-page corporate style manual guarantees that Copilot will overlook critical constraints due to attention dilution.
Keep it under 150 lines, focused on patterns the model frequently gets wrong:
# Repository Guidelines for GitHub Copilot
## Technology Stack & Architecture
- Framework: Next.js 14 App Router with React Server Components by default.
- Language: TypeScript in strict mode. Never use `any`; use `unknown` with runtime type narrowing.
- Styling: Tailwind CSS. Avoid inline CSS style attributes and separate CSS module files.
- State: Zustand for client store. Do not introduce Redux.
## Code Style & Constraints
- Prefer functional components and named exports over default exports.
- All database operations must go through Prisma clients located in `lib/prisma.ts`. Never query the database directly in client components.
- Handle API errors using custom `Result<T, E>` types instead of throwing raw exceptions.
## Testing Standards
- Test framework: Vitest and React Testing Library.
- Use the Given-When-Then structure for test naming.
- Mock network calls with MSW (Mock Service Worker), never raw `fetch` mocks.
Task-Specific Custom Rules in .vscode/settings.json
Repository-wide instructions set the general tone. But code generation, automated unit tests, and Git commit messages have conflicting requirements. A rule telling Copilot to write concise summaries for commit messages has no place inside your React architecture guidelines.
VS Code addresses this separation by exposing distinct instruction settings in your .vscode/settings.json (for project-specific sharing) or your global User Settings (for personal habits).
1. Code Generation Instructions
To guide chat edits and inline code synthesis, use github.copilot.chat.codeGeneration.instructions. You can provide inline text or point to dedicated external Markdown files:
{
"github.copilot.chat.codeGeneration.instructions": [
{
"text": "Always declare explicit return types on exported functions."
},
{
"file": "./docs/architecture-conventions.md"
}
]
}
2. Unit and Integration Test Generation
When triggering automated tests via Copilot Chat or CodeLens, github.copilot.chat.testGeneration.instructions steers test runner choices and assertion syntax:
{
"github.copilot.chat.testGeneration.instructions": [
{
"text": "Write tests using Playwright for end-to-end flows and Vitest for unit tests."
},
{
"text": "Never write empty test stubs. Mock external payments using Stripe Mock."
},
{
"file": "./.github/instructions/test-guidelines.md"
}
]
}
3. Commit Message Generation
Clicking the sparkle icon in the VS Code Source Control panel prompts Copilot to inspect staged diffs and draft a commit message. By default, it often writes unstructured sentences. You can force Conventional Commits using github.copilot.chat.commitMessageGeneration.instructions:
{
"github.copilot.chat.commitMessageGeneration.instructions": [
{
"text": "Follow the Conventional Commits specification: <type>(<scope>): <subject>."
},
{
"text": "Valid types: feat, fix, refactor, test, docs, chore. Subject must be in imperative mood and under 72 characters."
}
]
}
Scoped Rules for Monorepos: .github/instructions/
If you maintain a monorepo where the frontend runs React and the backend runs Go or Python, a single .github/copilot-instructions.md becomes messy. Instructions for React hooks clash with Python PEP-8 rules.
GitHub Copilot supports scoped instruction files placed in .github/instructions/:
- Create a file such as
.github/instructions/backend.instructions.md. - Add YAML frontmatter specifying an
applyToglob pattern:
---
applyTo: "apps/api/**/*.go"
---
# Go Backend Guidelines
- Use Go 1.22 standard library routing instead of Gin.
- Always check and wrap errors using `fmt.Errorf("...: %w", err)`.
- Use structured logging via `slog`.
When you edit a file matching that pattern, GitHub Copilot loads these scoped directives on top of the root instructions.
What 365Finds Recommends—and What to Avoid
At 365Finds, we look at custom instructions as lightweight rails, not magic wands. Here is where teams run into trouble:
- Instructions do not replace linters or compilers. If you want tabs instead of spaces, or no unused variables, configure ESLint, Biome, or Prettier. Copilot is non-deterministic. Expecting an LLM to never make a formatting error is an expensive mistake.
- Beware token inflation. Every instruction line eats context window budget. When you load 1,000 lines of markdown instructions, Copilot has less room for your actual code files, imported schemas, and conversation history.
- Show negative anti-patterns alongside positive rules. Telling Copilot "Use Prisma" often still results in it importing raw SQL libraries if that was common in older training data. Explicitly stating "Use Prisma; do not use raw
pgclient" gives the model a clear decision boundary. - Prefer
.github/copilot-instructions.mdover private user settings for team repositories. Personal settings live in your local VS Code profile; team files live in version control. Storing rules in the repository ensures that code written by junior engineers and senior engineers with Copilot assistance stays aligned with architectural choices.