OpenAI · Codex CLI · IDE extension · ChatGPT desktop app
OpenAI Codex rules files explained
Which instruction files OpenAI Codex reads (AGENTS.md, AGENTS.override.md), where to put them, and how to convert from other agents.
Files Codex reads
AGENTS.mdAGENTS.override.md
AGENTS.md: Yes: global ~/.codex/AGENTS.md plus one AGENTS.md (or AGENTS.override.md) per directory from the repo root down.
Skills folders: .codex/skills/
Who reads what
| Agent | Rules files | AGENTS.md |
|---|---|---|
| Claude | CLAUDE.md, .claude/rules/*.md | Only when no CLAUDE.md / CLAUDE.local.md exists (default, v2.1.277+); or import it with @AGENTS.md |
| Codex | AGENTS.md, AGENTS.override.md | Yes: global ~/.codex/AGENTS.md plus one AGENTS.md (or AGENTS.override.md) per directory from the repo root down |
| Cursor | .cursor/rules/*.mdc, AGENTS.md, .cursorrules (legacy) | Yes, in the project root and in subdirectories (nested files combine) |
| Copilot | .github/copilot-instructions.md, .github/instructions/*.instructions.md, AGENTS.md | Yes on most surfaces (cloud agent, CLI, VS Code chat, code review); not Copilot Chat on GitHub.com |
| Antigravity | AGENTS.md, GEMINI.md, .agents/rules/*.md | Yes: AGENTS.md or GEMINI.md at any directory level, always on |
How Codex builds its instruction chain
Codex reads instructions in two scopes. Globally, in your Codex home (~/.codex unless CODEX_HOME is set), it reads AGENTS.override.md if present, otherwise AGENTS.md, and uses only the first non-empty file. For the project, it starts at the project root, usually the Git root, and walks down to your current directory, checking each directory for AGENTS.override.md, then AGENTS.md, then any fallback names.
Files closer to where you work come later in the combined prompt, so they win on conflicts. Codex skips empty files and stops adding once the total reaches project_doc_max_bytes, 32 KiB by default, so a long root file can crowd out a nested one.
AGENTS.override.md is meant for temporary or team-specific changes: OpenAI's example puts one in services/payments/ to replace the general rules there. If your repository already uses another filename, such as TEAM_GUIDE.md, add it to project_doc_fallback_filenames in ~/.codex/config.toml and Codex treats it as an instructions file. To confirm what loaded, OpenAI suggests asking Codex to quote the items from your AGENTS.md before it proposes work.
Source: developers.openai.com · Checked Oct 24, 2026
Guides, pricing & comparisons
How to add an MCP server to Codex
Portable agent skills: one SKILL.md for every coding agent
Safe “always allow” rules for Claude Code and Codex CLI
Codex sandbox modes and approval policies explained
How to install the OpenAI Codex CLI
Agent Skills moves to the Agentic AI Foundation: what changes
MCP security: the risks in MCP servers and how to lock them down
What is AGENTS.md? The open instruction file for coding agents
Codex skills: create, install and use SKILL.md skills in Codex
GPT-6.1 Terra in Codex and the API: setup, pricing and limits
MCP OAuth: connect a remote MCP server in Claude Code, Codex and Cursor
Codex config.toml: location, precedence and the settings to change
Codex on Windows: native sandbox setup, WSL and fixes
Fix spawn npx ENOENT when starting an MCP server
MCP connection closed: find why a server will not connect
Claude Code vs OpenAI Codex: documented features compared
OpenAI Codex vs Cursor: documented features compared
OpenAI Codex vs GitHub Copilot: documented features compared
OpenAI Codex pricing and usage limits
AGENTS.md vs CLAUDE.md vs Cursor rules
AGENTS.md templates for Laravel and Next.js
MCP servers that work in every coding agent