Claude Code Subagent Generator
Describe one well-defined job you want to hand off - reviewing PRs for security holes, writing unit tests, researching how something works across a codebase - and get back a complete .claude/agents/<name>.md you can drop straight into Claude Code. The AI writes the content; the name, the YAML and the tool allowlist are checked against the real subagent rules as you edit.
1. Describe the job you want to delegate
Plain language is fine. Think of one well-defined slice of work you would happily hand to a specialist and only read the summary of - that is exactly what a subagent is good at.
Or start from one of these
Your .claude/agents/<name>.md will appear here, fully editable, with the name and description checked against the real subagent constraints as you type.
What a subagent file actually contains
A subagent is one markdown file: YAML frontmatter on top, a markdown body below. The body is not a hint or an addendum - it is the subagent's entire system prompt, replacing Claude Code's default one for as long as that subagent runs. It also starts in its own context window, with none of your current conversation carried over, so everything it needs to know has to be written into that body.
Only two frontmatter fields are required. name uses lowercase letters and hyphens only, contains no colons, and must be unique across your subagents - it is the file name and how you call the subagent by hand. description is the field worth agonising over, because it is the only text Claude reads when deciding which subagent should get a task. Two subagents with vague descriptions will get each other's work.
Everything else is optional and this builder wires each one into the file for real: tools (a comma-separated allowlist - omit it to inherit every tool), disallowedTools (the denylist), model (sonnet, opus, haiku, fable, a full model ID, or inherit), permissionMode, maxTurns (a cap on agentic turns before it stops and returns partial output), skills (skill names preloaded into its context) and color, which is display only.
The single most valuable thing you can do with that list is keep tools narrow. A code reviewer that only holds Read, Glob, Grep cannot rewrite your branch while it is “helping”, no matter how the conversation goes. This tool cross-checks the allowlist against what your description says the subagent is for, and flags a read-only job that has somehow been handed Write, Edit or Bash.
Preguntas frecuentes
What is a Claude Code subagent, exactly?
A subagent is a specialist Claude instance that runs in its own separate context window with a different system prompt, so you can delegate a well-defined subtask to it and get back only the summary. It is defined by a single markdown file at .claude/agents/<name>.md: YAML frontmatter with a name and a description on top, and a body that becomes that subagent's complete system prompt. Because it works in an isolated context, the long, messy exploration it does - reading fifty files, running greps, chasing dead ends - never lands in your main conversation. Only its final report does. That isolation is the whole point: it keeps your primary context clean, and it lets you give a narrow, dangerous-if-misused job a narrow set of tools.
Claude Code agents vs skills - what is the difference?
A skill loads instructions into the conversation you are already having; a subagent starts a new conversation of its own. When a skill fires, its SKILL.md body is added to Claude's current context and Claude keeps working as itself, with everything it already knew. When a subagent fires, Claude spawns a separate instance with a blank context and a different system prompt, that instance works alone, and only its final message comes back. So reach for a skill when you want to teach Claude how to do something it will then do here - a house style, a checklist, a release procedure. Reach for a subagent when you want work done elsewhere and only want the conclusion: a big search you do not want cluttering your context, or a review you want performed by something that literally cannot edit your files. They also compose - a subagent can preload skills through its skills frontmatter field. A slash command is a third, simpler thing again: a saved prompt you fire by typing /name, run inline, with no isolation and no separate identity.
How do I create a subagent in Claude Code?
Create the folder with mkdir -p .claude/agents, save a markdown file in it named after the subagent, and reload Claude Code. The file needs YAML frontmatter with at least name (lowercase letters and hyphens only, no colons, unique) and description (when Claude should delegate to it), followed by the body that acts as its system prompt. Put it at .claude/agents/ inside the repo to commit it to git and share it with your team, or at ~/.claude/agents/ in your home folder to keep it personal across every project on your machine. If both exist with the same name, the project one wins inside that repo. This generator writes the whole file for you and shows the exact path and mkdir command for whichever scope you pick.
What frontmatter fields can a subagent use?
name and description are required. Optional fields include tools (a comma-separated allowlist of the tools this subagent may use, such as Read, Glob, Grep - omit it entirely and the subagent inherits every tool available), disallowedTools (the denylist counterpart), model (sonnet, opus, haiku, fable, a full model ID, or inherit to use whatever the main conversation is using), permissionMode (default, acceptEdits, auto, dontAsk, bypassPermissions or plan), maxTurns (a cap on how many agentic turns it may take before it stops and returns partial output), skills (a list of skill names preloaded into its context) and color (red, blue, green, yellow, purple, orange, pink or cyan, for display only). Rarer advanced fields also exist - mcpServers, hooks, memory, background, effort, isolation, initialPrompt and experimental.cacheTtl among them. This claude subagent yaml generator deliberately does not emit those: writing a field whose behaviour it cannot describe accurately would be worse than leaving it out, so add them by hand if you need them.
Why does the tools allowlist matter so much?
Because it is the only hard limit on what a subagent can do. Leave tools out and the subagent inherits everything the main conversation has, including MCP tools - fine for a trusted helper, needlessly risky for one whose entire job is to look and report. A security reviewer given Read, Glob, Grep physically cannot modify your working tree; the same reviewer with Bash and Write can. The rule of thumb is least privilege: grant the minimum that does the job, add Write and Edit only for a subagent that is supposed to change files, and add Bash only when it genuinely has to run something like a test suite. This builder flags the mismatch both ways - a review-shaped description holding write tools, and a fix-shaped description with no way to write anything.
How does Claude decide which subagent to use?
It matches the task against each subagent's description, so that string is your routing table. A description like 'Reviews code' gives Claude nothing to discriminate on and will either be picked for everything or nothing. Name the concrete triggers instead: 'Reviews changed code for security vulnerabilities - injection, missing authorisation, unsafe deserialization, leaked secrets. Use proactively after any change to auth or input handling, and whenever the user asks for a security review.' Saying 'use proactively' encourages automatic delegation; you can always override by asking for one by name - 'use the security-code-reviewer subagent to check this diff'. In a claude code multi-agent setup where several subagents overlap, the descriptions need to draw clear borders between them, which is why this generator warns live when yours reads generically or drops the when half.
What should the body of the file actually say?
Write it in the second person, addressed to the subagent, and treat it as a complete briefing rather than a note. It replaces Claude Code's default system prompt entirely and starts with a blank context, so it should establish who the subagent is, the ordered steps it works through, the hard rules and things it must never do, and - crucially - what its final report must contain. That last part is easy to forget and it is what makes a subagent useful or useless: the main conversation sees nothing but that final message, so it needs to be self-contained, name absolute file paths, and not refer to 'the file above' or anything else the reader never saw.
Two companions to this one: the Claude Skill Generator writes a SKILL.md that loads instructions into the conversation you are already in, and the AI Slash Command Generator writes the single-file /command version.