How to Use the `review` Command for Non-Interactive Code Reviews with Codex CLI
The codex review --no-interactive command enables automated code reviews by skipping UI prompts and streaming JSON or text output directly to stdout, making it ideal for CI pipelines and pre-commit hooks.
The Codex CLI is a Rust-based command-line tool in the openai/codex repository that communicates with the Codex app-server over JSON-RPC. When you need to integrate automated code quality checks into your development workflow, the non-interactive review mode eliminates human-in-the-loop requirements while delivering structured feedback from the reviewer model.
How the Non-Interactive Review Workflow Works
The review workflow spans multiple crates within the Codex Rust workspace, from argument parsing through server-side model execution.
CLI Entry Point and Argument Parsing
The command-line interface is built with the clap crate. In [codex-rs/cli/src/main.rs](https://github.com/openai/codex/blob/main/codex-rs/cli/src/main.rs), the review sub-command is registered with the ReviewArgs struct, which defines flags including --no-interactive, --output, and --delivery.
When you execute codex review --no-interactive, the CLI maps these arguments and prepares to bypass any interactive prompts or editor spawns.
Client Construction and Authentication
The CLI instantiates a CodexClient defined in [codex-rs/utils/cli/src/client.rs](https://github.com/openai/codex/blob/main/codex-rs/utils/cli/src/client.rs). This thin wrapper around reqwest handles:
- Authentication: Injects the
CODEX_TOKENenvironment variable into request headers - Endpoint configuration: Respects the
CODEX_ENDPOINTenvironment variable to target specific Codex server instances
Review Request Building and Execution
The core orchestration happens in [codex-rs/cli/src/app_cmd.rs](https://github.com/openai/codex/blob/main/codex-rs/cli/src/app_cmd.rs) within the run_review function. This function:
- Packages supplied file paths into a
ReviewRequest - Sends the payload via
client.post("/v2/review", …) - Checks
args.no_interactiveto determine execution path - Skips UI prompts when
--no-interactiveis set, immediately streaming the JSON response to stdout - Formats output via
format_output—pretty-printed text by default, or raw JSON when--output jsonis specified
The underlying review operation in [codex-rs/core/src/codex.rs](https://github.com/openai/codex/blob/main/codex-rs/core/src/codex.rs#L4846) (line 4846) defines pub async fn review, which communicates with the app-server and returns the model output.
Server-Side Processing
On the server side, [codex-rs/app-server/src/codex_message_processor.rs](https://github.com/openai/codex/blob/main/codex-rs/app-server/src/codex_message_processor.rs#L5821) (line 5821) implements review_start. This handler:
- Creates a review turn
- Feeds the target (commit, custom instructions, etc.) into the reviewer model
- Emits
enteredReviewModeandexitedReviewModenotifications
The prompt generation logic resides in [codex-rs/core/src/review_prompts.rs](https://github.com/openai/codex/blob/main/codex-rs/core/src/review_prompts.rs#L39) (line 39), where review_prompt constructs the LLM input based on the requested review target.
Practical Code Examples
Because the request/response cycle is fully deterministic when --no-interactive is set, you can safely invoke the command from CI pipelines, pre-commit hooks, or any script requiring automated code-review feedback.
Review a Single File
codex review --no-interactive src/lib.rs
Generate Structured JSON for Downstream Tools
codex review --no-interactive \
--output json \
. > review-report.json
CI Integration with Severity Checks
Fail the build if any review item has "high" severity:
codex review --no-interactive --output json . | \
jq -e 'any(.suggestions[]; .severity == "high")' && exit 1
Detached Review Execution
Run the review in a new thread for asynchronous processing:
codex review --no-interactive --delivery detached .
Key Source Files and Implementation Details
| File | Role | Direct Link |
|---|---|---|
codex-rs/cli/src/main.rs |
CLI entry point; registers the review sub-command with clap |
view |
codex-rs/cli/src/app_cmd.rs |
Implements run_review, builds the request, and formats output |
view |
codex-rs/utils/cli/src/client.rs |
Thin reqwest wrapper handling CODEX_TOKEN and CODEX_ENDPOINT |
view |
codex-rs/core/src/codex.rs (line 4846) |
Core pub async fn review operation |
view |
codex-rs/app-server/src/codex_message_processor.rs (line 5821) |
Server-side review_start RPC handler |
view |
codex-rs/core/src/review_prompts.rs (line 39) |
Prompt generation logic for the reviewer model | view |
Summary
- The
codex review --no-interactivecommand skips all UI prompts and editor spawns, streaming results directly to stdout. - The workflow spans the CLI (
main.rs), client (client.rs), command logic (app_cmd.rs), and server-side processor (codex_message_processor.rs). - Use
--output jsonto generate machine-readable reports for CI pipelines and automated quality gates. - The command respects
CODEX_TOKENandCODEX_ENDPOINTenvironment variables for authentication and server targeting. - Because the review runs deterministically without human input, it integrates safely into pre-commit hooks and GitHub Actions workflows.
Frequently Asked Questions
What is the difference between interactive and non-interactive review mode?
Interactive mode spawns editors and prompts for user confirmation during the review process, while non-interactive mode (--no-interactive) suppresses all UI elements and streams the review results directly to stdout. This makes non-interactive mode suitable for automation, CI/CD pipelines, and scripting where no human is present to respond to prompts.
How do I authenticate the Codex CLI for automated reviews?
The CLI reads the CODEX_TOKEN environment variable to authenticate requests to the Codex app-server. Additionally, you can override the default server endpoint by setting CODEX_ENDPOINT. These variables are injected into the reqwest client inside codex-rs/utils/cli/src/client.rs, ensuring secure, configurable access for automated workflows.
Can I use the review command in GitHub Actions or other CI platforms?
Yes. Because codex review --no-interactive runs deterministically without user input and exits with appropriate status codes, it integrates seamlessly into GitHub Actions, GitLab CI, or any other CI platform. You can pipe the JSON output to tools like jq to enforce quality gates, such as failing builds when high-severity suggestions are detected.
What output formats does the non-interactive review support?
By default, the command prints a pretty-printed text summary suitable for human reading in logs. When you pass --output json, the CLI streams the raw JSON payload returned by the server, containing structured data about suggestions, severity levels, and file locations. This JSON format is ideal for parsing by downstream automation tools and reporting systems.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →