Learning how to write AGENTS.md well is less about literary style and more about deciding what must survive across tools and sessions. A strong root-level AGENTS.md is a skimable checklist: toolchain pins, layout pointers, verification commands, and absolute refusals. A weak one dumps ticket history, generic “be careful” advice, or three conflicting copies of the same convention that agents will pick from at random.

01

Independence note

02

Why a reusable AGENTS.md exists

Coding agents forget house style between chats. Humans forget which command is canonical after a toolchain bump. When more than one host touches the same repository—IDE agents, CLI agents, cloud runners— teams often want a single human-readable file that answers: How do we build? Where do routes live? What must the agent never touch?AGENTS.md (or a similarly named root agent notes file) is that shared checklist when your tooling loads it.

  • Stack pin: Node/pnpm versions, package manager, SSG vs SSR assumptions.
  • Source of truth: which file registers routes, sitemap, or feature flags.
  • Done checks: the exact commands reviewers will run.
  • Non-goals: deploy, DNS, secret files, out-of-scope packages.

Put facts that are true for the whole repo—not last week’s bug narrative. Session-level craft still belongs in a good agent prompt. The broader delivery loop lives in the coding agent workflow section of the agent engineering series.

03

An AGENTS.md outline you can copy

Start from this skeleton. Delete sections you do not need; fill paths and commands with your repository’s reality. Treat it as a template / examples starter—not a product-mandated schema.

# AGENTS.md — reusable instructions for coding agents

## Stack
- Node 22+, pnpm (see package.json packageManager if present)
- Hono JSX + Vite + Hono SSG → static dist/; no server runtime in prod

## Layout
- Routes + sitemap: src/index.tsx pages[]
- Pages: src/pages/*.tsx
- Static CSS/JS/images: public/

## Commands
- Dev: pnpm dev
- Typecheck: pnpm check
- Build: pnpm run build
- Do not deploy unless explicitly asked

## Conventions
- 4-space indent
- Mirror existing EN how-to pages for new docs
- Unique Title/Description; one H1 with the target phrase
- Bidirectional Related reading links to sibling guides

## Non-goals / safety
- No wrangler/Cloudflare/DNS changes unless requested
- No secrets in prompts, commits, or screenshots
- Do not invent indexed URLs beyond the task list

## When stuck
- Ask; do not invent a second router, package manager, or deploy path
- Prefer reading a sibling page before inventing a new layout

If another tool needs a short stub, point it back here instead of duplicating paragraphs. Parallel Claude-oriented memory is covered in how to write CLAUDE.md; editor rule files in cursor rules examples.

04

How to write AGENTS.md well

  1. Lead with verification. Put build/test commands near the top so agents see them early.
  2. Name files, not vibes. “Edit src/index.tsx pages[]” beats “update routing somehow.”
  3. Write non-goals as hard stops. Deploy, DNS, and secret files are classic accidental “helpful” edits.
  4. Link exemplars. Point at one good page or PR; agents copy structure better than abstract essays.
  5. Keep it skimable. Short bullets over paragraphs; humans must maintain this file.
  6. Separate session briefs. Ticket goals and acceptance checks belong in the prompt—see good agent prompts and cursor agent tips.

05

AGENTS.md vs CLAUDE.md vs Cursor rules (short)

All three can encode durable repo contracts. The difference is packaging and which host loads the file—not a magical superiority of one filename.

SurfaceBest fitWatch-outs
AGENTS.mdMulti-tool teams wanting one human-readable “how we work with agents” fileName and auto-load vary by product; easy to become a second README
CLAUDE.mdRepos that standardize on Claude Code-style sessionsTicket narratives go stale—see how to write CLAUDE.md
Cursor rulesIDE-heavy workflows needing always-on vs path-scoped contractsOver-long or contradictory rules—see cursor rules examples

For a fuller side-by-side—including when to stub vs mirror—read AGENTS.md vs CLAUDE.md vs Cursor rules. Prefer one clear statement of each convention rather than three novels.

06

Keep it alive

  • After a toolchain change (Node, package manager, CI), update commands the same day.
  • When the agent invents a wrong path twice, add an explicit pointer—then delete fluff elsewhere to stay short.
  • Review AGENTS.md in PRs that change conventions, not only in “docs” PRs.
  • Do not paste entire API references; link or point at the file that owns the schema.
  • Re-verify discovery paths after tool upgrades—front matter and loaders evolve.

Related reading: AGENTS.md vs CLAUDE.md vs Cursor rules · copilot-instructions.md examples · How to write CLAUDE.md · How to write GEMINI.md · Cursor rules examples · Cursor agent tips · Good agent prompts · Cursor skills examples · Agent engineering notes

07

FAQ

Is AGENTS.md the same as a system prompt?

Conceptually it is project-scoped durable instruction, not a one-shot chat message. Product loading rules differ by tool; this guide treatsAGENTS.md as a committed reusable instructions file you maintain like README conventions.

Should every detail go into AGENTS.md?

No. Ticket goals, temporary experiments, and “only for this customer” notes belong in the session prompt. Put durable contracts inAGENTS.md; put acceptance for this change in the prompt.

How does AGENTS.md relate to CLAUDE.md and Cursor rules?

All three can encode durable guidance. Many multi-tool repos useAGENTS.md as the human source of truth and keep thin tool-specific stubs. Claude Code-oriented workflows often invest in CLAUDE.md; Cursor-oriented teams use .cursor/rules. Prefer one clear statement of each convention. Full comparison: AGENTS.md vs CLAUDE.md vs Cursor rules.

What length is “enough”?

Enough that a new agent session can build, find the route registry, and avoid forbidden actions without guessing—usually one to two screens of dense bullets, not a novel. If nobody wants to update it, it is too long.

Is this official product guidance?

No. This is an unofficial engineering note on codemo.fun. Product docs, pricing, and support remain with their vendors. Re-check file discovery after upgrades before treating any path as permanent.