How to use Codex CLI: install, sign in and run
To use the Codex CLI, install it with npm install -g @openai/codex (or OpenAI's installer or Homebrew), open a project folder in your terminal, run codex, sign in with your ChatGPT account, and type what you want done. Codex reads your files, proposes and makes edits, and runs commands, asking first when it needs to step outside the project folder. It's included in ChatGPT Plus and higher plans, or you can pay per token with an API key. The commands below come from OpenAI's Codex docs as of November 2026 (Codex CLI, read November 2026).
Install Codex CLI
Pick one:
# macOS and Linux, OpenAI's installer
curl -fsSL https://chatgpt.com/codex/install.sh | sh
# npm, any platform with Node.js
npm install -g @openai/codex
# Homebrew
brew install --cask codex
On Windows, run OpenAI's installer from a new PowerShell window:
powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex"
To update, run the same installer or npm command again, or brew upgrade --cask codex.
Sign in
Open a project folder and run codex. The first time, choose Sign in with ChatGPT or another method. You have two options (authentication, read November 2026):
- ChatGPT account. Usage comes out of your plan. ChatGPT Plus at $20 a month includes Codex "on the web, in the CLI, in the IDE extension, and on iOS"; Pro, Business and Enterprise include more. Free and Go plans get limited Codex access in the desktop app only.
- API key. Usage is billed at OpenAI's API prices. This works for the CLI, SDK and IDE extension, but with "no cloud-based features" such as GitHub code review.
Your first task
Start with a question, so you can see how Codex reads the project before it changes anything:
Tell me about this project
Then give it a focused change, such as fixing a failing test or adding a small feature. Codex shows the commands it runs and the diffs it makes as they happen, and you can steer it mid-turn. OpenAI suggests making git commits before and after each task so you can roll back.
Permissions and the sandbox
Codex controls what it can do in two layers (approvals and security, read November 2026):
- The sandbox sets "what Codex can do technically":
read-only,workspace-writeordanger-full-access. - The approval policy sets "when Codex must ask you":
on-requestornever.
In a git repository the default is Auto, which is workspace-write with on-request approvals. In the CLI that means "no network access and write permissions limited to the active workspace," and Codex asks when it needs more. Folders such as .git and .codex stay read-only even inside the workspace. In a folder that isn't under version control, Codex starts read-only.
Type /permissions during a session to change when Codex can act without asking and to see the active sandbox. The --yolo flag, short for --dangerously-bypass-approvals-and-sandbox, removes both layers; OpenAI marks it "not recommended." Older guides may show approval_policy = "untrusted", which Codex no longer supports.
Choose a model
Type /model to switch models and reasoning effort. OpenAI recommends GPT-6.2 Sol for everyday coding and GPT-6.2 Astra for demanding work, with GPT-6.1 Terra as a fast option (Codex models, read November 2026). To set a default, add a line to ~/.codex/config.toml:
model = "gpt-6.2-sol"
You can also pick a model for one run with codex --model gpt-6.2-sol.
Give Codex standing instructions with AGENTS.md
"Codex reads AGENTS.md files before doing any work." Put general preferences in ~/.codex/AGENTS.md and project rules, such as how to run tests or which folders to leave alone, in an AGENTS.md at the root of the repository. Codex combines the files from the git root down to your current folder, up to 32 KiB by default (AGENTS.md, read November 2026). Claude Code and other agents can read the same file.
Commands worth knowing
| Command | What it does |
|---|---|
codex | Start an interactive session in the current folder |
codex resume | Reopen a recent chat from this repository |
codex --image <file> | Include a screenshot or diagram with your first prompt |
codex --search | Turn on live web search for the run |
codex exec "<task>" | Run one task without the interactive screen, for scripts and CI |
codex cloud | Browse and submit Codex cloud tasks and apply the results locally |
codex mcp | Add and sign in to MCP servers |
/model | Switch model and reasoning effort |
/permissions | Change what Codex can do without asking |
/review | Run a local code review |
Run Codex in scripts and CI
codex exec runs a single task and prints only the final answer to standard output, so you can pipe it:
codex exec "generate release notes for the last 10 commits" | tee release-notes.md
By default codex exec runs read-only. Add --sandbox workspace-write to let it edit files; OpenAI says to keep danger-full-access for "an isolated CI runner or container" (non-interactive mode, read November 2026).
Hooks, subagents and cloud tasks
Codex has hooks, scripts that run at points such as before a tool call; they are on by default and you must trust each one before it runs. It can hand parts of a large job to subagents and bring their findings back. And codex cloud sends a task to OpenAI's cloud, where "each task has its own workspace and can keep working while your computer is asleep."
Is Codex CLI open source?
Yes. The CLI is open source under the Apache 2.0 license at github.com/openai/codex, though OpenAI says the repository "doesn't accept external code contributions or pull requests." The IDE extension and Codex cloud aren't open source.
Codex CLI vs Claude Code
Codex is built around OpenAI's GPT models and Claude Code around Anthropic's Claude models; both cost $20 a month at the entry level. Codex's default is a strict sandbox; Claude Code's is an auto mode where a classifier reviews each action. Our Codex vs Claude Code post compares them in detail.
Using Codex inside Neotask
If Codex is one of several agents you use, Neotask's Code page can run it on one project and Claude Code, Cursor, Gemini CLI or Neotask's own agent on others. Neotask is a separate desktop app, not made by OpenAI. You install Codex and sign in yourself, and Neotask doesn't charge for turns that use your ChatGPT subscription. You can comment on Codex's changes line by line on the Diff page and commit only the files you tick. If you buy a Neotask cloud computer, Codex can run there with your own sign-in, with no browser needed on that computer.
Frequently asked questions
Is Codex CLI free? The CLI itself is free and open source, but it needs a ChatGPT plan that includes it, Plus at $20 a month or higher, or an API key billed per token.
How do I install Codex CLI on Windows? Run powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex" in a new PowerShell window, or use npm install -g @openai/codex.
How do I change the model in Codex CLI? Type /model in a session, run codex --model <name>, or set model in ~/.codex/config.toml.
Can Codex CLI run without asking for approval? Yes. /permissions lets you reduce the prompts, and --yolo removes approvals and the sandbox entirely, which OpenAI marks "not recommended."