Sub topic 3
The file format: just Markdown
This chapter assumes you know basic Git and repository layout, can write Markdown, and have run build and test commands from a terminal. It covers what an AGENTS.md file is made of and what that means for how you write one.
No required fields
AGENTS.md is an ordinary Markdown file. It has no schema, no front matter, and no required headings. A tool that supports it finds the file by name, reads the text, and passes that text to the model as context. Nothing validates it. A file with one line is as valid as a file with fifty.
This has three practical effects:
- You can start with a few lines and add to the file later.
- Nothing will warn you about a typo or a missing section. A wrong command in the file is read as if it were right.
- The model reads your words as written. Clear prose helps, and so does ordinary Markdown structure.
Conventional headings
Headings are not required, but they help. They split the file into pieces that a reader, human or model, can scan. Most files use headings like these:
| Heading | What it holds |
|---|---|
| Project overview | One or two lines on what the project is and its stack |
| Setup | Commands to install dependencies and start services |
| Build and test | Commands to build, run all tests, run one test file |
| Code style | Specific rules that linters do not already enforce |
| Project structure | Which directories hold which kind of code |
| Pull requests | Title format and test expectations |
These names are a convention. Rename them to fit your project. The next chapter covers what belongs in each section.
A complete example
This file is short, but it uses the common sections.
# AGENTS.md
## Project overview
Web API for invoice processing. TypeScript, Node.js 20, PostgreSQL.
## Setup
- Install dependencies: `npm ci`
- Start the local database: `docker compose up -d db`
## Build and test
- Build: `npm run build`
- Run all tests: `npm test`
- Run one test file: `npm test -- path/to/file.test.ts`
- Lint and type-check before finishing: `npm run lint && npm run typecheck`
## Code style
- Use named exports; do not add default exports.
- Keep route handlers thin and put business logic in `src/services/`.
## Project structure
- `src/routes/`: HTTP handlers
- `src/services/`: business logic
- `migrations/`: database migrations (never edit an existing migration)
## Pull requests
- Add or update tests for every behavior change.
- Use the title format `[area] Short description`.Look at how the Markdown is used:
- Commands sit in backticks, so the agent can copy them exactly.
- Each item is a short bullet with one instruction.
- Each rule states what to do. The migrations rule states a boundary: never edit an existing migration.
- Headings group related items, so the agent can find the test command without reading the whole file.
Why plain Markdown works well
A format with no fields has one clear advantage. Any tool can read it, and any person can edit it with a text editor in a pull request. The file is reviewed like code, and git blame shows who changed a rule and when.
It also has a cost. Because nothing is parsed, structure is only a hint. If you write "run the tests" without a command, the agent has to guess which command you meant. Put the exact command in the file.
Format habits that help
- Start with a single
#title. Use##for sections. - Put commands in inline code with backticks. Use a fenced block for multi-line commands.
- Prefer bullets over long paragraphs. One bullet should carry one instruction.
- Write in the imperative: "Run", "Use", "Do not add".
- Keep the file short enough that every line earns its place. Long files are harder to maintain and easier for a model to misread.
Exercise
A teammate adds a --- front matter block with commands: and style: keys to AGENTS.md, expecting the tool to parse them. What actually happens, and what should they do instead?
Show answer
Nothing parses the block. AGENTS.md has no schema, so the tool treats the front matter as plain text, and the model may or may not make sense of it. They should remove it and write the same information under normal Markdown headings, with exact commands in backticks, such as npm test under a "Build and test" heading.
Exercise
Rewrite this line so it fits the format advice in this chapter: "Make sure everything is tested and clean before you are done."
Show answer
For example: "Run npm run lint && npm test before finishing, and fix any failures you introduced." The rewrite names exact commands in backticks, uses the imperative, and gives one checkable instruction.