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.
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.
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.
- Goal: describe one user-visible or testable outcome.
- Scope: name the relevant files and what must not change.
- Evidence: provide an error, failing test, screenshot, or acceptance criterion.
- Verification: name the type check, test, lint, build, or manual flow that should pass.
- 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.
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.
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
No. The CLI is terminal-first local repository work. The desktop app provides a graphical workspace for planning, review, files, and longer tasks. OpenAI also documents IDE and cloud surfaces. Choose the surface that fits the task instead of assuming every feature behaves the same way.
Not for every local workflow. The official authentication guide supports ChatGPT sign-in for subscription access and API-key sign-in for usage-based access. Some cloud or workspace features depend on the chosen method and plan.
Yes. OpenAI currently documents npm install -g @openai/codex. Use npm again for updates, and check the active executable path if another installation method was previously used.
