Sub-Agent vs. Slash Command: Which Do I Write?
Both are markdown-plus-frontmatter files Claude Code plugin authors write — but they behave differently. Here's how to choose.
The short answer
Write a slash command when you want a reusable, parameterised prompt that you (or Claude) can fire on demand — “do this specific thing now”. Write a sub-agent when you want a focused assistant that Claude can delegate a class of work to, often automatically — “whenever a situation like X comes up, hand it off to this specialist”. Slash commands are verbs; sub-agents are roles.
Side by side
| Sub-agent | Slash command | |
|---|---|---|
| File | agents/<name>.md | commands/<name>.md |
| Body is… | a system prompt for the agent | a prompt template that runs as a message |
| Invoked… | automatically (via description) or by name | by typing /name, or by Claude via the SlashCommand tool |
| Key frontmatter | name, description, tools, model, color | allowed-tools, argument-hint, description, model, disable-model-invocation |
| Takes arguments? | no (you describe the task in prose when delegating) | yes — $ARGUMENTS, $1, $2… |
| Runs shell / includes files? | only by calling tools at runtime | yes, inline — !`cmd` and @file in the body |
| Has its own context window? | yes — runs as a separate sub-task | no — expands into the current conversation |
Decision guide
Walk down this list; stop at the first one that matches.
- Do you want to type something short to kick off a known workflow? (
/commit,/changelog,/review-pr 123) — that's a slash command. Especially if it takes arguments or needs to inlinegit status/ a config file. - Do you want Claude to recognise a recurring kind of task and hand it to a specialist on its own? (“after writing code, get it reviewed”; “for any database migration, use the migration expert”) — that's a sub-agent. The
descriptionis the trigger. - Do you need the work isolated in its own context (so a long investigation doesn't flood the main conversation)? — sub-agent. Sub-agents run as separate sub-tasks and report back a summary.
- Is it really just a saved prompt you reuse a lot? — slash command. Don't reach for a sub-agent when a template will do.
They compose
The two aren't mutually exclusive. A common pattern: a slash command that does the mechanical setup, then explicitly invokes a sub-agent for the judgement-heavy part — e.g. /review-pr checks out the branch and runs the tests, then hands the diff to a code-reviewer agent. Build the pieces with the Claude Code Agent & Slash-Command Builder and wire them together.
Once you've decided
- Sub-agent: see what is a Claude Code sub-agent for the full file format.
- Slash command: see the slash-command frontmatter reference for every key and placeholder.
- Either way, the builder gives you a validated, copy-ready file.
Further Reading
- Claude Code: Subagents (official documentation)
Canonical reference for the sub-agent file format and delegation behaviour.
- Claude Code: Slash commands (official documentation)
Canonical reference for slash-command files, arguments, and the SlashCommand tool.