Subagent Generator
Generate a single custom subagent .md file.
- $29 Free
- 45 sec
- No signup
Name the agent and describe it
Pick its tools and write the prompt
Download the .md into .claude/agents/
You get: A valid .claude/agents/*.md subagent file, ready to run.
Define your subagent
code-reviewer.md
--- name: code-reviewer description: Reviews code changes for correctness, security, and style. Use when a diff or set of changes needs review before merge. tools: Read, Grep, Glob model: opus --- You are a focused Claude Code subagent. Role: Reviews code changes for correctness, security, and style. When invoked: 1. Read the relevant files and understand the task before acting. 2. Do only the work described above - stay in scope. 3. Report back concisely with what you did and any findings. Guardrails: - Never touch files outside the task's scope. - If something is ambiguous, state your assumption instead of guessing silently.
Save to .claude/agents/code-reviewer.md in your repo (or ~/.claude/agents/ for a personal agent).
What a Claude Code subagent file actually is
A subagent is just a markdown file with YAML frontmatter at the top and a system prompt in the body. The frontmatter tells Claude Code what the agent is called, when to use it, which tools it may touch, and which model runs it. The body is the agent's instructions - its role, its process, and its guardrails. That is the entire format. This generator fills in the frontmatter correctly and gives you a solid prompt scaffold so the file loads and runs on the first try.
The reason people get subagents wrong is not the concept - it is the small details. A missing dash in the frontmatter, a description that never says when to invoke the agent, or a tools list with a typo will all quietly break delegation. Generating the file removes those failure modes.
The frontmatter fields, explained
- name - a short kebab-case identifier the main session uses to call the agent (for example, code-reviewer). This becomes the filename too.
- description - what the agent does and, critically, when to use it. This is the field Claude Code reads to decide whether to delegate a task, so make the 'when' explicit.
- tools - a comma-separated list of the tools this agent may use. Omit this field entirely and the agent inherits all tools; name them and it is restricted to exactly that list.
- model - opus, sonnet, or haiku to pin the model, or leave it out (or set inherit) to use the main session's model.
The description drives delegation
Claude Code decides whether to hand a task to your subagent by reading its description. If it only says what the agent does but not when to use it, delegation gets flaky. Write it as 'Reviews diffs for security and style. Use when a change needs review before merge.'
Why you should scope the tools
Leaving the tools field off is the convenient default, but it grants the agent every tool - including Edit, Write, and Bash. For a read-only role like a reviewer or a researcher, that is a liability: the agent can start changing things it was never meant to touch. Naming the tools explicitly keeps a specialist a specialist. As a rule, give read-only roles Read, Grep, and Glob; give building roles Read, Edit, Write, and Bash; and add WebFetch only when the agent genuinely needs the internet.
Writing the system prompt body
- State the single responsibility in one sentence. An agent that does one thing well beats one that does five things adequately.
- Give it a short numbered process - what to read first, what to do, and how to report back. This keeps behavior consistent across invocations.
- Add guardrails: what it must not do, and what to do when something is ambiguous. 'State your assumption instead of guessing silently' prevents a whole class of quiet failures.
- Specify the output format if the caller depends on it. A reviewer that returns a bullet list of required changes is more useful than one that writes prose.
- Keep it tight. The body is loaded every time the agent runs, so every extra paragraph is a recurring token cost.
Project agents vs personal agents
Save the file to .claude/agents/ inside your repo to make it a project agent - it is committed with the code and shared with your whole team, so everyone gets the same reviewer or tester. Save it to ~/.claude/agents/ to make it a personal agent that follows you across every project. When a project agent and a personal agent share a name, the project one wins. For anything the team relies on, prefer the project location so the behavior is version-controlled.
How the main session uses it
Once the file exists, the main Claude Code session can delegate to the agent by name - either automatically, when the task matches the description, or explicitly when you ask it to use that agent. The subagent runs in its own fresh context with only its allowed tools, does the scoped work, and returns a result. Because its context is separate, it does not pollute your main session with intermediate noise, which is a large part of why subagents improve reliability on long tasks.
Common mistakes this generator prevents
- Frontmatter that is not valid YAML - a missing dash line or a stray colon that stops the file loading.
- A description that never says when to invoke the agent, so the main session never delegates to it.
- An over-permissioned agent that inherits Bash and Write when it only needed to read.
- A name with spaces or capitals that does not match the expected kebab-case identifier.
- A bloated system prompt that costs tokens on every run without improving behavior.
Frequently asked questions
Where does the generated file go?
Save it to .claude/agents/ in your repo to share it with your team, or to ~/.claude/agents/ to keep it personal across projects. The filename should match the name field, in kebab-case.
What happens if I leave the tools field blank?
The agent inherits every tool available in the session, including Edit, Write, and Bash. That is fine for a general helper but risky for a read-only role. Name the tools explicitly to restrict it.
Which model should I pick?
Use opus for reasoning-heavy roles like reviewers and planners, sonnet for most build and test work, and haiku for cheap mechanical tasks. Choose inherit to just use whatever the main session is running.
Why is the description so important?
Claude Code uses the description to decide when to delegate to the agent. If it only describes what the agent does but not when to use it, the main session often will not route tasks to it. Always include a clear 'use when' clause.
Can I write my own system prompt?
Yes. If you paste one into the system prompt field it is used verbatim. If you leave it blank, the generator writes a solid scaffold from your name, description, and role that you can refine.
Is this file the same as a slash command?
No. A subagent is a delegated assistant with its own context and tools, defined in .claude/agents/. A slash command is a saved prompt you trigger yourself, defined in .claude/commands/. Use the right tool for the job.
Liked this tool? The club is the next step.
Join Claude Code Club for $9/month. 650+ lessons, weekly updates, and the workflows behind every tool on this site.
- No experience needed
- Cancel anytime
- Updated weekly
