Other coding agents

How to Get Started with OpenAI Codex CLI

3 min read

Codex CLI is OpenAI’s terminal coding agent. It runs on your machine and edits files in the repo you start it from.

1. Install it

With npm (any OS with Node installed):

npm install -g @openai/codex

On macOS with Homebrew:

brew install --cask codex

Or the standalone installer for macOS and Linux:

curl -fsSL https://chatgpt.com/codex/install.sh | sh

All three give you the same codex command on your PATH.

2. Sign in

Run it once with no arguments:

codex

The first run asks how to authenticate — pick Sign in with ChatGPT to use your existing plan. Other sign-in methods, including an API key, are listed in the Codex auth docs.

3. Your first task

Start Codex inside the repo you want it to work on — that’s the code it can see:

cd path/to/your/project
codex

Then type one concrete request:

Add a --dry-run flag to the CLI that prints the planned changes instead of writing files.

Codex reads the repo, proposes edits, and asks before it does anything outside what you’ve allowed. Review the diff before you accept it.

4. Decide what it may do without asking

Inside a session, run:

/permissions

That’s where you choose when Codex can edit files or run commands without stopping to ask, and where you inspect the active sandbox and its writable roots. Start restrictive: let it edit files in the workspace, but keep command execution on approval until you trust the task.

Codex also accepts approval and sandbox settings as command-line flags. Flag names change between releases, so read them off your own install rather than copying them from a blog:

codex --help

Tip: one task per session. A fresh codex run with a clean, specific request beats a long session that has drifted across three unrelated changes.

Next: Aider first steps or giving a coding agent the right context.

Open the full interactive version (with copy buttons) ↗

← All guides