diff --git a/README.md b/README.md index cd4470510..bb7f5243b 100644 --- a/README.md +++ b/README.md @@ -226,13 +226,15 @@ Key flags: `--model/-m`, `--approval-mode/-a`, `--quiet/-q`, and `--notify`. ## Memory & Project Docs -Codex merges Markdown instructions in this order: +Codex looks for Markdown agent files (preferred: `AGENTS.md`) in the following order 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`. + +For backwards-compatibility with older Codex versions, `instructions.md` and `codex.md` are still supported but `AGENTS.md` is recommended. --- @@ -437,7 +439,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 emojis diff --git a/codex-cli/src/cli.tsx b/codex-cli/src/cli.tsx index 059136e8c..c54b6f1ff 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 Include an additional markdown file at 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.ts index 87274e12e..8a522d98a 100644 --- a/codex-cli/src/utils/config.ts +++ b/codex-cli/src/utils/config.ts @@ -192,12 +192,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 +// mid-2024 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 { @@ -238,7 +248,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. *