Sub topic 18
Comparing the three tools and choosing one
This chapter assumes you have read the earlier chapters. You should know the agent loop, instruction files, approval modes, sandboxing, and non-interactive runs. Here you compare Claude Code, Codex CLI, and Copilot CLI and pick one for a task.
What the three tools share
All three run in your shell, read your repository, edit files, and run commands in a loop. They install as npm packages and start from the project directory. Each has an interactive session and a single-prompt mode, so you can script any of them.
claude -p "Explain what the build script in package.json does"
codex exec "Explain what the build script in package.json does"
copilot -p "Explain what the build script in package.json does"Each also has instruction files, permission or approval controls, and support for MCP servers. Your skills transfer between them.
Where they differ
The differences are mostly in naming and defaults. Check each tool's current documentation before relying on a detail, because these tools change quickly.
| Area | Claude Code | Codex CLI | Copilot CLI |
|---|---|---|---|
| Command | `claude` | `codex` | `copilot` |
| Instruction file | `CLAUDE.md` | `AGENTS.md` | Repository instruction files (see its docs) |
| Settings | `.claude/settings.json` with allow and deny rules | `~/.codex/config.toml` with approval policy and sandbox mode | Its own settings and trusted-directory prompts |
| Safety model | Per-command permission rules | Approval policy plus sandbox mode | Approval prompts per action |
| One-shot run | `claude -p` | `codex exec` | `copilot -p` |
Codex CLI separates two questions. The approval policy decides when the agent must ask you. The sandbox mode decides what the agent can touch at all. Claude Code centers on permission rules for specific tools and commands, such as allowing Bash(npm run test:*) and denying Read(./.env).
AGENTS.md is read by Codex CLI and by other tools. If your team uses several agents, one AGENTS.md can hold the shared conventions, which avoids keeping parallel files in sync.
Decision criteria
Choose by the constraints of the task, not by which tool is "best".
- Account and billing. The tool tied to a subscription you already have is the cheapest to start with. Copilot CLI fits teams already on GitHub Copilot. Claude Code and Codex CLI fit teams on Anthropic or OpenAI accounts.
- Control needs. If you need strict, auditable limits on file access, prefer the tool whose sandbox and permission model matches your policy.
- Shared conventions. If several tools must follow the same rules, prefer
AGENTS.md. - Automation. All three can run non-interactively. Test the exact flags in your CI environment before committing to one.
- Task fit. Models differ in speed, cost, and quality on your language and codebase.
Compare them on your own tasks
Benchmarks and opinions age fast. A better test is to run one small, well-scoped task in each tool on separate branches.
git switch -c agent/compare-claude
# run the task with claude, then:
git diff
npm test
git switch main
git switch -c agent/compare-codex
# run the same task with codex, then repeat the checksUse the same prompt, the same starting commit, and the same checks. Record test results, the size of the diff, how many approvals each tool asked for, and the time taken.
Exercise
Your team uses Codex CLI and Claude Code on the same repository. How can you avoid maintaining two separate sets of project conventions, and what should you check before choosing one tool for CI?
Show answer
Put the shared build, test, and style rules in AGENTS.md, which Codex CLI reads, and keep CLAUDE.md short, pointing to or repeating only what is specific to Claude Code. Check the tool's current documentation for how it reads instruction files. For CI, test the one-shot command (codex exec or claude -p) in the real CI environment, including authentication, approval and permission settings, and exit behavior, before adopting it.