API Dashboard ↗

Configuration & Concepts

Customize Codex behavior, sandboxing, integrations, and agent workflows

Customization

Codex customization operates across several interconnected layers:

AGENTS.md

Persistent instructions embedded in repositories. Keep it concise — build/test commands, code review expectations, conventions. Supports hierarchy: global (~/.codex/AGENTS.md) for personal preferences, repo-specific for team standards.

Skills

Reusable workflows packaged as discoverable capabilities. Structure: SKILL.md (required), scripts/, references/, assets/. Store at user level ($HOME/.agents/skills) or repo level (.agents/skills).

Plugins

Installable bundles packaging skills, app integrations, and MCP server configuration.


Sandboxing

The sandbox lets Codex act autonomously without unrestricted machine access.

Permission modes

Approval policies

Configure via CLI /permissions command or config.toml.


Model Context Protocol

MCP connects models to tools and context. Use it to give Codex access to third-party documentation, or to let it interact with developer tools like your browser or Figma.

Codex supports MCP servers in both the CLI and the IDE extension.

Supported MCP features

STDIO servers

Servers that run as a local process (started by a command). Support environment variables.

Streamable HTTP servers

Servers accessed at an address. Support:

Connect Codex to an MCP server

Codex stores MCP configuration in config.toml alongside other settings. Default location: ~/.codex/config.toml. You can also scope MCP servers to a project with .codex/config.toml (trusted projects only).

The CLI and IDE extension share this configuration.

Configure with the CLI

Add an MCP server:

codex mcp add <server-name> --env VAR1=VALUE1 --env VAR2=VALUE2 -- <stdio server-command>

Example (Context7):

codex mcp add context7 -- npx -y @upstash/context7-mcp

Run codex mcp --help for all available MCP commands. Use /mcp in the TUI to see active servers.

Configure with config.toml

Edit ~/.codex/config.toml for fine-grained control.

STDIO server options

Option Required Description
command Yes Command that starts the server
args No Arguments to pass
env No Environment variables to set
env_vars No Environment variables to allow and forward
cwd No Working directory

Streamable HTTP server options

Option Required Description
url Yes Server address
bearer_token_env_var No Env var name for bearer token
http_headers No Map of header names to static values
env_http_headers No Map of header names to env var names

Other options

Option Default Description
startup_timeout_sec 10 Server startup timeout
tool_timeout_sec 60 Tool runtime timeout
enabled true Set false to disable without deleting
required false Fail startup if server can't initialize
enabled_tools Tool allow list
disabled_tools Tool deny list

config.toml examples

STDIO server

[mcp_servers.context7]
command = "npx"
args = ["-y", "@upstash/context7-mcp"]

[mcp_servers.context7.env]
MY_ENV_VAR = "MY_ENV_VALUE"

HTTP server

[mcp_servers.figma]
url = "https://mcp.figma.com/mcp"
bearer_token_env_var = "FIGMA_OAUTH_TOKEN"
http_headers = { "X-Figma-Region" = "us-east-1" }

OAuth configuration

mcp_oauth_callback_port = 5555
mcp_oauth_callback_url = "https://devbox.example.internal/callback"

Advanced configuration

[mcp_servers.chrome_devtools]
url = "http://localhost:3000/mcp"
enabled_tools = ["open", "screenshot"]
disabled_tools = ["screenshot"]
startup_timeout_sec = 20
tool_timeout_sec = 45
enabled = true

Useful MCP servers


Subagents

Codex can run subagent workflows by spawning specialized agents in parallel and then collecting their results in one response.

Overview

Subagent workflows are enabled by default. They suit complex, highly parallel tasks like codebase exploration and multi-step feature planning. IDE Extension support coming soon.

Typical workflow

Codex orchestrates:

  1. Agent spawning
  2. Routing instructions to each agent
  3. Result collection
  4. Thread closure

Only spawns subagents when explicitly requested. Waits for all results before returning consolidated responses.

Example: PR review with parallel agents checking security, code quality, bugs, race conditions, test flakiness, and maintainability.

Managing subagents

Built-in agents

Three default agents ship with Codex:

Agent Description
default General-purpose fallback
worker Execution-focused implementation agent
explorer Read-heavy exploration agent

Custom agent configuration

Required fields

Optional fields

Global settings ([agents] section)

[agents]
max_threads = 6          # concurrent open agent cap
max_depth = 1            # nesting depth
job_max_runtime_seconds = 300  # worker timeout for CSV jobs

Example: PR review pattern

Three specialized agents:

[agents.pr_explorer]
description = "Read-only mapping of changes"
sandbox_mode = "read-only"

[agents.reviewer]
description = "Correctness and security focus"
developer_instructions = "Focus on bugs, security issues, and race conditions"

[agents.docs_researcher]
description = "API verification against documentation"
mcp_servers = ["context7"]

Example: Frontend debugging pattern

[agents.code_mapper]
description = "Maps component tree and state flow"

[agents.browser_debugger]
description = "Inspects browser console and network"
mcp_servers = ["playwright"]

[agents.ui_fixer]
description = "Applies CSS and layout fixes"

CSV batch processing Experimental

The spawn_agents_on_csv tool processes repeated tasks at scale:

  1. Reads CSV file
  2. Spawns one worker per row
  3. Waits for completion
  4. Exports combined results

Parameters:


Best Practices

Getting started with strong context

Treat Codex less like a one-off assistant and more like a teammate you configure over time. Effective prompts should include:

Choose reasoning levels based on task complexity:

Level Use case
LowSimple, well-defined tasks
MediumModerate complexity, some ambiguity
HighMulti-step reasoning, architectural decisions
Extra HighNovel problems requiring deep analysis

Planning for difficult tasks

Three approaches for tackling complex work:

  1. Plan mode — the easiest option, activated via /plan or Shift+Tab. Codex outlines steps before executing.
  2. Interview mode — request Codex to interview you first, gathering requirements before proposing a solution.
  3. PLANS.md templates — for advanced workflows, create structured planning documents that Codex follows step by step.

AGENTS.md for reusable guidance

AGENTS.md is an open-format README for agents that loads automatically when Codex starts in a repository. It should document:

Tip. Multiple AGENTS.md files can exist at different directory levels. Files closer to the working directory take precedence over those higher in the tree.

Configuration strategy

Store personal defaults in ~/.codex/config.toml and repo-specific settings in .codex/config.toml.

Start restrictive with permissions and loosen only when necessary. This protects against accidental destructive operations while you build trust with the tool.

Testing and review

Codex should create tests, run checks, confirm behavior, and review work. The /review command offers:

MCPs (Model Context Protocol)

Use MCPs when:

Tip. Add tools incrementally — start with 1–2 that remove manual loops, then expand as needed.

Skills for repetitive work

Package instructions in SKILL.md files for recurring tasks:

Store personal skills in $HOME/.agents/skills; team skills in .agents/skills within repos.

Automations for scheduled tasks

Use the Automations tab to schedule recurring work. Good candidates include:

Skills define the methodology; automations define the scheduling.

Session management

Keep one thread per coherent work unit. Useful slash commands for managing sessions:

Command Description
/experimentalToggle experimental features
/resumeRestore saved conversations
/forkCreate branches preserving history
/compactSummarize long threads
/agentSwitch between parallel agents
/themeChange syntax highlighting
/appsUse ChatGPT apps directly
/statusInspect session state

Use subagents for bounded work like exploration or testing.

Common mistakes to avoid