Coding & automation

Write AGENTS.md rules that belong to the right project folder

Where should the file go, and what changes when a nested override appears? A small product-writing exercise shows rule differences and the limits of an agent’s self-report.

Codex
AI-generated editorial illustration, not an actual product screenshot.
On this page
THE QUICK TAKE
  • Place shared rules at the root and task-specific rules nearer the working folder.
  • AGENTS.override.md replaces the selected AGENTS.md at the same directory.
  • Verify actual output and files rather than trusting a loaded-instructions claim.

Tested on 16 October 2026 with Windows, Codex CLI 0.163.0 and GPT-6.1 Sol/high. Two fresh runs restated already-loaded rules without tools. A separate product-reading/writing attempt was policy-blocked, so no description file was successfully saved. The responses also misidentified instruction filenames. Complete descriptions in the ZIP are editor-authored references.

Files for this exercise

AIHotple example files and prompts. Try the exercise before substituting real work data.

Turn recurring constraints into project instructions

If every product-writing request repeats “use the JSON, invent no shipping terms, save only the description,” those are candidates for AGENTS.md. Keep this task’s input and goal in the prompt; put recurring sources, boundaries and notation in the file. Our fictional notebook is A5, 80 pages and KRW 12,000, with shipping unspecified. Instructions do not replace factual review or enforce filesystem access controls.

Supporting editorial image for this topic
Supporting editorial image for this topic · Not an actual product screenshot.

1. Identify the root and the working subdirectory

The ZIP’s agents-practice directory is the practice root. catalog stores facts; content is the output directory. The override under reference is inactive for the content path until copied there. Official discovery walks from the project root, usually the Git root, to the working directory; without a discovered project root, only the current directory is checked. Initialize Git only in this new exercise and start inside content. Do not repeat git init indiscriminately in existing repositories.

Practice structure
agents-practice/
├─ AGENTS.md                  # Shared source and edit boundaries
├─ catalog/product.json
├─ content/AGENTS.md          # Korean presentation rules
└─ reference/AGENTS.override.md # Inactive comparison copy

2. Write shared rules around concrete files

The real root fixture below names the authoritative product file and the only output destination. It prohibits invented shipping promises and changes to the source. These are Korean files from the actual test, with their purpose explained here. Do not add a generic npm test rule to a document project that has no such test; the relevant check here is comparing product facts and unknowns.

Actual root AGENTS.md used in the experiment
# 모아문구 가상 실습
- 공개 가능한 가상 자료만 사용합니다.
- 상품 사실은 catalog/product.json을 기준으로 합니다. 가격·규격·쪽수·배송 조건을 지어내지 않습니다.
- 상품 소개 작업은 content/description.md에만 저장합니다. catalog/product.json과 이 규칙 파일을 수정하지 않습니다.
- 기본 독자는 한국어 독자입니다. 하위 폴더에 독자·표현 규칙이 있으면 해당 범위에서 적용합니다.
- 확인되지 않은 할인·배송일·성과 약속을 덧붙이지 않습니다. 실행하지 않은 검사를 완료했다고 말하지 않습니다.

3. Add the presentation rules in content

The child file specifies the Korean first line, two sentences, a specification table and currency notation. Shared rules need not be copied into every directory. Official discovery concatenates root-to-current instructions, with nearer guidance overriding conflicts. Our experiment started in content; it does not verify every situation where a session starts at the root and later edits another subtree.

Actual content/AGENTS.md
# 한국어 상품 소개
- 첫 줄은 정확히 "오늘의 기록을 가볍게."로 씁니다.
- 한국어 본문 두 문장 다음에 규격·쪽수·가격을 표로 씁니다.
- 가격은 12,000원처럼 쉼표와 원 단위를 사용합니다.
- 배송 조건이 미정이면 미정으로 표시합니다.

4. What two fresh runs actually restated

The first run used the base file. Before the second, we copied reference/AGENTS.override.md to content/AGENTS.override.md. The same Korean request asked only for a restatement of instructions already in context, with no command, read or write tools. It did not ask for a product description.

The first response repeated the Korean opening and 12,000원; the second repeated Supplier copy, English and KRW 12,000. Both retained shared source/edit constraints. However, the second called the selected file AGENTS.md and both were unable to identify the root file separately. We therefore report observed rule differences, not a reliable filename inventory. The ZIP preserves the actual Korean responses.

RuleBase responseOverride response
Opening오늘의 기록을 가볍게.Supplier copy
LanguageKoreanEnglish supplier copy
Price notation12,000원KRW 12,000
Unknown shipping미정Shipping: not specified
Filename reportExact path inventory unverifiedInaccurately called the override AGENTS.md
Copy and adapt this prompt
Do not run commands or read/write files. Restate only project instructions already present in your context. Identify root and content guidance if available; quote the required opening, language, price notation and unknown-shipping rule. Do not invent rules missing from the context. (English adaptation; actual runs used Korean.)

5. An override does not merge both files in its directory

Officially, each directory selects at most one non-empty instruction file: AGENTS.override.md first, then AGENTS.md, then configured fallback names. Adding an override in content replaces that directory’s selected base file; it does not remove root instructions. The comparison override below asks for English supplier copy. Keep the base file. To restore the base case, move only the practice override outside content and start a fresh run. No global instruction changes are required.

Actual comparison AGENTS.override.md
# 공급사 제출용 임시 규칙
- 이 폴더에서는 한국어 소개 규칙 대신 영어 공급사 소개문을 작성합니다.
- 첫 줄은 정확히 "Supplier copy"로 씁니다.
- 영어 본문 두 문장과 Size·Pages·Price 표를 작성합니다. 가격은 KRW 12,000처럼 씁니다.
- 배송 조건이 미정이면 "Shipping: not specified"로 씁니다.

6. Writing a product file needs a separate check

In a working read/write environment, the request below can produce description.md from the JSON. Open the saved file and check the first line, A5, 80 pages, KRW 12,000, unknown shipping and the output path. A completion message alone does not establish a saved artifact.

Our separate file-reading/writing attempt was policy-blocked. The expected Korean and English descriptions under reference are editor-authored examples, not successful Codex outputs. This distinction separates observing loaded rule differences from completing a file task.

PowerShell · a new practice repository
cd "C:/aihotple-practice/agents-practice"
git init
cd content
codex

# After exiting Codex, add the comparison override
Copy-Item ../reference/AGENTS.override.md ./AGENTS.override.md
codex
Copy and adapt this prompt
Write description.md using ../catalog/product.json. Do not invent product facts. Report the actual saved path, facts checked and any step you could not perform. (Adaptation; not an executed English request.)

When a rule appears to be ignored

Check the current directory, detected project root, same-directory override, exact filename and fresh-run state. AGENTS.md.txt is not the intended name. The default combined instruction limit is 32KiB, and global instructions may also affect the chain. Discovery is built at startup; do not assume changing a file instantly refreshes an existing conversation. Restart for comparison and inspect real output, numeric facts and edited files. If the agent’s filename report is ambiguous, compare locations with documented discovery before removing rules.

Choose a Codex surface and open the exercise folder →

Sources & verification

Tested on 16 October 2026 with Windows, Codex CLI 0.163.0 and GPT-6.1 Sol/high. Two fresh runs restated already-loaded rules without tools. A separate product-reading/writing attempt was policy-blocked, so no description file was successfully saved. The responses also misidentified instruction filenames. Complete descriptions in the ZIP are editor-authored references.

  1. OpenAI · AGENTS.md instructions
  2. OpenAI · Advanced configuration
  3. OpenAI · Codex CLI

Sources checked: 2026.10.16

Keep this guide for your next project.Report a correction