Codex CLI is OpenAI's terminal-based coding agent, similar to Claude Code but powered by GPT models.
Sandboxing is on by default. Expect restricted filesystem + network access until you explicitly lift restrictions per task.
# npm
npm install -g @openai/codex
# Homebrew
brew install --cask codex
# Or the official install script (macOS/Linux)
curl -fsSL https://chatgpt.com/codex/install.sh | sh
codexSign in with your ChatGPT account (Plus/Pro/Team plans include Codex usage), or
authenticate with an API key via export OPENAI_API_KEY=sk-....
Codex CLI reads your project structure, understands your codebase, and can:
| Feature | Codex CLI | Claude Code |
|---|---|---|
| Model | GPT-5.x-Codex family | Claude Sonnet/Opus |
| Provider | OpenAI | Anthropic |
| MCP support | Yes (native) * | Yes (native) |
| Background agents | No | Yes |
| Config file | ~/.codex/config.toml + AGENTS.md | CLAUDE.md |
| Sandboxing | Sandboxed by default | Configurable |
* Codex CLI gained native MCP support (STDIO + streamable HTTP servers), configured via ~/.codex/config.toml or the codex mcp command. See developers.openai.com/codex/mcp.
Codex CLI offers three approval modes (switch on the fly with /approvals):