AI 程式設計教學中文版
官方教學中文版團隊與整合

用 Codex 做 GitHub 程式碼審查

Codex code review 可以為 GitHub pull requests 增加一輪 high-signal review。

📖 本篇術語速查表
英文 / 縮寫中文一句話解釋
Code Review程式碼審查讓 Codex 審查 PR 並給意見。
Automatic Reviews自動審查PR 觸發時自動跑 Codex 審查。
Customize自定義設定 Codex 審查關注的重點。

不想讀完?把下面這段提示詞丟給 AI 幫你跑完——幫你配好 Codex 的 GitHub 程式碼審查(開啟、自動化、定製重點)。

你是 Codex GitHub 程式碼審查設定顧問,幫我配好 Codex 審查,讓它審到點子上又不打擾。

【角色】
你熟悉啟用前準備、設定 Codex Code Review、請求審查、開啟自動審查、定製審查關注點。

【輸入】
- 我的儲存庫和團隊規模:___
- 想讓 Codex 重點審什麼(安全 / 風格 / 邏輯 / 測試):___
- 手動觸發還是自動審查:___
- 現有的人工審查流程:___

【工作流程】
1. 給啟用前的準備和設定步驟
2. 說明手動請求和自動審查怎麼配
3. 定製審查關注點,避免噪音
4. 讓 Codex 審查和人工審查互補

【輸出規範】
▌一、啟用與設定步驟
▌二、手動 / 自動審查設定
▌三、審查關注點定製
▌四、和人工審查的配合

【硬約束】
- 審查重點按團隊實際定製,避免大量噪音
- Codex 審查是輔助,關鍵決策仍由人定
- 自動審查別淹沒真正重要的意見
- 敏感儲存庫的審查許可權收緊
- 不確定的設定標註需查官方文件

Codex code review 可以為 GitHub pull requests 增加一輪 high-signal review。

Codex 會 review pull request diff,遵循 repository guidance,併發布標準 GitHub code review,重點關注嚴重問題。

演示影片:

https://www.youtube.com/watch?v=HwbSWVg5Ln4

Before You Start

開始前,確認你已經具備:

  • 已為需要 review 的 repository 設定 Codex cloud
  • 可以訪問 Codex code review settings
  • 如果希望 Codex 遵循 repository-specific review guidance,請準備 AGENTS.md file。

Set Up Codex Code Review

  1. 設定 Codex cloud
  2. 開啟 Codex settings
  3. 為你的 repository 開啟 Code review

截圖:

https://developers.openai.com/images/codex/code-review/code-review-settings.png

Request a Codex Review

  1. 在 pull request comment 中 mention @codex review
  2. 等 Codex 先 reaction(👀),再發布 review。

截圖:

https://developers.openai.com/images/codex/code-review/review-trigger.png

Codex 會像 teammate 一樣在 pull request 上釋出 review。

在 GitHub 中,Codex 只標記 P0 和 P1 issues,讓 review comments 保持聚焦,集中在 high-priority risks 上。

示例截圖:

https://developers.openai.com/images/codex/code-review/review-example.png

Enable Automatic Reviews

如果希望 Codex 自動 review 每一個 pull request,請在 Codex settings 中開啟 Automatic reviews

開啟後,只要有人開啟新的 PR for review,Codex 就會發布 review,不再需要 @codex review comment。

Customize What Codex Reviews

Codex 會在 repository 中搜尋 AGENTS.md files,並遵循其中的 Review guidelines

要為 repository 設定 guidelines,請新增或更新 top-level AGENTS.md,加入類似 section:


## 審查建議

- Don't log PII.
- Verify that authentication middleware wraps every route.

Codex 會對每個 changed file 使用距離它最近的 AGENTS.md 中的 guidance。

如果某些 packages 需要額外審查,可以在 tree 更深處放更具體的 instructions。

如果只是單次 review 想臨時聚焦某個方向,可以寫在 pull request comment 中:

@codex review for security regressions

如果你希望 Codex 標記 documentation 中的 typos,請在 AGENTS.md 裡新增 guidance,例如:

Treat typos in docs as P1.

Act on Review Findings

Codex 釋出 review 後,你可以在同一個 pull request 裡再留一條 comment,讓它修復問題:

@codex fix the P1 issue

Codex 會以該 pull request 作為 context 啟動 cloud task。如果它具備對應 permission,也可以把 fix push 回該 branch。

Give Codex Other Tasks

如果你在 comment 中 mention @codex,但內容不是 review,Codex 會用該 pull request 作為 context 啟動一個 cloud task

@codex fix the CI failures

Troubleshoot Code Review

如果 Codex 沒有 reaction,也沒有釋出 review:

  • 確認已在 Codex settings 中為該 repository 開啟 Code review
  • 確認 pull request 所屬 repository 已設定 Codex cloud
  • 在 pull request comment 中使用精確 trigger:@codex review
  • 對 automatic reviews,檢查是否已開啟 Automatic reviews,以及 pull request event 是否匹配 review trigger settings。

本頁目錄