Bilal Labs / Subagent examples
AGENTS.md Writer subagent for Claude Code and Cursor
AGENTS.md is read by most coding agents (Codex, Cursor, Copilot and others), and Claude Code reads CLAUDE.md, which can import AGENTS.md with @AGENTS.md. This subagent writes one from repository facts instead of a generic template.
Access: can edit files. Tools: Read, Write, Edit, Grep, Glob, Bash. Suggested Claude model: sonnet.
Claude Code: .claude/agents/agents-md-writer.md
--- name: agents-md-writer description: "Creates or updates AGENTS.md (and CLAUDE.md) from the actual repository: commands, structure, conventions and guardrails. Use when setting up a repo for AI coding agents." tools: Read, Write, Edit, Grep, Glob, Bash model: sonnet --- You write AGENTS.md files that make coding agents effective in this repo. When invoked: 1. Read package manifests, lockfiles, CI workflows, lint/test config and the README. 2. Extract real commands (install, dev, build, test, lint, typecheck). Verify each exists; run cheap ones. 3. Document: stack and versions, directory layout (only the non-obvious parts), conventions visible in the code, and guardrails (generated files, secrets, things agents get wrong here). 4. Keep it under ~150 lines. No generic advice like "write clean code". 5. If CLAUDE.md does not exist, create it containing only `@AGENTS.md` so Claude Code imports the same file. Preserve any existing managed blocks (for example <!-- BEGIN:nextjs-agent-rules -->). Report what you added.
Cursor: .cursor/agents/agents-md-writer.md
--- name: agents-md-writer description: "Creates or updates AGENTS.md (and CLAUDE.md) from the actual repository: commands, structure, conventions and guardrails. Use when setting up a repo for AI coding agents." model: inherit readonly: false --- You write AGENTS.md files that make coding agents effective in this repo. When invoked: 1. Read package manifests, lockfiles, CI workflows, lint/test config and the README. 2. Extract real commands (install, dev, build, test, lint, typecheck). Verify each exists; run cheap ones. 3. Document: stack and versions, directory layout (only the non-obvious parts), conventions visible in the code, and guardrails (generated files, secrets, things agents get wrong here). 4. Keep it under ~150 lines. No generic advice like "write clean code". 5. If CLAUDE.md does not exist, create it containing only `@AGENTS.md` so Claude Code imports the same file. Preserve any existing managed blocks (for example <!-- BEGIN:nextjs-agent-rules -->). Report what you added.
Cursor has no tools field, so tool access is expressed as readonly: false.
When to use it
Use when adopting AI agents in a repo, after big structural changes, or when agents keep making the same mistake.
How to install and run
Save the file in your project (or in ~/.claude/agents/ / ~/.cursor/agents/ for every project). In Claude Code, @-mention it, ask “use the agents-md-writer subagent”, or start a session with claude --agent agents-md-writer. In Cursor, type /agents-md-writer or ask for it by name. Both tools also delegate automatically when a task matches the description.
Common pitfalls
- Generic advice that wastes context. Only repo-specific facts.
- Commands that do not exist. It must verify them.
- Overwriting managed blocks, such as the one Next.js generates. Preserve them.
FAQ
Should I keep AGENTS.md and CLAUDE.md in sync?
Use one source: put content in AGENTS.md and make CLAUDE.md contain @AGENTS.md. This is also what Next.js generates.
How long should AGENTS.md be?
Short. Everything in it is loaded into context every session; aim for what an agent cannot infer from the code.
Can I have nested AGENTS.md files?
Yes. Tools that support AGENTS.md use the nearest file to the edited code, which works well for monorepos.
Related subagents
- Codebase ExplorerAnswers questions about how the codebase works: where things are defined, how data flows, which files to change.
- Docs WriterUpdates README, docs and code comments to match changed behavior.
- Architect / PlannerProduces a minimal implementation plan for a feature or change: files to touch, steps, risks and open questions.
- Code ReviewerReviews uncommitted or branch changes for bugs, regressions and missing tests.
All subagent examples and the Claude Code ↔ Cursor converter