Lightweight coding agent that runs in your terminal
Rust
fix: migrate to AGENTS.md (#764)
Fouad Matin3104d81b7bdc
diff --git a/README.md b/README.mdindex bfbc53fcd1..33f6128bf5 100644--- a/README.md+++ b/README.md@@ -227,13 +227,13 @@ Key flags: `--model/-m`, `--approval-mode/-a`, `--quiet/-q`, and `--notify`.## Memory & project docs-Codex merges Markdown instructions in this order:+You can give Codex extra instructions and guidance using `AGENTS.md` files. Codex looks for `AGENTS.md` files in the following places, and merges them top-down:-1. `~/.codex/instructions.md` - personal global guidance-2. `codex.md` at repo root - shared project notes-3. `codex.md` in cwd - sub-package specifics+1. `~/.codex/AGENTS.md` - personal global guidance+2. `AGENTS.md` at repo root - shared project notes+3. `AGENTS.md` in the current working directory - sub-folder/feature specifics-Disable with `--no-project-doc` or `CODEX_DISABLE_PROJECT_DOC=1`.+Disable loading of these files with `--no-project-doc` or the environment variable `CODEX_DISABLE_PROJECT_DOC=1`.---@@ -446,7 +446,7 @@ Below is a comprehensive example of `config.json` with multiple custom providers### Custom instructions-You can create a `~/.codex/instructions.md` file to define custom instructions:+You can create a `~/.codex/AGENTS.md` file to define custom guidance for the agent:```markdown- Always respond with emojisdiff --git a/codex-cli/src/cli.tsx b/codex-cli/src/cli.tsxindex 059136e8c4..c54b6f1ff7 100644--- a/codex-cli/src/cli.tsx+++ b/codex-cli/src/cli.tsx@@ -68,7 +68,7 @@ const cli = meow(--auto-edit Automatically approve file edits; still prompt for commands--full-auto Automatically approve edits and commands when executed in the sandbox- --no-project-doc Do not automatically include the repository's 'codex.md'+ --no-project-doc Do not automatically include the repository's 'AGENTS.md'--project-doc <file> Include an additional markdown file at <file> as context--full-stdout Do not truncate stdout/stderr from command outputs--notify Enable desktop notifications for responses@@ -144,7 +144,7 @@ const cli = meow(},noProjectDoc: {type: "boolean",- description: "Disable automatic inclusion of project-level codex.md",+ description: "Disable automatic inclusion of project-level AGENTS.md",},projectDoc: {type: "string",diff --git a/codex-cli/src/utils/config.ts b/codex-cli/src/utils/config.tsindex 4c51deb316..d2a9304aec 100644--- a/codex-cli/src/utils/config.ts+++ b/codex-cli/src/utils/config.ts@@ -211,12 +211,22 @@ export type AppConfig = {export const PRETTY_PRINT = Boolean(process.env["PRETTY_PRINT"] || "");// ----------------------------------------------------------------------------// Project doc support (codex.md)+// Project doc support (AGENTS.md / codex.md)// ---------------------------------------------------------------------------export const PROJECT_DOC_MAX_BYTES = 32 * 1024; // 32 kB-const PROJECT_DOC_FILENAMES = ["codex.md", ".codex.md", "CODEX.md"];+// We support multiple filenames for project-level agent instructions. As of+// 2025 the recommended convention is to use `AGENTS.md`, however we keep+// the legacy `codex.md` variants for backwards-compatibility so that existing+// repositories continue to work without changes. The list is ordered so that+// the first match wins – newer conventions first, older fallbacks later.+const PROJECT_DOC_FILENAMES = [+ "AGENTS.md", // preferred+ "codex.md", // legacy+ ".codex.md",+ "CODEX.md",+];const PROJECT_DOC_SEPARATOR = "\n\n--- project-doc ---\n\n";export function discoverProjectDocPath(startDir: string): string | null {@@ -257,7 +267,8 @@ export function discoverProjectDocPath(startDir: string): string | null {}/**- * Load the project documentation markdown (codex.md) if present. If the file+ * Load the project documentation markdown (`AGENTS.md` – or the legacy+ * `codex.md`) if present. If the file* exceeds {@link PROJECT_DOC_MAX_BYTES} it will be truncated and a warning is* logged.*