AI 编程教程中文版
官方教程中文版实战场景

让 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

适合什么任务

场景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 surfaceshttps://github.com/openai/skills/tree/main/skills/.curated/security-best-practices

相关官方说明:

起始提示词

在 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 behaviorauth、billing、deletion、migration、background job 是否有风险
Documentationpublic API、配置、用户可见行为是否需要同步文档
Securitysecrets、permissions、dependency、input validation 是否有问题

如果 PR 很小,可以只用默认 review。如果 PR 涉及安全、权限、数据删除、支付或迁移,应该在 comment 或 AGENTS.md 里明确要求 Codex 提高这些风险的优先级。

使用方式

  1. 先把 Codex code review 添加到 GitHub organization 或 repository。
  2. 选择自动 review 每个 pull request,或在需要时用 @codex review 手动触发。
  3. 如果 Codex 提出问题,先 review 它的 evidence 和建议。
  4. 需要它修复时,再用 @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 里可以顶层写通用标准,再在支付、权限、数据层等目录放更具体规则。

官方资料

本页目录