Codex CLI is an agentic coding tool by OpenAI that operates directly in the terminal. It reads the project context, proposes file changes, runs commands, and iterates until the task is complete.
It is installed globally via npm and is not declared in the Brewfile.
Requires Node.js (already part of this setup). Install Codex globally:
npm install -g @openai/codexVerify the installation:
codex --versionCodex authenticates with an OpenAI API key. Set the key in your shell environment (do not commit it):
export OPENAI_API_KEY="..."Add this export to ~/.shell/local.zsh (gitignored) so it is available in
every session without being versioned.
Run Codex in any project directory:
codex "add input validation to the registration form"Codex reads the surrounding files, proposes changes, and asks for approval before writing anything. Review each diff before accepting.
Useful flags:
codex --help
codex "task description" --model <model-name> # see `codex --help` for current modelsCodex works best on well-scoped, atomic tasks:
- One feature or fix per session.
- Clear, specific instructions referencing file names or class names when possible.
- Always review the proposed diff before approving.
- Commit immediately after a successful change so the history stays clean.
| Aspect | Codex CLI | Claude Code |
|---|---|---|
| Provider | OpenAI | Anthropic |
| Model | OpenAI's current default (see codex --help) |
Claude Sonnet / Opus |
| Auth | OPENAI_API_KEY env var |
Anthropic account |
| Billing | OpenAI API usage | Anthropic subscription or API |
| Project instructions | AGENTS.md |
.claude/CLAUDE.md |
Use whichever fits the task or the model you prefer. Both tools can coexist in the same project.
Codex reads AGENTS.md from the project root if it exists:
my-project/
AGENTS.md # project-specific instructions for Codex
.claude/
CLAUDE.md # project-specific instructions for Claude Code
- The
OPENAI_API_KEYmust never be committed to any repository. - Store it in
~/.shell/local.zshor a secrets manager. - Codex operates with the permissions of the current user. Review all proposed changes before approving.
- Do not run Codex with auto-approve in a production environment.
Remove Codex with npm:
npm uninstall -g @openai/codex