Skip to main content

Overview

Global options can be used with any Codex CLI command. They are processed before subcommands and affect the behavior of the entire CLI session.

Configuration Override

-c, --config
string
Override configuration values using key=value pairs. Can be specified multiple times.Examples:
Common configuration keys:
  • model - Override the AI model
  • sandbox_mode - Control sandbox restrictions
  • approval_policy - Set approval mode
  • features.<name> - Toggle feature flags

Profile Selection

-p, --profile
string
Select a configuration profile from config.tomlExample:
Profiles allow you to maintain different sets of configuration for different use cases (development, production, experimental, etc.).

Working Directory

-C, --cwd
path
Change the working directory before executing the commandExample:

Model Selection

-m, --model
string
Specify the AI model to use for the sessionExample:
Common models:
  • o4-mini - Fast, efficient reasoning model (default)
  • gpt-4.1 - Advanced reasoning and coding
  • o3 - Advanced reasoning model with extended thinking

Open Source Models

--oss
boolean
Use open-source models instead of proprietary modelsExample:

Sandbox Control

--sandbox
enum
Control the sandbox mode for command executionOptions:
  • workspace-write - Allow writes within the workspace directory
  • full-access - Allow full filesystem access (use with caution)
Example:

Approval Policy

--ask-for-approval
enum
Set when the agent should ask for approval before executing commandsOptions:
  • on-request - Ask for approval when the agent requests it
  • always - Always ask before executing any command
  • never - Never ask (use with caution)
Example:
--full-auto
boolean
Enable fully automatic mode (equivalent to --ask-for-approval never)Example:
In full-auto mode, commands execute automatically. Use in sandboxed environments or Git-tracked directories.
--dangerously-bypass-approvals-and-sandbox
boolean
Bypass both approval prompts and sandbox restrictions
DANGEROUS: This option removes all safety guardrails. Only use in completely isolated test environments.
Enable web search capabilities for the agentExample:

Image Input

-i, --images
string
Provide image files as input (comma-separated paths)Example:

Directory Context

--add-dir
string
Add directories to the agent’s context (can be specified multiple times)Example:

Version Information

--version
boolean
Display the Codex CLI versionExample:
--help
boolean
Display help informationExample:

Combining Options

Global options can be combined to create powerful workflows:

Order of Precedence

When the same option is specified in multiple places, Codex uses this priority:
  1. Command-line flags (highest priority)
  2. -c config overrides
  3. Environment variables
  4. Profile settings (from --profile)
  5. config.toml base configuration
  6. Built-in defaults (lowest priority)

Feature Flags

Enable experimental features

Configuration

Learn about config.toml