用 Codex 做 GitHub 代码审查
Codex code review 可以为 GitHub pull requests 增加一轮 high-signal review。
📖 本篇术语速查表
| 英文 / 缩写 | 中文 | 一句话解释 |
|---|---|---|
| Code Review | 代码审查 | 让 Codex 审查 PR 并给意见。 |
| Automatic Reviews | 自动审查 | PR 触发时自动跑 Codex 审查。 |
| Customize | 自定义 | 配置 Codex 审查关注的重点。 |
不想读完?把下面这段提示词丢给 AI 帮你跑完——帮你配好 Codex 的 GitHub 代码审查(开启、自动化、定制重点)。
你是 Codex GitHub 代码审查配置顾问,帮我配好 Codex 审查,让它审到点子上又不打扰。
【角色】
你熟悉启用前准备、设置 Codex Code Review、请求审查、开启自动审查、定制审查关注点。
【输入】
- 我的仓库和团队规模:___
- 想让 Codex 重点审什么(安全 / 风格 / 逻辑 / 测试):___
- 手动触发还是自动审查:___
- 现有的人工审查流程:___
【工作流程】
1. 给启用前的准备和设置步骤
2. 说明手动请求和自动审查怎么配
3. 定制审查关注点,避免噪音
4. 让 Codex 审查和人工审查互补
【输出规范】
▌一、启用与设置步骤
▌二、手动 / 自动审查配置
▌三、审查关注点定制
▌四、和人工审查的配合
【硬约束】
- 审查重点按团队实际定制,避免大量噪音
- Codex 审查是辅助,关键决策仍由人定
- 自动审查别淹没真正重要的意见
- 敏感仓库的审查权限收紧
- 不确定的配置标注需查官方文档Codex code review 可以为 GitHub pull requests 增加一轮 high-signal review。
Codex 会 review pull request diff,遵循 repository guidance,并发布标准 GitHub code review,重点关注严重问题。
演示视频:
https://www.youtube.com/watch?v=HwbSWVg5Ln4
Before You Start
开始前,确认你已经具备:
- 已为需要 review 的 repository 设置 Codex cloud。
- 可以访问 Codex code review settings。
- 如果希望 Codex 遵循 repository-specific review guidance,请准备
AGENTS.mdfile。
Set Up Codex Code Review
- 设置 Codex cloud。
- 打开 Codex settings。
- 为你的 repository 打开 Code review。
截图:
https://developers.openai.com/images/codex/code-review/code-review-settings.png
Request a Codex Review
- 在 pull request comment 中 mention
@codex review。 - 等 Codex 先 reaction(👀),再发布 review。
截图:
https://developers.openai.com/images/codex/code-review/review-trigger.png
Codex 会像 teammate 一样在 pull request 上发布 review。
在 GitHub 中,Codex 只标记 P0 和 P1 issues,让 review comments 保持聚焦,集中在 high-priority risks 上。
示例截图:
https://developers.openai.com/images/codex/code-review/review-example.png
Enable Automatic Reviews
如果希望 Codex 自动 review 每一个 pull request,请在 Codex settings 中打开 Automatic reviews。
打开后,只要有人打开新的 PR for review,Codex 就会发布 review,不再需要 @codex review comment。
Customize What Codex Reviews
Codex 会在 repository 中搜索 AGENTS.md files,并遵循其中的 Review guidelines。
要为 repository 设置 guidelines,请添加或更新 top-level AGENTS.md,加入类似 section:
## 审查建议
- Don't log PII.
- Verify that authentication middleware wraps every route.Codex 会对每个 changed file 使用距离它最近的 AGENTS.md 中的 guidance。
如果某些 packages 需要额外审查,可以在 tree 更深处放更具体的 instructions。
如果只是单次 review 想临时聚焦某个方向,可以写在 pull request comment 中:
@codex review for security regressions如果你希望 Codex 标记 documentation 中的 typos,请在 AGENTS.md 里添加 guidance,例如:
Treat typos in docs as P1.Act on Review Findings
Codex 发布 review 后,你可以在同一个 pull request 里再留一条 comment,让它修复问题:
@codex fix the P1 issueCodex 会以该 pull request 作为 context 启动 cloud task。如果它具备对应 permission,也可以把 fix push 回该 branch。
Give Codex Other Tasks
如果你在 comment 中 mention @codex,但内容不是 review,Codex 会用该 pull request 作为 context 启动一个 cloud task。
@codex fix the CI failuresTroubleshoot Code Review
如果 Codex 没有 reaction,也没有发布 review:
- 确认已在 Codex settings 中为该 repository 打开 Code review。
- 确认 pull request 所属 repository 已设置 Codex cloud。
- 在 pull request comment 中使用精确 trigger:
@codex review。 - 对 automatic reviews,检查是否已打开 Automatic reviews,以及 pull request event 是否匹配 review trigger settings。