Part of my AI & code experiments.
The OpenAI Codex CLI is a coding agent that runs in your terminal: OpenAI’s answer to a hands-on, command-line assistant. It reads your repo, plans changes, edits files, and runs commands, all from an interactive terminal UI. Here is how I set it up.
What you need first
- A terminal on macOS, Linux, or Windows (on Windows, run it under WSL2 or PowerShell).
- Either a ChatGPT plan that includes Codex (Plus, Pro, Business, Edu, or Enterprise) or an OpenAI API key for usage-based billing.
Install the CLI
Pick whichever fits your setup:
# npm
npm install -g @openai/codex
# Homebrew
brew install --cask codex
# Standalone installer (macOS/Linux)
curl -fsSL https://chatgpt.com/codex/install.sh | sh
Sign in and run it
Move into a project folder and launch it:
cd my-project
codex
On first launch you are prompted to sign in. The easiest path is Sign in with ChatGPT, which uses your existing plan. If you would rather bill through the API, set an environment variable instead:
export OPENAI_API_KEY="your-key-here"
codex
Working in the terminal UI
Codex opens an interactive session where you describe a task and watch it work. A few things worth knowing early:
- Use
/modelto switch the underlying model for the task at hand. - Approval modes control how much it can do on its own, from asking before every file edit and command, up to a more autonomous mode. Start cautious.
- It can review your local changes, search the web, and accept images as input.
Stay the quality control
An agent that can edit files and run commands is powerful and a little dangerous. Keep approval modes tight until you trust a workflow, work in a clean git branch so every change is reviewable, and read the diff before you commit. The agent does the typing; you own the outcome.
The Codex CLI moves quickly, so check the official Codex CLI docs for the latest commands and options.

You Are the Quality Control
The OpenAI Codex CLI lets you write code faster than ever, but speed without judgement is exactly how bugs, data loss and security holes slip in. My book You Are the Quality Control is a practical guide to building secure software in the age of AI-assisted development, so you can move fast with tools like the OpenAI Codex CLI without compromising security, reliability or data safety.
Inside, you’ll learn how to:
- Review AI-generated code with a security-first eye, so risky changes never reach production.
- Put the right foundation, infrastructure and guardrails around AI-assisted projects.
- Build the habits and quality-first mindset that prevent data loss and costly mistakes.
- Stay the human in the loop, because the most important layer of quality control is still you.