# Codex vs Claude Code: Config Files and Sandbox

> Canonical: https://skillalmanac.com/learn/codex-vs-claude-code | Updated: 2026-11-26 | Index status: index-eligible

Compare where Codex and Claude Code store settings, how each sandboxes commands, and which tool fits your project setup.

## Facts

- 2026-11-26: Claude Code reads user settings from ~/.claude/settings.json and shared project settings from .claude/settings.json (https://code.claude.com/docs/en/settings)
- 2026-11-26: Claude Code gives managed settings the highest precedence, then command-line settings, then project local, shared project and user settings (https://code.claude.com/docs/en/settings)
- 2026-11-26: The Claude Code sandbox is off by default, is turned on with /sandbox or sandbox.enabled, and has no native Windows implementation; WSL2 is the documented route (https://code.claude.com/docs/en/sandboxing)
- 2026-11-26: The Claude Code sandbox covers only shell commands; built-in file and web tools follow permission rules, and command hooks and local MCP servers run with full access (https://code.claude.com/docs/en/sandboxing)
- 2026-11-26: Codex reads user settings from ~/.codex/config.toml and project settings from .codex/config.toml, which load only after you trust the project (https://learn.chatgpt.com/docs/config-file/config-basic)
- 2026-11-26: Codex uses sandbox_mode for filesystem and network access while running commands and approval_policy for when it pauses to ask; example values are workspace-write and on-request (https://learn.chatgpt.com/docs/config-file/config-basic)

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.toml` and wants `sandbox_mode` and `approval_policy` to 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

1. **A committed setting does not apply for a teammate.** Claude Code holds `permissions.allow` rules and most `env` values until each person trusts the folder. Run `/status` to see which files loaded.
2. **A higher layer silently wins.** Managed settings and `--settings` override project and user files. Run `/status` and read the `Setting sources` line to see which files loaded; the line does not show which file supplied each key.
3. **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.
4. **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.
5. **Treating AGENTS.md and CLAUDE.md as the same file.** By default, Claude Code reads `AGENTS.md` only when no `CLAUDE.md` or `CLAUDE.local.md` is in the working directory or above it (v2.1.277 or later). A personal `CLAUDE.local.md` counts, so adding one stops `AGENTS.md` from loading under the default. To load both files, set Project instructions to `claude-md-and-agents-md` in `/config`, or import `AGENTS.md` from `CLAUDE.md`. Some sessions cannot read `AGENTS.md` directly, 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](/skills/skill-almanac/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](/skills/skill-almanac/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

- [agent-instruction-files](https://skillalmanac.com/skills/skill-almanac/agent-instruction-files.md): Platform Score 46/100 (provisional)
- [coding-agent-guardrails](https://skillalmanac.com/skills/skill-almanac/coding-agent-guardrails.md): Platform Score 60/100

## Related guides

- [Agentic Coding Tools: What They Are and How to Choose One](https://skillalmanac.com/learn/choosing-an-agentic-coding-tool.md)
- [Install Codex CLI and Sign In](https://skillalmanac.com/learn/install-codex-cli.md)
- [Codex Skills Explained: Locations and AGENTS.md Differences](https://skillalmanac.com/learn/codex-skills-explained.md)
- [What Is Claude Code and What It Can Touch on Your Machine](https://skillalmanac.com/learn/what-is-claude-code.md)
- [Terminal AI Coding Assistants: Claude Code, Codex, and Gemini CLI](https://skillalmanac.com/learn/terminal-ai-coding-assistants.md)
- [Claude Code Slash Commands: Built-in vs Custom](https://skillalmanac.com/learn/claude-code-slash-commands-guide.md)

## Sources

- https://code.claude.com/docs/en/settings
- https://code.claude.com/docs/en/sandboxing
- https://code.claude.com/docs/en/memory
- https://learn.chatgpt.com/docs/config-file/config-basic
- https://learn.chatgpt.com/docs/agent-configuration/agents-md

Platform Scores report our assessment under a published method. They are not a safety guarantee.
