Skip to main content
Non-interactive mode allows you to run Codex without the terminal UI, making it ideal for automation, scripts, and CI/CD pipelines. Use the exec and review commands for headless execution.

The exec command

Run a one-off task without the interactive TUI:

Output formats

By default, exec provides human-readable output with progress indicators. For programmatic use, enable JSON output:
This streams JSONL (JSON Lines) events that you can parse:

Exit codes

codex exec returns meaningful exit codes for automation:

Command options

The review command

Request an automated code review from Codex:

Review targets

The review command supports multiple targets:
Review staged, unstaged, and untracked files:

Review output

Reviews produce structured feedback:

Resume and continue

Non-interactive mode supports resuming previous sessions:

CI/CD integration

Codex is designed to integrate seamlessly into automated workflows.

GitHub Actions

GitLab CI

.gitlab-ci.yml

Jenkins

Jenkinsfile

Structured output

Constrain the agent’s response to a specific JSON schema:
schema.json:
The final agent message will conform to this schema.

Ephemeral sessions

Run without persisting to disk:
Useful for:
  • One-off queries
  • Sensitive data that shouldn’t be logged
  • Reducing disk I/O in high-volume scenarios

Automation best practices

1

Use --full-auto for trusted environments

In sandboxed CI runners, use --full-auto to auto-approve operations:
2

Enable JSON output for parsing

Always use --json in automation to get structured events:
3

Check exit codes

Handle failures gracefully in scripts:
4

Capture final output

Use --output-last-message for the agent’s final response:
Never use --yolo (dangerously bypass approvals) in production or on untrusted inputs. This disables all safety checks.

Parsing JSONL output

Using jq

Using Python

Next steps

Interactive mode

Learn about the TUI for development

Sandboxing

Understand security in automation