Skip to content

OpenAI Codex CLI ​

Starter OpenAI’s terminal coding agent (2026).

What's new: see Agent CLI game changers, checked against 0.166.0.

Install ​

bash
# npm (cross-platform) — use the scoped package
npm install -g @openai/codex

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

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

WARNING

npm install -g codex (unscoped) is a different package. Always use @openai/codex.

bash
codex --version

First run ​

bash
cd ~/code/my-project
codex

Sign in with ChatGPT (subscription) or use API key auth depending on your setup.

Everyday usage ​

bash
# interactive
codex

# start with a prompt
codex "add unit tests for src/utils/date.ts"

# quieter / script-friendly modes exist — check `codex --help` on your version

Project guidance ​

Codex respects project instruction files commonly used by agents (e.g. AGENTS.md / repo docs). Keep them concise: how to build, test, and what not to touch.

WSL tip ​

Keep the repo under ~/…, not /mnt/c/…. Codex runs many filesystem and shell operations.

Approvals & sandbox (power user) ​

Codex can ask before running tools. Common approval styles (see codex --help / docs for exact flags on your version):

ModeBehavior
untrustedOnly trusted read-ish commands without asking; escalate otherwise
on-requestModel decides when to ask
neverNo approval prompts (CI / sandboxed automation only)

Example config sketch (~/.codex/config.toml — fields evolve; verify against current docs):

toml
approval_policy = "on-request"
sandbox_mode = "workspace-write"

[sandbox_workspace_write]
network_access = true

Safety ​

  • Review diffs before commit
  • Prefer a dedicated branch or worktree
  • Don’t paste secrets into prompts

Skills ​

Shared agent skills: apsolut/apsolut-skills

Official ​