让 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 里可以顶层写通用标准,再在支付、权限、数据层等目录放更具体规则。