How to use Codex /review: uncommitted changes, comparing against main, and codex review in CI (checked against the official rubric)

Tested with Codex CLI 0.164.0 and an API Key from this site: codex review --uncommitted flagged two [P1] issues on a clear regression (about 15.7s); minor flaws can produce an empty result; --base main took about 11.8s. Checked against the rubric, and with auto_review clearly separated from code review.

4 分钟阅读
How to use Codex /review: uncommitted changes, comparing against main, and codex review in CI (checked against the official rubric)

AI changes repositories faster and faster, and the bottleneck is often "who reviews this diff." On the Claude Code side, this site already covers /code-review and REVIEW.md; Codex CLI ships its own dedicated entry point: /review inside a session, or the non-interactive codex review. The official CLI docs place it as "local review before you commit or open a PR," separate from the main session where code gets written.

In this article we ran it for real on Codex CLI 0.164.0 + this site's api.aicodewith.ai provider (model=gpt-5.6-sol): a small local git repository with deliberately planted regressions, running both codex review --uncommitted and codex review --base main. The yardstick is still the open-source repository's rubric.md (rust-v0.164.0).

The bottom line first:

  • In-session /review / CLI codex review: pick one of four: uncommitted, against a base, a single commit, or a custom prompt.
  • The review thread defaults to sandbox: read-only and approval: never (as shown in the session header on stderr on our machine); it only reads the diff and does not change the working tree.
  • "Empty results" really do happen: minor flaws (such as "division by zero raises the standard exception") are filtered out by the rubric; clearly breaking existing semantics produces [P1].
  • approvals_reviewer=auto_review is not code review; don't confuse it with /review.

Create an API Key →

Our test environment

bash
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

Demo repository path: /workspace/codex-live-demo (main has the initial mathutil.py; feature/review-demo then adds helpers.py and divide).

How it lines up with "AI reviewing the diff before a PR"

The site's use case page AI code review is about having a model read the diff before a PR and find logic traps. Codex's /review is the official implementation of exactly that layer. For end-to-end acceptance by clicking through pages, see verification skill; this article covers only diff review.

GoalIn a sessionNon-interactive commandWhat it reads
Uncommitted changes/review → Uncommittedcodex review --uncommittedstaged + unstaged + untracked
Against a baseline (PR style)/review → base branchcodex review --base mainBranch diff against the merge-base
A single commit/review → commitcodex review --commit <SHA>Changes introduced by that commit
Custom instructions/review → customcodex review "Focus on …"Narrowed by your wording

Test 1: minor flaws → empty result (checking the rubric)

Against the main root commit, the working tree adds, uncommitted, divide(a,b): return a/b and an untracked helpers.py (first returns items[0]). Run:

bash
cd /workspace/codex-live-demo
codex review --uncommitted
# 墙钟耗时:18.656 秒;exit 0

Session header (stderr, excerpt):

text
OpenAI Codex v0.164.0
workdir: /workspace/codex-live-demo
model: gpt-5.6-sol
provider: codex
approval: never
sandbox: read-only

The stdout verdict, verbatim:

text
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.

This matches rubric.md: it only reports hard defects introduced by this change that "the author would most likely fix if they knew"; "no division-by-zero guard" often doesn't count when there is no project convention for it. An empty output does not mean the CLI is broken.

Test 2: a clear regression → two [P1]

Change the uncommitted edits so they clearly break existing semantics:

bash
# helpers.py:first 改成 return items[-1]
# mathutil.py:average 直接 return 0
codex review --uncommitted
# 墙钟耗时:15.659 秒;exit 0

stdout summary (original structure kept):

text
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...

Test 3: codex review --base main

After committing "add divide/helpers" on feature/review-demo, compare against main:

bash
codex review --base main
# 墙钟耗时:11.786 秒;exit 0

stderr shows the target as changes against 'main' and uses a merge-base style git diff <main-sha>. This time stdout judged that the new functions fit the "basic arithmetic" semantics and that division by zero raises the standard exception. Once again: a base review looks at the branch diff, not an audit of the whole repository.

How to set it up (command list)

For installing and connecting a Key from this site, see Install / Setup; for day-to-day use, see How to use.

bash
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"

Optional review_model

toml
# ~/.codex/config.toml
# slug 以 /model 列表为准
review_model = "gpt-5.6-sol"

In this test the review thread actually used the session model gpt-5.6-sol (no separate review_model was set).

Don't confuse it with auto_review / Claude Code

NameWhat it actually doesCommon misuse
/review or codex reviewReads the diff and reports prioritized issuesTreating it as automatic bug fixing
approvals_reviewer=auto_reviewReviews on your behalf whether to approve privilege escalation / network accessAssuming it reviews code
Claude Code /code-reviewA separate set of slash commands and REVIEW.mdCopying the commands verbatim into Codex
verification skillEnd-to-end proof by driving the real appUsing it and diff review as substitutes for each other

Troubleshooting errors

  • 401: first get a normal codex conversation working, then run review (see 401 troubleshooting).
  • At capacity / 429: see capacity / 429.
  • Empty result: first confirm the diff is not empty, then check against the rubric; if you need a strict security checklist, use a custom prompt.
  • Directory trust / sandbox: the review itself is read-only; for day-to-day write permissions, see Sandbox and /permissions.

Suggested workflow

  • After editing → codex review --uncommitted (on the clear regression this time, on the order of 16 seconds);
  • Before opening a PR → codex review --base main;
  • An empty result only means no hard defects by the rubric's standard, not that you can skip testing;
  • If you need proof by clicking through pages → use verification, not a longer review prompt.

Create an API Key →