Learn how to build and use GitHub Copilot custom instructions to make the AI behave predictably in your repos. Covers setup, writing techniques, three generation methods, and real-world troubleshooting.
This guide covers everything you need to know about GitHub Copilot custom instructions: what they are, why they matter, how to write them, and how to use them to make Copilot behave predictably in your repos. It is for developers who want to move beyond default Copilot behavior and get consistent, useful outputs from the AI assistant.
Before you start, you need the following:
Copilot instructions are Markdown files that tell Copilot how to behave in a specific context. They act like a briefing document for the AI: they set rules, define style, list constraints, and provide context that Copilot cannot guess on its own.
According to the official documentation, Copilot is an AI coding assistant that helps you write code faster and with less effort. But it is not a mind reader. The official best practices guide states: "Understand Copilot's strengths and weaknesses." Copilot excels at writing tests, debugging syntax, explaining code, and generating regular expressions. It is not designed to replace your expertise or respond to non-coding prompts.
Instructions bridge the gap between what Copilot can do out of the box and what you actually need it to do in your specific codebase.
Instructions are not a flat list. They form a priority stack. The order in which Copilot processes instructions matters. As one community expert explains: "The ordering matters. LLMs will start summarizing aggressively after processing the first chunk of input. If something matters, put it where it's least likely to be compressed."
The full set of system instructions that Copilot sends with every request includes:
If you introduce instructions that directly conflict with the system-level ones, the results get worse, not better. The community expert advises against using "expert" statements because the system already includes them, and they can do more harm than good by encouraging the model to overestimate its capabilities.
Instructions can exist at three levels:
.chatmode.md files.For repository-level instructions, create a file at one of these paths in your repo:
.github/copilot-instructions.md.github/instructions/ (a folder containing multiple instruction files)If you use the folder approach, you can create multiple instruction files with front-matter that defines which files they apply to. For example:
---
applyTo: src/main/java/dao/**/*
---
# My Custom Database Instructions
This file applies only when Copilot references files matching the applyTo glob pattern. This keeps instructions focused and prevents bloat in the main file.
The official documentation emphasizes prompt engineering: "Break down complex tasks. Be specific about your requirements. Provide examples of things like input data, outputs, and implementations. Follow good coding practices."
Instructions are essentially system prompts that you control. They should be:
Based on the community sources, effective instructions cover these areas:
One community expert uses this tone section:
## Tone and Behavior
- Be dry. Be pragmatic. Be blunt. Be efficient with words.
- Inject humor often, especially when aimed at the developer
- Emojis are encouraged **in chat** and **docs headers** only 🔧
- Confidence is earned through verification, not vibes
- You're supposed to be assholishly loud, when you know you're right
- You are not allowed to guess quietly
This is intentionally not the "helpful" default personality. The expert explains: "The very first thing I do with any new system is kill off the default 'helpful' personality." The goal is efficiency, not flattery.
To ensure Copilot verifies its own work, use a mandatory verification loop:
### Mandatory Verification Loop (Bounded, With Escape Hatch)
- Before responding with code or implementation changes, run a **validation loop** covering:
- formatting and linting
- tests executed and passing
- coverage reviewed
- documentation updated (when relevant)
- security implications considered
- solution simplicity verified
**Tool Preference**: When `make ai-checks` exists in the repo, prefer it over ad-hoc validation commands.
- **Maximum iterations: 3 total attempts.**
The community expert notes: "The simplest way I've found to standardize validation for AI is with a Makefile. It gives you one place, regardless of language, to define format, lint, and test, plus a dedicated ai-checks target that runs them in the correct order."
To keep Git history clean, restrict Copilot from staging, committing, or pushing:
### Git Discipline
- Never stage files.
- Never commit.
- Never push.
- The user owns git.
- You touch files, not history.
- All read **git** commands must disable paging using `--no-pager`.
- Any git command that opens a pager is a failure.
- If output disappears, the command might as well not have run.
The --no-pager rule prevents Copilot from getting stuck waiting for input when viewing diffs. The expert admits there is value in auto-commit for some setups, but as a baseline, the rule stays.
Prevent Copilot from silently modifying config files:
### Repository Configuration Boundaries
- You may **not** modify repository configuration files unless explicitly instructed.
- This includes: dotfiles, package.json, pyproject.toml, tsconfig.json, eslint configs, prettier configs, etc.
- This applies to files that **control or maintain the repo itself**.
- This does **not** include code or documentation the repo is designed to provide.
- You **must** surface recommended config changes clearly in chat when they would improve correctness, safety, or consistency.
- Suggestions are expected.
- Silent edits are forbidden.
This prevents Copilot from disabling linters or formatters to get a green check.
Define which tools Copilot should use for different languages:
## Language-Specific Toolchains
### Python Tooling
Apply these rules only in repositories that contain Python code:
- Always use **`uv`**.
- Never invoke `pip` directly.
- Assume `uv` for installs, execution, and environment management.
### Node.js Constraints
Apply these rules only in repositories that contain Node/JS/TS:
- Target **Node.js >= 24**.
- Target **ESM only**.
- Do not introduce:
- CommonJS patterns
- legacy loaders
- compatibility shims
### Java Management
Apply these rules only in repositories that contain Java or JVM-based builds:
- Use SDKMAN! with a checked-in `.sdkmanrc` for all Java-based repos.
- If any pinned version is unavailable on the host, bump to the nearest available patch of the same major/minor and update `.sdkmanrc` accordingly.
- Run Maven/Gradle only via the SDKMAN!-provided binaries, no ambient system Java.
These rules are a target state, not an existence check. If your local setup differs, adjust accordingly.

You do not have to write instructions from scratch. There are three main approaches, each with different strengths.
This is the built-in option in VS Code. It scans your repo and generates a structured instructions file.
How to run it:
Generate Instructions.Alternate method:
Chat: Generate Workspace Instructions File.What it produces: A structure-first document with sections like "Welcome to this repository," "Project Structure," and "Key Concepts." It calls out workflows and automation. It is tidy and functional.
Pros: Fast, built-in, no external tools needed. Cons: Can be verbose. Includes boilerplate like "Welcome" blurbs that are not useful for Copilot. May miss domain-specific context.
Community advice: "Let your formatter and linter handle style rules so you don't waste instruction space showing Copilot where commas go."
Coding Agent is an AI agent that runs on Claude Sonnet 4. You cannot change the model. It generates instructions by analyzing your repo on GitHub.com.
How to run it:
What it produces: A rules-of-the-game document with sections on guidelines, principles, and styles. It includes content guidelines, writing style notes, and real markdown link refs for internal docs. It also tries to add a Contribution Guidelines section, which belongs in CONTRIBUTING.md, not in Copilot instructions.
Pros: PR-safe (always creates a separate branch), good architectural overview, handles multiple tasks in one prompt. Cons: Can add unnecessary sections. May guess if you are not specific. Runs on a fixed model.
Community advice: "The specifics here are key. Think of it like you're leading KT. What are all the important highlights that you'll need to get the basics across? If you're not sure, it's better to omit something than be wrong or mention a maybe that will force Copilot to guess on your behalf."
This is a custom chat mode created by a community expert. It runs on GPT-4.1. It is a Q&A-based approach where you fill in the stuff Copilot cannot guess: SLAs, weird dependencies, production lore.
How to run it:
.chatmode.md) and copy the raw content.What it produces: A player's-role document that jumps straight into "Purpose" and "Value." It includes chat modes, prompts, and instructions that make Copilot's role more engaging. It adds extras: "Maturity Level" (is the project actively maintained?), "Dependencies on Other Systems," anti-patterns, testing plans, and deployment notes.
Pros: Deeply contextual, includes lore and anti-patterns, requires user participation for accuracy. Cons: Takes longer to spin up. Requires you to know and articulate your repo's specifics.
Community advice: "This is the only version that requires the user to participate up front. So naturally it takes longer to spin up. If you're asking me? Completely worth the trade off."
When you stack them side-by-side, the philosophy differences are clear:
The ideal file is a hybrid. Take structure from Microsoft, guideline clarity from Coding Agent, and persona and context from The Instructionalist. Every generated file is long, so cut anything that is not adding obvious value. Save extras in a /future-review folder. Keep essentials in the main file.
Instructions are not set-and-forget. The community expert warns: "Old instructions are just as dangerous as no instructions at all."
The community expert recommends using AI to write instructions for AI. Use prompts like:
- Review this #file:my-global-user.instructions.md for conflict, ambiguity or make targeted edits to optimize.
- Ask for clarity on intent, whenever needed.
- Optimize this file for AI consumption and processing without human input.
- Output all recommendations for changes that would resolve conflicts or resolve ambiguity.
- If it's simply clarity, then output in a separate list
This framing helps orient the system toward your actual goal instead of guessing.

If Copilot is not following your instructions, check these things:
.github/copilot-instructions.md or .github/instructions/.If Copilot writes essays instead of code, add tone rules like "Be dry. Be pragmatic. Be blunt. Be efficient with words." The community expert says: "The moment a small essay starts forming in chat, I'm out."
If Copilot is changing your eslint config or package.json, add configuration boundary rules. The expert's rule set explicitly forbids silent edits to config files.
If Copilot is touching Git history, add Git discipline rules. The expert's rule set says: "Never stage files. Never commit. Never push. The user owns git."
If Copilot uses pip instead of uv, or CommonJS instead of ESM, add language-specific toolchain rules. The expert's rule set defines tool preferences for Python, Node.js, and Java.
If Copilot presents code without running tests or linting, add a mandatory verification loop. The expert's rule set includes a bounded validation loop with a maximum of three attempts.
Once you have basic instructions working, explore these next steps:
applyTo front-matter to create focused instruction files for specific parts of your codebase.The community expert's awesome-github-copilot repo at github.com/anchildress1/awesome-github-copilot contains instruction templates, chat modes, and other resources. It is a work in progress but already has useful gems.
Remember: "AI is not a coding magician. It's also not a particularly great guesser." Instructions are your way to tell it what you expect. Invest the time upfront, and Copilot will reward you with consistent, predictable, useful outputs.
Learn how to use GitHub Copilot to convert issues into pull requests while managing premium request quotas. Covers model selection, step-by-step implementation, and community-tested workflow patterns.
Learn how to use GitHub Copilot for terminal command suggestions, including setup in Windows Terminal and VS Code, custom keybindings for commit messages, usage tracking with community tools, and creative CLI projects.
Learn how to set up and tune GitHub Copilot Code Review for automated PR feedback. Covers enabling the feature, writing custom instructions to reduce noise, and iterating on the setup for long-term value.
Learn how to set up GitHub Copilot in VS Code, JetBrains IDEs, and Neovim. This guide covers installation, authentication, inline suggestions, Copilot Chat, best practices, and advanced configuration with custom instructions for code review.
Master Copilot Agent Mode with practical examples for multi-file editing, terminal commands, and autonomous coding workflows.
Learn to build GitHub Copilot Extensions using the Extensions API to create custom chat participants, slash commands, and MCP integrations.
Workflows from the Neura Market marketplace related to this CoPilot resource