# 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.

- Canonical: https://guides-ai.pages.dev/guides/codex-cli-first-steps/
- Plate 14.01 · Topic: Other coding agents (https://guides-ai.pages.dev/topics/agents/)
- Published: 06 Sept 2026 · 3 min read
- Source site: guides-ai — https://guides-ai.pages.dev/

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):

```bash
npm install -g @openai/codex
```

On macOS with Homebrew:

```bash
brew install --cask codex
```

Or the standalone installer for macOS and Linux:

```bash
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:

```bash
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:

```bash
cd path/to/your/project
codex
```

Then type one concrete request:

```text
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:

```text
/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:

```bash
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](/guides/aider-first-steps/) or
[giving a coding agent the right context](/guides/ai-coding-agent-context/).
