Guide

What is an AGENTS.md file?

A short markdown file at your repository root that briefs AI coding agents — Cursor, Claude Code, Codex, Copilot, Gemini — on how your project works before they touch a line of code.

The one-sentence version

AGENTS.md is a plain-text README, but written for an AI agent instead of a human. It states your setup commands, your code conventions, your project structure, and the guardrails the agent must never cross. Modern coding agents look for it automatically and read it before starting a task.

Why it exists

Dropped into a repo with no context, an agent guesses. It reinvents patterns you already have, reaches for libraries you don’t use, edits generated files, and ignores your test and commit conventions — so you end up re-explaining the same rules in every prompt. AGENTS.md moves those rules out of your prompts and into the repo, where every agent and teammate reads the same thing.

What goes in it

A good AGENTS.md is short and specific. Five sections cover almost everything an agent needs:

A minimal example

Here’s what a small but complete AGENTS.md looks like for a Next.js project:

# AGENTS.md

## Project
Next.js 14 app (App Router) in TypeScript.

## Setup
- Install: `pnpm install`
- Dev: `pnpm dev`
- Test: `pnpm test` — run before marking any task done.

## Code style
- TypeScript strict mode; no `any` without a justifying comment.
- Prefer Server Components; add 'use client' only when needed.

## Guardrails
- Never edit files in `.next/` — they are build output.
- Never commit secrets or `.env` files.

Notice it’s mostly imperative, scannable lines — not prose. Agents follow short, explicit rules far more reliably than paragraphs.

Where it goes and who reads it

Place it as AGENTS.md at your repository root; agents read the nearest one in the tree, so monorepos can have a tailored file per package. It’s a shared convention across Cursor, Claude Code, OpenAI Codex, GitHub Copilot, Gemini, Windsurf, Zed and more. Tools that use their own filename can be pointed at it with a symlink, so you maintain one source of truth.

How it relates to .cursorrules and CLAUDE.md

Before AGENTS.md, each tool had its own file — Cursor’s .cursorrules, Claude Code’s CLAUDE.md, Copilot’s instructions file. AGENTS.md is the tool-neutral version of the same idea. The practical approach is to keep one canonical AGENTS.md and generate or symlink the tool-specific files from it, so they can’t quietly drift apart. See AGENTS.md vs .cursorrules and AGENTS.md vs CLAUDE.md for the details.

Common mistakes

The fastest way to write one

A blank file helps no one — the value is the specific rules your stack needs. The free agentsmd generator detects your stack from a manifest and writes a tuned file in about thirty seconds, then exports it to every agent format. If you already have one, the linter scores it and shows exactly what’s missing.

Frequently asked

Is AGENTS.md an official standard?

It’s an emerging open convention adopted across major AI coding tools rather than a single company’s spec. The shared idea is one root-level markdown file of agent instructions.

Do I need AGENTS.md if I already have .cursorrules or CLAUDE.md?

You can consolidate them. AGENTS.md is the tool-neutral home; you can export or symlink the others to it so you maintain one file instead of several that drift apart.

What’s the most important section?

Guardrails — the explicit “don’t do X” rules. They’re what agents most reliably get wrong and what saves you the most cleanup.

How long should an AGENTS.md be?

Short — usually well under a page. It should be a scannable list of commands, conventions and guardrails, not a long document. If it gets long, split per-package files in a monorepo.

Does it work with ChatGPT / Codex, Cursor, Claude Code and Copilot?

Yes. AGENTS.md is designed to be tool-neutral, and the major AI coding agents read it. Tools with their own filename can be pointed at it via a symlink or a generated copy.

Where exactly do I put the file?

At the root of your repository, named AGENTS.md. In a monorepo you can add a scoped file inside each package; agents use the nearest one.

Other stacks & guides

Build yours in thirty seconds

Detect your stack, tune the guardrails, export to every agent format. Free.

Open the generator