Codex CLI
Codex CLI is OpenAI's answer to the agentic coding assistant question — and the answer is fast. Like, noticeably faster than the competition. It's a terminal-based coding agent powered by OpenAI's latest models that takes natural language instructions and turns them into actual code changes in your repo. No GUI needed, no VS Code extension, just your terminal and an API key.
The core model is suggest-then-apply. By default, Codex shows you what it wants to change and waits for your approval. This is actually smart for a default — you see the diff, you approve or reject, you stay in control. But once you trust it, switch to full-auto mode with --full-auto and it just goes. Writes code, runs tests, fixes errors, commits. The whole loop.
The .codex/instructions.md file is where you make it smart about your project. This is your chance to tell it about your stack, your conventions, your testing setup, your deployment process. Codex reads this before every task, so it's not just guessing about how your project works — it actually knows. Think of it as the onboarding doc you wish every new hire would actually read.
Where Codex really shines is batch operations. Need to update 50 API endpoints to use a new auth pattern? Add error handling to every controller? Migrate a config format across an entire codebase? Codex handles the "do this repetitive thing 100 times" class of problems better than almost anything else. It's methodical, it doesn't get bored, and it doesn't miss edge cases on file 47 because it's tired.
Setup is clean: set your OPENAI_API_KEY, install with npm, run codex in your project directory. That's it. No config files to create, no workspace setup, no onboarding wizard. First run takes maybe 30 seconds from install to writing code. The simplicity is actually a feature — less ceremony means more actual work getting done.
The sandbox execution is a nice safety feature. Codex can run commands in a sandboxed environment so it can test its changes without touching your actual system. This means it can run your test suite, check build output, and validate its work without risk. For anything beyond trivial changes, this is the mode you want — it catches problems before they become your problems.
Model selection matters here. Codex supports OpenAI's full model lineup. Use the fast models for quick fixes and small tasks. Use the reasoning models for complex architecture decisions and debugging gnarly bugs. The difference in output quality between models is significant — don't cheap out on the hard problems.
The session history is stored locally in ~/.codex/sessions/. Every conversation, every change, every decision — it's all there. You can resume sessions, review what happened, and trace back why a particular change was made. This is way better than the "black box" approach where you just get a PR and have no idea what the AI was thinking.
Integration with OpenAI's ecosystem is tight. If you're already using OpenAI for other things — embeddings, fine-tuned models, batch processing — Codex fits naturally into that stack. The API key you're already using probably works. No new accounts, no new billing setups, no new vendor relationships.
Who's it for? Engineers who want speed and prefer OpenAI's models. Teams already in the OpenAI ecosystem who want an agentic tool that works with their existing setup. People doing bulk operations across large codebases. If you want the fastest path from "I need this changed" to "it's changed, tested, and committed" — Codex CLI is that path.
Power Tips
Non-obvious leverageQuick Wins
Write it once. Codex reads it every run. Put your stack, conventions, testing patterns, and rules here. It's the difference between a tool that guesses and one that knows your codebase.
Non-interactive mode. Perfect for automation, CI pipelines, and scripted tasks.
Three modes: suggest (show changes, ask), auto (apply without asking), full-auto (run commands too).
Codex reads your git history as part of its context. A clean commit before a big task also gives you a clear rollback point.
Don't point Codex at one file. It builds a mental model of your whole codebase and makes better decisions when it has full context.
Suppresses the "thinking" output for cleaner integration into shell pipelines and CI logs.
Hidden Features
For large tasks, Codex can spawn parallel worker agents automatically. It handles the orchestration — you don't need to break the task up manually. Just describe the full scope and it figures out the parallelism.
You can reference a URL in your task description and Codex will fetch and read it as context. Useful for "implement this API according to the spec at https://..."
Use a different model for different tasks without changing config. Fast model for exploration, smarter model for production code.
codex --model gpt-4o-mini "quick refactor of this function" Common Mistakes
Codex guesses your stack and conventions from scratch every run. Everything is slower and less accurate without it.
Create .codex/instructions.md before your first real task.full-auto runs shell commands without confirmation. In code you don't know well, this can delete files or run destructive migrations.
Use suggest on code you don't own. full-auto only for trusted, well-tested repos.If you don't like Codex's output, you need a clean commit to roll back to. Working with a dirty git state gives you no safety net.
git add -A && git commit -m "checkpoint" before every big Codex task.