October 23, 2026

How to Install and Set Up Codex CLI

Codex CLI is OpenAI's open-source coding agent for the terminal. This guide covers every way to install Codex CLI on macOS, Linux and Windows, how to sign in, your first session, configuration, and how to update it. Then it shows how to run Codex alongside Claude Code in Chief.

Quick install

PlatformCommand
macOS and Linuxcurl -fsSL https://chatgpt.com/codex/install.sh | sh
Windows (PowerShell)powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex"
npm (any platform)npm install -g @openai/codex
Homebrewbrew install --cask codex

Then run codex in your project folder and choose Sign in with ChatGPT.

Commands are from OpenAI's Codex README and docs, checked in October 2026. Check OpenAI's Codex docs for the latest.


Step 1: Install Codex CLI

macOS and Linux

OpenAI's standalone installer is the recommended way to install Codex CLI on macOS and Linux:

curl -fsSL https://chatgpt.com/codex/install.sh | sh

Codex CLI supports macOS on Apple Silicon and Intel, and Linux on x86_64 and arm64.

Prefer a package manager? Use Homebrew:

brew install --cask codex

or npm:

npm install -g @openai/codex

You can also download a binary for your platform from the Codex GitHub releases page and rename it to codex.

Windows

Codex CLI runs natively on Windows. To install Codex CLI on Windows, run this in PowerShell:

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

On Windows, Codex uses a native Windows sandbox by default, so you don't need WSL or a virtual machine. OpenAI suggests WSL2 when you need Linux-native tooling or your workflow already runs there; in that case, install Codex inside WSL with the macOS and Linux command above.

Check the install

codex --version

If something looks wrong, codex doctor checks your installation, config, sign-in and runtime health.

Step 2: Sign in

Run codex in any folder. The first time, it asks you to choose a sign-in method:

  • Sign in with ChatGPT uses your ChatGPT plan, so Codex usage comes with your subscription. It's the recommended option for Plus, Pro, Business, Edu and Enterprise plans.
  • Sign in with an API key bills usage to your OpenAI API account.

You can also sign in from the command line:

codex login                                            # browser sign-in
printenv OPENAI_API_KEY | codex login --with-api-key   # API key from stdin
codex login --device-auth                              # device code, for remote or headless machines
codex login status                                     # show the active sign-in
codex logout                                           # clear stored credentials

On a server or a machine without a browser, OpenAI recommends device code sign-in. Codex stores credentials in ~/.codex/auth.json or your operating system's credential store.

Step 3: Run your first session

Open your project and start Codex:

cd my-project
codex

Type a task in plain language, such as "add input validation to the signup form and a test for it". A few slash commands are worth knowing on day one:

CommandWhat it does
/initCreates an AGENTS.md file with instructions for Codex
/modelChooses the model and reasoning effort
/permissionsChooses what Codex can do without asking
/statusShows the current session configuration
/reviewReviews your changes and finds issues

AGENTS.md is where you tell Codex how your project works: how to run the tests, which conventions to follow, and what to avoid. Run /init once and edit the result.

Step 4: Set permissions and defaults

Codex asks before it edits files or runs commands outside the limits you set. You can change this per session with /permissions, or start Codex with flags:

codex --sandbox workspace-write --ask-for-approval on-request

The sandbox modes are read-only, workspace-write and danger-full-access. For lasting defaults, set the same options in ~/.codex/config.toml:

model = "gpt-6.1-sol"
approval_policy = "on-request"
sandbox_mode = "workspace-write"

Use codex --profile <name> to layer a named profile on top of your base config, for example one profile for careful work and another for quick experiments.

Step 5: Update Codex CLI

Codex updates often. The simplest way to update is:

codex update

Or update with the tool you installed it with:

curl -fsSL https://chatgpt.com/codex/install.sh | sh   # standalone installer: rerun it
npm install -g @openai/codex@latest                    # npm
brew upgrade --cask codex                              # Homebrew

Run codex --version afterwards to confirm the new version.

Useful Codex CLI commands

CommandWhat it does
codexStarts an interactive session
codex exec "<task>"Runs a task non-interactively, for scripts and CI
codex reviewRuns a code review non-interactively
codex resumeResumes a previous session (--last for the most recent)
codex --worktreeRuns the session in a new git worktree
codex mcpManages MCP servers
codex appLaunches the Codex desktop app

Run Codex alongside Claude Code in Chief

Once Codex CLI is installed and signed in, it's ready for Chief. Chief is an AI agent manager: you set a goal, Chief plans it as milestones and runs each one with the agent you choose.

  • Codex and Claude Code in one plan. Set a default agent per project and pick Codex or Claude Code for any milestone. See Claude Code vs Codex for where each one shines.
  • Runs the Codex you just installed. The Chief relay runs on macOS, Linux and Windows and starts the codex on your machine, signed in to your own ChatGPT account. Your code stays where it is.
  • Independent work runs in parallel. Chief runs every milestone whose dependencies are done at the same time and checks each result against its definition of done.
  • Talk to Chief from Codex. Add Chief's MCP server with codex mcp and ask what's waiting on you without leaving your session.

Run Codex with Chief. Start free →

More on the pairing: Chief + Codex.


FAQ

How do I install Codex CLI?

On macOS and Linux, run curl -fsSL https://chatgpt.com/codex/install.sh | sh. On Windows, run the PowerShell installer. You can also use npm install -g @openai/codex or brew install --cask codex. Then run codex and sign in.

Does Codex CLI work on Windows?

Yes. Codex CLI runs natively on Windows with a Windows sandbox, so WSL isn't required. You can still use WSL2 if your tools are Linux-native.

How do I update Codex CLI?

Run codex update, or update with the tool you installed it with: rerun the install script, npm install -g @openai/codex@latest, or brew upgrade --cask codex.

Is Codex CLI free?

The Codex CLI is open source under the Apache-2.0 license. Using it needs a ChatGPT plan that includes Codex or an OpenAI API key billed per token. Check OpenAI's pricing page for current plans.

Do I need Node.js to install Codex CLI?

No. The standalone installers and Homebrew don't need Node.js. You only need Node.js if you choose to install with npm.

Can I use Codex CLI and Claude Code together?

Yes. Give each its own branch or git worktree so they don't edit the same files, or let Chief plan the work and send each milestone to the agent you choose.

More articles

AI Agent Orchestration Guide

What AI agent orchestration is, how multi-agent orchestration works for Claude Code and Codex, and a comparison of orchestration approaches. Free guide.

What Is Agentic Engineering?

Agentic engineering means directing AI coding agents that write and test code while you set goals and review results. How it differs from agentic coding.

AI Code Review at Scale

What AI code review is, the main types of AI code review tools, and five workflows for reviewing AI-generated code from several coding agents at once.

Claude Code and Codex Pricing

Claude Code pricing from $20/mo (Pro) to $200/mo (Max 20x), Codex pricing from ChatGPT Free to Pro, usage limits and a comparison table, checked Oct 2026.

From Single Agent to Multi-Agent

Already using one AI coding agent? Here's how to scale to multiple instances running in parallel — the concurrency patterns, worktree isolation, and task decomposition strategies that make it work.

Vibe Coding at Scale

Vibe coding with one agent is fun. Vibe coding with five is chaos — unless you have orchestration. Here's how to scale the vibe without losing the quality.

Why AI Agents Need an Orchestration Layer

Running AI coding agents in terminal tabs works for two. Five signs you've outgrown it, tabs vs an orchestration layer, and what to look for in one.

Multi-Provider AI Orchestration

Claude Code, Codex, Cursor, Aider — each excels at different work. Here's how to combine providers into one coordinated workflow and why cross-provider review catches bugs single-provider setups miss.

Use Chief From Your AI Assistant

Chief's remote MCP server connects Claude, Claude Code and Codex to your projects. Ask what's waiting on you, catch up on what shipped and propose milestones.

Claude Code vs Codex: When to Use Each

Codex vs Claude Code: when each fits, a comparison table and FAQ. Claude Code vs Codex isn't either-or; Chief runs both on your projects.

Claude Code vs Cursor: When to Use Each

Cursor vs Claude Code: when each fits, a comparison table and FAQ. Claude Code vs Cursor isn't either-or; keep Cursor and let Chief run Claude Code.

How to Run Multiple Claude Code Agents in Parallel

Run multiple Claude Code agents in parallel, step by step: worktrees, background agents, subagents and review. Then let Chief orchestrate them for you.

Git Worktrees for AI Coding Agents

How to use git worktrees with Claude Code and Codex: one per agent, parallel runs, .env files, merging and cleanup. Every command, step by step.

How to Run Claude Code From Your Phone

Run Claude Code from your phone: Remote Control, cloud sessions in the Claude mobile app, or SSH and tmux, step by step. Plus approving agents in Discord.

The Best AI Coding Agents in 2026

The best AI coding agents of 2026: Claude Code, Codex, Cursor, Copilot and more agentic AI coding tools compared, and how to run several with Chief.

Subagents vs Parallel Agents

What is a subagent? How Claude Code subagents and Codex subagents work, how they differ from parallel agents, and when to use each one.

Ready to manage your agents?

_Codex is a trademark of OpenAI. Claude Code is a trademark of Anthropic. Chief is an independent product and is not affiliated with, sponsored by, or endorsed by either._