What is Codex?
Understanding OpenAI's terminal-based coding agent and how it fits into the AI developer tools landscape.
It is powered by OpenAI's models (like
o4-mini and o3) and works directly with your local files and development environment. You describe what you want in plain English, and Codex figures out how to do it.
- Write code -- Generate entire scripts, functions, or components from a description
- Fix bugs -- Point it at a broken file and let it diagnose and repair issues
- Refactor -- Clean up messy code, rename variables, restructure logic
- Explain code -- Ask it to walk you through what a function or file does
- Run commands -- Execute shell commands as part of its workflow
- Work with your codebase -- It reads your project files for context before acting
| Feature | Codex CLI | Claude Code |
|---|---|---|
| Provider | OpenAI | Anthropic |
| Models | o4-mini, o3 | Claude Sonnet, Opus |
| Open Source | Yes | No |
| Sandboxing | Built-in (network disabled by default) | Permission-based approvals |
| Approval Modes | suggest / auto-edit / full-auto | Interactive approval per action |
| Install | npm install -g @openai/codex |
npm install -g @anthropic-ai/claude-code |
| Best For | Quick tasks, sandboxed automation | Complex multi-file refactors, deep reasoning |
Where You Can Use It
codexGetting Set Up
From zero to running Codex in your terminal. Follow each step in order.
codex command available everywhere in your terminal.
npm install -g installs a package globally, meaning you can run codex from any directory in your terminal. The @openai/codex is the official package name on the npm registry.
1. Go to platform.openai.com/api-keys
2. Sign in or create an account
3. Click "Create new secret key"
4. Copy the key (it starts with
sk-)
export sets an environment variable in your current terminal session. This makes the key available to any program you run, including Codex. Replace your-key-here with your actual API key from step 3.
Note: This only lasts for the current terminal session. When you close the terminal, the variable is gone. The next step shows how to make it permanent.
>> operator appends text to the end of a file. ~/.zshrc is your Zsh shell configuration file that runs every time you open a new terminal.
source ~/.zshrc reloads the configuration file so the change takes effect immediately without opening a new terminal window.
Using Bash instead of Zsh? Replace
~/.zshrc with ~/.bashrc.
codex to make sure everything is set up correctly:
If you see an error about API keys: Double-check that your
OPENAI_API_KEY environment variable is set correctly by running echo $OPENAI_API_KEY.
Environment variable (recommended) -- Set
OPENAI_API_KEY as shown above.Login command -- Run
codex --login for browser-based authentication via ChatGPT. This stores credentials locally and does not require managing API keys manually.Project-level config -- Create a
codex.json or codex.yaml file in your project root to configure model, approval mode, and other settings per-project.
codex --login to authenticate without needing a separate API key or billing setup.How to Use Codex
From basic prompts to advanced workflows. Master the different ways to interact with Codex.
⚡ Basic Usage
codex command.
🗨 Interactive Mode
codex with no arguments to enter interactive mode. This lets you have a back-and-forth conversation, refine your requests, and build on previous responses.
📁 Working with Files
cd into your project folder before running Codex, and it will be aware of your codebase.
For best results:
- Run Codex from your project root so it can see all relevant files
- Be specific about which files to work with in your prompt
- Use a
AGENTS.mdfile to give Codex persistent context about your project structure, conventions, and preferences
🔒 Approval Modes
🏷️ Common Flags & Options
o4-mini. Use o3 for harder tasks.suggest, auto-edit, or full-auto.🔬 More Example Prompts
Codex Skills
Skills are reusable workflow packages that extend Codex with specialized capabilities. Think of them as plugins that teach Codex new tricks.
What Are Skills?
Skills package instructions, resources, and optional scripts into a reusable bundle. When you invoke a skill, Codex follows the workflow reliably every time — no need to re-explain complex processes.
- Perform specialized tasks consistently
- Encapsulate multi-step workflows into a single command
- Share and reuse across projects
- Can be invoked explicitly (
$skill-name) or automatically matched to your prompt
Enable & Install Skills
Enable the skills feature, then use the built-in installer:
Install skills from the catalog inside a Codex session:
Where Skills Live
Codex discovers skills from multiple locations (in order of precedence):
.agents/skills/ — project-specific, shared with your team
User
~/.codex/skills/ — your personal skills
Admin
/etc/codex/skills/ — system-wide
System
Built-in skills bundled with Codex
Anatomy of a Skill
Every skill is a folder with a SKILL.md file and optional extras:
my-skill/ ├── SKILL.md # required — name, description, instructions ├── agents/ │ └── openai.yaml # optional — UI, invocation policy ├── scripts/ # optional — helper scripts ├── references/ # optional — reference docs └── assets/ # optional — images, templates
⭐ Recommended Skills
skill-creator
Create new skills interactively. Generates the folder structure and SKILL.md for you. Type $skill-creator to start.
skill-installer
Browse and install skills from the official catalog. Handles download, placement, and configuration automatically.
create-plan
Generates structured implementation plans before writing code. Great for breaking down complex features into steps.
gh-address-comments
Reads GitHub PR review comments and generates fixes automatically. Saves time on code review cycles.
Design Skills
50+ community design skills for generating UI components, layouts, and styling. Install via the catalog or build your own.
Document Processing
Skills for working with spreadsheets, DOCX files, and PDFs. Transform, analyze, and generate documents from prompts.
.agents/skills/ in your repo. Your whole team gets the same Codex superpowers, and the skills evolve with the codebase.Fun Projects to Try
Put Codex to work on real projects. Each card includes the exact prompt to get started.