Codex CLI

Verified

OpenAI's local coding agent for inspecting repos, editing files, and running commands from your terminal.

Ada
78 views 1.1k listing impressions

Codex CLI is OpenAI's terminal-native coding agent: an open-source Rust client that reads your code, edits files, and runs commands from the current directory. It is the local half of the Codex family — the same account and task history also reach a cloud agent, an IDE extension, and a GitHub code-review integration, so a task can start on your laptop and finish in a pull request.

Install

curl -fsSL https://chatgpt.com/codex/install.sh | sh   # standalone installer
npm install -g @openai/codex                          # or npm
brew install --cask codex                            # or Homebrew (it's a cask)

Sign in with your ChatGPT account (usage draws on your plan) or with an API key (metered). Then run codex in a repository.

Sandbox and approvals — read this part

Codex's most consequential setting is how much it may do without asking. /permissions switches between modes ranging from read-only through auto-approval, and shows you the active sandbox and its writable roots before you continue. On Windows, /sandbox-add-read-dir grants the sandbox read access to an extra absolute path.

The honest guidance: start read-only on an unfamiliar repo, move to edit-with-approval once you trust its judgment on that codebase, and reserve full auto for a throwaway branch or a container. /approve retries a single action the automatic reviewer blocked, which is the escape hatch for a false positive rather than a reason to loosen the mode globally.

AGENTS.md

/init scaffolds an AGENTS.md in the current directory — persistent, checked-in instructions Codex reads on every run: build and test commands, conventions, directories to leave alone. The file format is shared with several other agents, so the same document does double duty. Repos with a real AGENTS.md get noticeably better results than repos without one; it is the cheapest quality intervention available.

Working the session

A handful of commands do most of the work:

Command What it's for
/plan Think before editing; optionally send an inline planning prompt
/review Review the working tree for behavior changes and missing tests
/diff Inspect the git diff, untracked files included, before keeping edits
/compact Summarize earlier turns to free context without losing the thread
/fork Branch the conversation to try a different direction
/status Model, approval policy, writable roots, token usage
/mcp Add local or remote MCP servers and inspect their tools
/skills Browse local skills and inject one into the current task

Scripting with codex exec

Non-interactive mode is what makes it a build-system citizen rather than a chat toy: codex exec runs a prompt to completion with no TTY, which is how you wire it into CI, pre-commit hooks, and repeatable pipelines. Pair it with a tight sandbox mode and a prompt that has a checkable definition of done.

Standout capabilities

  • Open-source Rust client; ChatGPT-account or API-key auth
  • Explicit sandbox with visible writable roots, not an implicit trust model
  • MCP support for external tools and data
  • Memories, skills, plugins, hooks, and Vim-mode editing in the composer
  • /import pulls in an existing Claude Code setup, project files, or recent chats
  • Background terminals (/ps, /stop) for long-running processes

Best for

Developers already inside a ChatGPT plan who want an agent in the terminal, and teams that want the local agent, the cloud agent, and PR review to share one account and one instruction file.

Where it struggles

  • The docs move. developers.openai.com/codex/* now redirects to learn.chatgpt.com/docs/codex/*; bookmarks and blog posts rot quickly here.
  • Approval fatigue — the strict modes ask a lot, and the tempting fix (auto-approve everything) is exactly the one to resist outside a sandbox.
  • Windows is the least-worn path; WSL remains the smoother route.

Worth knowing

Usage counts against your ChatGPT plan's Codex allowance, and a long autonomous run can consume a surprising amount of it. Check /usage before you assume the quiet failure is a bug.

Comments (0)

Sign in to join the conversation.

No comments yet.

Related tools