Short answer
A coding agent is an AI system that doesn't just suggest code but carries out a programming task itself: it reads your project, edits files, runs commands and tests, and repeats until the job is done or it gets stuck. OpenAI's new Codex, which works in a cloud sandbox, and Anthropic's Claude Code, which works in your terminal, are two leading examples.
Follow-up question How do you give an agent a task it can actually finish?
For a few years, AI coding help meant autocomplete: you typed, and a model guessed the next lines. A coding agent works at a different level. You describe a task, such as "fix the bug where the login page crashes on an empty password," and the agent explores the code, makes changes across files, runs the tests, reads the errors and tries again. You review the result rather than each keystroke.
Two launches this year show the idea taking shape. In February, Anthropic released a limited research preview of Claude Code alongside its Claude 3.7 Sonnet model. Last Friday, 16 May, OpenAI opened a research preview of Codex, an agent that does software engineering work in the cloud, to ChatGPT Pro, Team and Enterprise subscribers.
Two ways to work: your terminal or a cloud sandbox
Claude Code is a command-line tool. You run it inside a project folder on your own machine, and it can search and read the code, change files, create tests and run them, push commits to GitHub, and call other command-line tools. Anthropic says it keeps the developer in the loop at every step, and by default it asks permission before actions that change your system, such as writing files or running many shell commands.
Codex runs in the cloud. You open it from the ChatGPT sidebar, type a task and click "Code" (or "Ask" for a question about the codebase). Each task gets its own isolated container preloaded with your repository. Codex can edit files and run tests, linters and type checkers, and OpenAI says a task usually takes between 1 and 30 minutes. You can start several at once. The model behind it, codex-1, is OpenAI's o3 reasoning model further trained for software work.
| Claude Code | Codex | |
|---|---|---|
| Where it runs | Your machine, in the terminal | OpenAI's cloud, one sandbox per task |
| How you watch | Interactively, approving actions | Check back when the task finishes |
| Internet during a task | Uses your environment's tools | Disabled |
| Project instructions file | CLAUDE.md | AGENTS.md |
How an agent knows your project
Both tools read a plain-text instructions file you keep in the repository. Codex looks for AGENTS.md; Claude Code loads CLAUDE.md automatically. These files tell the agent how the project is organized, which commands build and test it, and which conventions to follow. A few lines go a long way:
# AGENTS.md
- Install with: npm install
- Run all tests with: npm test (must pass before you finish)
- Use TypeScript strict mode; no new dependencies without asking.
- Keep changes small and explain each one in the pull request summary.OpenAI's announcement puts it simply: like people, Codex agents do best with configured development environments, reliable tests and clear documentation.
Safety and review
Giving software the power to run commands calls for care. Codex has internet access switched off while it works, so it can only touch the code you provided and the dependencies installed by your setup script. It also cites terminal logs and test results, so you can trace what it did, and it says so when tests fail. Even so, OpenAI stresses that people must still review and validate agent-written code before merging or running it.
Claude Code works on your real machine, which is why it asks before risky actions. Anthropic's best-practices guide notes that skipping those permission checks can lead to data loss or to prompt injection, where malicious text in a file or web page tricks the agent into doing something you didn't intend. Its advice is to do that only inside a container without internet access.
Try it: Pick a small open-source project you know, or one of your own. Write a five-line AGENTS.md or CLAUDE.md with the install and test commands, then ask an agent to explain the project's structure without changing anything. Check its explanation against what you know.
How do you give an agent a task it can actually finish?
Give it a target it can check. Anthropic's guide says Claude does best with a clear goal to iterate against, such as a test suite or a visual mock-up. Without one, the agent can only guess when it's done. With one, it can run the check, read the failure and keep going. A good task names the expected behavior and the proof:
Users report that saving a profile with an empty phone number crashes the app. Look at src/profile/save.ts. First write a failing test that reproduces the crash. Then fix the code so the test passes without changing the test. Run the full test suite before you finish and summarize what you changed.Keep the scope narrow. OpenAI says its own engineers mostly hand Codex repetitive, well-scoped jobs such as refactoring, renaming and writing tests, and it recommends spreading several well-defined tasks across agents rather than one sprawling request. "Improve the app" is not a task; "add input validation to the signup form, with tests" is.
For bigger changes, split thinking from doing. Anthropic recommends a sequence: ask the agent to read the relevant files and make a plan without writing code yet, review that plan, then let it implement and commit. Test-driven development fits especially well: have the agent write tests from examples of input and output, confirm they fail, commit them, and only then write the code to make them pass.
Finally, plan to review. These are research previews: Codex can't yet take image inputs or accept mid-task corrections, and both companies expect a human to read the diff. A finished task is the start of your review, not the end of it.
Sources
- Introducing Codex — OpenAI, May 16, 2025
- Claude 3.7 Sonnet and Claude Code — Anthropic, February 24, 2025
- Claude Code: Best practices for agentic coding — Anthropic, April 18, 2025