AI 改仓库越来越快,瓶颈常卡在「谁来审这一版 diff」。Claude Code 侧站内已有 /code-review 与 REVIEW.md;Codex CLI 则自带专用入口:会话里 /review,或非交互 codex review。官方 CLI 文档把它放在「提交或开 PR 前的本地审查」位置,和写代码的主会话分开。
本文在 Codex CLI 0.164.0 + 本站 api.aicodewith.ai Provider(model=gpt-5.6-sol)上做了真实跑通:本地小 git 仓、故意埋回归,分别跑 codex review --uncommitted 与 codex review --base main。评分尺仍对照开源仓库 rubric.md(rust-v0.164.0)。
先说结论:
- 会话内
/review/ CLIcodex review:未提交、对照 base、单 commit、自定义 prompt 四选一。 - 审查线程默认
sandbox: read-only、approval: never(本机 stderr 会话头如此),只读 diff,不改工作区。 - 「空结果」真的会发生:弱瑕疵(如「除零会抛标准异常」)会被尺子滤掉;明显破坏既有语义时会出
[P1]。 approvals_reviewer=auto_review不是代码审查——别和/review搞混。
本机实测环境
codex --version
# 输出:codex-cli 0.164.0
# Provider / 模型(config.toml,不展示 Key)
# model_provider = "codex"
# model = "gpt-5.6-sol"
# base_url = https://api.aicodewith.ai/chatgpt/v1
# wire_api = responses
演示仓路径:/workspace/codex-live-demo(main 有初始 mathutil.py;feature/review-demo 上再引入 helpers.py 与 divide)。
和「开 PR 前 AI 审 diff」怎么对齐
站内场景页 AI code review 讲的是:开 PR 前让模型读 diff、找逻辑坑。Codex 的 /review 正是这一层官方落地。端到端点页面验收见 verification skill;本文只讲审 diff。
| 目标 | 会话里 | 非交互命令 | 读什么 |
|---|---|---|---|
| 未提交改动 | /review → Uncommitted | codex review --uncommitted | staged + unstaged + untracked |
| 相对基线(PR Style) | /review → base branch | codex review --base main | 相对 merge-base 的分支 diff |
| 单个 commit | /review → commit | codex review --commit <SHA> | 该 commit 引入的变更 |
| 自定义说明 | /review → custom | codex review "Focus on …" | 按你的文字收窄 |
实测 1:弱瑕疵 → 空结果(验证 rubric)
工作区相对 main 根提交,未提交地加上 divide(a,b): return a/b 与未跟踪 helpers.py(first 取 items[0])。跑:
cd /workspace/codex-live-demo
codex review --uncommitted
# 墙钟耗时:18.656 秒;exit 0
会话头(stderr,节选):
OpenAI Codex v0.164.0
workdir: /workspace/codex-live-demo
model: gpt-5.6-sol
provider: codex
approval: never
sandbox: read-only
stdout 结论原文:
The new code has no identifiable regression or actionable defect based on the available repository context. Division by zero and empty-sequence access retain standard Python exception behavior.
这和 rubric.md 一致:只报「作者知道了多半会修」的、由本次改动引入的硬伤;「没写除零保护」在没有项目约定时常常不算。空输出不是 CLI 坏了。
实测 2:明确回归 → 两条 [P1]
把未提交改动改成明显破坏既有语义:
# helpers.py:first 改成 return items[-1]
# mathutil.py:average 直接 return 0
codex review --uncommitted
# 墙钟耗时:15.659 秒;exit 0
stdout 摘要(原文结构保留):
Both modified functions violate their existing behavior: `first` returns the wrong element for multi-item inputs, and `average` ignores its input entirely.
Full review comments:
- [P1] Preserve first-item semantics — /workspace/codex-live-demo/helpers.py:3-3
For any sequence containing more than one item, this now returns the last element instead of the first...
- [P1] Compute the requested average — /workspace/codex-live-demo/mathutil.py:7-7
For every non-empty input whose average is not zero, this returns `0` regardless of the supplied values...
实测 3:codex review --base main
在 feature/review-demo 提交「加 divide/helpers」后对照 main:
codex review --base main
# 墙钟耗时:11.786 秒;exit 0
stderr 显示目标为 changes against 'main',并用 merge-base 式 git diff <main-sha>。本次 stdout 认为新增函数符合「基本运算」语义、除零走标准异常——再次说明:base 审查看的是分支 diff,不是全仓审计。
怎么接入(命令清单)
curl -fsSL https://chatgpt.com/codex/install.sh | sh
cd your-repo
codex # 交互里输入 /review
codex review --uncommitted
codex review --base main
codex review --commit <SHA> --title "…"
codex review "Focus on edge cases"
可选 review_model
# ~/.codex/config.toml
# slug 以 /model 列表为准
review_model = "gpt-5.6-sol"
本次审查线程实际用的就是会话模型 gpt-5.6-sol(未另设 review_model)。
别和 auto_review / Claude Code 搞混
| 名字 | 实际干什么 | 常见误用 |
|---|---|---|
| /review 或 codex review | 读 diff,出优先级问题 | 当成自动修 bug |
| approvals_reviewer=auto_review | 代审是否批准越权/联网 | 以为会审代码 |
| Claude Code /code-review | 另一套斜杠与 REVIEW.md | 命令原样抄到 Codex |
| verification skill | 驱动真应用端到端证明 | 和审 diff 互相替代 |
报错怎么办
- 401:先让普通
codex对话通,再跑 review(见 401 排查)。 - 满载/429:见 capacity / 429。
- 空结果:先确认 diff 非空,再对照 rubric;需要硬安全清单用自定义 prompt。
- 目录信任/沙盒:审查本身 read-only;日常写权限见 沙盒与 /permissions。
建议工作流
- 改完 →
codex review --uncommitted(本次明确回归约 16 秒量级); - 开 PR 前 →
codex review --base main; - 空结果只代表尺子下没硬伤,不代表可免测;
- 需要点页面证明 → verification,而不是加长 review prompt。



