Codex vs Claude Code: Config Files and Sandbox
Compare where Codex and Claude Code store settings, how each sandboxes commands, and which tool fits your project setup.
Updated · Markdown version
Codex and Claude Code both read user and project configuration, both can limit what shell commands touch, and both load standing instructions into a session. They differ in file format, layering order and how far the sandbox reaches, so the choice often comes down to which of those constraints your project needs. This guide compares the two side by side and ends with a decision rule.
Config files and precedence
| Feature | Claude Code | Codex |
|---|---|---|
| User config | ~/.claude/settings.json | ~/.codex/config.toml |
| Project config | .claude/settings.json (commit to share), .claude/settings.local.json (personal) | .codex/config.toml, loaded only after you trust the project |
| Format | JSON; a comment or trailing comma is a syntax error | TOML |
| Top layer | Managed settings, then --settings for one session | CLI flags, then project files closest to the working directory, then named profiles |
| Instruction file | CLAUDE.md; by default AGENTS.md is read instead only when no CLAUDE.md or CLAUDE.local.md exists (Claude Code v2.1.277 or later); the Project instructions setting can load both | AGENTS.md from the Codex home directory and from the project root down to the working directory |
| Sandbox switch | /sandbox or sandbox.enabled | sandbox_mode, for example workspace-write |
| Approval control | allow, ask and deny permission rules | approval_policy, for example on-request or never |
Claude Code merges list keys such as permissions.allow across files instead of replacing them, so a personal allow entry adds to the team file. Codex also resolves a key from the highest layer that sets it (CLI flags, then project files closest to the working directory, then profiles, then user config), and your organization may also enforce constraints with requirements.toml.
Sandbox boundaries
Claude Code's sandbox is an operating-system boundary around Bash, PowerShell and Monitor commands and the processes they start. macOS uses Seatbelt, and Linux and WSL2 use bubblewrap and socat; run /sandbox to see any missing dependency. Native Windows runs commands unsandboxed. Network traffic from sandboxed commands goes through a proxy whose allowlist starts empty.
Codex controls the same two concerns through sandbox_mode, which sets how much filesystem and network access Codex has while it runs commands, and approval_policy, which sets when it pauses to ask first. The Codex config page names these values but does not describe how each operating system enforces them, so check the Codex sandbox documentation before you depend on platform-specific behavior.
A worked example: a developer on native Windows who wants Claude Code to stay away from .env files cannot count on the sandbox. A rule such as Read(./.env) in .claude/settings.json can deny Claude Code's built-in Read tool access to that file. It does not sandbox native-Windows shell commands, and it does not cover MCP servers or hooks.
Decision rule
- Choose Claude Code when you want OS-level containment for shell commands on macOS or Linux or WSL2, and you want layered JSON settings with managed settings at the highest precedence.
- Choose Codex when your team already keeps profiles in
config.tomland wantssandbox_modeandapproval_policyto be the main controls. - If your team works on native Windows and needs sandboxed shell commands, run the Claude Code sandbox inside WSL2 or check how Codex's sandbox behaves on Windows before deciding.
Pitfalls
- A committed setting does not apply for a teammate. Claude Code holds
permissions.allowrules and mostenvvalues until each person trusts the folder. Run/statusto see which files loaded. - A higher layer silently wins. Managed settings and
--settingsoverride project and user files. Run/statusand read theSetting sourcesline to see which files loaded; the line does not show which file supplied each key. - Assuming the sandbox covers everything. The Claude Code sandbox covers only shell commands. File tools and web tools follow permission rules instead. Command hooks and local MCP servers run with your full access, so assess them through their own configuration and permissions.
- A JSON comment breaks the whole file. Claude Code reports a Settings Error at the next start. Remove comments and trailing commas, then reopen the session.
- Treating AGENTS.md and CLAUDE.md as the same file. By default, Claude Code reads
AGENTS.mdonly when noCLAUDE.mdorCLAUDE.local.mdis in the working directory or above it (v2.1.277 or later). A personalCLAUDE.local.mdcounts, so adding one stopsAGENTS.mdfrom loading under the default. To load both files, set Project instructions toclaude-md-and-agents-mdin/config, or importAGENTS.mdfromCLAUDE.md. Some sessions cannot readAGENTS.mddirectly, and there the import is the documented route. Keep one source of truth, so the two tools do not receive different rules.
When to use a skill instead
Reading a comparison once is enough for a single setup decision. The recurring problem is instruction drift: rules in CLAUDE.md or AGENTS.md go stale, and the same guardrails need to hold in every session. agent-instruction-files writes, audits and restructures the instruction files that coding agents load every session, keeping rules specific to the project. coding-agent-guardrails gives an agent a pre-action checklist covering destructive git commands, edits to generated files, skipped tests, scope creep and committed secrets. Ad hoc prompting is fine for one settings change. A skill is the better choice when the same rules must apply across sessions and across both tools. No related skill covers the comparison itself, which is a reading task.
FAQ
Does the Claude Code sandbox work on native Windows?
No. The Claude Code sandbox has no native Windows implementation, so commands run unsandboxed there. The documented route is to run Claude Code inside WSL2. Check the sandboxing page for current platform support, as of 2026-11-26.
Where do user-level settings live for each tool?
Claude Code uses ~/.claude/settings.json, and on Windows ~ resolves to %USERPROFILE%. Codex uses ~/.codex/config.toml. Project-level files are .claude/settings.json and .codex/config.toml.
Is CLAUDE.md read in every session?
By default, yes. Claude Code's memory documentation says CLAUDE.md files load into every session. The same page says that, by default, Claude Code reads AGENTS.md only when no CLAUDE.md or CLAUDE.local.md exists in the working directory or above (v2.1.277 or later). The Project instructions setting in /config changes which files load: both files, only CLAUDE.md, or only managed instructions.
Related skills in this catalog
Platform Score is our assessment under a published method. It is not a safety guarantee.
Related guides
- Agentic Coding Tools: What They Are and How to Choose One
- Install Codex CLI and Sign In
- Codex Skills Explained: Locations and AGENTS.md Differences
- What Is Claude Code and What It Can Touch on Your Machine
- Terminal AI Coding Assistants: Claude Code, Codex, and Gemini CLI
- Claude Code Slash Commands: Built-in vs Custom
Sources
- https://code.claude.com/docs/en/settings (accessed 2026-11-26)
- https://code.claude.com/docs/en/sandboxing (accessed 2026-11-26)
- https://code.claude.com/docs/en/memory (accessed 2026-11-26)
- https://learn.chatgpt.com/docs/config-file/config-basic (accessed 2026-11-26)
- https://learn.chatgpt.com/docs/agent-configuration/agents-md (accessed 2026-11-26)