AGENTSMD(5)AGENTSMD(5)

NAME

AGENTS.md — instruction file for GitHub Copilot, OpenAI Codex CLI, Lovable

SYNOPSIS

~/.codex/AGENTS.md

./AGENTS.md

./<subdir>/AGENTS.md

METADATA

FORMATMarkdown
FILENAMEAGENTS.md
CASE SENSITIVEYes
TOOLGitHub Copilot, OpenAI Codex CLI, Lovable
ENCODINGUTF-8
GIT COMMITTEDYes
MAX SIZE64KB (configurable via project_doc_max_bytes in Codex)
SINCEGitHub Copilot (early 2025), Codex CLI (2025)

DESCRIPTION

AGENTS.md is a shared instruction file read by both GitHub Copilot and OpenAI Codex CLI (as well as Lovable and other tools). It follows a similar philosophy to CLAUDE.md — a Markdown file committed to your repository that tells AI agents how to work with your codebase.

The critical behavioral difference between tools is the scoping model. Codex CLI concatenates all AGENTS.md files from the Git root down to the current working directory, with later files overriding earlier guidance. Each file appears as its own user-role message with a header like '# AGENTS.md instructions for <directory>'. GitHub Copilot uses nearest-ancestor-only resolution — it walks up from the current file and uses only the first AGENTS.md it finds, ignoring all parent files.

Codex CLI also supports AGENTS.override.md at each directory level: if found, the regular AGENTS.md in that directory is skipped. This enables personal overrides without modifying team files. Additionally, Codex supports fallback filenames (configurable via project_doc_fallback_filenames in config.toml) and a configurable max file size (project_doc_max_bytes, default 64KB).

AGENTS.md has no special syntax — it is plain Markdown. There are no include directives, no YAML frontmatter, and no glob patterns.

Load Order
1~/.codex/AGENTS.md(global)
2./AGENTS.md(project)
3./<subdir>/AGENTS.md(directory)

Lower numbers load first. Higher-priority files override lower ones.

STRUCTURE

├──Project Overview
Brief description of the project, its purpose, and key technologies.
├──Code Conventions
Naming conventions, formatting rules, import ordering, and style preferences.
├──Architecture
Directory structure, key modules, and data flow patterns.
├──Testing
Test framework, file naming conventions, and testing patterns to follow.
└──Build & Deploy
Commands for building, testing, linting, and deploying the project.

ANNOTATED EXAMPLE

AGENTS.md
markdown
1# AGENTS.md
2
3## Project Overview
4
5This is a Next.js 14 e-commerce application using the App Router,
6Server Components, and Drizzle ORM with PostgreSQL.
7
8## Code Conventions
9
10- Use TypeScript strict mode throughout
11- Prefer Server Components; use "use client" only when necessary
12- Name files with kebab-case: `product-card.tsx`, not `ProductCard.tsx`
13- Co-locate tests: `product-card.test.tsx` next to `product-card.tsx`
14
15## Architecture
16
17- `app/`           — Next.js App Router pages and layouts
18- `components/`    — Shared UI components
19- `lib/`           — Utilities, database client, auth helpers
20- `actions/`       — Server Actions for mutations
21
22## Testing
23
24- Use Vitest for unit tests, Playwright for E2E
25- Mock database calls using `lib/test-utils.ts` helpers
26- Every new component needs at least one test
27
28## Build Commands
29
30```bash
31pnpm dev          # Start dev server
32pnpm build        # Production build
33pnpm test         # Run Vitest
34pnpm test:e2e     # Run Playwright
35pnpm lint         # ESLint check
36```

COMMON MISTAKES

Gotchas
&cross;WRONG agents.md, Agents.md
&check;RIGHT AGENTS.md (exact uppercase required)

Like CLAUDE.md, the filename must be exactly AGENTS.md with uppercase letters. Both Codex CLI and GitHub Copilot look for this exact name.

&cross;WRONG Assuming all tools handle directory hierarchy the same way
&check;RIGHT Codex concatenates root-to-CWD; Copilot uses nearest-ancestor-only

This is a critical difference. Codex CLI walks from the Git root down to CWD and concatenates ALL AGENTS.md files found along the path — later files override earlier ones. GitHub Copilot uses nearest-ancestor-only: it walks up from the current directory and uses only the first AGENTS.md it finds, ignoring parent files entirely. Subdirectory files must be self-contained for Copilot but can be incremental for Codex.

&cross;WRONG Using @-include directives like CLAUDE.md
&check;RIGHT AGENTS.md does not support @-imports — put all content inline

There is no include directive. If you need to reference other documentation, link to it or copy the relevant sections directly into the file.

&cross;WRONG Ignoring AGENTS.override.md for personal customizations
&check;RIGHT Use AGENTS.override.md for personal overrides (gitignored)

Codex CLI checks for AGENTS.override.md before AGENTS.md at each directory level. If the override file exists, AGENTS.md in that same directory is skipped entirely. This allows personal customizations without modifying team files. Not supported by GitHub Copilot.

&cross;WRONG Writing extremely long AGENTS.md files without checking limits
&check;RIGHT Codex default limit is 64KB (project_doc_max_bytes); keep it focused

Codex CLI enforces a configurable max bytes limit (default 65536) when building project instructions. AI agents read this on every interaction, so verbose files waste context window. You can adjust the limit in ~/.codex/config.toml.

&cross;WRONG Expecting fallback filenames to work everywhere
&check;RIGHT Codex supports project_doc_fallback_filenames; Copilot does not

Codex CLI can be configured to look for alternative filenames like TEAM_GUIDE.md or .agents.md via the project_doc_fallback_filenames setting in config.toml. These are only checked if no AGENTS.md or AGENTS.override.md is found. GitHub Copilot only looks for AGENTS.md.

USED BY

SIMILAR FILES

CLAUDE.mdClaude Memory File

COMPARISONS

agentconfig.ing2026-03-16AGENTSMD(5)