AI
OpenAI Codex
What is Codex?
Codex is OpenAI's coding agent for the terminal. It reads your code, edits files, and runs commands in your project directory.
Installation
macOS
Use the standalone installer:
curl -fsSL https://chatgpt.com/codex/install.sh | sh
Or install it with Homebrew:
brew install --cask codex
Linux
Use the standalone installer:
curl -fsSL https://chatgpt.com/codex/install.sh | sh
Windows
Run this in PowerShell:
powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex"
You can also run Codex inside WSL. Open your WSL distribution and use the Linux installer above.
Any OS (npm)
If you already have Node.js installed, you can install Codex from npm:
npm install -g @openai/codex
Binary Download
Prebuilt binaries are available from the latest GitHub release:
| Platform | File |
|---|---|
| macOS (Apple Silicon) | codex-aarch64-apple-darwin.tar.gz |
| macOS (Intel) | codex-x86_64-apple-darwin.tar.gz |
| Linux (x86_64) | codex-x86_64-unknown-linux-musl.tar.gz |
| Linux (arm64) | codex-aarch64-unknown-linux-musl.tar.gz |
Each archive holds a single binary named after its platform. Rename it to codex and move it into a directory on your PATH.
Sign In
Open a project directory and start Codex:
cd your-project
codex
On first launch, choose Sign in with ChatGPT. Signing in with an API key needs some extra setup.
Configuration (config.toml)
Codex reads its settings from a TOML file:
| Scope | Location | Notes |
|---|---|---|
| User | ~/.codex/config.toml | Applies to every project |
| Project | .codex/config.toml | Only loaded for trusted projects |
| Profile | ~/.codex/<name>.config.toml | Selected with codex --profile <name> |
On Windows, ~ is your user folder, e.g. C:\Users\<you>\.codex\config.toml.
Create the file if it does not exist:
mkdir -p ~/.codex && touch ~/.codex/config.toml
Permission Settings
Two keys control how much Codex can do on its own:
sandbox_mode decides what model-generated commands can access:
read-only: Codex can read files but cannot write or use the network.workspace-write: Codex can edit files in the current project. Network access is off unless you enable it.danger-full-access: no sandbox. Codex can read and write anywhere and use the network.
approval_policy decides when Codex stops to ask you:
on-request: Codex asks when it needs to go beyond the sandbox. Recommended for interactive use.never: Codex never asks. Anything outside the sandbox fails instead of prompting.
Recommended: Full Access Inside the Project
This lets Codex edit files and run commands in your workspace without asking, including network access for npm install, pip install, git push, and similar commands. Everything outside the project stays protected.
# ~/.codex/config.toml
approval_policy = "never"
sandbox_mode = "workspace-write"
[sandbox_workspace_write]
network_access = true
# Optional: extra folders Codex may write to
# writable_roots = ["/home/you/shared-libs"]
Full Access to the Whole Machine
This turns the sandbox off completely, so Codex can run any command on your computer without asking.
# ~/.codex/config.toml
approval_policy = "never"
sandbox_mode = "danger-full-access"
Use with care
With danger-full-access and approval_policy = "never", Codex can delete files, change system settings, and use your credentials without asking. Only use it in a container, a VM, or a disposable machine, and commit your work to Git first so you can roll back.
Use a Profile Instead
To keep your normal setup safe and enable full access only when you need it, put the settings in a profile file:
# ~/.codex/yolo.config.toml
approval_policy = "never"
sandbox_mode = "danger-full-access"
Then start Codex with that profile:
codex --profile yolo
Model Settings
You can also set the default model and reasoning effort in the same file:
model = "gpt-6.1-sol"
model_reasoning_effort = "high"
The available models and effort levels depend on your account.
Command-Line Flags
You can override the config for a single run without editing config.toml:
# Full access inside the project, no prompts
codex --sandbox workspace-write --ask-for-approval never
# No sandbox and no prompts (same as danger-full-access + never)
codex --dangerously-bypass-approvals-and-sandbox
# or the short alias
codex --yolo
Inside a running session, type /permissions to see or change the current sandbox and approval mode.
Update
Run the installer again, or use the same package manager you installed with:
# Standalone installer
curl -fsSL https://chatgpt.com/codex/install.sh | sh
# Homebrew
brew upgrade --cask codex
# npm
npm install -g @openai/codex@latest
Check the installed version:
codex --version