Lesson 31 of 2116
Installing and Using the OpenAI Codex CLI
Codex CLI is OpenAI's terminal coding agent. It runs locally, supports MCP, and ships a codex cloud mode for background tasks. Let's install it and compare it honestly to Claude Code.
Lesson map
What this lesson covers
Learning path
The main moves in order
- 1OpenAI's Answer to Claude Code
- 2Codex CLI
- 3exec mode
- 4codex cloud
Concept cluster
Terms to connect while reading
Section 1
OpenAI's Answer to Claude Code
Codex CLI is OpenAI's lightweight coding agent. It runs in your terminal, inspects your repo, edits files, and executes shell commands. It ships on macOS, Windows, and Linux, and its premium models are included with ChatGPT Plus, Pro, and Business plans.
Install and first run
As of April 2026, gpt-5.5 is the recommended model for complex work; gpt-5.3-codex is tuned for fast edits.
# Install via npm (macOS, Linux, Windows)
npm install -g @openai/codex
# Or via Homebrew on macOS
brew install openai/codex/codex
# Launch in your project directory
cd my-project
codex
# Type /model to pick a model
# Default in 2026: gpt-5.5 for complex work, gpt-5.3-codex for fast tasksTwo modes you will use
Compare the options
| Mode | Command | What it's for |
|---|---|---|
| Interactive TUI | codex | Conversational coding, the default experience |
| Exec | codex exec "<prompt>" | Scripted, non-interactive runs — great for CI |
| Cloud | codex cloud | Offload long tasks to OpenAI's infra, review locally |
A realistic exec workflow
Exec mode turns Codex into a scriptable tool you can chain with Make, GitHub Actions, or cron.
# Automate a recurring task with `codex exec`
codex exec "Find all task list comments in src/, group them by file, \
and write a markdown summary to TODO_REPORT.md"
# Run in CI after PR checks pass
codex exec --model gpt-5.5 "Review the diff against main and \
flag any missing test coverage for changed functions."codex cloud: the superpower
The codex cloud command launches tasks on OpenAI infrastructure, which can run long without tying up your laptop. You can hand off a refactor at 5pm and pull the PR in the morning. Running codex cloud with no arguments opens an interactive picker of active and finished tasks.
Image input
You can paste screenshots or design specs directly into the Codex composer or pass image files on the command line. This is ideal for turning a mockup into real components or diagnosing a UI bug from a screen recording.
Claude Code vs. Codex CLI: the honest comparison
Compare the options
| Dimension | Claude Code | Codex CLI |
|---|---|---|
| Model | Claude family | GPT family |
| Project memory | CLAUDE.md | AGENTS.md (similar concept) |
| Parallel agents | Up to 10 subagents | Single-session + cloud offload |
| Extensibility | Skills, hooks, 25+ lifecycle events | MCP, exec scripts, cloud tasks |
| Pricing entry | Claude Pro $20/mo | Included in ChatGPT Plus/Pro |
“The best agent is the one whose workflow matches your brain.”
Key terms in this lesson
The big idea: Codex CLI and Claude Code are two terminal agents racing to the same destination. Install both, try them on real tasks for a week each, and let your wrists decide the winner.
End-of-lesson quiz
Check what stuck
15 questions · Score saves to your progress.
Tutor
Curious about “Installing and Using the OpenAI Codex CLI”?
Ask anything about this lesson. I’ll answer using just what you’re reading — short, friendly, grounded.
Progress saved locally in this browser. Sign in to sync across devices.
Related lessons
Keep going
Creators · 50 min
The Landscape: Copilot vs. Cursor vs. Windsurf vs. Claude Code
The AI coding tool market fragmented fast. Let's map the 2026 landscape honestly: who is for autocomplete, who is for agents, who wins on cost, and what the tradeoffs actually feel like.
Creators · 55 min
Building a Minimal MCP Server
Model Context Protocol lets agents plug into your tools. A 40-line server exposes a real capability to Claude.
Creators · 50 min
Installing and Using Claude Code CLI
Claude Code is Anthropic's terminal-native coding agent. Let's install it, wire it to a project, and use the features most engineers miss on day one.
