OpenAI Codex CLI¶
Project Introduction
Codex CLI is a coding agent from OpenAI that runs locally on your computer.
Codex CLI is a coding agent from OpenAI that runs locally on your computer.
- Official Homepage: https://chatgpt.com/codex
- Project Homepage: https://github.com/openai/codex
- Installation Method: See the tutorial below on this page
Demonstration¶

Features¶
| Function Category | Feature |
|---|---|
| Terminal-Based Coding Assistant | Codex CLI is a terminal-based interactive coding assistant used for editing code, generating patches, and running commands in the command line. |
| Tool-Driven Architecture | Provides tools such as apply_patch, shell, update_plan, and multi_tool_use for controlled modifications to repository files and operations. |
| Atomic Patch Editing | Uses a specialized patch format to atomically add/update/delete files via apply_patch, facilitating auditing and rollback. |
| Sandboxing and Approval | Supports sandboxing policies (e.g., workspace-write, read-only) and approval modes (on-request, on-failure, never) to control write and network access permissions. |
| Plan Tracking | update_plan is used to list steps and track status, requiring only one in_progress step at all times to maintain clear progress. |
| Interaction Guidelines | Sends brief introductory explanations before important operations, maintaining a friendly, concise tone and providing progress updates. |
| Security Constraints | Adheres to strict rules (no arbitrary changes to unrelated files, no adding copyright headers, no executing destructive commands), requiring user approval for sensitive operations. |
| Testing and Formatting | Recommended to run relevant tests and formatting tools after modification, but not responsible for fixing issues unrelated to the current task. |
| Output and Style | Final output adheres to CLI rendering specifications (e.g., ** headings, backticks for paths/commands), maintaining a scannable and concise structure. |
| Parallel Execution | Supports running multiple tools in parallel via multi_tool_use.parallel to improve efficiency. |
AI Model Configuration Method¶
Windows Graphical Guide¶
1. Open Terminal¶

2. Install WSL¶
For optimal performance on Windows, please install and use the Windows Subsystem for Linux (WSL2).
Install WSL2, Restart Windows Computer
Restart the Windows computer after installationWindows Notes
- It is recommended to use PowerShell instead of CMD
- If you encounter permission issues, try running as administrator
- Some antivirus software may flag this as a false positive; you may need to add it to a whitelist

Download Node Version Manager (NVM)

NVM Install Node.js 22
Open a new PowerShell window in the tab bar and start WSL
Install Node.js
The version number is time-sensitive; please install the corresponding version according to the OpenAI official website requirements: https://developers.openai.com/codex/windows

3. Install Codex CLI¶
Install Codex CLI
This command downloads and installs the latest version of Codex CLI from the official npm repository.
4. Modify Configuration File¶
One-Click Modification of Codex CLI Configuration File

5. Start Using Codex CLI¶
You can now start using Codex CLI!
Launch Codex CLI
Start WSL2
Launch Codex CLI directly: Use in a specific project: Press Enter to launch Codex CLI

Set Codex CLI permissions: 1. Allow Codex to modify files directly; 2. Codex requires manual authorization to modify files




Note: After modifying the interface address, all models (including official preset models) will call the custom access point and will not use the official account quota.
macOS Graphical Guide¶
1. Install Homebrew (Skip if already installed)¶
Homebrew is the package manager for macOS that installs missing software.
Official Website: https://brew.sh

Install Homebrew



2. Install Node.js Environment¶
Node.js Environment Installation Steps
Update Homebrew
Install Node.jsmacOS Notes
- If you encounter permission issues, you may need to use
sudo - The first run may require permission in System Preferences
- It is recommended to use
TerminaloriTerm2


Verify Successful Installation
After installation, open the terminal and enter the following commands:
If the version number is displayed, the installation was successful3. Install Codex CLI¶
Install Codex CLI
Open the terminal and run the following command:
If you encounter permission issues, you can use sudo:
Verify Codex CLI Installation
After installation, enter the following command to check if the installation was successful:
If the version number is displayed, congratulations! Codex CLI has been successfully installed.4. Modify Configuration File¶
One-Click Modification of Codex CLI Configuration File

5. Start Using Codex CLI¶
You can now start using Codex CLI!
Launch Codex CLI
Launch Codex CLI directly:
Use in a specific project: Press Enter to launch Codex CLI

Set Codex CLI permissions: 1. Allow Codex to modify files directly; 2. Codex requires manual authorization to modify files




Note: After modifying the interface address, all models (including official preset models) will call the custom access point and will not use the official account quota.
6. macOS Common Issues Resolution¶
Permission Error During Installation
Try the following solutions:
- Install using
sudo:sudo npm install -g @openai/codex - Or configure
npmto use the user directory:npm config set prefix ~/.npm-global
macOS Security Settings Block Execution
If the system blocks Codex CLI from running:
- Open "System Preferences" → "Security & Privacy"
- Click "Open Anyway" or "Allow"
- Or run in
Terminal:sudo spctl --master-disable
Linux Graphical Guide¶
1. Install Node.js Environment¶
Codex CLI requires the Node.js environment to run.
Node.js Environment Installation Steps
Add NodeSource repository
Install Node.jsLinux Notes
- Some distributions may require installing additional dependencies
- Use sudo if you encounter permission issues
- Ensure your user has write permissions in the npm global directory


Verify Successful Installation
After installation, open the terminal and enter the following commands:
If the version number is displayed, the installation was successful2. Install Codex CLI¶
Install Codex CLI
Open the terminal and run the following command:
If you encounter permission issues, you can use sudo:
Verify Codex CLI Installation
After installation, enter the following command to check if the installation was successful:
If the version number is displayed, congratulations! Codex CLI has been successfully installed.3. Modify Configuration File¶
One-Click Modification of Codex CLI Configuration File

4. Start Using Codex CLI¶
You can now start using Codex CLI!
Launch Codex CLI
Launch Codex CLI directly:
Use in a specific project: Press Enter to launch Codex CLI

Set Codex CLI permissions: 1. Allow Codex to modify files directly; 2. Codex requires manual authorization to modify files




Note: After modifying the interface address, all models (including official preset models) will call the custom access point and will not use the official account quota.
5. Linux Common Issues Resolution¶
Permission Error During Installation
Try the following solutions:
-
Install using
sudo:sudo npm install -g @openai/codex -
Or configure
npmto use the user directory:npm config set prefix ~/.npm-global -
Then add to
PATH:export PATH=~/.npm-global/bin:$PATH