Custom instructions and agent files

GH-600 · Agentic AI concepts on GitHub · Updated

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

FileScopeNotes
.github/copilot-instructions.mdWhole repositoryRead by chat, agent mode, the coding agent and Copilot code review
.github/instructions/*.instructions.mdMatching pathsFrontmatter applyTo: "src/**/*.ts"
AGENTS.mdRepository or folderAgent instructions; the nearest file wins
Personal and organization instructionsUser or orgLower 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.md with applyTo, not a second root file.
  • Agent files under .github/agents define 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.

GH-600 course outline

All 7 lessons · Course overview
  1. Copilot agent mode vs the coding agentAgentic AI concepts on GitHub Free
  2. Custom instructions and agent filesAgentic AI concepts on GitHub Free
  3. Copilot CLI plan mode, commands and permissionsDevelop with AI agents Full access
  4. Custom agents, subagents and handoffsDevelop with AI agents Full access
  5. Coding agent setup, secrets and monitoringDevelop with AI agents Full access
  6. Rulesets and guardrails for agentsGovern and secure agentic workflows Full access
  7. Audit logs, autonomy levels and agent evaluationGovern and secure agentic workflows Full access