The Codex CLI offers a flexible approval mode system that allows users to control the level of autonomy the AI assistant has when editing files and executing commands. Switching approval modes in the Codex CLI can be done through command-line flags or interactively during the workflow. The CLI supports three main approval modes with distinct behaviors and security models:
1. Suggest Mode (Default)
This is the safest mode and the default setting. In Suggest mode, the Codex CLI requires explicit user approval at every step, including file creation, file editing, and execution of shell commands. Each action is presented as a prompt, and the user must respond to approve or reject the action. This mode provides the highest level of user control and is ideal for cautious use or learning the tool.
Usage example to invoke Suggest mode explicitly:
bash
codex --approval-mode suggest "Your command here"
The CLI will walk you through each step, requesting confirmation before proceeding.
2. Auto Edit Mode
Auto Edit mode grants the CLI permission to automatically create and modify files but still requests user approval before executing any shell commands. This mode balances automation and control, speeding up file editing tasks while retaining oversight of potentially system-altering commands like installation or execution steps.
Usage example to invoke Auto Edit mode:
bash
codex --approval-mode auto-edit "Your command here"
Here, the CLI skips approval prompts for file edits but asks for permission before running commands.
3. Full Auto Mode
Full Auto mode is the most autonomous and requires no user input to create, modify, or execute files and commands. The CLI operates fully automatically with built-in safety restrictions such as running commands within a sandbox without network access and only within the current working directory. This mode is efficient for trusted workflows and rapid prototyping.
Usage example to invoke Full Auto mode:
bash
codex --approval-mode full-auto "Your command here"
The CLI runs everything seamlessly without any prompts.
Switching Between Approval Modes
- Command-Line Flag on Invocation
The primary method to switch approval modes is by using the `--approval-mode` flag followed by the desired mode (`suggest`, `auto-edit`, or `full-auto`) when running the `codex` command. This sets the mode for the duration of that command execution.
- Interactive Switching During Approval Prompts
When working in Suggest or Auto Edit modes, you may encounter approval prompts for file edits or commands. The CLI allows switching approval modes on the fly without cancelling the current process.
At the approval prompt for shell commands, an option to switch approval modes is provided (usually by typing `v` or selecting the "Switch approval mode" option). This opens a menu listing the available modes, allowing you to change from, say, `suggest` to `full-auto` immediately. After switching, you return to the pending approval prompt with the new mode applied, enabling smoother workflow without interruptions or negative feedback to the model.
Safety and Restrictions
Each mode comes with built-in safety features to protect your system:
- Suggest mode requires explicit user approvals, minimizing unintended changes.
- Auto Edit mode automates file operations but keeps shell commands under user control to prevent risky system commands from running without consent.
- Full Auto mode operates under sandbox constraints where commands have no external network access and cannot escape the current directory, reducing risk while maximizing automation. The CLI also warns when operating in directories without Git tracking for better version control awareness.
Practical Use Cases
- Suggest Mode: Best for new users, learning, or when working with sensitive codebases where strict oversight is necessary.
- Auto Edit Mode: Ideal when making repetitive or bulk code changes but requiring final say on commands like deployments, testing, or package installs.
- Full Auto Mode: Suited for trusted projects where rapid iterations, bug fixes, or prototyping are prioritized without manual intervention.
Summary
To switch approval modes in the Codex CLI:
- Use the command-line flag `--approval-mode` with the values `suggest`, `auto-edit`, or `full-auto` to set the mode upfront.
- During approval prompts in Suggest or Auto Edit mode, use the interactive option to switch modes on the fly without aborting the current session.
This flexibility allows a tailored balance between control and automation, enhancing productivity and safety when leveraging Codex capabilities through the command line.
This explanation covers the operational concepts, usage, and the safety rationale behind mode switching in Codex CLI, detailing how users can efficiently work with the assistant while controlling its actions effectively. The CLI's design emphasizes a robust approval system combined with the ability to escalate automation as confidence and use cases grow.