---
title: "Claude Code vs Codex CLI: Config, Permissions, API, Login (2026)"
description: "Claude Code vs Codex CLI compared on config files, permissions and sandboxing, API format, and login, plus a decision table and setup checklist."
url: https://cdnping.org/en/blog/claude-code-vs-codex-cli
language: en
published: 2026-11-26
category: "Developer tools"
tags: ["Claude Code","Codex CLI","CLI coding agent","configuration","permissions"]
source: cdnping.org
license: Free to quote and summarize with a link to the url above.
---
# Claude Code vs Codex CLI: Config, Permissions, API, Login (2026)

Claude Code and Codex CLI are both coding agents that run in your terminal, and the basic loop is similar: read code, edit files, run commands. They differ mainly in four places: where the config files live, how permissions and sandboxing are tiered, which API format they expect, and which ways you can log in. This article compares only those four things, not model quality, because models change with every release while configuration methods stay relatively stable.

Directory names, config keys, and flags below should be checked against each tool's official documentation. Both tools update quickly, so run `--help` or read the docs before you start.

## Where do the config files live?

**Claude Code** is configured mainly through JSON, in several layers: user-level in `~/.claude/settings.json`, project-level in `.claude/settings.json` inside the repo, and personal local overrides in `.claude/settings.local.json`. Long-lived instructions for the agent go in `CLAUDE.md`. Environment variables can go in the `env` field of settings. For layers and precedence, see [Claude Code settings.json layers, precedence, and env configuration](/en/blog/claude-code-settings-json-guide). For how to write `CLAUDE.md`, see [What is CLAUDE.md and how to write one that helps Claude Code](/en/blog/what-is-claude-md).

**Codex CLI** is configured in TOML. The user-level file is usually `~/.codex/config.toml`, and long-lived project instructions go in `AGENTS.md`. Custom model providers, the default approval policy, and similar settings are declared in that TOML file.

| Item | Claude Code | Codex CLI |
| --- | --- | --- |
| Config format | JSON (settings.json) | TOML (config.toml) |
| User-level location | `~/.claude/` | `~/.codex/` |
| Project instructions | `CLAUDE.md` | `AGENTS.md` |
| Project-level config | `.claude/settings.json` | See the official docs |

## How do permissions and sandbox modes differ?

This is the most noticeable difference in day-to-day use, because it determines whether the agent asks you before every step.

Claude Code works on "permission rules plus modes." In settings you can write allow / deny rules that say which tool calls run automatically and which are blocked, then combine them with a permission mode (for example, ask for each action by default, auto-accept file edits, or plan only without executing). Mode names and how to switch them are defined in the official docs.

Codex CLI splits "what it can do" and "when it asks" into two separate dimensions. The sandbox mode controls which paths commands can read and write (commonly three levels: read-only, workspace-writable, full access), and the approval policy controls which actions need human confirmation. The two can be combined.

Practical advice:

- On your first run, pick the most conservative combination: leave Claude Code on its default ask-first behavior, and run Codex read-only or workspace-writable with manual approval.
- In a repo you don't know, don't start with "full access" or with confirmations skipped.
- If you want it to run tests or install dependencies, allow those specific commands individually rather than opening everything up.

## Do they expect the same API format?

No, and this is the easiest trap when you change the endpoint URL.

- **Claude Code** sends requests in Anthropic's Messages API format by default. To change the endpoint you usually set `ANTHROPIC_BASE_URL`, with the key in `ANTHROPIC_AUTH_TOKEN` or `ANTHROPIC_API_KEY`.
- **Codex CLI** sends requests in OpenAI's API format by default. For a custom provider, you declare in `config.toml` the provider's `base_url`, the name of the environment variable that holds the key, and which request protocol to use (an option such as `wire_api`; see the official docs for allowed values).

So an endpoint that only offers the OpenAI format generally won't work if you plug it into Claude Code, and the reverse is also true. The target endpoint has to be compatible with the format each tool uses. For the exact settings, see [Custom API endpoints for Claude Code, Codex, and OpenCode](/en/blog/configure-custom-api-endpoint-claude-code-codex).

## Which login methods are available?

| Method | Claude Code | Codex CLI |
| --- | --- | --- |
| Official subscription login | Supported (Claude subscription) | Supported (ChatGPT account) |
| API key | Supported (Anthropic Console key) | Supported (OpenAI API key) |
| Cloud provider channels | Supports Bedrock and Vertex AI | See the official docs |
| Custom endpoint | Supported, via environment variables | Supported, via config.toml |

Subscription login and API keys are billed differently; for the trade-offs, see [Claude Code: subscription or API billing](/en/blog/claude-code-subscription-vs-api-billing). The subscription accounts for both tools are subject to the vendor's supported regions and terms of service, so go by the official statements.

## How to choose: a decision table

| Your situation | Leaning toward |
| --- | --- |
| You already have an Anthropic account or key, and you're comfortable with JSON config and `CLAUDE.md` | Claude Code |
| You already have an OpenAI account or key, and you're comfortable with TOML config and `AGENTS.md` | Codex CLI |
| You want fine-grained control over which commands run automatically | Claude Code (its rules are more direct) |
| You want to set sandbox scope and confirmation separately | Codex CLI |
| You want to try both | Install each and run both in a small repo |

The two tools aren't mutually exclusive. You can install both and switch by task. For a beginner walkthrough, see [How to use Codex CLI: install, log in, and first run](/en/blog/codex-cli-beginner-guide). For a side-by-side of network requirements, see [Claude Code network requirements: domains, ports, and proxy settings compared with Codex](/en/blog/claude-code-vs-codex-network-requirements).

## Pre-flight checklist

1. Confirm that your Node version or install method meets the requirements (check each tool's official docs).
2. Decide on the authentication method first: official account, API key, or custom endpoint.
3. Try it once in a small repo, keeping permissions at the most conservative setting.
4. Write a `CLAUDE.md` or `AGENTS.md` and put your build and test commands in it.
5. If a request fails, check whether the service is up first: the [Claude Code status page](/en/down/claude-code) and the [Codex status page](/en/down/codex) combine the official status pages with API probes, and [API status](/en/status) has a 30-day history. Telling "the service is down" apart from "my config is wrong" saves a lot of time.

## If you don't want separate accounts for two tools

If you'd rather not deal with separate Anthropic and OpenAI accounts and overseas payments, you can look at AGI Plan. AGI Plan is a commercial partner of cdnping. It is a multi-provider LLM aggregation gateway with monthly subscriptions, payment in RMB, and no overseas credit card required, and it is compatible with both the OpenAI and Anthropic API formats. Claude Code and Codex connect by changing a single endpoint URL. Claude Code doesn't need a Claude account, Codex doesn't need a ChatGPT account, and one quota can be switched between multiple capability groups.

Note that AGI Plan states explicitly that it is not an officially authorized channel, and some models are marked "overseas only"; check the [models page](https://agiplan.dev/models) for specifics. To find out how quota works and whether it can be shared, read [Can Claude Code and Codex share one quota?](/en/blog/claude-code-and-codex-one-quota). For setup steps, see the [AGI Plan getting-started page](https://agiplan.dev/startup): sign up with an email verification code, pick a plan and create a key, and change one setting.

## Next steps

Pick one tool using the decision table above and get it working once in a small repo. Then use the API format section to check that your endpoint matches the tool. If you want both, set up authentication for each and note where each one's config file lives, which will make troubleshooting much faster later.
