{"slug": "how-to-write-an-agents-md-for-codex-claude-code-and-cursor", "title": "How to Write an AGENTS.md for Codex, Claude Code, and Cursor", "summary": "A developer released a guide and starter kit for writing AGENTS.md files that give AI coding agents like Codex, Claude Code, and Cursor the context they need to work safely. The guide emphasizes short, specific instructions with exact commands, explicit boundaries for risky surfaces, and a definition of done based on evidence. The developer also offers a free AgentBrief starter and a paid Pro kit with templates and playbooks.", "body_md": "An AI coding agent can only work safely with the context it receives. A good `AGENTS.md`\n\ngives that context once, close to the code, so every task starts with the same commands, boundaries, and definition of done.\n\nThis guide shows a practical structure you can use with Codex, Claude Code, Cursor, GitHub Copilot, and other repository-aware coding agents.\n\nAn `AGENTS.md`\n\nis not a long prompt or generic advice. It should answer the questions an experienced contributor would ask before editing:\n\nThe best file is short enough to scan and specific enough to execute.\n\nName the important directories and what owns them. Avoid listing every folder. Focus on the paths that determine where an agent should inspect or edit.\n\n```\napp/     product routes and UI\ndb/      schema and database access\nworker/  deployment entry point\ntests/   focused regression coverage\npublic/  static assets only\n```\n\nAdd a sentence about where business logic belongs and where it does not. This prevents an agent from placing a quick fix in the wrong layer.\n\nNever say “run the tests” when the repository has several test modes. Provide exact commands and explain when each one applies.\n\n```\nnpm install\nnpm run lint\nnpm test -- path/to/relevant.test.ts\nnpm run build\n```\n\nIf a command requires credentials, external services, or a long-running environment, say so. Agents should not guess at missing access or silently skip validation.\n\nMake risky surfaces explicit. Common examples include authentication, payment flows, migrations, deployment files, generated code, lockfiles, analytics contracts, and public APIs.\n\nA useful rule is concrete:\n\nDo not edit generated migrations by hand. Create a new migration and include a rollback note.\n\nA weak rule is vague:\n\nBe careful with the database.\n\nSpecific boundaries reduce accidental scope expansion and make review faster.\n\nDescribe the smallest reliable sequence for a task:\n\nThis workflow matters because coding agents often optimize for producing code quickly. Your repository instructions should optimize for producing verified results.\n\nA definition of done should describe evidence, not confidence:\n\nIf a validation step is impossible, require the agent to say why. An honest limitation is more useful than a false green check.\n\nLarge repositories may need more than one instruction file. Keep repository-wide rules at the root, then add narrower instructions inside high-risk or specialized areas such as payments, infrastructure, or mobile apps.\n\nThe closer file can refine commands and guardrails without repeating the entire root document. Avoid contradictions: more specific rules should clarify the general workflow, not replace its safety standards.\n\nA practical `AGENTS.md`\n\nshould reduce decisions the agent must invent while preserving the decisions that belong to the developer.\n\nUse these sections as a first draft:\n\nThen replace every generic sentence with evidence from the repository itself.\n\nYou can inspect the [free AgentBrief starter and public release](https://github.com/agentbriefstudio/agentbrief) before buying anything.\n\nIf you want a larger reusable library, [AgentBrief Pro](https://payhip.com/b/TCHaM) includes 18 AGENTS.md templates, 12 task briefs, 8 recovery playbooks, and 5 quality gates. It is an editable Markdown kit with instant delivery for **$25**.\n\nIf you prefer a repository-specific result, the [AgentBrief site](https://agentbrief-launch.groovy-vine-6579.chatgpt.site) links to a fixed-scope custom AGENTS.md service delivered in 24 hours.", "url": "https://wpnews.pro/news/how-to-write-an-agents-md-for-codex-claude-code-and-cursor", "canonical_source": "https://dev.to/agentbriefstudio/how-to-write-an-agentsmd-for-codex-claude-code-and-cursor-4l06", "published_at": "2026-08-11 01:12:24+00:00", "updated_at": "2026-08-11 01:45:56.299432+00:00", "lang": "en", "topics": ["ai-agents", "developer-tools", "ai-tools"], "entities": ["Codex", "Claude Code", "Cursor", "GitHub Copilot", "AgentBrief"], "alternates": {"html": "https://wpnews.pro/news/how-to-write-an-agents-md-for-codex-claude-code-and-cursor", "markdown": "https://wpnews.pro/news/how-to-write-an-agents-md-for-codex-claude-code-and-cursor.md", "text": "https://wpnews.pro/news/how-to-write-an-agents-md-for-codex-claude-code-and-cursor.txt", "jsonld": "https://wpnews.pro/news/how-to-write-an-agents-md-for-codex-claude-code-and-cursor.jsonld"}}