Skip to the content.

Awesome AGENTS.md: Real-World Examples and Patterns for Codex, Cursor, Copilot, Gemini CLI and Claude Code

A gallery of AGENTS.md examples for different kinds of projects, plus the patterns that make them work across tools: nested files in monorepos, override files, and small “bridge” configs so Claude Code, Gemini CLI / Antigravity CLI, Aider, Cursor, GitHub Copilot and OpenAI Codex all read the same instructions. A tested checker script finds the setup mistakes that make agents silently ignore your file.

AGENTS.md is a plain Markdown file at the root of a repository (and optionally in subdirectories) that tells AI coding agents how to build, test and work in the project. This repo is for teams who want one instruction file that every agent respects.

Last reviewed: December 2026. Tool behavior was checked against each tool’s official documentation, linked in Where to go next. Tools change often; when in doubt, trust the docs.

Contents

Example Project type Patterns shown
minimal Any small repo The smallest useful file: commands, two conventions, a done check
python-cli Python CLI (uv, Typer) Layer rules (CLI vs core), error/exit-code convention, safe defaults
typescript-library npm library Zero-dependency rule, public API and changesets, bundle size budget
fullstack-monorepo Next.js + NestJS + Prisma Root file plus web, api and db files
polyglot-microservices Go + Python + TS services, gRPC, Kafka Service table with test commands, contract-first changes, backward compatibility
mobile-app Expo / React Native Native rebuild warnings, secrets in bundles, platform checks
data-pipeline dbt + Airflow Modeling layers, tests per model, never touch the production target
kubernetes-platform Helm + Kustomize + Argo CD Read-only commands only, manifest requirements, rendered diffs
open-source-project Rust CLI with outside contributors Stability promises, MSRV, rules for AI-assisted contributions
regulated-fintech Payments ledger (JVM) Non-negotiable invariants, an explicit “agents must not” list
docs-site Astro Starlight docs Writing style rules, build as link checker, prose linting
ml-research PyTorch research code Reproducibility rules, no full training runs, evaluation isolation
legacy-codebase Old PHP monolith Characterization tests first, known traps, dependency direction
override-pattern Service with special rules AGENTS.override.md for a directory

Bridges (configs that point other tools at AGENTS.md): Claude Code, Gemini CLI, Aider, Cursor scoped rule, Copilot path instructions, Codex config.

All examples pass the checker in tools/. Project names in the examples are fictional.

What a good AGENTS.md contains

AGENTS.md has no required fields; it is ordinary Markdown. What separates useful files from ignored ones is content an agent cannot infer from the code, stated as exact, checkable instructions.

Include Example line
Exact commands, including a single test Tests: `uv run pytest -q`; one test: `uv run pytest tests/test_x.py::test_y`
Where things go “src/routes/ is HTTP only; logic lives in src/services/.”
Invariants a linter cannot check “Ledger entries are append-only; corrections are reversing entries.”
Known traps “Times in orders are server local time, not UTC.”
Boundaries “Never run kubectl apply; Argo CD applies merged changes.”
What “done” means “Tests, ruff and mypy pass; new options documented in README.”
PR conventions “Title: type(scope): summary; include a changeset.”
Leave out Why
Formatting rules your formatter enforces Wastes context
“Write clean, maintainable code” Changes no behavior
Architecture essays Link to docs instead
Secrets, tokens, internal URLs with credentials The file is committed and read by many tools
Weekly-changing facts Goes stale and misleads

Anatomy, section by section

A pattern most of the examples follow:

# AGENTS.md

<One or two sentences: what this is, main technologies, what matters most (stability? speed? safety?).>

## Commands          setup, run, test (all + single), lint, typecheck, build
## Layout            what lives where; which layers may import which
## Rules             invariants and conventions, each with a reason or a location
## Known traps       the things that bite newcomers
## Boundaries        never do / ask first
## Done means        the checks to run and report before finishing
## Pull requests     title format, changelog, what to include

Writing tips that make a measurable difference:

Pattern: nested files in a monorepo

Put a short AGENTS.md at the root for cross-cutting rules and one in each app or package for local commands and conventions. The fullstack-monorepo example:

AGENTS.md                    install, turbo commands, import rules, PR format
apps/web/AGENTS.md           Next.js rules, how to run web tests
apps/api/AGENTS.md           NestJS rules, guards, DTO validation
packages/db/AGENTS.md        migration rules, regenerate client

How tools treat this layout:

Rules of thumb: never repeat root rules in nested files; nested files should add, not contradict; keep each file short so the combined chain stays small (Codex caps the combined size, 32 KiB by default).

Pattern: override files

Codex checks each directory for AGENTS.override.md before AGENTS.md and uses only the first non-empty match per directory. An override is for a directory whose rules must replace the usual file there, for example a payments service with its own test runner and a hands-off zone (example). Root-level files still apply above it.

Codex also reads a global file from its home directory (~/.codex/AGENTS.override.md if present, otherwise ~/.codex/AGENTS.md), which is a good place for personal preferences.

Other tools do not read AGENTS.override.md; if you rely on it, keep critical rules in a file every tool reads too.

Pattern: one file, every tool (bridges)

Tool What to add Bridge
Claude Code Nothing if there is no CLAUDE.md (recent versions read AGENTS.md directly). If you need Claude-specific lines, a CLAUDE.md that starts with @AGENTS.md CLAUDE.md
Gemini CLI .gemini/settings.json with "context": {"fileName": ["AGENTS.md", "GEMINI.md"]} settings.json
Antigravity CLI Nothing: it reads AGENTS.md and GEMINI.md in the workspace -
Aider read: AGENTS.md in .aider.conf.yml .aider.conf.yml
Cursor Nothing for AGENTS.md; optional .cursor/rules/*.mdc for glob-scoped rules react-components.mdc
GitHub Copilot Nothing for AGENTS.md; optional .github/instructions/*.instructions.md with applyTo globs tests.instructions.md
OpenAI Codex Nothing; optional project_doc_fallback_filenames and project_doc_max_bytes in ~/.codex/config.toml config.toml

The Claude Code trap: by default Claude Code reads AGENTS.md only when there is no CLAUDE.md, .claude/CLAUDE.md or CLAUDE.local.md in the working directory or above. Adding a personal CLAUDE.local.md therefore makes Claude stop reading AGENTS.md unless the CLAUDE file imports it (@AGENTS.md) or the project-instructions setting is changed. The checker flags this.

Symlinks: ln -s AGENTS.md CLAUDE.md works on macOS and Linux, but avoid it if anyone clones on Windows, where Git may check symlinks out as plain text files.

How each tool reads AGENTS.md

Tool Reads AGENTS.md Nested files Other instruction files Notes
OpenAI Codex Yes Root to working dir, one per directory, concatenated AGENTS.override.md; global ~/.codex/AGENTS.md; fallback names configurable Combined size default limit 32 KiB (project_doc_max_bytes); empty files skipped
Claude Code Yes, when no CLAUDE.md is present (recent versions) Parent directories at launch; subdirectories on demand CLAUDE.md, .claude/CLAUDE.md, CLAUDE.local.md, .claude/rules/*.md @path imports (four hops); /memory shows what loaded
GitHub Copilot Yes Nearest file wins .github/copilot-instructions.md, .github/instructions/*.instructions.md, root CLAUDE.md or GEMINI.md Personal > repository > organization instructions
Cursor Yes Root and subdirectories .cursor/rules/*.mdc with description, globs, alwaysApply Rule types: always, glob-attached, agent-requested, manual
Gemini CLI When configured via context.fileName Global, workspace and just-in-time subdirectory loading GEMINI.md, ~/.gemini/GEMINI.md @file imports; /memory show and /memory reload
Antigravity CLI Yes - GEMINI.md, ~/.gemini/GEMINI.md Google recommends AGENTS.md going forward
Aider When passed with read: or --read - Any conventions file you pass Loaded as read-only context
Others The agents.md site lists Jules, Zed, Warp, Windsurf, Devin, Junie, Amp, goose, opencode, RooCode, Kilo Code, Factory, Augment Code and more Varies Varies Check each tool’s docs

Migrating from other instruction files

You have Move to AGENTS.md by Keep the old file?
.cursorrules (single legacy file) Copy general rules into AGENTS.md; turn glob-specific rules into .cursor/rules/*.mdc Delete after migrating
.github/copilot-instructions.md Move shared content into AGENTS.md; keep Copilot-only notes there Optional
CLAUDE.md Move shared content into AGENTS.md; leave @AGENTS.md plus Claude-only lines in CLAUDE.md Yes, as a bridge, or delete if empty
GEMINI.md Move shared content into AGENTS.md; configure context.fileName or rely on Antigravity reading both Optional
CONVENTIONS.md for Aider Rename to AGENTS.md, set read: AGENTS.md No
A wiki page Extract commands, rules and traps; link to the wiki for background Yes, for humans

A one-liner from the agents.md FAQ for renaming while keeping the old name working: mv AGENT.md AGENTS.md && ln -s AGENTS.md AGENT.md.

Claude Code can also import configuration from other agents with /import codex, /import gemini or /import cursor.

Copy-paste section library

Reusable blocks for common concerns. Paste the ones that apply, then make them specific to your project (replace the examples in angle brackets).

Git and pull requests

## Git
- Never commit or push unless asked. Never force-push shared branches.
- Branch names: `<type>/<ticket>-<short-slug>` (e.g. `fix/PAY-142-refund-rounding`).
- Commit messages: Conventional Commits; the body explains why.
- One concern per PR; include how you verified the change.

Testing

## Testing
- Run the narrowest relevant tests first: `<single-test command>`, then `<full suite>`.
- Bug fixes start with a failing test that reproduces the bug.
- No sleeps in tests; use fake timers. No real network calls; use the fixtures in `<path>`.
- Do not delete or weaken a test to make a change pass; explain instead.

Dependencies

## Dependencies
- Ask before adding a dependency. Prefer the standard library and existing packages.
- Add packages with `<package manager command>` so the lockfile updates; never edit the lockfile by hand.
- New dependencies need a reason in the PR description (size, maintenance, license compatibility).

Security

## Security
- Never print, log or commit secrets; read them from environment variables listed in `.env.example`.
- Validate all external input at the boundary (`<validation library>`); parameterize every query.
- Every new endpoint checks authorization, not just authentication.
- Do not disable security linters or checks; flag the finding instead.

Database

## Database
- Schema changes only through new migrations in `<path>`; never edit merged migrations.
- Migrations must work while the previous app version is still running (expand/contract).
- Large-table changes: concurrent index creation, batched backfills, `lock_timeout`.

Frontend and accessibility

## Frontend
- Semantic HTML first; every interactive element is keyboard accessible with an accessible name.
- Text contrast at least 4.5:1; no layout breakage at 320 px width or 200% zoom.
- Images have width/height and alt text; the LCP image is never lazy-loaded.

Performance

## Performance
- Measure before and after any optimization and report both numbers.
- Watch for N+1 queries in list endpoints; use `<eager loading API>`.
- Do not add caching without stating the invalidation rule.

Documentation

## Docs
- User-visible changes update `README.md` or `docs/` in the same PR.
- Public functions have doc comments with an example.
- Add a CHANGELOG entry under Unreleased.

Working style

## Working style
- Restate the task; ask (with a proposed default) when something is ambiguous.
- Do what was asked and nothing more; list other problems you notice instead of fixing them.
- Before finishing, run the checks and report the exact commands and results; say what you could not verify.

Annotated walkthrough: the monorepo root file

Line by line, why the fullstack-monorepo root file is written the way it is:

Line Purpose
“Each app and package has its own AGENTS.md … nearest takes precedence” Tells every tool (and human) that local files exist and win locally
pnpm turbo run lint typecheck test --filter=...[origin/main] One command that runs exactly what CI runs for affected packages
--filter=@acme/api example Shows the syntax for one package so the agent does not run the whole repo
docker compose up -d with ports Prevents the most common “tests fail locally” confusion
“Packages import each other via workspace names” An invariant that linters often miss and agents often break
“Database schema changes only in packages/db” Routes the agent to the right nested file
“CI runs the same turbo command; run it locally first” Ties the definition of done to CI

What it deliberately does not contain: framework rules (those live in the app files), code style (the formatter handles it), and architecture history (that belongs in docs).

Generate a first draft with an agent

A prompt that produces a good starting point in most repositories (then edit it down):

Read this repository's manifests, CI configuration, Makefile/scripts, README and a few
representative source files. Draft an AGENTS.md under 120 lines with sections: one-line
summary, Commands (install, dev, test all, test one, lint, typecheck, build - only commands
you verified exist), Layout, Rules (only non-obvious ones, each with a reason), Known traps,
Boundaries (never / ask first), Done means. Do not include generic advice or anything a
formatter enforces. Mark anything you could not verify with TODO.

Then run python3 tools/agents_md_check.py . and resolve every TODO by hand.

Check your setup

python3 tools/agents_md_check.py /path/to/repo
Instruction files:
  AGENTS.md
  CLAUDE.local.md
  apps/web/AGENTS.md
CLAUDE.local.md: warning: [claude-shadow] Claude Code reads this instead of AGENTS.md (by default). Add '@AGENTS.md' to it, or remove it.
CLAUDE.local.md: warning: [claude-shadow] Claude Code reads this instead of apps/web/AGENTS.md (by default). Add '@AGENTS.md' to it, or remove it.
2 finding(s)
Rule Severity Finds
claude-shadow warning A CLAUDE.md/CLAUDE.local.md at or above an AGENTS.md that does not import it
override-sibling warning AGENTS.override.md and AGENTS.md in one directory (Codex reads only the override)
size-chain warning Combined AGENTS size from root to a directory over Codex’s default 32 KiB
empty warning Empty instruction files (skipped by Codex)
long warning A single file over 300 lines
no-commands warning No code-formatted commands
broken-link error Relative links to missing files
secret error Credentials in an instruction file

It also lists every instruction file it finds (AGENTS, CLAUDE, GEMINI, Copilot and Cursor files), which is a quick way to see what agents will read. Python 3.9+, no dependencies, --json for CI, exit code 1 on errors. Tests: python3 -m unittest discover -s tests -v.

Writing checklist

Anti-patterns

Anti-pattern Why it fails Instead
A 900-line file pasted from the wiki Important rules get lost; Codex may truncate the chain Short root file, nested files, links to docs
“IMPORTANT!!!” on every rule Emphasis stops meaning anything Reserve emphasis for one or two invariants
Commands that no longer exist Agent wastes turns, then guesses Re-verify commands after tooling changes; CI can run them
Contradictions between root and nested files Behavior becomes arbitrary Root holds cross-cutting rules only
Tool-specific syntax in AGENTS.md (@imports, frontmatter) Other tools show it as noise Keep AGENTS.md plain; put tool-specific parts in bridge files
A CLAUDE.local.md added to an AGENTS.md-only repo Claude Code stops reading AGENTS.md Import @AGENTS.md in it
Rules about one task Pollutes every future session Put one-off instructions in the prompt
Relying on AGENTS.md for safety Instructions guide; they do not enforce Use permissions, hooks, branch protection and CI for hard limits

FAQ

What is AGENTS.md? A plain Markdown file of instructions for AI coding agents, placed at the repository root (and optionally in subdirectories). It is supported by many tools, including OpenAI Codex, Cursor, GitHub Copilot’s coding agent, Gemini CLI (via configuration), Antigravity CLI, Aider, Jules, Zed, Warp and Claude Code.

Does AGENTS.md have a required format? No. Any headings work. Clear sections for commands, rules and boundaries make it easier for both agents and people.

AGENTS.md vs CLAUDE.md: which should I use? If your team uses several agents, make AGENTS.md the source of truth. Claude Code reads it when no CLAUDE.md exists; if you need Claude-specific instructions, add a CLAUDE.md that imports @AGENTS.md.

How long should AGENTS.md be? Short enough that every line matters: most good root files are 40-150 lines. Codex’s default combined limit across nested files is 32 KiB; Claude Code’s guidance for CLAUDE.md is under 200 lines.

Which file wins when there are several? In Codex, files are concatenated from the root down and closer files come later. In Copilot, the nearest AGENTS.md takes precedence. In all tools, the user’s explicit chat instructions override the file.

Should AGENTS.md be committed? Yes. It is project documentation. Keep personal preferences in your tool’s user-level file (~/.codex/AGENTS.md, ~/.claude/CLAUDE.md, ~/.gemini/GEMINI.md).

Can AGENTS.md include other files? Not as a standard feature. Claude Code and Gemini CLI support @path imports in their own files; for portability, link to docs with normal Markdown links and keep AGENTS.md self-contained.

Is AGENTS.md read by GitHub Copilot code review? Check GitHub’s documentation for your Copilot surface; path-specific .instructions.md files can target code review or the cloud agent with excludeAgent.

Where to go next

Contributing

New examples are welcome, especially for project types not covered yet (game engines, embedded, scientific computing, Salesforce, WordPress). An example should be realistic, under about 150 lines per file, use fictional project names, pass python3 tools/agents_md_check.py, and show at least one pattern worth copying. Corrections to the tool behavior tables need a link to the tool’s current documentation.

If this helped you, a star helps others find it.

More free resources

Part of the Ralpberry Labs open-source collection. See also Top 100 Open Source.