Codex and Claude Code are the two coding agents people compare most on X. Our sample had about 16,600 posts mentioning both. If you've only used Codex in the browser, the CLI is worth ten minutes. It runs on your own machine, inside your real project.
This guide gets you from nothing to a first safe task.
1. Install it
From the official README:
Mac or Linux
curl -fsSL https://chatgpt.com/codex/install.sh | sh
Windows (PowerShell)
powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex"
Package managers
npm install -g @openai/codex
# or
brew install --cask codex
Piping a script into your shell runs code from the internet. That's standard for CLI installers, but only do it from the official URL. If you'd rather read before running, use npm or Homebrew, or download a binary from GitHub Releases.
2. Sign in
Run:
codex
Choose Sign in with ChatGPT. OpenAI recommends this so Codex usage comes out of your Plus, Pro, Business, Edu or Enterprise plan.
You can use an API key instead, but the README says it "requires additional setup". With a key you also pay per token, so set a spend limit at the provider first. The OpenCode Console breach is a good reminder of why.
3. Open a project and run /init
cd into a project. Ideally it's a git repo with a clean working tree, so every change is easy to see and undo. New to git? Start with Git and GitHub basics.
Inside Codex, type:
/init
Codex reads your project and writes an AGENTS.md file: instructions it loads at the start of every session. Open the file and fix it. Add your real test command, your package manager, and anything it must never touch. Our AGENTS.md guide and starter template show what good looks like.
4. Check the model and permissions
Before your first real task, run:
| Command | What it shows or does |
|---|---|
/status |
The current session: model, approvals, workspace |
/permissions |
What Codex may do without asking you |
/model |
Switch models |
Keep approvals strict at first. Let Codex read freely, but have it ask before editing files or running commands. Loosen up once you trust it. Our guide to running coding agents safely explains the trade-offs.
5. Your first task
Start small and checkable:
Add a unit test for the formatPrice function in src/utils.ts.
Run the existing test command and show me the result.
Good first tasks have a clear finish line, like a passing test or a lint error fixed. Avoid "refactor the whole app" on day one.
When it's done, review the diff yourself:
git diff
6. Commands worth learning next
| Command | Use it for |
|---|---|
/review |
Have Codex review your changes |
codex exec "…" |
Run a task non-interactively, e.g. from a script |
codex resume |
Pick up a previous session |
codex --image screenshot.png |
Attach an image, like a UI bug |
codex --search |
Allow web search for the session |
codex mcp |
Manage MCP servers (tools Codex can call) |
codex app |
Open the Codex desktop app |
For MCP setup, see how to add an MCP server to Codex, Cursor and Claude Code.
Common beginner mistakes
- Running it outside git. If you can't diff it, you can't review it.
- Approving everything. Read the command before you say yes, especially anything that deletes, installs or pushes.
- Never editing AGENTS.md. The
/initdraft is a starting point, not a finished file. - Skipping review. Agent code still needs a human pass. Our checklist for reviewing AI-written code takes five minutes.
Codex CLI vs the alternatives
Codex CLI is open source (Apache-2.0), runs locally, and uses your ChatGPT plan. If you're choosing between agents, our Cursor vs Claude Code vs Codex comparison breaks down the differences. If you want to drive several agents from one window, look at T3 Code.






