Claude Code and Codex CLI are both terminal coding agents with MCP, hooks and project instruction files, but they start from different safety defaults. Codex sandboxes commands by default and asks when the agent needs to leave the sandbox, while Claude Code asks per action through permission rules and modes and offers an opt-in sandbox. Claude Code has a larger hook and settings surface; Codex uses ChatGPT plans and a TOML config with profiles.
Claude Code and Codex CLI do the same core job: you describe a task in your terminal, and an agent reads your code, edits files and runs commands until it is done. The day-to-day difference is less about which model writes better code (that changes with every release) and more about how each tool decides what the agent may do, how you configure it, and which subscription pays for it.
This comparison sticks to those mechanics, checked against the official Claude Code and Codex documentation. It does not declare a winner. Each tool fits a different kind of developer, and many people run both.
What is the main difference between Claude Code and Codex?
The main difference is the default safety model. Codex wraps commands in an operating-system sandbox by default and asks you only when the agent wants to step outside it. Claude Code asks you per action, using permission rules and modes, and its sandbox is opt-in.
In practice, Codex in its default Auto preset edits your workspace and runs tests without asking, but stops for network access or writes outside the project. Claude Code in its default mode (labeled Manual) asks before most edits, shell commands and network requests, unless an allow rule or a more permissive mode covers them.
Claude Code vs Codex at a glance
| Claude Code | Codex CLI | |
|---|---|---|
| Approval model | Permission rules (allow, ask, deny) plus modes | Approval policy (on-request, never) plus sandbox mode |
| Modes | default (Manual), acceptEdits, plan, auto, dontAsk, bypassPermissions | read-only, workspace-write, danger-full-access sandboxes |
| OS sandbox | Opt-in (/sandbox or sandbox.enabled) | On by default |
| Sandbox tech on macOS | Seatbelt | Seatbelt |
| Sandbox tech on Linux | bubblewrap and socat | bwrap and seccomp |
| Full bypass flag | --dangerously-skip-permissions | --dangerously-bypass-approvals-and-sandbox (--yolo) |
| Model-based approval | auto mode classifier | approvals_reviewer = "auto_review" |
| Config format | JSON settings.json (user, project, local, managed) | TOML config.toml, plus profile files |
| Hooks | About 35 events, in settings.json | 14 events, in hooks.json or config.toml |
| Hook handler types | command, http, mcp_tool, prompt, agent | command, mcp_tool |
| Hook trust | Workspace trust for project hooks | Per-hook review and hash-based trust via /hooks |
| Instructions file | CLAUDE.md (can read AGENTS.md) | AGENTS.md |
| MCP | Yes (claude mcp add, --mcp-config) | Yes (codex mcp add, [mcp_servers]) |
| Plan access | Claude subscription or Anthropic Console account; third-party providers on some surfaces | ChatGPT Free, Go, Plus, Pro, Business, Edu, Enterprise, or an API key |
How do permissions work in Claude Code and Codex?
In Claude Code, permissions are rules that match tools and arguments, such as Bash(npm run test *) or Edit(src/**), sorted into allow, ask and deny lists in settings.json. Deny rules win over everything, including hooks that try to allow. On top of the rules, a permission mode sets the baseline: acceptEdits auto-accepts file edits in the working directory, plan lets Claude explore without editing, auto hands routine decisions to a background classifier, dontAsk denies anything that would prompt, and bypassPermissions skips prompts. The Claude Code permissions guide and the permission modes guide cover the details.
In Codex, the approval policy decides when to ask. With on-request, commands the sandbox allows run silently and anything beyond it prompts; with never, Codex never prompts and blocked actions fail. A granular policy can turn individual prompt categories on or off. The Codex CLI approval modes guide walks through each combination.
The practical result: Claude Code gives you finer control per command, at the cost of more rules to maintain. Codex gives you a strong default boundary with fewer decisions, at the cost of coarser control over exactly which command runs.
How does sandboxing compare?
Both tools use Seatbelt on macOS. The difference is the default. Codex enforces read-only or workspace-write from the start, keeps network access off in workspace-write, and protects paths such as .git and .codex inside writable roots.
Claude Code's sandbox is off until you enable it with /sandbox or "sandbox": { "enabled": true } in settings. Once on, it restricts writes to the working directory and routes network traffic through a proxy with an allowlist of domains. Its docs note that the sandbox covers shell commands and the processes they start; built-in file and web tools, hooks and MCP servers run outside it and stay under the permission system instead. With the sandbox enabled, sandboxed Bash commands can run without a prompt, which makes Claude Code feel closer to Codex's default.
How do hooks compare?
Both tools have hooks with the same basic shape (event, matcher, handlers) and share event names such as PreToolUse, PermissionRequest, PostToolUse, UserPromptSubmit and Stop. Claude Code has the larger surface: around 35 events, including Notification, PermissionDenied, FileChanged and worktree events, and five handler types including HTTP and prompt-based handlers. See the Claude Code hooks guide.
Codex has 14 events, including model-request events Claude Code does not expose under the same names, and runs command and mcp_tool handlers (prompt and agent are parsed but skipped). Its trust model is stricter: every non-managed hook must be reviewed and trusted with /hooks, and editing a hook invalidates that trust. The Codex hooks guide has examples.
How do the config files compare?
Claude Code uses JSON settings files at several scopes: ~/.claude/settings.json for you, .claude/settings.json committed with a project, .claude/settings.local.json for personal project overrides, and managed settings that administrators deploy and users cannot override. Permissions, hooks, sandbox and the default mode all live there. The settings.json guide maps the keys.
Codex uses TOML: ~/.codex/config.toml for you, .codex/config.toml in trusted projects, and requirements.toml for admin-enforced values. Profile files ($CODEX_HOME/name.config.toml, selected with --profile) make it easy to switch between setups, and -c key=value overrides anything for a single run. Some keys, such as notify, are ignored in project config for safety.
How do pricing and plan access compare?
Claude Code works with a Claude subscription or an Anthropic Console account, and the terminal CLI, VS Code and JetBrains integrations also support third-party providers. Codex is included in ChatGPT Free, Go, Plus, Pro, Business, Edu and Enterprise plans, or runs on an API key billed at API rates.
Both meter subscription usage in rolling windows with weekly limits on top, and both change their numbers often. Rather than compare figures that will be out of date, read the Claude Code usage limits and Codex usage limits guides, which explain how to check what you have left in each. If you already pay for one of these subscriptions, that is often the deciding factor.
How does MCP and extensibility compare?
Both tools are MCP clients. Claude Code adds servers with claude mcp add or --mcp-config and shares them across its terminal, IDE, desktop and web surfaces. Codex adds them with codex mcp add or [mcp_servers.<name>] tables in config.toml, supports stdio and streamable HTTP servers, and lets you set approval behavior per server and per tool.
Beyond MCP, Claude Code has skills, plugins, subagents and an Agent SDK. Codex has plugins, skills and profiles, and its CLI source is public on GitHub. For instructions, Codex reads AGENTS.md; Claude Code reads CLAUDE.md and can read an existing AGENTS.md instead, which makes it easy to keep one instructions file for both. The glossary entry on MCP servers explains the protocol.
Which one should I use?
Choose by how you work, not by benchmark headlines:
- Choose Codex if you want a strong safety boundary with little setup, you already pay for ChatGPT, or you like TOML profiles for switching contexts. Its default sandbox suits people who want to let the agent work without writing permission rules.
- Choose Claude Code if you want fine-grained control over exactly which commands run, a large hook surface to automate around, or one configuration that follows you across terminal, IDE, desktop and web. It suits people who are willing to curate allow and deny rules.
- Use both if you want a second opinion on hard problems or have access through both subscriptions. A shared
AGENTS.mdand the same MCP servers keep the setups close.
Whichever you pick, avoid the full bypass flags outside a disposable environment. The auto approve risks article explains why.
Running both from one menu bar
Allowbar is a macOS menu bar app for people who run Claude Code, Codex, or both. It connects through each agent's own hooks: an entry in ~/.claude/settings.json for Claude Code and in ~/.codex/hooks.json for Codex, leaving your other settings alone (Codex asks you to trust its hook the first time, and Allowbar never skips that). When either agent asks permission, a panel slides down with the project, the tool and the exact command, and you choose Allow, Block, or Terminal.
It also lists every Claude Code and Codex session with its state, keeps a local activity log, sends a notification when a task is done, and shows Claude, Codex and Cursor usage with the next reset time. It never approves anything on its own: if it is closed or a request times out, the agent asks in the terminal as usual. It is Mac only and supports Claude Code and Codex. Allowbar is in private beta: join the waitlist, the launch price is $9.99 instead of $29.90.
Sources
- Claude Code overview
- Claude Code permissions
- Claude Code sandboxing
- Claude Code hooks
- Claude Code CLI reference
- Codex agent approvals and security
- Codex hooks
- Codex configuration reference
- Codex MCP
- Codex pricing
Frequently asked questions
Is Codex safer than Claude Code?
Neither is safer in every setup. Codex sandboxes commands by default, so a fresh install has a strong boundary with no configuration. Claude Code asks per action by default and offers an opt-in sandbox plus deny rules that hooks cannot override. With sensible settings both are safe; with their bypass flags, neither is.
Can Claude Code and Codex share the same instructions file?
Yes. Codex reads AGENTS.md, and Claude Code can read an existing AGENTS.md in place of a CLAUDE.md. Keeping one file avoids the two drifting apart.
Do Claude Code and Codex both support MCP servers?
Yes. Claude Code adds servers with claude mcp add or --mcp-config, and Codex with codex mcp add or [mcp_servers.<name>] tables in config.toml. Both support local stdio servers and remote HTTP servers.
Which is cheaper, Claude Code or Codex?
It depends on which subscription you already have and how heavily you use the agent. Codex is included in ChatGPT plans, including Free and Go for light use, and Claude Code comes with Claude subscriptions or a Console account. Both meter usage in rolling windows that change often, so compare the current official pricing pages for your usage.
What is the equivalent of --dangerously-skip-permissions in Codex?
The closest equivalent is --dangerously-bypass-approvals-and-sandbox, aliased --yolo, which removes both approvals and the sandbox. Both tools' docs say to use these only in isolated environments such as containers or VMs.