AI Learn
OpenAI Codex · Practical Tutorial

Run a read-only Codex code review with /review before pushing

Choose the correct diff scope, run Codex’s dedicated reviewer, verify prioritized findings and keep the review phase separate from code changes.

Reviewed September 20, 2026Independent tutorialFeatures may vary
Not official support. AI Learn is an independent education site. Check the provider’s current documentation for plan-specific limits, pricing and feature availability.
Before you start

A review is more useful when the diff is scoped and the working tree is understood. Codex review can inspect base-branch or uncommitted changes without modifying the worktree; use that separation to avoid “reviewing while rewriting.”

1. Check Git status and decide whether you are reviewing uncommitted changes, a branch or a specific commit

Check git status and decide exactly what is under review: uncommitted changes, a commit, or the branch relative to its base. A precise scope prevents old unrelated code from dominating the report.

2. Run /review and select the intended comparison scope

Run `/review` in read-only review mode for that scope and ask it to prioritize behavior, security, regressions and missing tests over formatting. The goal is defect discovery, not style normalization.

3. Read prioritized findings and open the exact diff lines they refer to

Open every cited line in context and verify that the described execution path is actually reachable. Lower-confidence style or maintainability notes should not distract from reproducible failures.

4. Reproduce high-impact findings with tests or a minimal scenario before editing

For high-impact findings, create a minimal test or reproduction before editing. This turns the finding into a regression test and protects against fixing the symptom while preserving the underlying bug.

5. Start a separate fix pass only for confirmed findings, then rerun /review

Make fixes in a separate step, run tests, then execute `/review` again on the resulting diff. The second review should specifically look for regressions introduced by the fix.

Try this prompt

Run a read-only review of this branch against [base]. Prioritize correctness, security, regressions and missing tests. Do not edit the worktree. For each high/medium finding, show the affected lines, why it can fail and the smallest reproduction or test that would confirm it.

Common mistakes

Reviewing the wrong base branch; treating suggestions as facts; clicking fix before understanding the failure mode; mixing unrelated local changes into the diff; skipping the second review after fixes.

Finish check

The review scope is explicit, every accepted finding is reproducible or otherwise evidenced, the first review did not alter the worktree, and the final diff passes tests and a second review.

开始之前

当 diff 范围清楚、工作区状态可解释时,代码审查最有价值。Codex 的审查流程可以检查基准分支或未提交改动而不修改工作树,应该利用这种分离,避免“边审边重写”。

1. 先看 Git status,确定审查的是未提交改动、整个分支还是具体提交

先查看 Git Status,并明确 Review 的对象到底是未提交改动、某个 Commit,还是相对 Base Branch 的整个分支。范围清楚可以避免旧代码把真正要审的修改淹没。

2. 运行 /review,并选择正确的对比范围

针对这个范围以只读方式运行 `/review`,并要求优先检查行为错误、安全、回归和缺失测试,而不是格式。目标是找缺陷,不是自动统一代码风格。

3. 阅读按优先级排列的发现,并打开对应的具体 diff 行

逐个打开被引用的代码行并查看上下文,确认描述的执行路径确实可达。低置信度的风格或维护性建议,不应抢走对可复现故障的注意力。

4. 高影响问题先用测试或最小场景复现,再修改

高影响 Finding 在修改前先做最小复现或测试。这样它会变成真正的回归测试,避免只修表面症状而底层问题仍然存在。

5. 只针对确认问题开启单独修复阶段,然后再次运行 /review

把修复放到独立步骤里,跑测试,然后对修复后的 Diff 再执行一次 `/review`。第二轮应特别检查“修复本身有没有制造新的回归”。

可以直接套用的提示词

对当前分支相对 [base] 做只读审查。优先检查正确性、安全、回归和缺失测试。不要修改工作树。每个高/中影响发现都写出受影响行、为什么会失败,以及最小复现或测试方法。

常见错误

选错基准分支;把建议当事实;没理解失败模式就直接修;diff 混进大量无关本地改动;修复后不再跑第二轮审查。

完成检查

审查范围明确,采纳的发现都能复现或有其他证据,第一轮审查没有修改工作树,最终 diff 通过测试和第二轮审查。

開始之前

當 diff 範圍清楚、工作區狀態可解釋時,程式碼審查最有價值。Codex 的審查流程可以檢查基準分支或未提交改動而不修改工作樹,應該利用這種分離,避免“邊審邊重寫”。

1. 先看 Git status,確定審查的是未提交改動、整個分支還是具體提交

先查看 Git Status,並明確 Review 的對象到底是未提交改動、某個 Commit,還是相對 Base Branch 的整個分支。範圍清楚可以避免舊代碼把真正要審的修改淹沒。

2. 執行 /review,並選擇正確的對比範圍

針對這個範圍以只讀方式運行 `/review`,並要求優先檢查行為錯誤、安全、回歸和缺失測試,而不是格式。目標是找缺陷,不是自動統一代碼風格。

3. 閱讀按優先順序排列的發現,並打開對應的具體 diff 行

逐個打開被引用的代碼行並查看上下文,確認描述的執行路徑確實可達。低置信度的風格或維護性建議,不應搶走對可復現故障的注意力。

4. 高影響問題先用測試或最小場景復現,再修改

高影響 Finding 在修改前先做最小復現或測試。這樣它會變成真正的回歸測試,避免只修表面症狀而底層問題仍然存在。

5. 只針對確認問題開啓單獨修復階段,然後再次執行 /review

把修復放到獨立步驟裡,跑測試,然後對修復後的 Diff 再執行一次 `/review`。第二輪應特別檢查“修復本身有沒有製造新的回歸”。

可以直接套用的提示詞

對當前分支相對 [base] 做只讀審查。優先檢查正確性、安全、回歸和缺失測試。不要修改工作樹。每個高/中影響發現都寫出受影響行、為甚麼會失敗,以及最小復現或測試方法。

常見錯誤

選錯基準分支;把建議當事實;沒理解失敗模式就直接修;diff 混進大量無關本地改動;修復後不再跑第二輪審查。

完成檢查

審查範圍明確,採納的發現都能復現或有其他證據,第一輪審查沒有修改工作樹,最終 diff 通過測試和第二輪審查。

Official references

Check current product details at the source

Related practical tutorials

Continue with another single-task workflow.

All tutorials →