讓 Codex 審查 GitHub PR
說明 Codex code review 如何在 GitHub PR 上補充 regression、missing tests 和 risky behavior signals。
📖 本篇術語速查表
| 英文 / 縮寫 | 中文 | 一句話解釋 |
|---|---|---|
| PR 審查 | PR review | 用 Codex 審查一個 Pull Request。 |
| 關注點 | review focus | 這次審查重點看什麼。 |
| 人工把關 | human gate | 關鍵決策仍由人定。 |
不想讀完?把下面這段提示詞丟給 AI 幫你跑完——幫你用 Codex 審查一個 GitHub PR,審到點子上又不漏關鍵問題。
你是 Codex PR 審查顧問,幫我用 Codex 審查一個 PR,聚焦關鍵問題、不漏不噪。
【角色】
你知道怎麼用 Codex 審查 GitHub PR、怎麼定審查關注點、怎麼讓 AI 審查和人工把關互補。
【輸入】
- PR 的改動範圍和目的:___
- 我最擔心的方面(正確性 / 安全 / 效能 / 風格):___
- 專案的關鍵約定:___
- 是否有測試:___
【工作流程】
1. 定這次審查的關注點(按風險排序)
2. 讓 Codex 按關注點審查改動
3. 區分必須改、建議改、可忽略
4. 標出需人工最終把關的部分
【輸出規範】
▌一、審查關注點
▌二、按關注點的審查發現
▌三、必須改 / 建議改 / 可忽略
▌四、需人工把關的部分
【硬約束】
- 聚焦關鍵風險,不堆一堆雞毛蒜皮
- 安全 / 正確性問題優先標出
- 關鍵決策由人定,Codex 是輔助
- 審查意見對應具體程式碼行
- 不臆斷意圖,存疑的標出來
- 給的發現具體可操作Codex code review 可以在 GitHub pull request 上自動指出 regressions、missing tests、documentation issues 和 risky behavior changes,作為人工 review 前的額外訊號。
官方頁面:https://developers.openai.com/codex/use-cases/github-code-reviews
官方封面圖路徑:https://developers.openai.com/codex/use-cases/gh-pr-use-case.png
PR review use case
用 Codex 在 GitHub PR 上捕捉 regression 和 missing tests。
GitHub integration
設定自動 review、手動 @codex review 和後續 fix task。
Rules and AGENTS.md
用儲存庫規則告訴 Codex 哪些風險更重要。
適合什麼任務
| 場景 | Codex 應該做什麼 |
|---|---|
| 團隊希望 merge 前多一個 review signal | 自動 review 每個 PR,或按需透過 comment 觸發 |
| 生產專案的大型 codebase | 重點看 regression、missing tests 和 risky behavior changes |
| PR 涉及 secrets、auth、dependency changes | 用 $security-best-practices 強化安全相關 review |
推薦執行環境:cloud。
使用的能力
| 能力 | 用法 | 連結 |
|---|---|---|
$security-best-practices | 把 review 聚焦到 secrets、auth、dependency changes 等 risky surfaces | https://github.com/openai/skills/tree/main/skills/.curated/security-best-practices |
相關官方說明:
- Codex code review in GitHub:https://developers.openai.com/codex/integrations/github
- Custom instructions with AGENTS.md:https://developers.openai.com/codex/rules
起始提示詞
在 GitHub pull request comment 裡可以這樣觸發:
@codex review 請重點檢查 security regressions、missing tests 和 risky behavior changes。如果 Codex 指出了 regression 或 potential issue,可以繼續在 PR 裡評論:
@codex fix it 請修復這個問題。這會啟動一個新的 cloud task,修復問題並更新 pull request。
Review 重點
Codex review 的價值不在於代替人類做所有判斷,而是在 merge 前多一層機器可重複掃描:
| 重點 | Codex 應該看什麼 |
|---|---|
| Regression | 已有行為、測試、介面或 UI 是否被無意改變 |
| Missing tests | 新邏輯、bug fix、edge case 是否缺少覆蓋 |
| Risky behavior | auth、billing、deletion、migration、background job 是否有風險 |
| Documentation | public API、設定、使用者可見行為是否需要同步文件 |
| Security | secrets、permissions、dependency、input validation 是否有問題 |
如果 PR 很小,可以只用預設 review。如果 PR 涉及安全、許可權、資料刪除、支付或遷移,應該在 comment 或 AGENTS.md 裡明確要求 Codex 提高這些風險的優先順序。
使用方式
- 先把 Codex code review 新增到 GitHub organization 或 repository。
- 選擇自動 review 每個 pull request,或在需要時用
@codex review手動觸發。 - 如果 Codex 提出問題,先 review 它的 evidence 和建議。
- 需要它修復時,再用
@codex fix it觸發後續 task。
定義 Review Guidance
如果希望 Codex 按團隊標準 review,在 repo 頂層 AGENTS.md 中加入 review guidance。
官方示例:
## 審查建議
- 把 typos 和 grammar issues 標為 P0 issues。
- 把 potential missing documentation 標為 P1 issues。
- 把 missing tests 標為 P1 issues。
...實際專案裡,建議把 guidance 寫成真正的風險標準,例如:
- secrets、tokens、credentials 相關改動必須指出。
- auth、payment、permission、data deletion 改動要提高優先順序。
- public API、database migration、background job 要檢查回復和相容。
- 缺少測試時說明應補哪類測試。
Codex 會讀取離 changed file 最近的 AGENTS.md。如果某個 package 需要更具體的 review 標準,可以在更深層目錄放一個更貼近該模組的 AGENTS.md。
驗收重點
Codex review 不是替代人工 review。它適合先篩出:
- regression risk。
- missing tests。
- risky behavior changes。
- documentation gaps。
- security-sensitive surfaces。
人工 review 仍然要判斷業務語義、產品取捨和最終合併風險。
推薦團隊規則
可以把 review guidance 寫得更像工程標準:
## Review guidelines
- Prioritize P0/P1 findings only.
- Treat auth, billing, permissions, data deletion, migrations, background jobs, and dependency changes as high-risk surfaces.
- Missing tests are P1 when the PR changes behavior, fixes a bug, or adds a new branch in business logic.
- Do not flag style-only issues unless they affect readability or maintainability.
- If a finding depends on an assumption, state the assumption and the file evidence.Codex 會按 closest AGENTS.md 應用規則。monorepo 裡可以頂層寫通用標準,再在支付、許可權、資料層等目錄放更具體規則。