讓 Codex 審查 GitHub PR
說明 Codex code review 如何在 GitHub PR 上補充 regression、missing tests 和 risky behavior signals。
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 裡可以頂層寫通用標準,再在支付、許可權、資料層等目錄放更具體規則。