🧠 All Things AI
Advanced

Codex CLI

The Codex CLI is OpenAI's official terminal-based coding agent — an open-source tool that brings the Codex Agent experience to your command line. It reads your local codebase, reasons about your request, suggests or implements changes, and executes shell commands, all within a sandboxed environment directly in your terminal.

What the Codex CLI Is

The Codex CLI is a locally-running agentic coding assistant. It is built in Rust and published as open source on GitHub at openai/codex. When you invoke it, it reads your codebase context, understands your request, and takes action — writing code, running commands, and iterating on the results. This is fundamentally different from a general-purpose API CLI tool.

Important Clarification

There is no general-purpose openai CLI for making arbitrary API calls from the terminal — no official tool equivalent to the AWS CLI or Stripe CLI for listing models, running completions, or managing resources via shell commands. For scripted API calls from the command line, use the Python SDK, curl, or HTTPie. The Codex CLI is specifically a coding agent, not an API CLI.

Installation

Install the Codex CLI via npm or Homebrew:

# via npm (requires Node.js)
npm i -g @openai/codex

# via Homebrew (macOS)
brew install --cask codex

After installation, authenticate with your OpenAI API key. Your ChatGPT Plus, Pro, Business, Edu, or Enterprise subscription is required — the CLI uses your API access, not a separate product purchase.

What It Does

The Codex CLI operates as a local coding agent in your terminal:

  • Codebase reading: Reads your local files to understand project structure, conventions, and context before acting
  • Code suggestions and implementation: Proposes changes and, with your approval, writes them directly to your files
  • Command execution: Runs shell commands (build tools, test runners, linters) and reads their output to inform the next step
  • OS-level sandboxing: Operates within a security sandbox to prevent unintended side effects — file system access is scoped, and commands are reviewed before execution
  • Iterative problem solving: Reads test failures, compiler errors, and runtime output, then adjusts its approach accordingly

OS-Level Sandboxing

The Codex CLI implements sandboxing at the operating system level. File system access is scoped to the project directory. Commands that would affect system-wide state require explicit user confirmation. This design means the agent can be productive in your development environment without posing a risk of accidental or malicious system changes. The security model is a key advantage of the CLI approach over asking a model to describe commands you then run manually.

Evolution of the Coding Surface

The Codex CLI represents a shift in how OpenAI thinks about developer tooling. In 2023–2024, the primary pattern was "a model you prompt for code snippets." By 2025, Codex CLI had evolved into a full coding surface combining reasoning models (GPT-5-Codex), developer tooling (shell access, file I/O, test runners), and agentic orchestration — closer to a junior engineer in your terminal than a smart autocomplete.

Access Requirements

The Codex CLI requires an active ChatGPT subscription at the Plus, Pro, Business, Edu, or Enterprise tier. It is not available on the Free plan. The CLI is open source (MIT licensed), meaning you can inspect, fork, and contribute to the codebase — though the underlying Codex model it calls is proprietary.

Checklist

  • What language is the Codex CLI built in, and where is its source code hosted?
  • How do you install the Codex CLI using npm?
  • What does "OS-level sandboxing" protect against in the context of the Codex CLI?
  • Is there a general-purpose openai CLI for API calls? What should you use instead?
  • Which subscription plans allow use of the Codex CLI?