Skip to content

Configuration

You authenticated, launched Codex, and it immediately tried to run rm -rf node_modules without asking. Or worse, it asked permission for every single ls command before doing anything useful. The difference between these experiences is one file: config.toml. Get it right, and Codex feels like a trusted senior colleague. Get it wrong, and it is either reckless or paralyzed.

  • A ~/.codex/config.toml configured with your preferred model, approval policy, and sandbox level
  • Project-level overrides in .codex/config.toml for team-specific settings
  • A clear understanding of the configuration precedence order
  • Feature flags enabled for the capabilities you want
  • Web search mode tuned for your security requirements

Codex reads configuration from TOML files. Your personal defaults live at ~/.codex/config.toml, and project-specific overrides go in .codex/config.toml at the root of your repository.

Both the CLI and IDE extension share the same config layers. The App reads them too. Configure once, use everywhere.

Codex resolves settings in this order, from highest to lowest priority:

  1. CLI flags and --config overridescodex -a never beats everything.

  2. Profile values — From --profile <name> if you use named profiles.

  3. Project config.codex/config.toml files, ordered from the project root down to your current working directory. Closest directory wins. Only loaded for trusted projects.

  4. User config~/.codex/config.toml.

  5. System config/etc/codex/config.toml on Unix (if present).

  6. Built-in defaults — Codex’s factory settings.

This means your team can commit a .codex/config.toml to the repo that sets project-specific approval policies, and individual developers can override with their own ~/.codex/config.toml preferences.

Here is a production-ready ~/.codex/config.toml with the settings most developers change first.

~/.codex/config.toml
# Model selection -- GPT-5.3-Codex is the default and best for coding tasks
model = "gpt-5.3-codex"
# Approval policy -- controls when Codex pauses to ask before running commands
# Options: "on-request" (ask for everything), "on-failure" (auto-approve,
# ask on errors), "never" (full autonomy -- the "yolo mode")
approval_policy = "on-failure"
# Sandbox mode -- controls filesystem and network access
# Options: "workspace-write" (default, scoped to project), "danger-full-access"
sandbox_mode = "workspace-write"
# Web search mode
# Options: "cached" (default, pre-indexed results), "live" (real-time),
# "disabled" (no web search)
web_search = "cached"
# Reasoning effort -- how much the model thinks before responding
# Options: "low", "medium", "high"
model_reasoning_effort = "high"
# Credential storage
cli_auth_credentials_store = "auto"

The approval policy is the single most impactful setting. Here is what each mode actually does.

Codex pauses and asks permission before every file edit and command execution. This is the safest mode but creates the most friction.

approval_policy = "on-request"

Use when: Working in unfamiliar codebases, running Codex for the first time, or operating in production environments.

For team settings, create .codex/config.toml in your repository root:

# .codex/config.toml -- committed to the repo
# Team-standard approval policy
approval_policy = "on-failure"
# Sandbox scoped to workspace
sandbox_mode = "workspace-write"
# Team prefers high reasoning for this complex codebase
model_reasoning_effort = "high"

When a developer clones the repo and trusts the project, these settings apply automatically. Their personal ~/.codex/config.toml still takes precedence for settings they override explicitly.

Optional capabilities live under the [features] table:

[features]
# Speed up repeated commands by snapshotting your shell environment
shell_snapshot = true
# Enable undo via per-turn git ghost snapshots (on by default)
undo = true
# Enable smart approvals that suggest prefix rules
request_rule = true

Key feature flags:

FlagDefaultWhat it does
shell_snapshotfalseCaches shell environment for faster repeated commands
undotrueCreates per-turn Git snapshots so you can roll back
request_ruletrueSmart approvals suggest reusable permission rules
unified_execfalseUses a unified PTY-backed exec tool (beta)
remote_compactiontrueCompacts context remotely (ChatGPT auth only)

Enable from the CLI without editing config:

Terminal window
codex --enable shell_snapshot

Codex supports an experimental communication style setting:

# Options: "friendly", "pragmatic", "none"
model_personality = "pragmatic"

You can also change this per-session with /personality in the TUI.

Control which environment variables Codex passes to spawned commands:

[shell_environment_policy]
include_only = ["PATH", "HOME", "NODE_ENV", "DATABASE_URL"]

This is critical for security. Without this policy, Codex forwards your entire shell environment to any command it runs, which could leak secrets.

You do not always need to edit config.toml. The CLI accepts one-off overrides:

Terminal window
# Override model for this session
codex -c model=gpt-5.2
# Override approval policy
codex -a never
# Enable a feature flag
codex --enable shell_snapshot
# Combine multiple overrides
codex -c model=gpt-5.2 -c model_reasoning_effort=low

“Untrusted project” warning and project config ignored: Codex asks you to trust a project the first time you open it. If you declined, project-level .codex/config.toml files are skipped. Re-run Codex in the project and accept the trust prompt.

Approval mode seems wrong: Check the precedence. A CLI flag overrides everything. Run codex without flags to test the config file settings in isolation.

Feature flag not taking effect: Some flags require restarting Codex. Close the App, exit the CLI, and reopen. Feature flags are read at startup, not hot-reloaded.

“sandbox_mode not allowed” error: Your organization may enforce constraints via requirements.toml. Contact your admin if managed policies block your preferred sandbox mode.

Environment variables missing in commands: If Codex runs npm test and it fails because DATABASE_URL is missing, check your [shell_environment_policy]. Either add the variable to include_only or remove the policy to forward everything.