# copilot-instructions.md template

> GitHub Copilot reads .github/copilot-instructions.md and adds it to every chat, agent and code review request in the repository. Copy the example below, replace the commands and rules with your own, and add files under .github/instructions for rules that apply only to some paths.

Updated November 30, 2026. Canonical: https://sniptide.com/templates/copilot-instructions
Open it in the Sniptide editor: https://app.sniptide.com/new?template=copilot-instructions
Files as JSON: https://sniptide.com/templates/copilot-instructions.json

## Files

### .github/copilot-instructions.md

```markdown
# Copilot instructions

This repository is a Next.js app with a Postgres database. It uses TypeScript, React Server
Components and Tailwind CSS. Packages are managed with pnpm.

## Build and test

- Install: `pnpm install --frozen-lockfile`
- Start the database: `docker compose up -d --wait`
- Run the app: `pnpm dev`, then open `http://localhost:3000`
- Before you finish, run `pnpm lint`, `pnpm typecheck` and `pnpm test`. All three must pass.

## Project layout

- `app/` holds routes. A folder is a URL segment, and `page.tsx` renders it.
- `components/ui/` holds shared components. Use them before writing new markup.
- `lib/db/` holds the schema and queries. Every query goes through these functions.
- `lib/db/migrations/` holds SQL migrations. Never edit one that has been merged.

## Code style

- Write server components by default. Add `"use client"` only for state, effects or browser APIs.
- Validate every request body and form input with the Zod schemas in `lib/validation`.
- Name files in kebab-case and components in PascalCase.
- Use Tailwind classes and theme tokens. Do not write hex colors in components.

## Testing

- Put a test next to the code it covers, as `name.test.ts`.
- Test behavior through public functions, not private helpers.
- A bug fix starts with a test that fails without the fix.

## Pull requests

- Keep one change per pull request, and describe what changed and how you checked it.
- Do not add dependencies without saying why in the pull request description.
- Never commit secrets. Configuration comes from environment variables listed in `.env.example`.
```

### .github/instructions/tests.instructions.md

```markdown
---
applyTo: "**/*.test.ts,**/*.test.tsx"
---

# Tests

- Use Vitest with `describe` and `test`. Do not use `it`.
- Build test data with the factories in `test/factories.ts` instead of inline objects.
- Tests that touch the database run against the Compose Postgres and clean up their own rows.
- Assert on what a user or caller sees, such as returned values and rendered text.
- Do not mock modules from this repository. Mock only network calls to other services.
```

## Where Copilot reads it [#where-copilot-reads-it]

Commit the file at `.github/copilot-instructions.md` on your default branch. Copilot Chat in VS Code and other supported editors, the Copilot coding agent and Copilot code review all add it to their requests in this repository. Check which surfaces your editor version supports in [GitHub's custom instructions documentation](https://docs.github.com/en/copilot/how-tos/configure-custom-instructions/add-repository-instructions).

To check that it loaded, ask Copilot Chat a question about the repository and open the references under the answer. `.github/copilot-instructions.md` appears in the list when Copilot used it.

## What each section does [#what-each-section-does]

| Section | What it gives Copilot | When to change it |
| --- | --- | --- |
| Opening paragraph | The stack in two sentences, so suggestions use the right framework and package manager. | When you change frameworks or package managers. |
| Build and test | The exact commands to install, run and check the project. The agent runs them before it finishes. | When a script in `package.json` changes. |
| Project layout | Where each kind of code lives. | When you add or move a top-level folder. |
| Code style | Rules a linter can't enforce, such as when to use client components. | When a review comment repeats. Turn it into a rule here. |
| Testing | Where tests go and what a good one checks. | When your test setup changes. |
| Pull requests | What the coding agent's pull requests must include. | When your review process changes. |

Keep each rule short and checkable. "Write clean code" changes nothing. "Validate every request body with the Zod schemas in `lib/validation`" changes the code Copilot writes.

## Path-specific instructions [#path-specific-instructions]

Files in `.github/instructions/` that end in `.instructions.md` apply only to the paths in their `applyTo` frontmatter. The example applies to test files, so test rules stay out of requests about other code. `applyTo` takes glob patterns separated by commas.

## Variant: one file for every agent [#variant-one-file-for-every-agent]

Copilot also reads `AGENTS.md`. When your team uses several agents, keep the shared rules in an [AGENTS.md](/templates/agents-md) and leave only Copilot-specific notes in `copilot-instructions.md`:

```md title=".github/copilot-instructions.md"
# Copilot instructions

Follow the project rules in `AGENTS.md` at the repository root.

When you review a pull request, comment only on correctness, security and missing tests.
Formatting is handled by the linter.
```
