Sub topic 3
Scoping Copilot Reviews with Path-Specific Instructions
Assume you know Git branches, pull requests, basic Markdown, and YAML frontmatter. This chapter focuses on configuring Copilot reviews, not on creating a pull request.
Scope guidance to selected files
A path-specific instruction file applies guidance only to matching files. Store one in .github/instructions/, and add applyTo frontmatter with a repository-relative glob.
---
applyTo: "**/*.ts"
---
- Flag use of `any` unless a comment explains why it is needed.
- Check that async functions handle rejected promises.
- Prefer errors that include the operation and relevant identifier.This example guides reviews of TypeScript files without applying TypeScript rules to documentation or shell scripts. Keep instructions specific and testable. Explain what Copilot should check and why. Repository-wide instructions belong in .github/copilot-instructions.md; path-specific files add narrower rules.
Set up automatic reviews
Automatic reviews can request Copilot when a pull request is created or updated. Depending on your plan and organization settings, configure this through your personal GitHub settings or a repository ruleset. Check the resulting rule before relying on it. Confirm which branches and events trigger a review, and ensure required human reviewers remain required.
Review changes in your editor
Some supported editors can review local changes before you open a pull request. Open the source-control or Copilot review command, select the changed files, and inspect the findings. Editor support and commands vary by extension and plan. Treat this as an early feedback pass, not as the pull request's official review.
Limitations
Copilot can miss bugs, misunderstand project rules, or report harmless code. Its output is probabilistic, so repeated reviews can differ. It may also lack runtime context, private system knowledge, or the effects of a dependency change. Reproduce important findings with tests, documentation, or a local analysis tool.
Combine Copilot with human review
Use Copilot for repetitive checks and possible defects. Ask human reviewers to confirm requirements, architecture, security impact, data handling, and operational risk. A human owner should decide whether to apply or dismiss every finding.
Exercise
Where should a rule go if it should apply only to TypeScript files?
Show answer
Put it in a .github/instructions/*.instructions.md file and use applyTo: "**/*.ts" in its frontmatter.