Custom instructions and agent files
Copilot behaves according to the context you give it. Several files exist, and the exam checks whether you know which one fits a requirement.
Instruction files
| File | Scope | Notes |
|---|---|---|
.github/copilot-instructions.md | Whole repository | Read by chat, agent mode, the coding agent and Copilot code review |
.github/instructions/*.instructions.md | Matching paths | Frontmatter applyTo: "src/**/*.ts" |
AGENTS.md | Repository or folder | Agent instructions; the nearest file wins |
| Personal and organization instructions | User or org | Lower priority than repository ones |
Instructions are plain Markdown: build commands, test commands, coding conventions, what to avoid. Keep them short and specific. Vague text such as “write good code” does nothing.
Prompt files and custom agents
A prompt file (.github/prompts/name.prompt.md) is a reusable prompt you run on demand, for example from the chat with a slash command. It is a task template.
A custom agent (.github/agents/name.agent.md) is a persona with its own instructions, allowed tools and sometimes a model. The frontmatter holds description, tools, and optional handoffs. Use one when a role needs a different tool set, such as a read-only planner and an implementation agent.
Instructions are guidance, not enforcement
If an agent must not change .github/workflows/*, an instruction is a request the model may ignore. Real enforcement lives in GitHub settings: rulesets, required reviews and CODEOWNERS, covered in the governance lessons.
Excluding content
Instruction files shape behavior; they do not hide files. Content exclusion is a separate Copilot policy set by administrators. A .copilotignore file is not the mechanism the exam expects.
Exam traps
- Repository-wide review guidance goes in
.github/copilot-instructions.md, not in the pull request template. - Path scoping uses
.instructions.mdwithapplyTo, not a second root file. - Agent files under
.github/agentsdefine agents; they do not apply as general repository instructions. - Instructions do not enforce policy. Use rulesets when something must be blocked.
Practice questions
Choose an answer, then review the explanation to check your understanding.
1. You want guidance that applies to every request in a repository, including Copilot code review. Which file do you create?
Show answer
Answer: B..github/copilot-instructions.md holds repository-wide instructions that Copilot features, including code review, apply.
2. Rules should apply only to files that match src/**/*.ts. What do you use?
Show answer
Answer: A.Files in .github/instructions/ named *.instructions.md use an applyTo glob to scope the rules.
3. Where do you define a reusable specialist agent with its own tools and prompt?
Show answer
Answer: A.Custom agents are .agent.md files, with YAML frontmatter for tools and model, stored in .github/agents.
4. A coding agent keeps editing workflow files to hide failing checks. Which control actually enforces that it cannot do this?
Show answer
Answer: B.Instructions guide behavior but are not enforcement. A ruleset with required reviewers enforces it.