Terminal agent

Codex CLI

Coding agent from OpenAI. Runs on: macOS, Linux, Windows, Terminal, VS Code. Supports MCP servers.

Checked 2026-10-31

Install

npm install -g @openai/codex

Commands come from the project's own docs or registry entry. Check them against the source before you run them.

Loading poll...

Codex CLI is OpenAI's coding agent that runs on your computer, and the code is open under Apache-2.0. You install it with one command, run codex, and sign in with a ChatGPT plan or an API key. If you already pay for ChatGPT, it is the cheapest agent to try. Facts checked 31 October 2026.

At a glance

Codex CLI

Vendor

OpenAI

License

Apache-2.0 (the openai/codex repository)

Runs

Locally in your terminal; also an IDE extension, a desktop app (codex app) and a cloud agent (Codex Web)

Sign-in

ChatGPT account (Plus, Pro, Business, Edu, Enterprise) or an API key

Models

OpenAI models; the docs show gpt-6.1-sol in a sample session and /model to switch

Project instructions

AGENTS.md, created with /init

Extending

MCP (codex mcp), skills, plugins

Non-interactive

codex exec

What it is

OpenAI describes Codex CLI as "a coding agent from OpenAI that runs locally on your computer." The same name covers a few products, which confuses people, so here is the split the README gives:

  • Codex CLI: this page. A terminal agent.
  • Codex in your editor: an extension for VS Code, Cursor and Windsurf.
  • Codex app: a desktop experience, started with codex app.
  • Codex Web: the cloud-based agent at chatgpt.com/codex.

The CLI is the open-source part. That makes it unusual among the big vendors' agents: you can read the code, build it yourself and file issues against the real thing. The repository's license file is Apache-2.0, which is a permissive license that allows commercial use.

Install

The README gives several routes. Pick the one that matches how you manage tools.

# macOS and Linux: standalone installer
curl -fsSL https://chatgpt.com/codex/install.sh | sh

# Windows PowerShell
powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex"

# npm
npm install -g @openai/codex

# Homebrew
brew install --cask codex

The standalone installers download from releases.openai.com/codex and fall back to GitHub Releases if that is unavailable. If you want GitHub Releases only, set CODEX_INSTALLER_USE_RELEASES_OPENAI_COM=false before the installer.

You can also download a binary from the latest GitHub release. The README names these archives:

Platform

Archive

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 one executable with the platform in its name, so rename it to codex after extracting.

Windows has its own sandbox and WSL pages in the docs. The security docs say Windows supports a native sandbox, with older elevated and unelevated modes as fallbacks, and that inside WSL2 Codex uses the Linux sandbox. WSL1 was supported only through Codex 0.114, because the Linux sandbox moved to bwrap in 0.115. So native Windows works, and WSL needs to be version 2.

First run and sign-in

Run codex in a project folder. It shows a sign-in choice. The README recommends Sign in with ChatGPT, so that Codex counts as part of your Plus, Pro, Business, Edu or Enterprise plan. An API key works too, but "requires additional setup", which the auth docs describe.

A few commands you will use early, from the CLI page:

Command

What it does

/init

Creates an AGENTS.md for the project

/model

Picks the model and reasoning effort

/permissions

Controls when Codex can edit files or run commands without asking; shows the sandbox and writable roots

/status

Shows the session state

/review

Asks for a review of changes

codex resume

Picks up an earlier session

codex exec

Runs one prompt without the interactive screen

codex --image

Attaches an image to the prompt

codex --search

Allows web search

codex cloud

Works with cloud tasks

The CLI page does not name the sandbox and approval modes, but the security docs do: sandbox modes read-only, workspace-write and danger-full-access, and approval policies such as on-request and never. The older untrusted policy is retired, and a leftover setting can stop the client starting.

Plans and prices

Codex is bundled with ChatGPT plans, so its price is the plan's price. The pricing page lists these plans:

Plan

Notes from the pricing page

Free and Go

Listed with the lighter GPT-6 Luna model on the desktop app, subject to rollout

Plus

Message estimates per five-hour period, by model (below)

Pro

Several tiers; Ultrafast mode is limited to the $500 Pro tier and eligible Enterprise or Edu plans

Business

Same local-message estimates as Plus

Enterprise and Edu

Contact sales

API key

Pay as you go at API rates

The dollar amounts, from our Codex pricing page, are Go $8, Plus $20, Pro from $100 (with $200 and $500 tiers) and Business $20 per seat on annual billing or $25 monthly.

The part we could confirm in the page text is the per-model message estimate for Plus and Business, local messages per five hours:

Model

Messages per 5 hours

GPT-6 Astra

5 to 45

GPT-6.1 Sol

15 to 160

GPT-6.1 Terra

35 to 285

GPT-6 Sol

15 to 150

GPT-6 Luna

350 to 3,000

Weekly limits may also apply. For credit-based usage the page lists rates per million tokens (input, cached input, output):

Model

Input

Cached input

Output

GPT-6.1 Sol

50 credits

2.5 credits

250 credits

GPT-6.1 Terra

25 credits

1.25 credits

125 credits

GPT-6 Luna

2.5 credits

0.25 credits

12.5 credits

GPT-6 Astra

250 credits

25 credits

1,250 credits

The page says a typical GPT-5.6 Sol task may use 2 to 15 credits. It does not give the dollar value of a credit, so we do not convert. If you sign in with an API key, usage is billed at the API rates instead; see our OpenAI API pricing comparison.

The wide range in message estimates is the main thing to understand. The same plan gives you ten times more small-model messages than large-model messages, so which model you select matters more than which tier you buy.

Models

Codex uses OpenAI models. The /model command chooses both the model and the reasoning effort, and the docs show a sample session on gpt-6.1-sol at medium effort. The pricing page names these model families: GPT-6.1 Sol, GPT-6.1 Terra, GPT-6 Sol, GPT-6 Astra and GPT-6 Luna, plus older GPT-5.6 entries. Names and availability shift often, so treat this list as the page of 31 October. Enterprise admins can control access; the page says GPT-6.1 Sol is off by default until an admin enables it.

Unlike Cursor, you do not choose a model from a different vendor. If you want Claude models in a terminal, look at Claude Code; if you want to mix, look at OpenCode.

MCP, skills and plugins

Three extension routes are documented on the CLI page.

  • MCP. codex mcp adds local or remote servers, handles authentication when needed, and lists the tools available in a session. Servers you already use in other clients, such as Playwright MCP or GitHub MCP, are the first to try. Browse the MCP server list.
  • Skills. You package repeatable instructions as skills. See skills.
  • Plugins. Plugins connect Codex to team tools and data, and you browse them from available marketplaces. See plugins.

Project guidance lives in AGENTS.md. That file is also read by several other agents, and Claude Code can read it in place of a CLAUDE.md, so one file can serve a mixed team.

Sandbox and approvals, set deliberately

Codex splits the question "what may it touch" into two settings, and the defaults suit a quick trial more than a production repository. The security docs describe them like this.

Setting

Values

What it controls

sandbox_mode

read-only, workspace-write, danger-full-access

Which files the agent can change, and whether commands get network access

approval_policy

on-request, never

When Codex stops and asks before doing something

In the Auto preset, which is workspace-write with on-request, Codex can read files, make edits and run commands in the working directory automatically. It asks before editing outside the workspace or running commands that need the network. The docs add that network access is off by default in workspace-write, and you turn it on in configuration, not by accident. For chat or planning with no changes, use read-only, which the /permissions command switches to.

A conservative starting point for an unfamiliar repository goes in ~/.codex/config.toml:

sandbox_mode = "read-only"
approval_policy = "on-request"

Or start one session the same way with codex --sandbox read-only --ask-for-approval on-request. Then widen as trust grows. When you want edits, switch to workspace-write. Reserve danger-full-access for a throwaway container, since it removes the protection that makes unattended runs reasonable. If a tutorial shows approval_policy = "untrusted", delete it. The docs say that policy is retired and can prevent the client from starting.

Where configuration lives

The config basics page gives a precedence order, from strongest to weakest, which is worth knowing when a setting seems ignored.

  1. Command-line flags
  2. Project files at .codex/config.toml, closest to your working folder first, and only for projects you trust
  3. Profile files chosen with --profile name, kept at ~/.codex/name.config.toml
  4. Your user file, ~/.codex/config.toml
  5. Defaults delivered by your workspace admin, when signed in
  6. A system file, /etc/codex/config.toml on Unix

Codex loads project .codex/ layers only after you trust the project, which is a sensible guard against a cloned repository that tries to loosen your settings. Profiles are the clean way to keep a strict default and a looser one for a sandboxed container, with a flag to pick between them.

What a message estimate means for a working day

The plan table gives message ranges per five hours. Turn them into a day to see what a plan can carry. These ranges are OpenAI's estimates for Plus and Business, and a work session of an eight-hour day spans a bit under two windows.

Model

Messages per 5 hours

Across two windows (about a working day)

GPT-6 Astra

5 to 45

10 to 90

GPT-6.1 Sol

15 to 160

30 to 320

GPT-6.1 Terra

35 to 285

70 to 570

The spread is the point. Complex tasks with a large model sit at the bottom of each range, because each message does more work, and small edits sit at the top. A person who runs long agent tasks on the biggest model can use up a plan in a single morning. Someone who asks for small changes on a mid-size model will rarely notice a limit. If you hit the ceiling often, the cheaper fixes come before the upgrade: drop to a smaller model for routine steps, keep sessions short and start a fresh one for each task, and attach less context. The credit rates in the table above show the same spread from the other side, with GPT-6 Luna at 2.5 credits per million input tokens against 250 for GPT-6 Astra.

A first hour with Codex

  1. Install and sign in. Use the installer for your platform, run codex in a scratch folder, and choose Sign in with ChatGPT.
  2. Set the sandbox. Run /permissions and confirm you are in a mode you chose, not the default you did not read.
  3. Make it read. In a real repository, ask for an explanation of the folder layout. This costs little and shows whether it finds the right files.
  4. Generate guidance. Run /init and read the AGENTS.md it proposes. Delete anything wrong or obvious. Add the exact test command.
  5. One small edit with a test. Ask for a change that has a pass or fail check, and run the check yourself.
  6. Review. Use /review on the diff, then read it yourself.
  7. Script one thing. Try codex exec with a harmless prompt, such as summarizing the latest commits, to see the non-interactive route.

Running it in CI

codex exec runs one prompt and exits, which fits a pipeline step. Keep to a few rules.

  • Pin the version. Download one of the release archives by tag instead of following the latest installer, so a release cannot change a pipeline overnight.
  • Use an API key for pipelines. A personal ChatGPT login does not belong on a shared runner. An API key bills at API rates, and you can scope and rotate it.
  • Choose the narrowest sandbox. A job that summarizes a diff needs read-only. A job that fixes lint errors needs workspace-write and no network.
  • Set `approval_policy` to `never` only inside a throwaway runner. No human is there to answer a prompt, so the sandbox is your safety net.
  • Treat output as untrusted. Review anything it writes before merging, and never give the job a token that can push to your main branch.

Limits, privacy and data handling

The CLI runs on your computer, but the model runs at OpenAI, so your prompts and the code the agent reads go to OpenAI's servers while you work. What happens to that data depends on the account: ChatGPT consumer plans, Business and Enterprise have different data controls. The one thing we can say from the docs is that /permissions and the sandbox control what the agent can touch on your machine: edit files, run commands, and which folders are writable.

Practical limits:

  • Plan limits are the real ceiling. The five-hour message estimates above are estimates, not guarantees.
  • Pro plans have, per the pricing page, no five-hour limit at present.
  • Image input, web search and cloud tasks are separate flags or commands, so check that the one you need is on.

Who it suits

  • ChatGPT subscribers who want an agent without a second bill.
  • People who want to read the code of their agent, or run a build they control.
  • Teams on Business or Enterprise who already administer ChatGPT and want admin control over models.
  • Terminal and CI users, through codex exec.

It suits less well if you want several vendors' models in one picker, or a Claude-centered workflow.

Moving to it from another agent

  1. Carry your instructions: if your repo has AGENTS.md, Codex reads it. If you only have a CLAUDE.md, copy the content into AGENTS.md, or run /init and paste in what is missing.
  2. Re-add MCP servers with codex mcp.
  3. Check /permissions before the first real task, since the defaults differ from other agents.
  4. Run the same small task in both agents and compare the diffs.

Alternatives and duos

Compare with

Page

Claude Code

Claude Code vs Codex

Cursor

Cursor vs Codex

Gemini CLI

Codex vs Gemini CLI

Open-source terminal agents

OpenCode, open source AI agents

The full field is on AI coding agents.

Repository health

Because the CLI is open source, you can check how alive it is before depending on it. On 31 October 2026 the GitHub repository showed about 131,900 stars and a last push on 30 October. The README links a contributing guide, build instructions and an open source fund page. Stars say little about quality, but a push the day before you look says the project is moving.

The README also gives two other things worth noting. Releases are published on GitHub as plain archives for four platform builds, so you can pin an exact version in CI instead of following the latest installer. And the installer's fallback to GitHub Releases means a problem on one download host does not have to block a build.

Questions people ask before installing

Do I need a ChatGPT subscription? No. An API key works, with extra setup, and is billed at API rates. A subscription is simply the route the README recommends.

Can I run it in a script? Yes. codex exec runs a prompt without the interactive screen, which is the building block for CI and cron jobs.

Can it look at screenshots? The CLI page lists codex --image for attaching images.

Can it browse the web? codex --search is listed. Whether you want that on is a privacy choice, since search queries leave your machine.

Where do cloud tasks run? codex cloud works with the cloud-based agent, Codex Web, at chatgpt.com/codex. Your code is then handled by OpenAI's infrastructure instead of your laptop.

What if I switch editors? The IDE extension covers VS Code, Cursor and Windsurf, so the same agent follows you between those editors.

Our take

This is built from the README, the CLI page and the pricing page. We did not run a test for this page.

The strongest point is the combination of open source and plan bundling. Few vendors let a subscriber use a permissively licensed agent at no extra charge. That makes it the natural first step for anyone already inside ChatGPT, and an easy second agent for someone who mainly uses another tool.

The weak spot is clarity. OpenAI's product names overlap (CLI, app, Web, IDE extension), the model list moves quickly, and the CLI page leaves the sandbox modes and config path to other pages. Budget a little time to read the sandbox docs before you let it run commands unattended.

If you pay for ChatGPT, install it and try one task. If you do not, the cost question is whether a ChatGPT plan is worth buying for this alone; compare with the Claude pricing ladder first.

Checklist

  • Sign in with ChatGPT or set up an API key, knowing which one bills you
  • Run /permissions and read the sandbox settings
  • Run /init and edit the generated AGENTS.md
  • Add one MCP server with codex mcp
  • Choose a model with /model and note the message estimate for it
  • Re-check the plan prices on the live pricing page

Mentioned here

  • Claude Code

    Claude Code is Anthropic's coding agent for the terminal, VS Code, JetBrains, a desktop app and the web.

    • Terminal agent
    • MCP

    Subscription · 153,977 stars

  • Cursor

    Cursor is a desktop AI editor with a terminal CLI and cloud agents that work in their own virtual machines.

    • AI code editor
    • MCP

    Free tier + paid

  • GitHub Copilot

    GitHub Copilot is GitHub's assistant for editors, the terminal and github.com, with an agent mode, a CLI and a cloud agent.

    • Editor extension
    • MCP

    Free tier + paid

  • Gemini CLI

    Gemini CLI is Google's Apache-2.0 terminal agent.

    • Terminal agent
    • Open source
    • MCP

    Free · 108,636 stars

  • OpenCode

    OpenCode is an MIT-licensed coding agent for the terminal, a desktop app and IDEs.

    • Terminal agent
    • Open source
    • MCP

    Free · 223,319 stars

  • Aider

    Aider is an Apache-2.0 terminal coding agent that maps your repository and commits each change to git, so every edit can be reviewed or undone with ordinary git commands.

    • Terminal agent
    • Open source

    Free · 49,833 stars

Questions

Is Codex CLI open source?

Yes. The openai/codex repository is licensed under Apache-2.0.

How do I sign in?

Run codex and choose Sign in with ChatGPT to use it as part of a Plus, Pro, Business, Edu or Enterprise plan. An API key also works but needs extra setup.

Does Codex read AGENTS.md?

Yes. The CLI docs say /init creates an AGENTS.md file with instructions for the project.

Does Codex support MCP?

Yes. The codex mcp command adds local or remote MCP servers, handles authentication and lists the tools in a session.

Loading poll...

Reviews

Loading reviews…

Write a review

Your rating

Up to 1000 characters. Stars alone are enough.

Sources

  1. developers.openai.com/codex/agent-approvals-security
  2. developers.openai.com/codex/config-basic
  3. github.com/openai/codex
  4. learn.chatgpt.com/docs/codex/cli
  5. learn.chatgpt.com/docs/pricing

Add-ons that work with Codex CLI

All add-ons
  • browser-use MCP

    Browser Use is an open-source Python library for AI browser agents, and our entry covers its MCP route.

    • MCP server
    • Official

    browser-use · 119,597 stars

  • Scrapling MCP Server

    Scrapling is a Python web scraping framework from D4Vinci, described on GitHub as handling everything from a single request to a full-scale crawl, and this entry is its MCP server.

    • MCP server

    D4Vinci · 90,477 stars

  • Netdata MCP

    Netdata is an observability platform, and this entry is its hosted MCP endpoint at app.netdata.cloud, reached over streamable HTTP.

    • MCP server

    netdata · 81,227 stars

  • claude-flow MCP

    Claude Flow is published on npm as claude-flow, and its repository now sits at ruvnet/ruflo, which the GitHub description calls the original agent harness for deploying multi-agent swarms and coordinating autonomous workflows.

    • MCP server

    ruvnet · 80,298 stars

  • tldraw MCP

    tldraw is an infinite-canvas SDK for React, and this entry is a hosted MCP endpoint run on a tldraw Workers address, reachable over streamable HTTP and SSE.

    • MCP server

    tldraw · 51,163 stars

  • Metabase MCP

    Metabase is an open-source business intelligence and embedded analytics tool, and this entry is the MCP endpoint its server exposes at your own host under /api/mcp, over streamable HTTP.

    • MCP server

    metabase · 50,029 stars

  • Codebase Memory MCP

    Codebase Memory is an npm package from DeusData, installed with npx -y codebase-memory-mcp over stdio.

    • MCP server

    DeusData · 47,863 stars

  • CCXT MCP

    CCXT is a unified trading API covering more than 100 crypto exchanges and prediction markets, written for JavaScript, TypeScript, Python, C#, PHP, Go, Java and Rust, and this entry is its npm MCP package, installed with npx -y ccxt-mcp over stdio.

    • MCP server

    ccxt · 44,630 stars

Alternatives

  • Amp

    Amp, from Sourcegraph, runs each coding agent on its own remote machine, called an Orb, and works from the web, apps and a CLI.

    • Terminal agent
    • MCP

    Free tier + paid

  • Crush

    Crush is a terminal coding agent from Charm, with MCP support, for macOS, Linux and Windows.

    • Terminal agent
    • MCP

    Free · 28,890 stars

  • Factory Droid

    Factory's Droid is a coding agent that runs in the terminal and on the web, with MCP support, aimed at software teams and enterprises.

    • Terminal agent
    • MCP

    Subscription

Part of the Wbcom Designs family

The all-in-one WordPress community stack

Also ours: wbcomdesigns.comvapvarun.combrndle.com