AGENTS.md vs CLAUDE.md vs Cursor rules
People searching for an AGENTS.md generator usually want one durable instruction file that keeps coding agents from repeating the same mistakes. The safest pattern is to make AGENTS.md the concise operational source of truth, then bridge tool-specific files to it when needed. That avoids maintaining three long, drifting instruction documents.
Codex has first-class AGENTS.md discovery. OpenAI's Codex documentation says it reads AGENTS.md files before work starts, layers global and project guidance, and lets closer files override broader ones. Claude Code uses memory files such as CLAUDE.md, and its documentation recommends using `/memory` to verify what loaded. Cursor uses project rules, commonly stored under `.cursor/rules`, and the older `.cursorrules` format has been treated as a legacy path in Cursor docs.
| Tool |
Primary guidance file |
Best use |
Risk to avoid |
| Codex |
AGENTS.md and optional nested overrides. |
Repository commands, test expectations, deployment boundaries, and local conventions. |
Overly large files that hit instruction-size limits or conflict with deeper directory rules. |
| Claude Code |
CLAUDE.md, often importing or summarizing AGENTS.md. |
Small project memory, recurring corrections, model/workflow hints. |
Long stale memory files that consume context on every turn. |
| Cursor |
.cursor/rules/*.mdc or project rules. |
Scoped rules for frameworks, directories, test commands, and coding standards. |
A broad always-on rule set that makes every task carry irrelevant context. |
Recommended AGENTS.md structure
A useful AGENTS.md should read like an internal runbook for an agent that can edit files. It should not be a marketing README, a full architecture book, or a copy of framework documentation. The generated template uses six sections because they map to the moments where agents need concrete direction: project context, commands, coding rules, safety/data rules, verification, and final response expectations.
- Project context: stack, app type, ownership boundaries, and where the important code lives.
- Commands: install, lint, test, build, local server, and deployment check commands.
- Coding rules: concrete local rules such as component patterns, API helpers, database migration policy, and formatting expectations.
- Safety and data: files or directories never to expose, secrets handling, production deployment rules, and billing-sensitive actions.
- Verification: what must be run for frontend, backend, docs, migrations, or generated assets.
- Final response: what the agent should report back, including changed files and checks run.
Examples by project type
For a static website or pSEO site, AGENTS.md should mention canonical URL rules, sitemap updates, analytics/ad placement constraints, and the public-only deploy directory. For a React or Next.js app, it should include package manager, build command, component conventions, route structure, and accessibility checks. For a backend, the file should make database migration, auth, secrets, and test fixture rules explicit. For a monorepo, keep the root file short and add path-scoped guidance near specialized packages.
The generator intentionally creates a compact file. If the output grows beyond a few hundred lines, split it. A root AGENTS.md can hold global rules, while `apps/web/AGENTS.md`, `services/billing/AGENTS.md`, or `.cursor/rules/frontend.mdc` can hold scoped rules. Smaller scoped rules are easier to keep current and less likely to pollute unrelated tasks.
Maintenance workflow
- Add a rule only after the same correction happens more than once.
- Remove rules that no longer match the codebase or CI pipeline.
- Keep commands copied from package scripts or CI, not memory.
- After changing stack, deployment, ads, analytics, billing, or auth, update AGENTS.md in the same pull request.
- Ask the agent to list active instructions before a risky refactor so you can catch stale guidance early.
FAQ
Should I commit AGENTS.md?
For project-specific instructions, yes. Versioning the file keeps agent behavior aligned with code changes and lets teammates review changes to commands, safety rules, and verification policy.
Can AGENTS.md contain private deployment notes?
It can contain operational rules, but not secrets. Do not include API keys, cookies, account recovery details, private customer data, or anything that would be harmful if committed or accidentally deployed.
How long should AGENTS.md be?
Short enough that an agent can use it on every task. A practical root file is often 50-150 lines. If a rule only applies to one directory or framework, put it in a scoped file instead of the root.