Skip to main content

OpenAI Codex

OpenAI’s AI coding CLI. Pioneered the AGENTS.md format. Has a richer native extension model than the AGENTS.md standard alone: TOML custom agents, native skills concept, and layered instruction discovery.

Instruction Layer (AGENTS.md)

Reads AGENTS.md as ambient layered instructions:
  • Discovery: global ~/.codex/AGENTS.md → project root → CWD walk
  • Override: AGENTS.override.md takes precedence over AGENTS.md at the same directory level (useful for temporary local overrides; rm AGENTS.override.md to restore default)
  • Limit: 32 KiB default instruction chain (project_doc_max_bytes)
  • Merge order: root→CWD concatenated, joined by blank lines; later (closer to CWD) wins
  • Profiles: CODEX_HOME env var for multiple setups (e.g., CODEX_HOME=$(pwd)/.codex codex exec "...")
Raise the 32 KiB limit or add fallback filenames in ~/.codex/config.toml:
Verification:
Troubleshooting:

Custom Agents — TOML Format

Note: Codex agents use TOML, not YAML. This is the format reported in official docs as of 2026. Location: ~/.codex/agents/ (global) or .codex/agents/ (project-scoped).
Schema:
  • name — identifier; used for invocation and routing
  • description — signal for when primary agent should delegate
  • developer_instructions — multiline system prompt for this agent
  • model — model override (can differ from primary session model)
  • [sandbox] — network/filesystem restrictions for this agent

Skills

Codex has a first-class skills concept. The native entrypoint is skills/<name>/SKILL.md, with optional product metadata in skills/<name>/agents/openai.yaml.
Example metadata:
Skills are invocable on demand and can also be injected implicitly when allowed by policy. This is closer to CC’s Skill tool mechanism than to ambient AGENTS.md rules.

Hooks

Codex supports repo-local hooks in config.toml, including events such as PostToolUse. Minimal pattern:

Three-Layer Stack


Migration from Claude Code

See Claude Code → Cross-Platform Migration Matrix for full matrix.