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:
codex -c model=gpt-4.1 -c sandbox_mode=workspace-write
codex exec -c features.js_repl=true "test the app"
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:
codex --profile production
codex exec --profile experimental "refactor utils"
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:
codex -C /path/to/project "fix tests"
codex --cwd ~/projects/app exec "run linter"

Model Selection

-m, --model
string
Specify the AI model to use for the sessionExample:
codex -m gpt-4.1
codex --model o4-mini "explain this code"
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:
codex --oss "help me debug"

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:
codex --sandbox workspace-write
codex exec --sandbox full-access "system diagnostic"

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:
codex --ask-for-approval always
codex exec --ask-for-approval never "run tests"
--full-auto
boolean
Enable fully automatic mode (equivalent to --ask-for-approval never)Example:
codex --full-auto "create a todo app"
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:
codex --search "find the latest React best practices"

Image Input

-i, --images
string
Provide image files as input (comma-separated paths)Example:
codex -i screenshot.png "implement this UI"
codex --images "design.png,mockup.png" "create components"

Directory Context

--add-dir
string
Add directories to the agent’s context (can be specified multiple times)Example:
codex --add-dir src --add-dir tests
codex --add-dir lib "explain the architecture"

Version Information

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

Combining Options

Global options can be combined to create powerful workflows:
codex -m gpt-4.1 --profile dev -C ~/project --search

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