Sub topic 19
Comparing the three tools and choosing one
This chapter assumes you have read the earlier chapters. You should know the agent loop, instruction files, permission and approval modes, sandboxing, non-interactive runs, and MCP. It compares Claude Code, Codex CLI, and Copilot CLI on those shared parts and gives a way to pick one for a task.
The tools change quickly. Treat the specifics below as a snapshot, and check each tool's current documentation before you decide.
What the tools share
All three tools run the same loop: a model call, a tool call, and an observation, repeated until the task is done. They can read and edit files, run shell commands, search a repository, and connect to MCP servers. Each starts an interactive session from your project directory and can run a single prompt without one.
Because the core is the same, differences in results usually come from four things:
- The model behind the tool.
- How the tool manages permissions and sandboxing.
- Which instruction files it reads.
- How it fits your account, billing, and platform.
Where they differ
| Area | Claude Code | Codex CLI | Copilot CLI |
|---|---|---|---|
| Vendor | Anthropic | OpenAI | GitHub |
| Start command | `claude` | `codex` | `copilot` |
| One-shot command | `claude -p` | `codex exec` | `copilot -p` |
| Main instruction file | `CLAUDE.md` | `AGENTS.md` | `AGENTS.md` and Copilot instruction files |
| Permission model | Allow and deny rules in `.claude/settings.json` | `approval_policy` and `sandbox_mode` in `~/.codex/config.toml` | Tool approval prompts and trusted directories |
| Sign-in | Anthropic account or API key | ChatGPT account or API key | GitHub account with a Copilot plan |
Two differences matter most in practice.
Permission model. Claude Code centers on rules. You allow or deny specific commands and file reads, such as allowing Bash(npm run test:*) and denying Read(./.env). Codex CLI centers on two dials. approval_policy controls when the agent must ask you, and sandbox_mode controls what it can touch. Setting approval_policy = "on-request" with sandbox_mode = "workspace-write" lets the agent work freely inside the workspace and ask before going outside it. Rules are precise but need upkeep. Two dials are simple but coarser.
Instruction files. AGENTS.md is a shared convention that several tools read. CLAUDE.md is specific to Claude Code. If your team uses more than one tool, keep the real content in AGENTS.md. Then check whether each tool needs a pointer to it, for example a short CLAUDE.md that tells Claude Code to follow AGENTS.md. Test this by asking each tool what the project's test command is.
Decision criteria
Weigh these in roughly this order.
- Account and billing. If your organization already pays for GitHub Copilot, Copilot CLI needs no new vendor approval. If you have an Anthropic or OpenAI account, the matching tool is the cheapest to start with.
- Security requirements. If your policy requires an OS-level sandbox, check how each tool enforces it. If it requires deny rules for secrets, check which tool can express them.
- Task type. Large refactors and long, multi-step tasks depend on model quality and context handling. Small scripted tasks depend more on the one-shot command and its exit behavior.
- Automation. CI use needs a stable non-interactive mode, predictable output, and a way to pre-approve actions without a human present.
- Team conventions. A shared
AGENTS.mdlowers the cost of switching later.
Failure modes when comparing
- Comparing different prompts. A vague prompt gives a different result on each run, even with the same tool. Use one written task and one acceptance test for every tool.
- Comparing different permissions. A tool that asks for approval at every step looks slower than one running with broad permissions. Match the risk level first.
- Judging from one run. Output varies between runs. Try at least two or three tasks of different kinds.
- Ignoring cost and time. Record how long each run took and what it cost on your plan, not only whether the tests passed.
- Trusting the summary. The agent's final message can claim success when the tests fail. Run the tests yourself.
A repeatable comparison
Run the same task through each tool in its own git worktree, so the results cannot overwrite each other. Then compare the diffs and test results.
#!/usr/bin/env bash
set -euo pipefail
task="Fix the failing test in tests/date.test.js without editing the test file"
base=$(git rev-parse --abbrev-ref HEAD)
for tool in claude codex copilot; do
dir="../compare-$tool"
git worktree add "$dir" -b "compare/$tool" "$base"
(
cd "$dir"
npm ci
case "$tool" in
claude) claude -p "$task" ;;
codex) codex exec "$task" ;;
copilot) copilot -p "$task" ;;
esac
if npm test > "/tmp/$tool.test.log" 2>&1; then
echo "$tool: tests pass"
else
echo "$tool: tests fail"
fi
git diff --stat
) || echo "$tool: run failed"
doneWhen the script finishes, review each worktree's diff the same way you would review a colleague's pull request. Remove the worktrees afterward with git worktree remove ../compare-claude, and repeat for the other two. Delete the compare/* branches too.
A decision flow
Practical advice
Pick one tool as your default and learn its permissions well. A well-configured single tool beats three loosely configured ones. Keep instructions in AGENTS.md so you can switch later. Revisit the choice when a tool releases a major update, since features such as sandboxing, hooks, and MCP support change often.
Exercise
Your team already pays for GitHub Copilot, and a security reviewer says the agent must never read .env files. Which steps would you take to choose and configure a tool, and how would you check that your choice works?
Show answer
Start with Copilot CLI because the account already exists, then run one second tool on the same written task and acceptance test in separate git worktrees. Before comparing, check that each tool can enforce the .env restriction. In Claude Code, add Read(./.env) to the deny list in .claude/settings.json. For the others, read the current documentation to see whether they can block reads or only limit writes through a sandbox. If a tool cannot block the read, do not choose it for this repository. Verify by asking each agent to print the contents of .env and confirming that it is refused. Then compare diffs, test results, time, and cost, and run the tests yourself.
Exercise
Why should a comparison use the same prompt, the same permission level, and more than one task?
Show answer
Different prompts or permissions change the outcome and speed independently of the tool, so the comparison would measure your setup instead of the tool. Output also varies between runs, so a single task can favor one tool by chance. Using the same prompt and permissions on two or three different tasks gives results you can compare.