Skip to content

Add staged-only code review target via index snapshot #14361

@0xble

Description

@0xble

Summary

Add a staged-only review mode to codex exec review and the app-server review APIs.

Proposed usage:

  • codex exec review --staged

Motivation

review --uncommitted is useful for reviewing the entire working tree, but in many real workflows the desired review scope is the exact staged set that is being prepared for shipping. Uncommitted changes are often broader or noisier than the intended review target, while staging provides precise control over scope, including hunk-level selection within a file.

Proposed behavior

When --staged is used, review should run against a temporary snapshot materialized from the current Git index, so the reviewer sees exactly the staged contents and does not get confused by unstaged edits in the working tree.

Implementation notes

The core design is to treat this as a Git/data-source feature rather than a prompt-only feature:

  • add a staged review target through protocol and app-server surfaces
  • add --staged to codex exec review
  • create a detached temporary worktree from HEAD
  • copy the current index into that worktree
  • materialize the staged tree with git checkout-index
  • run the review turn from that snapshot cwd for the lifetime of the review task

Validation

A working implementation is available here:

That PR is for my personal use right now, and I am using it locally from my fork rather than submitting it as an upstream PR.

That PR includes passing targeted tests for git snapshot behavior, core prompt/hint behavior, exec request building and CLI parsing, and app-server review start behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    code-reviewIssues relating to code reviews performed by codexenhancementNew feature or requestexecIssues related to the `codex exec` subcommand

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions