·

Codex Review: Base Branch vs Uncommitted

Prepared and checked using AI. Sources are linked in the article.

codex-cli code-review git-worktrees ai-coding

For Codex review base branch versus uncommitted, choose by the changes you want reviewed: --base compares against a base branch, --commit targets one commit, and --uncommitted includes staged, unstaged, and untracked changes. For a completed agent branch, use --base with the intended integration branch and a clean worktree. For unfinished local edits, use --uncommitted; for one specific change already committed, use --commit.

Choose the review target

The commands below assume Codex CLI is already set up. For example, suppose your agent works in ../project-agent on agent/fix-retries, targeting main on the remote named origin.

Intended scopeCommandMain limitation
Branch changes against the integration targetcodex review --base origin/mainCheck the base and worktree cleanliness first
Changes introduced by the current commitcodex review --commit HEADEarlier commits and subsequent local edits are outside the requested scope
Current staged, unstaged, and untracked changescodex review --uncommittedAlready committed work is outside the requested scope

These are review targets, not author filters. Choose a scope containing only the work you intend to assess.

Start in the agent’s worktree

Use git worktree list to identify the checkout, revision, and branch, then enter the agent’s directory:

git worktree list
cd ../project-agent

Each worktree has its own HEAD, so selecting the directory matters when using HEAD or reviewing local edits. If the checkout is unclear, follow the steps to verify an agent’s worktree and branch.

Check the branch and local changes with git status --short --branch --untracked-files=all:

git status --short --branch --untracked-files=all

The branch header identifies the current branch; file entries identify changes to inspect before choosing the review scope. Ask the agent to pause edits during review so the intended change set stays stable.

Use —base for the branch’s combined changes

Choose the branch the work should integrate into. A task targeting a release branch needs that release branch as its comparison target; main is not automatically the right answer.

If you want the latest remote state, git fetch origin updates remote-tracking refs according to the configured fetch refspecs:

git fetch origin

With the usual mapping for remote branches, this refreshes origin/main. A restricted fetch configuration may omit it, so confirm the intended target is available.

Preview the branch comparison before starting Codex. git merge-base finds a best common ancestor:

git merge-base HEAD origin/main

Then inspect git diff origin/main...HEAD, which compares that common ancestor with HEAD:

git diff origin/main...HEAD
codex review --base origin/main

This preview answers what the committed branch adds since the shared ancestor. A direct git diff origin/main HEAD instead compares the two tips and can include differences caused by changes on the target branch.

A dirty worktree can broaden —base

The current upstream base-review prompt instructs the reviewer to run git diff against the merge-base SHA. A single-commit-argument Git diff compares that commit with the working tree, so tracked local edits can enter the review alongside committed branch changes.

Consequently, treat a clean worktree as a prerequisite for a review limited to committed branch changes. Finish and commit intended edits, or use a separate clean checkout if other local work must remain in place. The three-dot preview above ends at HEAD; it is not a complete preview of a dirty working tree.

main can resolve through its upstream

The current merge-base implementation can prefer a local branch’s upstream when that upstream contains commits absent from the local branch. Therefore, --base main is not always equivalent to comparing against the local main tip alone.

Prefer an explicit remote-tracking target when that is your intent. These implementation details can change between releases; check the review’s stated comparison before relying on it.

Use —commit for one committed change

Inspect git show HEAD to see the current commit’s message and patch, then request its review:

git show HEAD
codex review --commit HEAD

Use this for a focused review of one agent commit. If the task spans several commits, choose a base review for their combined result. To keep the selection stable while the branch advances, replace HEAD with the intended commit’s full SHA.

Use —uncommitted for unfinished edits

codex review --uncommitted

Choose this while the agent’s intended work remains staged, unstaged, or untracked. If the agent has already committed the implementation and left only a follow-up edit, this scope requests review of the follow-up rather than the entire task.

For a task containing both commits and unfinished edits, decide whether you want separate reviews or one final branch review after committing the intended remainder.

Keep custom instructions separate from target flags

The target flags conflict with each other and with the positional review prompt. You cannot append custom instructions to --base, --commit, or --uncommitted in the current CLI.

For a custom review, supply the scope inside the prompt instead:

codex review "Review the diff from the merge base of origin/main and HEAD to HEAD. Focus on retry correctness. Exclude uncommitted changes."

This expresses the scope as instructions rather than selecting the built-in base target. Inspect the comparison the reviewer uses, then evaluate findings as part of your review of AI-generated code.

Where Parallel Code fits

Parallel Code is our free, open-source desktop app for macOS and Linux, running several AI coding agents in parallel, each isolated in its own git worktree. Its diff-first review surface helps inspect agent changes; use the worktree, base, and commit checks above when choosing the scope for a Codex review.