guides/agents-md.md +65 −22
1# Custom instructions with AGENTS.md1# Custom instructions with AGENTS.md
2 2
3Give Codex extra instructions and context for your project
4
5Codex reads `AGENTS.md` files before doing any work. By layering global guidance with project-specific overrides, you can start each task with consistent expectations, no matter which repository you open.3Codex reads `AGENTS.md` files before doing any work. By layering global guidance with project-specific overrides, you can start each task with consistent expectations, no matter which repository you open.
6 4
7## How Codex discovers guidance5## How Codex discovers guidance
80 82
81Here is a sample repository after you add a global file and a payments-specific override:83Here is a sample repository after you add a global file and a payments-specific override:
82 84
8385- AGENTS.md Repository expectations<FileTree
8486- services/ class="mt-4"
8587 tree={[
8688 - payments/ {
8789 name: "AGENTS.md",
8890 - AGENTS.md Ignored because an override exists comment: "Repository expectations",
8991 - AGENTS.override.md Payments service rules highlight: true,
9092 - README.md },
9193 - search/ {
9294 name: "services/",
9395 - AGENTS.md open: true,
9496 - … children: [
97 {
98 name: "payments/",
99 open: true,
100 children: [
101 {
102 name: "AGENTS.md",
103 comment: "Ignored because an override exists",
104 },
105 {
106 name: "AGENTS.override.md",
107 comment: "Payments service rules",
108 highlight: true,
109 },
110 { name: "README.md" },
111 ],
112 },
113 {
114 name: "search/",
115 children: [{ name: "AGENTS.md" }, { name: "…", placeholder: true }],
116 },
117 ],
118 },
119 ]}
120/>
95 121
96## Customize fallback filenames122## Customize fallback filenames
97 123
110 137
111With the fallback list in place, Codex treats the alternate files as instructions:138With the fallback list in place, Codex treats the alternate files as instructions:
112 139
113140- TEAM\_GUIDE.md Detected via fallback list<FileTree
114141- .agents.md Fallback file in root class="mt-4"
115142- support/ tree={[
116143 {
117144 - AGENTS.override.md Overrides fallback guidance name: "TEAM_GUIDE.md",
118145 - playbooks/ comment: "Detected via fallback list",
119146 highlight: true,
120147 - … },
148 {
149 name: ".agents.md",
150 comment: "Fallback file in root",
151 },
152 {
153 name: "support/",
154 open: true,
155 children: [
156 {
157 name: "AGENTS.override.md",
158 comment: "Overrides fallback guidance",
159 highlight: true,
160 },
161 {
162 name: "playbooks/",
163 children: [{ name: "…", placeholder: true }],
164 },
165 ],
166 },
167 ]}
168/>
121 169
122Set the `CODEX_HOME` environment variable when you want a different profile, such as a project-specific automation user:170Set the `CODEX_HOME` environment variable when you want a different profile, such as a project-specific automation user:
123 171