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.

The ChatGPT desktop app, CLI, and VS Code-family IDE extension share the same local config layers when they use the same CODEX_HOME. Codex Cloud has separate environment and workspace configuration; local config.toml settings do not automatically sync to cloud tasks.

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

  1. CLI flags and --config overrides — for example, codex -a on-request beats file-based defaults.

  2. 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.

  3. Profile file$CODEX_HOME/<name>.config.toml, selected with --profile <name>.

  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 a trusted repo’s .codex/config.toml overrides profile and user defaults. Use a CLI flag or -c key=value for a one-off override; use managed requirements.toml when an administrator must constrain allowed values.

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

~/.codex/config.toml
# Model selection -- choose the GPT-5.6 tier by workload.
# Sol: frontier quality; Terra: balanced; Luna: high-volume efficiency.
model = "gpt-5.6-terra"
# Approval policy -- controls when Codex asks to cross a permission boundary
# Use "on-request" for interactive work. Reserve "never" for explicitly
# trusted unattended runs; it does not weaken the sandbox.
approval_policy = "on-request"
# Sandbox mode -- controls filesystem and network access
# Options: "read-only", "workspace-write" (default), "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: "minimal", "low", "medium", "high", "xhigh" (xhigh is model-dependent)
model_reasoning_effort = "high"
# Credential storage
cli_auth_credentials_store = "auto"

Approval policy and sandbox mode are separate axes: the sandbox defines what a command can technically access, while the approval policy defines whether Codex may ask to cross that boundary. Changing one does not silently change the other.

Codex works autonomously inside the active sandbox and asks when it needs to cross that boundary, for example to write outside the workspace or use blocked network access. It does not ask before every routine edit or command that already fits the sandbox.

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-request"
# 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. Project config takes precedence over profile and personal config; only CLI flags/-c sit above it.

Optional capabilities live under the [features] table:

[features]
# Speed up repeated commands by snapshotting your shell environment
shell_snapshot = true
# Persisted goals and automatic continuation are stable and on by default.
goals = true

Key feature flags:

FlagDefaultWhat it does
shell_snapshottrueStable; snapshots the shell environment for faster repeated commands
unified_exectrue except WindowsStable PTY-backed execution; Windows keeps it off by default
goalstrueStable persisted goals and automatic continuation

Enable from the CLI without editing config:

Terminal window
codex features list

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.6-sol
# Override approval policy for an interactive session
codex -a on-request
# Inspect current feature state
codex features list
# Combine multiple overrides
codex -c model=gpt-5.6-sol -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.

Requested GPT-5.6 model is unavailable: Check your plan and workspace role before changing model IDs. Free and Go use Terra; eligible Plus, Pro, Business, and Enterprise users can select all three tiers, unless an admin policy narrows access.

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.