How to Write AGENTS.md
One file that works across Codex, Cursor, Jules, GitHub Copilot, and Gemini CLI. Here is exactly how to write it.
Why AGENTS.md exists
As AI coding tools multiplied, teams ended up maintaining separate CLAUDE.md, .cursorrules, and other tool-specific files that drifted out of sync. AGENTS.md is the open-standard solution: one plain-markdown file that any compliant tool reads. No proprietary syntax, no required structure. You write it once; every tool that supports the standard reads it.
Which tools support AGENTS.md
As of mid-2026: OpenAI Codex, Cursor (reads it alongside .cursor/rules), Google Jules, GitHub Copilot Agent mode, Gemini CLI, and a growing list of others. The standard is governed by the Agentic AI Foundation under the Linux Foundation -adoption is accelerating.
Structure your AGENTS.md for compliance
No required structure, but these sections are most effective: (1) Project overview -one paragraph. (2) Tech stack -specific versions matter. (3) Repository structure -an annotated directory tree. (4) Coding conventions -concrete rules, not principles. (5) Must-not-do list -explicit prohibitions. (6) Test commands -so agents can verify their changes.
Complete AGENTS.md template
Copy this and customize the stack section for your project.
# Project Agent Guidelines
## Overview
[One paragraph: what this project does and who uses it.]
## Tech Stack
- Language: TypeScript 5.x (strict mode)
- Framework: Next.js 16 (App Router)
- Runtime: Node.js 20+
- Styling: Tailwind CSS v4
- Database: PostgreSQL via Prisma
- Auth: [your auth provider]
- Testing: Vitest + React Testing Library + Playwright
## Repository Structure
```
src/
├── app/ # Routes (App Router). Thin pages only.
├── components/ # Shared UI (used in 2+ routes).
├── features/ # Business domain modules.
├── hooks/ # Shared custom React hooks.
├── lib/ # Server-only utilities (import 'server-only').
├── store/ # Zustand stores (UI state only).
├── types/ # Global TypeScript types.
└── utils/ # Pure helpers (client + server safe).
```
## Code Conventions
### TypeScript
- strict: true -no any, no implicit returns, no unchecked indexing.
- Interface for object shapes. Type alias for unions and utility types.
- No enums -use union string literals.
- Zod validates all external data. Infer types with z.infer<typeof Schema>.
### React
- Named exports only for all components and hooks.
- One component per file. Props typed with interfaces.
- Default to Server Components. "use client" only when required.
- No useEffect for data fetching.
### Naming
- Files: kebab-case | Components: PascalCase | Hooks: useCamelCase
- Booleans: isX, hasX, canX | Handlers: handleX | Callbacks: onX
## Must NOT Do
- Create pages/ directory -App Router only.
- Use any without written justification.
- Store server/async data in Zustand.
- Import lib/ utilities from Client Components.
- Use default exports for components.
## Tests
```bash
npm run test # unit + integration
npm run test:e2e # Playwright e2e
npm run type-check # TypeScript compiler
npm run lint # ESLint
```
## PR Guidelines
- Every new feature needs at least one test.
- Types go in src/types/ (global) or feature/types.ts (local).
- Keep PRs focused -one concern per PR.