Write concise project instructions and check them with a small task. You need a project folder open in Codex and a clear outcome. Use a practice copy if the working folder contains unfinished changes.
AGENTS.md is a Markdown file of lasting instructions for an agent: how the project is organized, which checks to run and what counts as finished. It sets working rules; MCP connects tools and data.
Step 1. How to find the active instructions
Read the existing agreements before adding another file. Ask Codex which instructions apply to the selected directory. The official AGENTS.md documentation describes guidance from global settings, the project root and nested directories. Within one directory, AGENTS.override.md takes precedence over AGENTS.md.
Where to put AGENTS.md
| Location | Purpose |
|---|---|
~/.codex/AGENTS.md |
Your defaults across projects; a custom CODEX_HOME changes this directory |
AGENTS.md in the project root |
Build steps, checks and agreements for this project |
AGENTS.md in a nested working directory |
Instructions specific to that part of the project |
On startup, Codex builds a chain from global guidance through the project root to the current directory. Instructions closer to that directory refine earlier guidance. Each directory contributes one non-empty file: AGENTS.override.md takes precedence over AGENTS.md. Keep team rules in the project rather than only in your personal global file.
Paste this into the Codex chat for your project:
Find the current project root and the AGENTS.md and AGENTS.override.md instructions that apply to the working directory. Read them and identify the source of each rule. Find the project's actual verification commands. Do not change files yet. Report unavailable files or commands separately.
Continue when Codex has read the named files and found commands in the project rather than guessing from its programming language.
Step 2. How to write lasting agreements
Useful instructions answer recurring questions. They do not need the entire documentation or an error log.
| What to record | Example content |
|---|---|
| Project map | Where the interface and data handling live |
| Verification | Commands from project configuration and their prerequisites |
| Completion | User actions that must work |
| Preservation | Neighboring parts that must stay unchanged for this task |
This is a structure, not a description of your folder. Ask Codex to fill it using the files it read. If you only have an idea, start with the website plan.
Use the project files you read to prepare a concise AGENTS.md. Preserve existing agreements. Include the folder map, actual verification commands and completion criteria. Leave out secrets and today's error history. Show the changes and identify decisions that require my input.
Check that each command and directory exists and that the proposed rules agree with the project's decisions.
Step 3. How to separate rules from task progress
“Check form submission after changing its handler” can be a lasting rule. “Submission is broken today” belongs in task state. Keep these apart so AGENTS.md does not become an endless collection of old problems.
Ordinary state and verification files can help resume work. Choose their names and ask Codex to read them when continuing. They are not an automatic memory connection. See how to continue a project.
Compare AGENTS.md with the project's current state. Keep lasting rules in it and propose separate files for task progress and verification results. Do not delete existing notes. Show what should move where and preserve links to the files needed to resume work.
Check that the decisions remain available and the notes explain unfinished work.
Step 4. How to test the instructions on a small task
After changing instructions, start a new Codex run in the intended directory. The documentation describes loading the instruction chain at the start of a run. Ask which instructions are active, then give a small task with an observable check, such as checking an existing practice form without changing its design.
Read the instructions active in the current directory and list their sources. Choose a small verification already provided by this project and run it without changing source files. Show the actual command, its result and the rule that guided the choice. If the check cannot run, explain why and do not mark it successful.
A file's existence does not prove that its rules were followed. Compare the actions and result with the instructions. If the wrong set was selected, check the working directory and override files.
If Codex is not reading AGENTS.md, check these in order:
- The filename: the default is
AGENTS.md, plural.agent.mdis not an automatic replacement. Other names require an explicitproject_doc_fallback_filenamessetting. - The working directory and profile: these determine the discovery chain. A file in a neighboring project does not apply to the current run.
- Any
AGENTS.override.md: it can replace the ordinary file in the same directory. Compare their contents before removing existing decisions. - A new run after the edit, and instruction size. The documented combined default is 32 KiB (
project_doc_max_bytes); shorten long guidance or split it across the relevant directories.
What you will have and what to do next
You will have a concise AGENTS.md with verifiable project details and separate task-state notes. A successful trial shows that the selected run used the intended instructions; it does not prove every future action.
Project instructions are different from installing a skill or connecting MCP. Choose the next guide for your task.
Prompt for Codex
Paste into your project chat:
Help organize this project's lasting instructions. Find the active AGENTS.md and AGENTS.override.md files, read the structure and verification commands, and prepare a concise update without losing existing decisions. Keep current task state separate. Then use a new run to check instruction loading and perform a small verification provided by the project. Distinguish proposed changes from commands actually run and their results.