Skip to content

Codex

OpenAI Codex

Codex uses AGENTS.md as its primary instruction mechanism, with a hierarchical directory-based scoping model.

File Overview

CategoryFileScope
InstructionsAGENTS.mdProject-wide and per-directory guidance
InstructionsAGENTS.override.mdOverride file (takes precedence over AGENTS.md)
Instructions~/.codex/AGENTS.mdUser-level global instructions
Skills.agents/skills/<name>/SKILL.mdRepository-scoped skills
Skills~/.agents/skills/<name>/SKILL.mdUser-level skills
Skills/etc/codex/skills/<name>/SKILL.mdAdmin-level skills
Subagents.codex/agents/*.tomlProject-scoped subagents
Subagents~/.codex/agents/*.tomlUser-level subagents
Settings.codex/config.tomlProject-scoped runtime config
Settings~/.codex/config.tomlUser-level runtime config
Hooks.codex/hooks.jsonProject-scoped hooks (experimental)
Hooks~/.codex/hooks.jsonUser-level hooks
Commands~/.codex/prompts/*.mdCustom prompts (deprecated, use skills)

Instruction Hierarchy

Codex builds an instruction chain by walking from the repository root to the current working directory. At each level, it looks for (in priority order):

  1. AGENTS.override.md
  2. AGENTS.md
  3. Fallback filenames (configurable in config.toml)

Instructions accumulate — deeper directories add specificity to root-level rules. This makes AGENTS.md placement a structural design decision.

Skills

Codex skills use the .agents/skills/ directory (not .codex/skills/). Each skill requires a SKILL.md with YAML frontmatter.

Skill Frontmatter

yaml
---
name: add-endpoint          # Required. Skill identifier
description: Add a new ...  # Required. Used for progressive disclosure matching
---

Codex has the most minimal skill frontmatter. The description is critical because Codex reads metadata first and loads full content only when needed (progressive disclosure).

Additional configuration can go in agents/openai.yaml within the skill directory.

Settings (config.toml)

config.toml separates runtime concerns from project guidance:

SettingPurpose
modelDefault model selection
approval_policyuntrusted / on-request / never
sandbox_modeFile access scope
project_root_markersHow Codex finds project boundaries
project_doc_fallback_filenamesAdditional instruction file names
[mcp_servers.*]External tool connections
[agents.*]Subagent definitions
[tools]Tool enablement (e.g., web_search)

Key distinction: AGENTS.md = how to think about the code; config.toml = how to run the agent.

Subagents

Codex subagents are defined as TOML files in .codex/agents/. Each file defines one custom agent.

Required Fields

FieldPurpose
nameAgent identifier used when spawning
descriptionGuidance for when to use this agent
developer_instructionsCore behavioral instructions (multi-line basic string)

Optional Fields

FieldDefaultPurpose
modelInherited from parentLLM selection
model_reasoning_effortInheritedReasoning effort level
sandbox_modeInheritedFile access scope (e.g., read-only)
nickname_candidatesDisplay name pool for spawned instances
mcp_serversInheritedExternal tool connections
skills.configInheritedSkill configuration overrides

Example

toml
name = "reviewer"
description = "Read-only codebase explorer for gathering evidence."
model = "o3"
sandbox_mode = "read-only"
developer_instructions = """
Stay in exploration mode.
Trace the real execution path, cite files and symbols.
"""

The filename conventionally matches the name field (e.g., reviewer.toml), but the name field is the source of truth.