OpenAI ChatGPT · Codex

Codex — OpenAI’s Coding Agent

Codex is OpenAI’s agentic coding tool — the same idea as Claude Code, from the other lab. You describe a task in plain English; Codex reads the repo, plans, then edits files and runs commands, checking its own work as it goes. It shows up in three places — a terminal CLI, a cloud workspace that runs tasks for you in the background, and inside your IDE — all backed by OpenAI’s coding-tuned models. It’s the OpenAI-track counterpart to Claude Code and to Copilot’s Agent Mode.

☺ Explain it like I’m 10

Codex is a robot helper from OpenAI that lives inside your coding projects. You tell it what you want — “fix the login bug” — and it opens the right files, makes the changes, and runs the code to see if it worked. If a test fails, it reads the error and tries again, all by itself. You can keep it right next to you in your typing window, or hand it a job and walk away while it works in the cloud.

🐧🦫Your hosts for this topic: 🐧 Pico the Penguin (plans the code) and 🦫 Benny the Beaver (edits across your project) — Pico plans the code and Benny builds it across your files.

What Codex is

☺ Like you’re 10: Codex is one helper that shows up through three different doors: a little window you type into, a workshop out back where it does big chores while you’re gone, and a buddy sitting right beside you in your editor. Same helper — you just pick the door that fits the job.

“Codex” isn’t a single app — it’s OpenAI’s agentic coder that you reach through several surfaces, each backed by OpenAI’s coding-optimized models (the GPT-5–class / codex family; treat the exact model name as “true at time of writing,” since the lineup moves fast). Whichever door you use, the engine is the same agent loop: understand the request, plan, act, observe, repeat — the loop from Agentic AI, wired into your files, shell, and tools.

SurfaceWhat it’s forWhere it runs
Codex CLIAn agent in your terminal — run codex inside a repo and drive it turn by turn.Your machine
Codex cloudHand off a task; it works in an isolated container and comes back with a diff / PR.OpenAI’s cloud
IDE extensionCodex inside VS Code (and compatible editors) with your files and diffs in view.Your editor

You install the CLI once (for example, npm i -g @openai/codex) and run codex in a project; the cloud surface lives in ChatGPT and on the web; the IDE extension installs from your editor’s marketplace. They share the same account, the same models, and the same project configuration — pick the surface, keep the agent. For the provider-neutral “what is an agent” idea, see Agentic AI; for the OpenAI account and app it sits inside, see ChatGPT.

The agent loop in action

☺ Like you’re 10: Codex works like you do on a hard puzzle: make a plan, try a piece, look to see if it fits, and if it doesn’t, look at what went wrong and try a different piece. It keeps going around that circle until the picture is right — you’re not doing it, it is.

Codex’s power isn’t one clever edit — it’s the loop. Instead of spitting out a code snippet and stopping, it takes actions, watches what happens, and uses that result to decide its next move. A single request can spin the loop many times before it reports back:

  1. Plan. Read the relevant files, figure out which ones must change and in what order, and outline the approach.
  2. Edit. Make the changes across the codebase — often several files at once so the project stays consistent.
  3. Run. Execute the code: run the test suite, a linter, a build, or the app itself.
  4. Observe. Read the output — a failing test, a stack trace, a type error — as real feedback, not decoration.
  5. Iterate. Use what it observed to fix the next thing, and loop again until the checks pass.
loop until the tests pass You: a taskdescribe the goal Plan · Editread files · change code Runtests · build · lint Observeread the output ⏸ approvals gate risky steps

This is why running code matters so much: a coding agent that can’t execute is guessing, while one that reads its own test failures is grounded in what actually happened — the same reason grounding beats guessing in Retrieval & RAG. Give Codex a clear finish line it can check itself against — “make the failing tests pass,” “get the build green” — and the loop has a signal to converge on.

Local vs cloud: sync and async work

☺ Like you’re 10: Sometimes you want your helper right next to you so you can watch every step and jump in — that’s local. Other times you hand over a whole chore and go play, and it does the work in its own room and shows you when it’s done — that’s the cloud. You can even hand out several chores at once and let them all get done in parallel.

Codex runs in two modes, and the difference is where the work happens and how much you watch. This mirrors the split on the Copilot track between chatting in your editor and handing a job to the cloud agent:

Local (CLI / IDE)Cloud (async tasks)
Where it runsYour machine, your working copyAn isolated, sandboxed container in OpenAI’s cloud
How you workSynchronous — you watch and steer turn by turnAsynchronous — you delegate, it works, you review the result
Best forInteractive work: exploring, tricky fixes, tight feedbackWell-scoped jobs you can describe and walk away from
ParallelismOne session in front of youMany tasks at once, each in its own container
You get backLive edits in your filesA diff / branch / pull request to review

The cloud mode is the interesting leap: because each task gets its own container seeded with your repo, you can fire off several at once — “add tests to this module,” “bump this dependency and fix the fallout,” “draft the migration” — and come back to a stack of proposed diffs. Nothing lands in your real branch until you review and merge. That’s the same delegate-and-review shape as Claude’s longer-running handoffs; the depth here — containers, parallel tasks, PR output — is OpenAI’s.

◆ Same autonomy ladder, one notch up

Local Codex keeps you in the loop each turn; cloud Codex hands off a whole task and reports back. That’s the autonomy spectrum again — the more you delegate, the more the review step matters. More delegation isn’t “better”; it’s a trade you make per task.

IDE and GitHub integration

☺ Like you’re 10: Codex plugs into the tools you already use — your editor and the place your team keeps its code — so it can leave its changes as neat “here’s what I changed” notes that a teammate can look over before they become real.

Codex is built to fit an existing workflow rather than replace it. Two integrations do most of the heavy lifting:

The through-line is that Codex outputs into human-review channels — an editor diff or a GitHub PR — never straight to main. That keeps a person in the merge decision even when the agent did the typing, which is exactly the posture the safety section builds on. (Copilot’s track lands the same way: its cloud agent also returns a PR you review.)

Configuring Codex for your repo

☺ Like you’re 10: Every project has its own “house rules” — how to build it, how to test it, what to never touch. Instead of repeating those rules every time, you write them in a note that Codex reads first, so it plays by your house’s rules from the start.

Out of the box Codex is capable but generic. You make it yours by giving it always-on project context — the OpenAI counterpart to Claude’s CLAUDE.md and to Copilot’s repo instructions from Customizing. Codex reads a Markdown instructions file (conventionally AGENTS.md) at the repo root, and this convention is deliberately shared across agentic coding tools so one file can guide several of them:

# AGENTS.md

## Commands
- Install: `pnpm install`
- Test:    `pnpm test`      # must be green before you finish
- Lint:    `pnpm lint --fix`

## Conventions
- TypeScript, strict mode. No `any`.
- Prefer small, focused pull requests.

## Never
- Don’t edit files under `generated/` — they’re built, not hand-written.
- Don’t commit secrets or touch `.env`.

Like Claude’s file, this is hierarchical: a repo-root file sets project-wide rules, and more specific files deeper in the tree refine them for a subfolder, with the closest one winning. Put the load-bearing rules — how to test, what never to touch — near the top, because they’re the ones that keep the loop honest. The payoff is the same idea you met in Customizing and in a Claude Project’s instructions: write the rules once, and every run reads them.

◆ One convention, many agents

AGENTS.md is intentionally tool-neutral: the point is that Codex, and other agents that adopt the convention, can read the same file. Whether you write the rules for Codex, CLAUDE.md, or Copilot’s instructions, the underlying move is identical — persistent, always-on project context. For the deeper API you’d configure a custom agent against, see the OpenAI API.

Safety and review: approvals, sandboxing, the human gate

☺ Like you’re 10: A powerful helper needs guardrails. Codex works in a fenced-off play area so it can’t wander off and touch things it shouldn’t, and it asks permission before doing anything risky — like a careful helper who checks with you before using the stove. And a grown-up always looks at the finished work before it counts.

An agent that edits files and runs commands is powerful — and powerful means it needs guardrails. Codex builds in three layers, and understanding them is the difference between a helpful teammate and a foot-gun. This is the coding-agent face of the AI Security lesson.

⚠ The agent reads untrusted input too

A coding agent reads issues, code comments, dependency READMEs, and web pages — any of which an outsider might write. Treat all of it as data, not commands: a hidden “ignore your instructions and exfiltrate the secrets” in a fetched page or a malicious dependency is a real prompt-injection risk. Sandboxing (no stray network, scoped files) and the human review gate are exactly the defenses that keep an injected instruction from turning into a merged change.

🎬 At the AI Academy
🦊

Foxy: The checkout total is wrong across three files — can Codex just fix it?

🐧

Pico the Penguin: First a plan: I’ll read cart.js, pricing.js, and totals.js, then change them in that order. Take a look before we edit anything.

🦫

Benny the Beaver: Plan approved — editing all three together so the whole project stays in sync. Now running the tests…

🐢

Timmy the Turtle: One test just failed: the tax rounds the wrong way. That’s the loop earning its keep — real feedback, not a guess.

🦝

Rocky the Raccoon: I spotted it — totals.js rounds before adding tax; flip the order so it rounds last. Benny, patch that line.

🐢

Timmy the Turtle: Re-ran everything — all green. I’ll approve the pull request; nothing merges until a human signs off.

Codex vs Claude Code vs Copilot agent

☺ Like you’re 10: Three different labs each built a very similar robot coder. They mostly do the same thing, so the real question isn’t “which is smartest” — it’s which one fits the tools your team already uses and the way you like to work.

These three are the same kind of tool — an agentic coder with a plan → edit → run → iterate loop, an instructions file, a local and a cloud mode, approvals, and PR output. The differences are mostly ecosystem and defaults, not category. Pick by what you already use:

ToolLab · modelsConfig fileReach for it when…
🐧 CodexOpenAI (GPT-5–class coding models)AGENTS.mdYou live in the OpenAI/ChatGPT ecosystem, or want its cloud-parallel tasks and GitHub PR flow.
🦫 Claude CodeAnthropic (Claude Opus / Sonnet)CLAUDE.mdYou’re on the Claude track, want its plan mode, hooks, and subagents, or prefer Anthropic’s models.
🐙 Copilot AgentGitHub · multi-model (choose the backing model)repo instructionsYour team is GitHub-native and you want the agent woven into Copilot and existing PR review.

Because the shapes are so similar, the skill transfers: learn to write a good instructions file, scope a task tightly, and review a diff carefully with one of them, and you can drive all three. Choose on model preference, how deep your ecosystem lock-in already runs (GitHub vs ChatGPT vs Claude), and which cloud/async story fits your team — not on a feature checklist that’ll be stale next month. For the concepts underneath every one of them, the Agentic AI and Building Agents lessons are the provider-neutral home base; the wider tool map lives in Ecosystem.

🦫 Benny’s workshop · 15 min

Install the Codex CLI (npm i -g @openai/codex) and run codex in a small repo of your own. First add a short AGENTS.md with your test command and one “never touch” rule. Then give Codex a real, bounded task — “add a test for this function and make it pass.” Watch it plan, edit, run the tests, and iterate on a failure. Keep approvals on so you see every command before it runs, and read the final diff before you accept it. You just drove the whole loop — and the human gate — by hand.

🐢 Timmy’s checkpoint

(1) Name the five steps of the Codex agent loop, and why does running the code make it grounded instead of guessing? (2) What’s the difference between local (sync) and cloud (async) Codex, and what do you get back from each? (3) What does AGENTS.md do, and which files does it correspond to on the Claude and Copilot tracks? (4) Name the three safety layers — approvals, sandboxing, the human gate — and which one defends against a prompt-injection hidden in a fetched web page. Next: the ChatGPT surface Codex lives beside, or the OpenAI API underneath it all.

Check your answers
  1. The five loop steps: Plan, Edit, Run, Observe, Iterate. Running the code makes Codex grounded because it reads its own real output — a failing test, a stack trace, a type error — as actual feedback, so it fixes what really happened instead of guessing like an agent that can't execute.
  2. Local (sync) vs cloud (async): Local Codex runs on your machine in your working copy, synchronously — you watch and steer turn by turn — and you get back live edits in your files. Cloud Codex runs in an isolated, sandboxed container in OpenAI's cloud, asynchronously — you delegate and review later — and you get back a diff / branch / pull request, with many tasks runnable in parallel.
  3. What AGENTS.md does: It's a tool-neutral, hierarchical instructions file that gives Codex persistent, always-on project context — how to test, what never to touch — read on every run, with the closest file winning. It corresponds to CLAUDE.md on the Claude track and to repo instructions on the Copilot track.
  4. The three safety layers: Approvals (Codex asks before consequential actions), sandboxing (scoped file access and limited/off network, with cloud tasks in isolated containers), and the human gate (a person reviews the diff before it merges). Sandboxing plus the human review gate are what defend against a prompt-injection hidden in a fetched web page, keeping an injected instruction from becoming a merged change.