How to install and use OpenAI Codex CLI: sign-in, first coding task, sandbox and safety
Install Codex CLI, sign in, run your first small approved change in a project folder, and keep workspace-write sandbox defaults.
To run your first job with OpenAI Codex CLI, finish four steps: official install, sign in (ChatGPT or API key), launch codex in a repo, then approve a small change inside sandbox defaults.
Facts follow developers.openai.com/codex Authentication, Sandbox, and Permissions plus GitHub openai/codex Quickstart. Queries: Codex CLI install, OpenAI Codex sandbox workspace-write. For a short huddle see sitdraw and create and join a room.
CLI vs IDE extension
Codex CLI
Runs in your terminal against the current working tree—handy for SSH remotes and editor-free workflows.
Shared login
CLI and IDE extension share cached credentials; logging out of one requires signing in again on the other.
| Goal | Entry | First-hour check |
|---|---|---|
| Install | install.sh / npm / Homebrew | codex starts |
| Sign in | Sign in with ChatGPT or API key | Active session; protect ~/.codex/auth.json |
| First coding task | Prompt in repo root | Approve diff → verify with git diff |
| Sandbox | config.toml or flags | Not danger-full-access by default |
Install, sign in, first task, safety defaults
- 01Install Codex CLI
macOS/Linux:
curl -fsSL https://chatgpt.com/codex/install.sh | sh. Windows: official PowerShell one-liner. Ornpm install -g @openai/codex,brew install --cask codex. - 02Sign in
Run
codex→ Sign in with ChatGPT (browser OAuth) or API key perdevelopers.openai.com/codex/auth. Never commitauth.json. - 03First coding task
cdyour project root. Ask Codex for a one-line README tweak or comment-only change; Approve each step; confirm withgit diff. - 04Sandbox and approvals
Set
sandbox_mode = "workspace-write"andapproval_policy = "on-request", or--sandbox workspace-write --ask-for-approval on-request. Installbubblewrapon Linux/WSL; type/permissionsto inspect. Read every shell command before approving.
# First hour · OpenAI Codex CLI · 2026-09
# curl -fsSL https://chatgpt.com/codex/install.sh | sh
# npm install -g @openai/codex · brew install --cask codex
# codex → Sign in with ChatGPT
# cd my-repo && codex · workspace-write · on-request approvals
# Linux/WSL: bubblewrap (bwrap)
# developers.openai.com/codex · github.com/openai/codex- Compare Cline or Gemini CLI?
- Codex CLI is OpenAI’s terminal agent; see our Cline guide and Gemini CLI guide.
- Missing bwrap on Linux?
- Install the distro
bubblewrappackage; see Sandbox docs for WSL2 notes. - ChatGPT vs API key?
- ChatGPT sign-in for daily use; API keys for CI—never in public shells.
- Whiteboard?
- No—open sitdraw for diagrams.
Sandbox first, then Approve
Keep the first task to one small diff; treat terminal commands and auth.json as sensitive.