Codex
Use Codex CLI to Review a Small Change Before You Commit
Cihan's view: Ask Codex to review the current diff, then check each finding against the file and the project's own tests before you commit.
For: a developer or operator who has made one small change in a local repository and wants a second pass before committing it.
Artifact: a short review record with findings, file and line references, and a decision for each finding.
Evidence label: Documentation-based guide. The workflow follows current Codex CLI documentation. No Codex execution is claimed here.
Advanced builder lesson: this requires a terminal, Git, a local repository, and a Codex CLI installation. If that is not your setup, use the no-code alternative below.
The fictional task
Assume you changed src/discount.js in a small sales tool. The change should apply a 10 percent discount only when customerTier is gold. You want a review before committing, but you do not want the reviewer to rewrite files.
Starting change:
-const discount = customerTier === "gold" ? 0.05 : 0;
+const discount = customerTier === "gold" ? 0.10 : 0;
The review question is narrow: does this change match the request, preserve existing behavior for other tiers, and leave unrelated files alone?
Three steps
- Open a terminal at the repository root. Inspect the working tree and the diff before asking for a review:
git status --short
git diff --stat
git diff -- src/discount.js
If the diff contains unrelated work, separate it first. A review of a mixed diff is harder to trust.
- Start Codex with
codex, then ask for a review without edits:
Review the current uncommitted changes only. Do not edit files, run destructive commands, or create a commit.
Review question:
Does the change in src/discount.js correctly change the gold-tier discount from 5 percent to 10 percent while preserving behavior for every other customer tier?
Check:
- the diff against the stated request
- nearby assumptions and callers
- existing tests or documented checks
- whether unrelated files changed
Return a review record with severity, file and line, evidence, and a recommended next action. If there is not enough information, say what is missing instead of guessing.
Codex documents a dedicated review flow for uncommitted changes, commits, and base branches. The exact menu labels and model options can vary by installation.
- Verify the review outside the agent:
git diff --check
git diff --name-only
npm test
Run the repository’s documented test command, not necessarily npm test. If no test command exists, record that fact. Inspect the file and compare each review finding with the original request.
Illustrative review output
This is a manually written example, not a Codex result:
Status: needs human decision
Finding: medium
Location: src/discount.js:1
Evidence: the diff changes the gold-tier value from 0.05 to 0.10; no other tier appears in this file.
Next action: confirm that 0.10 is the intended business rule and check the caller's percentage format before commit.
Unrelated files: none in the reviewed diff.
The output is useful because it points to a decision. It does not prove that the code is correct or that tests passed.
Acceptance checks
Accept the change only if:
git diff --name-onlylists the intended file or files only.- The review addresses the stated request rather than inventing a wider refactor.
- Every finding has a file, line, or other checkable reference.
- The relevant repository checks pass, or their absence is recorded.
- You have checked the business rule yourself before committing.
Common failure fixes
The review says there are no changes. Run git status --short and git diff. You may be in the wrong directory, or the change may already be staged. Use the appropriate staged-diff command when needed.
Codex proposes edits during review. Stop and keep the review read-only. Ask for findings first, then make any repair as a separate, reviewable change.
The review is too broad. Name the file, request, and acceptance checks. Ask it to report missing context instead of filling gaps with assumptions.
No-code alternative
Use your editor’s diff view and a short checklist with the same questions. A colleague can review the diff, or you can inspect the file against the request yourself. The review boundary matters more than the tool name.
Limits and access
Codex CLI can inspect local files and run available commands, but it does not know whether a business rule is correct unless you provide that rule and check it. Access, permissions, models, and commands vary by installation. Keep secrets out of prompts and do not treat a review as approval to deploy.
Sources
Want a weekly task like this? Join The Weekly Verdict.