§14.01

How to Get Started with OpenAI Codex CLI

Install Codex CLI with npm or Homebrew, sign in with ChatGPT, run your first task in a repo, and use /permissions to set what it can do. Copy-paste.

published 06 Sept 2026 checked against docs 06 Sept 2026 3 min in Other coding agents Markdown

Step 1 of 6 · Try the other coding agents

On this page4 sections
  1. 1. Install it
  2. 2. Sign in
  3. 3. Your first task
  4. 4. Decide what it may do without asking

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.

← All Other coding agents plates · Search all guides

↑↓ move↵ openalt+↵ copy first command

Keyboard

⌘/ctrl+K or /
Search all guides
alt+↵
In search: copy the guide's first command
j / k
Move through a list of guides
c
On a guide: copy its first command
t
Toggle light / dark
?
This list