Custom Instructions and Prompt Files
30-second answer
Custom instructions are standing rules that Copilot adds to requests for you. Repository-wide rules go in .github/copilot-instructions.md, which Copilot Chat, the coding agent and code review all read; path-specific rules go in .github/instructions/*.instructions.md with an applyTo glob; agents also read AGENTS.md. A prompt file (.github/prompts/*.prompt.md) is a reusable prompt you run with /name in chat, with front matter for mode, description, tools and model and ${input:name} variables, so everyone on the team sends the same request.
Exam objective: 2.3.3 Use Spaces, Spark, Pull Request summaries, and customizable review standards via instructions files. 2.3.4 Understand the limits, options, feedback, and commands of GitHub Copilot Chat; include prompt file reuse for consistent responses. (Skills measured as of August 7, 2026)
Simulations
Feel it before you read it. No account needed, nothing leaves this page.
<strong>Repository custom instructions</strong> live in <code>.github/copilot-instructions.md</code>. Copilot Chat, the coding agent and code review add them to requests in this repo automatically.
👆 Click the glowing item on screen to continue
Read the steps as text
- Repository custom instructions live in .github/copilot-instructions.md. Copilot Chat, the coding agent and code review add them to requests in this repo automatically.
- Path-specific instructions go in .github/instructions/.instructions.md with an applyTo glob, so test rules only apply to test files.
- A prompt file (.github/prompts/.prompt.md) is a reusable prompt. Everyone on the team gets the same, consistent request.
- Run it in chat by typing /new-endpoint. The answer shows which instruction and prompt files were used, so you can check they applied. Personal and organization instructions can be added too.
🧪 Simulation for learning. Screens are simplified versions of Visual Studio Code and github.com with GitHub Copilot; names, files and suggestions are examples. Not affiliated with GitHub or Microsoft, and nothing here touches your real account.
🖱️ Drag to rotate · scroll or pinch to zoom
Custom instructions
Repository instructions (.github/copilot-instructions.md) and path-specific .instructions.md files are added to requests automatically, so the house rules travel with every prompt.
🤔 What happens if…
Read this tour as text
- A vague prompt. Copilot only knows what is in the prompt. “Write a function” leaves it to guess the language, inputs, outputs and rules, so you get something generic.
- Structure: goal, context, constraints. A good prompt has a goal (what and why), context (which code, which framework) and constraints (style, edge cases, what not to do). Short is fine; vague is not.
- How context is chosen. In chat, Copilot uses the active file and any selection, plus what you add:
#file,#codebase(search your workspace),#terminalSelection, images, or a participant such as@workspace. Inline suggestions also use open tabs, so close unrelated ones. - Zero-shot and few-shot. Zero-shot: just the instruction. Few-shot: include one or more examples of the input and the output you want, then ask. Few-shot wins when your format is unusual.
- Break it down, then iterate. Split a big task into small steps and check each answer. Then iterate: keep what’s right and ask for the next change. Prompting is a conversation.
- Custom instructions. Repository instructions (
.github/copilot-instructions.md) and path-specific.instructions.mdfiles are added to requests automatically, so the house rules travel with every prompt. - Chat history is context too. Earlier messages in the same conversation go into the prompt. That helps follow-ups (“now add tests”) but old, unrelated turns can confuse the answer and fill the context window.
- The prompt process, end to end. Your words + selected context + instructions + history → the prompt. The model answers, you review, then refine. Better input, less clean-up.
Stop repeating yourself in every prompt. Write repository instructions, add path-specific instructions for tests, and create a custom agent that only writes tests, then watch Copilot follow them.
🎓 Education-only simulation. Your lab is saved in this browser, so you can leave and continue later.
😟 THE PROBLEM
You type “use the Node test runner, ES modules, no console.log” in every prompt.
😊 THE SOLUTION
Write it once as custom instructions, and save repeat tasks as prompt files.
- Repeating house rules✓ .github/copilot-instructions.md
- Rules for one folder✓ .instructions.md with applyTo
- The same task every week✓ .prompt.md run with /name
Start with a question
Why do I have to tell Copilot 'we use ES modules and the Node test runner' every single time?
You join the contoso-shop team. On day one you ask Copilot for a test, and it writes Jest with require(). The team uses the Node test runner and ES modules. So you correct it. Next chat, same thing. Next developer, same thing.
A new colleague would read the team’s README once and remember. Copilot doesn’t remember between chats, but it does read a file you give it. Put the house rules in .github/copilot-instructions.md and Copilot adds them to every request in that repo. Save the tasks you repeat as prompt files, and the whole team runs the same prompt with one slash command.
Explain it like I’m 10
Visual: Custom instructions in motion
Watch which instruction files ride along with a request, how applyTo picks the right ones, and how a prompt file runs with one slash command.
Read the video script
- Copilot guesses your conventionsYou ask Copilot for a test in contoso-shop. It doesn't know your team uses the Node test runner, so it writes Jest with require. Wrong for this repo.
- Write the rules down onceSo you write the house rules once, in dot github, copilot instructions dot md. Node 22, ES modules, tests with node dash dash test.
- The rules join every requestAsk again. This time the repository file rides along with your request, and the test uses node test and ES imports.
- Rules for some files onlyTest rules only matter for test files. Put them in a path-specific file with applyTo. You're working in tests slash cart dot test dot js, the glob matches, so it joins too.
- No match, no extra rulesNow you edit source discount dot js. The glob doesn't match, so the test rules stay out. Only the repository rules go in.
- A prompt the team reusesFor tasks you repeat, save a prompt file. Type slash new endpoint, resource equals orders, and the input variable becomes orders. Everyone sends the same request.
- Check what was usedThe answer lists the files it used, so you can check your rules applied. And the same repository file is read by Copilot Chat, the coding agent and code review.
- Steer, then verifyRemember, instructions steer the model, they don't enforce anything. Keep them short and clear, and let review and tests have the final word.
The technical explanation
Copilot only knows what’s in the prompt. Custom instructions and prompt files are two ways to put the same good context into the prompt every time, without typing it.
The instruction files
| File | Where | When it applies | Who reads it |
|---|---|---|---|
copilot-instructions.md | .github/ | Every request in the repository | Copilot Chat, Copilot coding agent, Copilot code review |
*.instructions.md | .github/instructions/ | Only when the files involved match its applyTo glob | Chat and agents in supported editors, coding agent, code review |
AGENTS.md | Repo root (or a folder) | Agent work in that part of the repo | Agents, including the coding agent |
| Personal and organization instructions | Your GitHub settings, or set by the org | Your requests, or the org’s | Copilot Chat on github.com and supported clients |
A repository file for contoso-shop might look like this:
# Copilot instructions for contoso-shop
- Node.js 22, ES modules, no CommonJS.
- Tests use the Node test runner: node --test.
- Never log secrets; read config from environment variables.
Keep it short and true for the whole repo. Rules that only matter for some files go in a path-specific file:
---
applyTo: "tests/**/*.js"
---
Arrange, act, assert. One behaviour per test.
Name each test after the behaviour it checks.
Save that as .github/instructions/tests.instructions.md. When you ask Copilot to change tests/cart.test.js, both files go into the prompt. When you change src/discount.js, only the repo-wide file does.
Did it work?
In Copilot Chat, the answer’s references list shows the instruction files that were used. If yours isn’t there, check the folder and file name, check that instruction files are turned on in your editor’s Copilot settings, and check that the applyTo glob really matches.
Prompt files: reusable prompts
A prompt file is a saved task. It lives in .github/prompts/ and ends in .prompt.md. The front matter is optional and can set:
| Field | What it does |
|---|---|
mode (or agent) | Which chat mode or custom agent runs it, for example agent |
description | The text you see when you pick the command |
tools | Which tools the prompt may use |
model | A model to use, if your organization allows it |
---
mode: agent
description: Add a REST endpoint with validation and tests
---
Create a new endpoint for ${input:resource}.
Validate input, return 400 on bad data, and add tests.
Save it as .github/prompts/new-endpoint.prompt.md and type /new-endpoint resource=orders in Chat. ${input:resource} becomes orders. Because the file is in the repo, the prompt gets reviewed in pull requests and improves over time, and every developer gets a consistent response shape.
Custom agents, briefly
If you keep asking Copilot to play the same role, make a custom agent: .github/agents/test-writer.agent.md with a name, a description, a short list of tools and its own instructions. In the CLI you can keep personal agents in ~/.copilot/agents/ and run one with --agent=test-writer or pick it with /agent.
-
1 You type
/new-endpoint resource=orders
-
2 Prompt file
new-endpoint.prompt.md expands with orders filled in.
-
3 Repo rules
.github/copilot-instructions.md is added.
-
4 Path rules
tests.instructions.md joins only when tests/ files are involved.
-
5 Answer
The references list shows which files were used.
Architect level Instructions steer; they don't enforce
Instructions are text added to the prompt. The model weighs them with everything else, so a long, contradictory file works worse than ten clear lines. Write rules as short statements, avoid “always try to” phrasing, and don’t paste whole style guides. If a rule must never break (no console.log of tokens, no new dependencies without approval), back it with a linter rule, a test or a branch protection check. Copilot code review reading your instructions is useful, but it leaves comments only, and a person still decides.
Real-world business scenario
Contoso (fictional)
- The problem
- Twelve developers on contoso-shop got Copilot answers in three test frameworks and two module styles, and new endpoints all looked different. Reviews kept catching the same style issues.
- What they used
- A ten-line .github/copilot-instructions.md, a tests.instructions.md with applyTo for tests/, and a new-endpoint.prompt.md that runs in agent mode.
- Why that choice
- The rules ride along with every chat, coding agent task and Copilot code review in the repo, and the prompt file gives everyone the same starting request.
- The result
- Generated tests now use the Node test runner by default, new endpoints follow one pattern, and reviewers spend their time on logic instead of style.
When to use it and when not to
✓ Use it when…
- Rules that are true for the whole repository: language version, test runner, security basics.
- Rules that only apply to some folders or file types, using applyTo.
- Tasks your team repeats, saved as prompt files so the request is the same every time.
✕ Think twice when…
- Secrets or private data. Instruction and prompt files live in the repo and go into prompts.
- Rules that must never break. Use linters, tests and branch protection, and let instructions remind.
- A huge style guide pasted in full. Short, clear rules work better.
↔ Alternatives to consider
- Custom agents (.agent.md) when you want a named role with its own tools.
- Copilot Spaces when the team needs shared documents and issues as context, not rules.
Test yourself with exercises
5 original practice questions in the GH-300 style. Pick your answers, then check them. You will see why each option is right or wrong. Score 75% or more and this topic is marked complete.
Interview preparation
Say your answer out loud first, then open the model answer. Interviewers care more about your reasoning than the exact words.
Beginner What's the difference between custom instructions and a prompt file?
Model answer
Custom instructions are always on. Copilot adds them to every relevant request without me asking, so they're for house rules like "we use ES modules". A prompt file only runs when I call it with /name. It's a saved task, like "add a REST endpoint with validation and tests".
Interviewer follows up
Where do they live?
You
Repository instructions in .github/copilot-instructions.md, path-specific ones in .github/instructions/ with an applyTo glob, and prompt files in .github/prompts/ as .prompt.md files.
Intermediate Your test rules keep showing up when Copilot edits production code. How would you fix that?
Model answer
I'd move them out of copilot-instructions.md into a path-specific file, say .github/instructions/tests.instructions.md, with applyTo set to "tests/**/*.js". Then they only ride along when the work touches test files.
Experienced developer How do you check that Copilot actually used your instructions?
Model answer
The chat response lists its references, and the instructions file shows up there when it was applied. If it's missing, I check the file name and folder, that the setting for instruction files is on in my editor, and that the applyTo glob really matches the file I'm working on.
Interviewer follows up
Can instructions guarantee Copilot follows a rule?
You
No. They're added to the prompt, so they steer the model, but the output still needs review. For hard rules I add a linter or a test that fails the build.
Scenario Five developers write the same "new endpoint" prompt five different ways and get five different styles. What do you do?
Model answer
Write one prompt file, .github/prompts/new-endpoint.prompt.md, with agent mode in the front matter and an ${input:resource} variable. Commit it, and everyone types /new-endpoint resource=orders. Same request, same shape of result, and the prompt gets reviewed like code.
Architecture & design How would you organise instructions in a large monorepo?
Model answer
Keep copilot-instructions.md short and true for the whole repo: language version, test runner, security rules. Then add one .instructions.md per area with its own applyTo, like the API, the web front end and the tests. Prompt files cover repeated tasks, and a custom agent covers a role such as a test writer with limited tools. Everything is in .github, so changes go through pull requests.
Quick revision
Key points
- .github/copilot-instructions.md holds repository-wide rules. Copilot Chat, the coding agent and code review read it.
- Path-specific rules go in .github/instructions/*.instructions.md with an applyTo glob in front matter.
- Agents also read AGENTS.md. Personal and organization instructions can exist too.
- Prompt files are .github/prompts/<name>.prompt.md and run with /name in chat.
- Prompt file front matter can set the mode or agent, a description, tools and the model. ${input:name} adds variables.
- Custom agents live in .github/agents/*.agent.md (repo) or ~/.copilot/agents/ (CLI, personal).
Important terminology
- Repository custom instructions
- A Markdown file at .github/copilot-instructions.md whose rules Copilot adds to chat, coding agent and code review requests in that repository.
- Path-specific instructions
- Files in .github/instructions/ ending in .instructions.md, with an applyTo glob in front matter so the rules only apply to matching files.
- applyTo
- The front matter field in an .instructions.md file that holds a glob such as "tests/**/*.js" to say which files the rules cover.
- AGENTS.md
- An instructions file that agents, including the Copilot coding agent, read for project rules.
- Prompt file
- A reusable prompt saved as .github/prompts/<name>.prompt.md and run in Copilot Chat by typing /name.
- Input variable
- A placeholder such as ${input:resource} in a prompt file that Copilot fills from what you type after the command.
- Custom agent
- A named persona with its own instructions and tools, defined in .github/agents/<name>.agent.md (or ~/.copilot/agents/ for the CLI).
Common mistakes
- Putting every rule in copilot-instructions.md so test-only rules apply to all code.
- Treating instructions as a guarantee. They steer the model; reviews, linters and tests still enforce the rule.
- Saving a prompt file outside .github/prompts or without the .prompt.md ending, then wondering why /name doesn't appear.
Exam tips
- "Rules for the whole repository, used by chat, coding agent and code review" = .github/copilot-instructions.md.
- "Rules only for some files" = .instructions.md with applyTo.
- "Reuse the same prompt for consistent responses" = prompt file run with /name.
Five quick revision questions
-
1.Which file holds repository-wide custom instructions?Show
.github/copilot-instructions.md.
-
2.Which front matter field limits an .instructions.md file to certain paths?Show
applyTo, with a glob.
-
3.How do you run .github/prompts/new-endpoint.prompt.md in chat?Show
Type /new-endpoint.
-
4.How do you add a variable to a prompt file?Show
With ${input:name}, for example ${input:resource}.
-
5.Does Copilot code review read repository custom instructions?Show
Yes, it uses them as the team's review standards.
Official references
Finished this lesson? Tick it off. Your progress is saved in this browser.
Next up: Copilot Code Review on Pull Requests
Lesson done? Make it stick with a quick gameSort It, Match the Pairs, Lightning Round and Who Am I? Earn XP and badges.