Codex CLI: install, sign in, and start safely

Install Codex CLI on macOS, Linux, or Windows, choose a sign-in method, run a first repository task, and review permissions and changes…

A hand-drawn Codex CLI setup path from install and login through project selection, permissions, task, and review.

From install to reviewed change

A six-step Codex CLI path from installation and login through project selection, permissions, a bounded task, and diff review.

  1. Install
  2. login
  3. project
  4. permissions
  5. task
  6. review

Better Design

On this page

Direct answer

Codex CLI is OpenAI's terminal coding agent for inspecting a local repository, editing files, running commands, and automating repeatable development work. Install it with OpenAI's standalone script, npm, or Homebrew. Run codex from a project directory and sign in. Give it one bounded task. Review its commands and diff before keeping the change.

Key takeaways

  • OpenAI currently documents standalone installers for macOS, Linux, and Windows, plus npm and Homebrew options.
  • Run the tool from the repository you want it to inspect instead of from a broad parent folder.
  • Local work supports ChatGPT sign-in and API-key sign-in; the billing and workspace controls differ.
  • Start with one observable outcome and keep the repository in version control before edits begin.
  • Permissions, sandbox scope, command output, tests, and the final diff remain part of the developer's review.

What the OpenAI Codex CLI does

The terminal interface works against a local repository. OpenAI's documentation describes a loop in which the agent inspects files, makes changes, and runs installed development tools. The interactive codex command launches the terminal UI. The separate codex exec command supports non-interactive scripts and pipelines. Use the interactive path for a first installation so approvals and changes stay visible.

Official Codex CLI guide

Choose a Codex download and install method

Use one supported method and keep using that method for updates. The standalone installer is the shortest official path on each operating system. npm fits a machine that already manages global command-line packages with Node.js. Homebrew fits a macOS setup that already uses casks. Avoid installing through several methods because multiple codex binaries can make later troubleshooting confusing.

Install Codex CLI on macOS or Linux

OpenAI documents this standalone installer for macOS and Linux: curl -fsSL https://chatgpt.com/codex/install.sh | sh. Read the official page and the script source before piping a remote script into a shell if that is part of your security policy. Run the same documented installer again when you want to update that installation.

npm or Homebrew alternatives

npm
install globally with npm install -g @openai/codex and use the same command to update.
Homebrew
install with brew install --cask codex and update with brew upgrade --cask codex.
Verification
run codex, or use codex --help when you want to confirm the command is on the active path.

Codex for Windows

OpenAI currently documents a standalone PowerShell installer for Windows: powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex". Confirm that the command comes from the current official page before running it. The current CLI also documents native Windows sandbox commands and Windows-specific behavior. An old guide that requires WSL may not describe every supported path.

Sign in after the Codex CLI install

Run codex inside a project directory. The first run offers available sign-in methods. OpenAI documents ChatGPT sign-in for subscription access and API-key sign-in for usage-based access. The local app, CLI, and IDE extension support both methods. Codex cloud requires ChatGPT sign-in. Your choice also determines which workspace, retention, and billing controls apply.

ChatGPT
run codex login and complete the browser flow.
API key
pipe OPENAI_API_KEY to codex login --with-api-key instead of placing the secret in shell history.
Status
run codex login status to confirm that valid credentials are present.
Sign out
run codex logout to clear the cached credentials.

Official authentication guide

Run a first repository task

Create or open a Git repository, confirm its current status, and run codex from that directory. Ask for explanation before mutation: identify the application entry point, test command, and one relevant module. Then give one bounded task with an expected result and verification command. Inspect the proposed plan, each command, the changed files, and the final test output.

  1. Goal: describe one user-visible or testable outcome.
  2. Scope: name the relevant files and what must not change.
  3. Evidence: provide an error, failing test, screenshot, or acceptance criterion.
  4. Verification: name the type check, test, lint, build, or manual flow that should pass.
  5. Review: inspect the diff and run the relevant checks before committing.

Keep permissions proportional to the task

The CLI lets a user control approvals and sandbox policy. Start with the narrowest workspace and permissions that can complete the task. Grant another directory only when the task needs it. Avoid the documented bypass flag unless the process already runs inside a separate hardened environment. A generated command can still be wrong even when the sandbox limits its reach.

Official command-line reference

Give interface work a real design source

For interface work, provide the current design system and interaction rules. Add the content patterns and required states. Better Design makes that context available through MCP and provides a separate rendered-review checklist. This helps the agent work from owned decisions. The developer remains responsible for testing the actual interface.

Install Better Design for Codex

Update or troubleshoot the installation

Update with the same installer or package manager you chose. Run which codex on macOS or Linux, or Get-Command codex in PowerShell, when the wrong version appears. The documented codex doctor command can generate a diagnostic report for installation, configuration, authentication, runtime, Git, terminal, app-server, and thread inventory issues. Do not paste credential files into a ticket or chat.

Frequently asked questions