-
Notifications
You must be signed in to change notification settings - Fork 2.1k
fix: migrate to AGENTS.md #764
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
fouad-openai
wants to merge
3
commits into
main
Choose a base branch
from
add-agents-md
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+24
−11
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggested change: remove this from the docs. |
||
|
||
--- | ||
|
||
|
@@ -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 | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 2025 |
||
// 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. | ||
* | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggested change: "You can give Codex extra instructions and guidance using
AGENTS.md
files. Codex looks forAGENTS.md
files in the following places, and merges them top-down:"