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) coding agent that runs entirely in your terminal: it reads files, edits them on disk, and runs shell commands inside an OS-level sandbox that defaults to no network and workspace-scoped writes. Sandbox modes and approval policies control what it can do and when it must ask; auth is 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 defaults to no network access and write permissions scoped 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. You can authenticate with a ChatGPT plan (Plus, Pro, Business, Edu, or Enterprise) or an OPENAI_API_KEY, and the same binary works on macOS, Linux, and Windows (natively or via WSL).
Highlights
- Two-layer security model — sandbox modes (
read-only,workspace-write,danger-full-access, via--sandbox) control what the agent can technically do; approval policies (on-request,untrusted,never) control when it must stop and ask before acting. - Sandboxed by default — the
workspace-writemode limits writes to the active workspace and blocks outbound network, so edits stay local until you explicitly widen the boundary. - Model switching — use
/modelto choose among the models available to your account and adjust reasoning effort per task. - 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. - Session resume and image input — pick up past transcripts with
codex 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 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, available on macOS and Linux natively and on Windows (natively via PowerShell or under WSL2). Model usage is not free: you either consume your ChatGPT plan's included Codex allowance or pay 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.
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 defaults to no network access and write permissions scoped to your workspace. It is written in Rust.
- Is Codex CLI free?
- The tool itself is free and open source under Apache-2.0, but model usage is not: you either consume your ChatGPT plan's included Codex allowance (Plus, Pro, Business, Edu, or Enterprise) or pay per token with an OPENAI_API_KEY.
- 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 WSL).
- 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.
Related
- OpenAI Codex: A Practical Guide for DevelopersLearn how OpenAI Codex works across the terminal, IDE, desktop app, and cloud — then set up a safe, repeatable workflow for real repositories.
- Codex config.toml: Settings, Precedence, and Safe DefaultsConfigure OpenAI Codex with config.toml — user and project scopes, precedence, sandbox and approvals, MCP, subagents, profiles, and safe defaults.
- Gemini CLIGoogle's open-source terminal AI agent powered by Gemini models, with a 1M-token context window and built-in tools.
- Codex Automations: Schedule Reliable Background WorkSchedule Codex tasks for recurring checks and follow-ups — choose chat or standalone runs, local projects or worktrees, skills, permissions, and stopping rules.
- Claude CodeAnthropic’s official agentic coding tool that runs in the terminal, IDE, and web.
- AiderOpen-source terminal AI pair programmer that edits files in your Git repo and auto-commits each change, working with Claude, GPT, and other models you bring.
- Codex Skills: Build Reusable Workflows with SKILL.mdCreate, install, and test Codex skills with SKILL.md — including trigger descriptions, repo and user paths, progressive disclosure, and distribution.
- AGENTS.md for Codex: Project Instructions That Actually WorkWrite an effective AGENTS.md for OpenAI Codex — what belongs in it, how nested overrides work, and how to verify the instructions Codex loaded.