739 字
4 分鐘

GitHub Copilot Code Review 怎麼用 Skills 與 MCP?先限制脈絡與驗證方式

GitHub Copilot Code Review 現在可以使用 repository 的 agent skills 與 MCP server。最重要的邊界是:把它當成補充審查脈絡的唯讀工具,不是自動同意或自動修正的機制。

GitHub 2026 年 7 月 29 日將這兩項能力列為正式可用;Code Review 的 MCP tool call 受限於唯讀。既有給 Copilot cloud agent 的 repository MCP 設定會套用到 Code Review,GitHub MCP 與 Playwright MCP 預設開啟。

先分配 Skills、instructions 與 MCP 的工作#

需要的內容放置位置適合用途
長期、每次都適用的規則AGENTS.md.github/copilot-instructions.md架構、安全與測試基準
特定目錄才適用的規則.github/instructions/例如後端或 infrastructure 目錄
可重複執行的審查流程.github/skills/<name>/SKILL.mdmigration、付款或權限檢查
PR 外的即時資訊repository MCP 設定issue、文件、service catalog 或 incident 脈絡

不要把密碼、完整 production 設定或「可直接合併」這種指令塞進 skill。skill 內容應說明要驗證什麼、可用哪些唯讀資料,以及遇到不確定時應留下的問題。

一個可維護的 review skill#

為了讓用途清楚,目錄名稱直接描述 review 任務:

.github/skills/
└── code-review-security/
└── SKILL.md
---
name: code-review-security
description: Review authentication and authorization changes in pull requests.
---
When reviewing authentication code:
1. Identify every new trust boundary and authorization check.
2. Confirm tests cover denied as well as allowed access.
3. If an issue ID is present in the PR description, use the approved MCP source
only to compare the stated requirement; do not infer missing requirements.
4. Report unknowns as questions. Do not approve a pull request.

這份檔案的價值是讓 review 有可審核的範圍,不是把團隊手冊完整複製一次。GitHub 指出,review-focused 的 skill 名稱與描述、custom instruction 及 PR 中的 issue/incident 識別字,都能讓 Code Review 更容易採用相關脈絡。

特別注意 head branch#

Copilot review 讀的是 PR 的 head branch 上的 custom instructions、agent instructions 與 skills,不是 base branch。這讓你能在同一個 PR 測試 skill 變更,但也表示 reviewer 要把「變更過的規則」本身視為 review 對象。

提交前先做三件事:

  1. 比對 .github/skills/AGENTS.md.github/copilot-instructions.md 是否在這個 PR 被修改。
  2. 檢查 skill 是否引導讀取超出任務必要範圍的 MCP 資料。
  3. 把 rule 的預期效果寫在 PR 描述,讓人類 reviewer 能對照實際 comment。

驗證 MCP 有沒有真的被使用#

不要只因為 comment 看起來很精準,就假設它取用了正確外部資料。GitHub 的作法是從 PR timeline 開啟連結的 review session,再看 session logs 中實際呼叫的 MCP server 與 tool。若某個 server 不應出現在 code review,於 repository 設定關閉「Allow Copilot to use MCP tools when reviewing pull requests」;這不會等同停用 cloud agent 的所有 MCP 用途。

最後,人類 review 與 required approvals 仍要存在。Copilot 的 review comment 不會取代 required approval;skills 與 MCP 只是讓它提出更有脈絡、也更需要被追問的建議。

參考資料:

GitHub Changelog:Copilot Code Review 的 Skills 與 MCP 正式可用

GitHub Docs:Copilot Code Review 的 agent skills 與 MCP

GitHub Docs:新增 Copilot agent skills

GitHub Copilot Code Review 怎麼用 Skills 與 MCP?先限制脈絡與驗證方式
https://laplusda.com/posts/github-copilot-code-review-skills-mcp/
作者
Zero
發佈於
2026-07-30
許可協議
CC BY-NC-SA 4.0
這篇文章有幫助嗎?

回報錯字、失效連結,或告訴我你想看的延伸主題。