Sub topic 2
Applying and Dismissing Copilot Review Suggestions
Assume you know Git branches, commits, pull requests, and human review comments. You also need basic Markdown and YAML frontmatter.
Apply a suggestion
Read the comment before changing code. Confirm that the reported behavior is a real problem and that the proposed edit fits the surrounding design. Copilot's suggestion is advice, not an approval requirement.
For a simple inline suggestion:
- Open the pull request's Files changed tab.
- Read the comment and inspect nearby code.
- Select Commit suggestion if the proposed edit is correct.
- Add a useful commit message, then commit the change to the pull request branch.
- Run tests and inspect the resulting diff.
For a larger change, edit the branch locally instead. You may need to change tests, configuration, or related files that the suggested patch does not include.
Dismiss a suggestion
Dismiss a comment when it is incorrect, irrelevant, duplicated, or intentionally conflicts with the project's design. Add a short explanation when your team benefits from knowing why. Do not change code merely to remove a comment.
| Decision | Appropriate action |
|---|---|
| The issue is valid and the patch is safe | Apply it, then test |
| The issue is valid but the patch is incomplete | Make the full fix locally |
| The issue does not apply | Dismiss it with a reason |
Re-request a review after new commits
After pushing fixes, Copilot's earlier review may describe code that no longer exists. Use the re-request review control beside Copilot in the pull request's reviewer list. Request a fresh review after related commits, rather than repeatedly requesting reviews while the branch is changing.
Guide reviews with repository instructions
Repository-wide instructions give Copilot recurring review priorities. Save them as .github/copilot-instructions.md.
Path-specific instructions apply only to matching files. For example, save this as .github/instructions/typescript.instructions.md:
---
applyTo: "**/*.ts"
---
- Flag use of `any` unless a comment explains why it is needed.
- Check that async functions handle rejected promises.Keep instructions specific and focused on correctness, security, and project conventions. Do not ask Copilot to replace required human approval.
Exercise
You receive a suggestion to replace a database query with string concatenation. What should you do?
Show answer
Reject the suggestion, because concatenating query input can enable injection. Keep a parameterized query, explain the decision if needed, test the code, and request another review after committing related changes.