codex-review

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Codex Review

Codex代码审查

Run Codex's built-in code review as a closeout check. This is code review (
codex review
), not Guardian
auto_review
approval routing.
Use when:
  • user asks for Codex review / autoreview / second-model review
  • after non-trivial code edits, before final/commit/ship
  • reviewing a local branch or PR branch after fixes
将Codex内置的代码审查作为收尾检查来运行。这是代码审查(
codex review
),而非Guardian的
auto_review
审批流程。
适用场景:
  • 用户要求进行Codex审查/自动审查/第二模型审查
  • 在完成非琐碎代码编辑后、最终提交/发布前
  • 修复后审查本地分支或PR分支

Contract

规范

  • Treat review output as advisory. Never blindly apply it.
  • Verify every finding by reading the real code path and adjacent files.
  • Read dependency docs/source/types when the finding depends on external behavior.
  • Reject unrealistic edge cases, speculative risks, broad rewrites, and fixes that over-complicate the codebase.
  • Prefer small fixes at the right ownership boundary; no refactor unless it clearly improves the bug class.
  • Keep going until Codex review returns no accepted/actionable findings.
  • If a review-triggered fix changes code, rerun focused tests and rerun Codex review.
  • Never switch or override the review model. If the review hits model capacity, retry the same command a few times with the same model. If it hits sandbox/permission limits, use the helper's
    --full-access
    option instead of changing models.
  • Stop as soon as the review command/helper exits 0 with no accepted/actionable findings. Do not run an extra direct
    codex review
    just to get a nicer "clean" line, a second opinion, or clearer closeout wording.
  • Treat the helper's successful exit plus absence of actionable findings as the clean review result, even if the underlying Codex CLI output is terse.
  • If rejecting a finding as intentional/not worth fixing, add a brief inline code comment only when it explains a real invariant or ownership decision that future reviewers should know.
  • Do not push just to review. Push only when the user requested push/ship/PR update.
  • 将审查结果视为参考建议,切勿盲目应用。
  • 通过阅读实际代码路径及关联文件验证每一项发现。
  • 当发现内容依赖外部行为时,查阅依赖文档/源码/类型定义。
  • 拒绝不切实际的边缘情况、推测性风险、大范围重写以及使代码库过度复杂的修复方案。
  • 优先在合适的职责边界进行小修复;除非能明确改善bug类别,否则不要重构。
  • 持续运行直到Codex审查不再返回可接受/可执行的发现。
  • 若审查触发的修复修改了代码,重新运行针对性测试并再次执行Codex审查。
  • 切勿切换或覆盖审查模型。若审查达到模型容量限制,使用相同模型重试几次相同命令。若遇到沙箱/权限限制,使用助手的
    --full-access
    选项而非更换模型。
  • 一旦审查命令/助手以0状态退出且无任何可接受/可执行的发现,立即停止。不要为了获得更美观的“干净”输出、二次意见或更清晰的收尾表述而额外运行
    codex review
  • 即使底层Codex CLI输出简洁,只要助手成功退出且无任何可执行发现,即可视为审查结果干净。
  • 若因设计如此/修复价值低而拒绝某项发现,仅当该发现涉及未来审查者应知晓的实际不变量或职责决策时,添加简短的行内代码注释。
  • 不要只为了审查而推送代码。仅当用户要求推送/发布/更新PR时才进行推送。

Pick Target

选择审查目标

Dirty local work:
bash
codex review --uncommitted
Use this only when the patch is actually unstaged/staged/untracked in the current checkout. For committed, pushed, or PR work, review the branch against its base instead; do not force
--mode local
/
--uncommitted
just because the helper docs mention dirty work first. A clean
--uncommitted
review only proves there is no local patch.
Branch/PR work:
bash
git fetch origin
codex review --base origin/main
Do not pass an inline prompt with
--base
; current CLI rejects
--base
+
[PROMPT]
even though help text is ambiguous. If custom instructions are needed, run the plain base review first, then do a local/manual follow-up pass.
If an open PR exists, use its actual base:
bash
base=$(gh pr view --json baseRefName --jq .baseRefName)
codex review --base "origin/$base"
Committed single change:
bash
codex review --commit HEAD
本地未提交工作:
bash
codex review --uncommitted
仅当当前检出版本中确实存在未暂存/已暂存/未跟踪的补丁时使用此命令。对于已提交、已推送或PR中的工作,请审查分支与其基准分支的差异;不要因为助手文档首先提到未提交工作就强制使用
--mode local
/
--uncommitted
--uncommitted
审查仅能证明本地无补丁。
分支/PR工作:
bash
git fetch origin
codex review --base origin/main
使用
--base
时不要传入内联提示;当前CLI会拒绝
--base
+
[PROMPT]
组合,尽管帮助文本表述模糊。若需要自定义指令,先运行基础审查,再进行本地/手动后续检查。
若存在已打开的PR,使用其实际基准分支:
bash
base=$(gh pr view --json baseRefName --jq .baseRefName)
codex review --base "origin/$base"
已提交的单次变更:
bash
codex review --commit HEAD

Parallel Closeout

并行收尾

Format first if formatting can change line locations. Then it is OK to run tests and review in parallel:
bash
scripts/codex-review --parallel-tests "<focused test command>"
Tradeoff: tests may force code changes that stale the review. If tests or review lead to code edits, rerun the affected tests and rerun review until no accepted/actionable findings remain. Once that rerun exits cleanly, stop; do not spend another long review cycle on redundant confirmation.
若格式化会改变代码行位置,先执行格式化。之后可并行运行测试与审查:
bash
scripts/codex-review --parallel-tests "<focused test command>"
权衡点:测试可能会强制修改代码,导致审查结果过时。若测试或审查引发代码编辑,重新运行受影响的测试并再次执行审查,直到无任何可接受/可执行的发现。一旦重新运行后干净退出,立即停止;不要花费额外的审查周期进行冗余确认。

Context Efficiency

上下文效率

Codex review is usually noisy. Default to a subagent filter when subagents are available. Ask it to run the review and return only:
  • actionable findings it accepts
  • findings it rejects, with one-line reason
  • exact files/tests to rerun
Run inline only for tiny changes or when subagents are unavailable.
Codex审查通常会产生较多冗余信息。当有子代理可用时,默认使用子代理过滤器。要求它运行审查并仅返回:
  • 它接受的可执行发现
  • 它拒绝的发现及一行理由
  • 需要重新运行的具体文件/测试
仅在微小变更或子代理不可用时直接运行审查。

Helper

助手工具

Bundled helper:
bash
~/.codex/skills/codex-review/scripts/codex-review --help
If installed from
agent-scripts
, path is:
bash
/Users/steipete/Projects/agent-scripts/skills/codex-review/scripts/codex-review --help
The helper:
  • chooses dirty
    --uncommitted
    first
  • otherwise uses current PR base if
    gh pr view
    works
  • otherwise uses
    origin/main
    for non-main branches
  • should be left in
    --mode auto
    or forced to
    --mode branch
    for committed/PR work; do not force
    --mode local
    after committing
  • writes only to stdout unless
    --output
    or
    CODEX_REVIEW_OUTPUT
    is set
  • supports
    --dry-run
    and
    --parallel-tests
  • supports
    --full-access
    for nested review runs that need localhost bind/listen tests
  • prints
    codex-review clean: no accepted/actionable findings reported
    when the selected review command exits 0
内置助手:
bash
~/.codex/skills/codex-review/scripts/codex-review --help
若从
agent-scripts
安装,路径为:
bash
/Users/steipete/Projects/agent-scripts/skills/codex-review/scripts/codex-review --help
助手功能:
  • 优先选择未提交的
    --uncommitted
    模式
  • gh pr view
    可用,则使用当前PR的基准分支
  • 否则,对非主分支使用
    origin/main
    作为基准
  • 应保持
    --mode auto
    或对已提交/PR工作强制使用
    --mode branch
    ;提交后不要强制使用
    --mode local
  • 除非设置了
    --output
    CODEX_REVIEW_OUTPUT
    ,否则仅输出到标准输出
  • 支持
    --dry-run
    --parallel-tests
    选项
  • 支持
    --full-access
    选项,用于需要本地主机绑定/监听测试的嵌套审查运行
  • 当选定的审查命令以0状态退出时,输出
    codex-review clean: no accepted/actionable findings reported

Final Report

最终报告

Include:
  • review command used
  • tests/proof run
  • findings accepted/rejected, briefly why
  • the clean review result from the final helper/review run, or why a remaining finding was consciously rejected
Do not run another Codex review solely to improve the final report wording. If the final helper run exited 0 and produced no accepted/actionable findings, report that exact run as clean.
需包含:
  • 使用的审查命令
  • 运行的测试/验证依据
  • 接受/拒绝的发现及简要理由
  • 最终助手/审查运行返回的干净结果,或为何有意识地拒绝剩余发现
不要只为了优化最终报告的表述而再次运行Codex审查。若最终助手运行以0状态退出且无任何可接受/可执行的发现,直接报告该次运行结果为干净。