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