Skip to content
agentscamp

Codex CLI

OpenAI's open-source terminal coding agent with sandboxed execution and two-layer approval controls.

Codex CLI is OpenAI's open-source (Apache-2.0) terminal coding agent: it reads files, edits them on disk, and runs shell commands in an OS-level sandbox with network off by default and, in trusted folders, workspace-scoped writes. Sandbox modes and approval policies control what it can do and when it must ask; sign in with a ChatGPT plan or API key.

Codex CLI is OpenAI's open-source coding agent that runs entirely in your terminal. You point it at a repository, describe a task in plain language, and it reads files, edits them on disk, and runs shell commands to get the job done — all inside an OS-level sandbox that blocks network access by default and, once you trust the folder, scopes writes to your workspace. It is written in Rust and ships as a binary installable via npm, Homebrew, or a one-line shell installer.

It is aimed at developers who live in the terminal and want an agent backed by OpenAI's frontier models without leaving the shell. As of November 2026 (v0.172.0), you can authenticate with a paid ChatGPT plan (Plus, Pro, Business, Edu, or Enterprise; Free and Go only cover GPT-6 Luna in the desktop app, subject to rollout) or an OPENAI_API_KEY, and the same binary works on macOS, Linux, and Windows (natively with the MXC sandbox or via WSL2). Beyond the terminal, Codex ships an IDE extension, a Codex SDK, and the Codex cloud agent, and codex app opens the desktop experience inside the ChatGPT desktop app on macOS, Windows, and Linux.

Highlights

  • Two-layer security model & auto-review — sandbox modes (read-only, workspace-write, danger-full-access, via --sandbox) control what the agent can technically do; approval policies (on-request, never, or granular) control when it must ask, and --approve-for-me routes approval prompts to an automatic reviewer model. The untrusted approval value was retired in August 2026 and prevents Codex from starting (per-project trust_level = "untrusted" still works).
  • Sandboxed by default — outbound network is blocked by default, and in a trusted project workspace-write limits writes to the active workspace (untrusted folders start in read-only), using Seatbelt on macOS, bubblewrap on Linux/WSL2, and MXC (or legacy elevated/unelevated) on Windows.
  • Model switching & cloud/local providers — defaults to GPT-6.2 Sol (alongside GPT-6.2 Astra, GPT-6.1 Terra, GPT-6 Luna, and Ultra multi-subagent mode) with /model and reasoning-effort control; also supports Amazon Bedrock, Google Cloud Vertex AI (model_provider = "gcp"), custom Responses-compatible providers, and local open-weight models via --oss with Ollama or LM Studio.
  • MCP support — connect external tools through STDIO or Streamable HTTP servers configured in config.toml.
  • Non-interactive codex exec — run Codex headlessly in scripts and CI, piping the final result to stdout (pass --trust to load project configs and MCP servers in untrusted directories).
  • Session resume and image input — pick up past transcripts (and saved sandbox permissions) with codex resume or codex exec resume, and attach screenshots or design specs as context.

In an AI-assisted workflow

Codex CLI fits where you already run Git and your build. A typical loop is to start it in a trusted repo with the default workspace-write sandbox mode and on-request approval policy, let it draft edits, and approve anything that reaches outside the workspace or touches the network. It reads AGENTS.md files for project-specific context, so you can encode conventions and commands once and have them apply on every run. Repeatable procedures can move into Codex skills instead of growing the always-on instruction file.

npm install -g @openai/codex
cd your-project
codex "Add a retry with backoff to the API client and a test for it"

TIP

Start with the read-only sandbox mode on an unfamiliar repository to have Codex propose a plan before it edits anything, then widen to workspace-write once you trust the direction.

NOTE

Unlike Aider, Codex does not auto-commit each change — it edits the working tree and leaves staging and committing to you, so review the diff before committing.

Good to know

Codex CLI is free and open source under the Apache-2.0 license (v0.172.0, ~137k GitHub stars as of November 2026), available on macOS and Linux natively and on Windows (natively via PowerShell or under WSL2). Model usage draws on your paid ChatGPT plan's Codex CLI allowance (Plus, Pro, Business, Edu, or Enterprise; Free and Go cover GPT-6 Luna in the desktop app only) or is billed per token with an API key. The danger-full-access sandbox mode removes network and filesystem guardrails — use it only on repositories and tasks you fully trust.

For setup, AGENTS.md, and sandboxing walkthroughs, read our OpenAI Codex guide. Comparing agents? See Claude Code vs Codex CLI, the best Claude Code alternatives, Claude vs GPT vs Gemini for coding, or browse Codex CLI alternatives.

Frequently asked questions

What is Codex CLI?
Codex CLI is OpenAI's open-source coding agent that runs entirely in your terminal. You point it at a repository, describe a task in plain language, and it reads files, edits them on disk, and runs shell commands — all inside an OS-level sandbox that blocks network access by default and, once you trust the folder, scopes writes to your workspace (it can start read-only until then). It is written in Rust.
Is Codex CLI free?
The tool itself is free and open source under Apache-2.0. For model usage (as of November 2026), Codex CLI authenticates with a paid ChatGPT plan (Plus $20/mo, Pro $100/$200/$500/mo, Business $20/user/mo, Edu, or Enterprise) or bills per token via an OPENAI_API_KEY; ChatGPT Free and Go ($8/mo) only include GPT-6 Luna in the desktop app, subject to rollout.
How do I install Codex CLI?
Install it with npm install -g @openai/codex — it also ships via Homebrew or a one-line shell installer — then run it in a repo, e.g. codex 'Add a retry with backoff to the API client and a test for it'. The same binary works on macOS, Linux, and Windows (natively or via WSL2).
Codex CLI vs Aider?
One concrete difference: unlike Aider, Codex does not auto-commit each change. It edits the working tree and leaves staging and committing to you, so review the diff before committing.

Filed under

cli · agent · terminal · openai · codex

Related