Codex CLI can use multiple configurations. First select the scope according to your needs, and then decide which way to start.
| way | Suitable for the scene | Start the example |
|---|---|---|
| Profile file | Toggle common settings for development, review, and more | codex -p review |
| CODEX_HOME | Switch the entire local configuration and status directory | CODEX_HOME="$HOME/.codex-work" codex |
| Command line override | Temporarily adjust the parameters of this operation | codex -c 'model_reasoning_effort="high"' |
This article is for the Codex CLI 0.160.0, configure the rules in 2026-10-08 Verify against OpenAI official documentation. Shell examples are available for macOS, Linux, and WSL.
01
Default profile
The default user profile is located at:
~/.codex/config.tomlWhen started directly, Codex will read the basic configuration and superimpose other configuration layers according to rules:
codexThe basic configuration is suitable for saving settings common to various usage scenarios. Other configuration layers only need to supplement or override the fields that differ.
02
Use Profile to save frequently used settings
Profile is a named configuration file superimposed on the basic configuration. It is suitable for saving settings separately for development, code review and other scenarios.
File structure
~/.codex/
├── config.toml
├── work.config.toml
└── review.config.tomlBasic configuration
File:~/.codex/config.toml
model_reasoning_effort = "medium"
approval_policy = "on-request"
sandbox_mode = "workspace-write"The above are only examples; if you already have a configuration file, just merge the required fields.
development configuration
File:~/.codex/work.config.toml
model_reasoning_effort = "medium"
sandbox_mode = "workspace-write"Review configuration
File:~/.codex/review.config.toml
model_reasoning_effort = "high"
sandbox_mode = "read-only"Profile only needs to fill in the fields that are different from the basic configuration, and other fields continue to inherit the basic configuration. The development example retains two commonly used fields and can also omit the same values as the base configuration.
The example does not specify a model, and the existing model configuration will be used; the inference strength needs to be supported by the selected model.
Start command
# Use development configuration
codex --profile work
# Use review configuration
codex --profile review
# abbreviation
codex -p review
# Run non-interactively
codex exec -p review "Review current code changes"--profile review Correspond review.config.toml, the file extension is not included in the parameter.
03
Use CODEX_HOME to switch environments
CODEX_HOME Determine the local configuration and status directory of Codex. The default is ~/.codex. Different directories can be maintained for work and personal use:
~/.codex-work/
├── config.toml
└── review.config.toml
~/.codex-personal/
└── config.tomlCreate the directory first, and then add the configuration files separately:
mkdir -p "$HOME/.codex-work"
mkdir -p "$HOME/.codex-personal"Select directory on startup:
CODEX_HOME="$HOME/.codex-work" codex
CODEX_HOME="$HOME/.codex-personal" codexTwo commands are read separately:
~/.codex-work/config.toml
~/.codex-personal/config.tomlUsed in combination with Profile
CODEX_HOME="$HOME/.codex-work" codex -p reviewThis command reads the basic configuration of the working environment and then overlays it ~/.codex-work/review.config.toml。
Impact on login status
switch CODEX_HOME It also changes where local state such as history, logs, and caches are stored.
When using a file to store credentials,auth.json Located in this directory; when using the system keychain, the login status also depends on the credential store configuration. Therefore, you may need to log in again after switching directories:
CODEX_HOME="$HOME/.codex-work" codex loginThis way of writing environment variables inline only affects the current command and does not permanently modify the environment variables. Profile itself will not automatically switch accounts.
04
Temporarily overwrite using the command line
Use -c or --config Override settings for this run:
codex -c 'model_reasoning_effort="high"'Can be reused -c:
codex \
-c 'model_reasoning_effort="high"' \
-c 'sandbox_mode="read-only"'You can also continue to override Profile:
codex -p review -c 'model_reasoning_effort="medium"'Even if review.config.toml Set to high, this run will also use the command line specified medium。
These settings are not automatically written back to the configuration file. Values are parsed as TOML, and nested fields can use dots.
05
Configure coverage order
The priorities of common configuration layers from low to high are as follows. When the same field appears in multiple layers, subsequent settings override previous settings.
User config.toml
↓
Profile File
↓
Project .codex/config.toml
↓
Command line parameters and -c CoverFor example, the same field is set to:
| Configuration layers (lower to higher) | model_reasoning_effort |
|---|---|
| User configuration | medium |
| review Profile | high |
| Trusted project configuration | low |
| Command line override | medium |
Finally, use the command line to specify medium. If there is no command line override, the one in the project configuration will be used low。
Project configuration is only loaded when the project is trusted; in the same project, the configuration closer to the current working directory has a higher priority. Some provider, credential, and Profile related fields cannot be overridden by project configuration.
The lower priority built-in, system and cloud management defaults are omitted above. Organization-enforced policies also constrain available settings, and configuration priorities cannot bypass these requirements.
06
How to choose and check
- Need to save common settings such as development and review: use Profile。
- Requires different local configuration and state directories: use CODEX_HOME。
- If you only want to temporarily change one or two fields: use -c。
The three methods can be used in combination. When the troubleshooting settings do not take effect, first confirm the current CODEX_HOME and Profile name, and then check whether the project configuration and command line cover the same field.
Check the local version and supported parameters:
codex --version
codex --help