Based on OpenAI’s official docs, checked
How to install the OpenAI Codex CLI
The Codex CLI is OpenAI’s coding agent for the terminal. It installs with a standalone script on macOS, Linux and Windows, or through npm or Homebrew. This guide lists each install and update command, how to sign in and how to run a first task, based on OpenAI’s Codex CLI docs checked October 22, 2026.
1. Install on macOS or Linux
Use OpenAI’s standalone installer. Running the same command again updates Codex.
curl -fsSL https://chatgpt.com/codex/install.sh | sh2. Install on Windows
Open a new PowerShell window and run the Windows installer. The same command also updates it.
powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex"3. Or use npm or Homebrew
npm install -g @openai/codex installs and updates via npm. On Homebrew, install with brew install --cask codex and update with brew upgrade --cask codex.
npm install -g @openai/codex4. Run Codex and sign in
Open a project directory and run codex. The first time, choose Sign in with ChatGPT or another available sign-in method.
codex5. Start your first task
Describe what you want, for example asking Codex to explain the project. OpenAI suggests creating Git checkpoints before and after a task so you can revert changes.
Tell me about this project
What to set up next
Permissions: /permissions chooses when Codex can edit files or run commands without asking. See our guide to Codex sandbox modes and approval policies.
MCP: codex mcp adds local or remote MCP servers.
Automation: codex exec runs Codex non-interactively in scripts and CI.
Shell completions: codex completion generates completions for your shell.
Useful commands after installing
codex resume reopens a recent chat from the current repository.
codex --image passes a screenshot or diagram with the first prompt.
codex --search switches a run to live web search.
codex cloud browses and submits Codex cloud tasks from the terminal.
Tips
- Re-run the installer to update; for npm or Homebrew use their own update command.
- Commit or stash your work before the first task so you can roll back easily.
- OpenAI’s CLI page does not list system requirements; check the troubleshooting docs if the installer fails.
Next steps
Verified MCP servers for Codex
Generate an MCP config for Codex
OpenAI Codex hub
Claude Code vs OpenAI Codex: documented features compared
OpenAI Codex vs Cursor: documented features compared
How to add an MCP server to Codex
How to add an MCP server to Cursor
How to add an MCP server to GitHub Copilot in VS Code
How to add an MCP server to Google Antigravity
How to migrate from Gemini CLI to Antigravity CLI
Portable agent skills: one SKILL.md for every coding agent
Safe “always allow” rules for Claude Code and Codex CLI
GitHub Copilot CLI yolo mode: --allow-all and safer tool rules
Codex sandbox modes and approval policies explained
How to install Claude Code on macOS, Linux and Windows
Claude Code auto mode: what runs, what gets blocked, how to turn it off
Agent Skills moves to the Agentic AI Foundation: what changes
MCP security: the risks in MCP servers and how to lock them down
Claude Code in VS Code: install, shortcuts and CLI differences
What is AGENTS.md? The open instruction file for coding agents
Claude Code on Windows: native, WSL and common errors
Codex skills: create, install and use SKILL.md skills in Codex
GitHub Copilot CLI: install, sign in and start using it
Cursor Agent SDK: build, test and deploy agents as code
GPT-6.1 Terra in Codex and the API: setup, pricing and limits
MCP OAuth: connect a remote MCP server in Claude Code, Codex and Cursor
Codex config.toml: location, precedence and the settings to change
Codex on Windows: native sandbox setup, WSL and fixes
Antigravity CLI (agy): install, sign in, modes and commands
Google Antigravity on Windows: install, WSL, sandbox and fixes
GitHub Copilot coding agent (now cloud agent): how to use it
GitHub Copilot agent mode: how to use it in your IDE
Codex sandbox modes and approval policies explained
How to add an MCP server to Codex
Codex pricing
Codex config.toml: location, options and examples
Codex on Windows: sandbox setup, WSL and fixes
Frequently asked questions
On macOS or Linux run curl -fsSL https://chatgpt.com/codex/install.sh | sh. On Windows run the PowerShell installer from OpenAI’s docs. npm install -g @openai/codex and brew install --cask codex also work.
Sources
- https://developers.openai.com/codex/cli · checked 2026-10-22