From claude-code-tools
Expert guidance for creating Claude Code subagents and multi-agent workflows. Use when designing new subagents, configuring agent tools/permissions, implementing orchestration patterns, or troubleshooting agent delegation.
How this skill is triggered — by the user, by Claude, or both
Slash command
/claude-code-tools:creating-agentsThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Expert guidance for designing and implementing Claude Code subagents based on Anthropic's official specification and industry best practices.
examples/real-world-agents.mdreferences/anti-patterns.mdreferences/official-spec.mdreferences/orchestration-patterns.mdreferences/tool-permissions.mdtemplates/code-reviewer.mdtemplates/debugger.mdtemplates/domain-expert.mdtemplates/researcher.mdworkflows/audit-existing-agent.mdworkflows/create-code-writer-agent.mdworkflows/create-read-only-agent.mdworkflows/create-research-agent.mdExpert guidance for designing and implementing Claude Code subagents based on Anthropic's official specification and industry best practices.
Subagents solve three fundamental problems:
Main conversation context is precious. Subagents isolate verbose operations (test runs, documentation fetches, log analysis) and return only summaries.
Without subagents: Running tests consumes 50K+ tokens in your main context With subagents: Test output stays in subagent context; you get a 500-token summary
Launch multiple subagents simultaneously for independent tasks:
Research the authentication, database, and API modules in parallel using separate subagents
Each explores its area independently, then Claude synthesizes findings.
A single agent handling everything becomes a "jack of all trades, master of none." As instruction complexity increases, reliability decreases. Subagents enable focused expertise with minimal tool access.
Claude automatically delegates based on each subagent's description field. Write clear descriptions that include:
Good description:
description: Reviews code for quality, security, and best practices. Use proactively after code changes or when user mentions review, audit, or code quality.
Bad description:
description: Helps with code
Each subagent should excel at ONE specific task. Don't create a "helper" agent that does everything.
Good: code-reviewer, test-runner, doc-researcher
Bad: general-helper, code-assistant, utility-agent
Grant only the tools necessary for the task:
| Role | Recommended Tools |
|---|---|
| Reviewer/Auditor | Read, Grep, Glob |
| Researcher | Read, Grep, Glob, WebFetch, WebSearch |
| Implementer | Read, Write, Edit, Bash, Glob, Grep |
| Domain Expert | Read, Grep, Glob + domain-specific |
See references/tool-permissions.md for detailed guidance.
The markdown body becomes the subagent's system prompt. Be specific about:
| Field | Required | Description |
|---|---|---|
name | Yes | Unique identifier (lowercase, hyphens) |
description | Yes | When Claude should delegate |
tools | No | Tools the agent can use (inherits all if omitted) |
disallowedTools | No | Tools to explicitly deny |
model | No | Model to use (default: inherit) |
permissionMode | No | Permission handling mode |
skills | No | Skills to preload into context |
hooks | No | Lifecycle hooks for this agent |
See references/official-spec.md for complete specification.
Multiple agents explore different areas simultaneously:
Use subagents to research authentication patterns, database schema, and API design in parallel
Best for: Independent research tasks, codebase exploration, documentation gathering.
Chain agents where each builds on previous results:
First use code-reviewer to find issues, then use debugger to fix them
Best for: Review-then-fix workflows, multi-stage processing.
A lead agent decomposes tasks and delegates to specialists:
Analyze this feature request and delegate implementation to appropriate specialists
Best for: Complex features, large-scale refactoring.
See references/orchestration-patterns.md for detailed patterns.
Avoid these mistakes when creating agents:
| Anti-Pattern | Problem | Solution |
|---|---|---|
| Vague description | Claude doesn't know when to delegate | Include specific trigger keywords |
| Over-broad tools | Security risk, unfocused behavior | Grant minimal necessary permissions |
| No verification | Can't tell if agent succeeded | Include verification steps in prompt |
| Premature complexity | Multi-agent when single suffices | Start simple, add agents as needed |
| Generic naming | Hard to discover and delegate | Use specific, task-focused names |
See references/anti-patterns.md for detailed guidance.
Choose by agent type:
Ready-to-use agents you can customize:
# Test delegation
Use the [agent-name] to [task description]
# Test automatic delegation (if description says "use proactively")
[Task that should trigger the agent]
Check the agent has exactly the tools it needs, no more:
Use [agent-name] to describe what tools you have access to
If you set model: haiku for speed, ensure instructions are clear enough:
| Location | Scope | Use Case |
|---|---|---|
.claude/agents/ | Current project | Team-shared, version-controlled |
~/.claude/agents/ | All your projects | Personal agents |
--agents CLI flag | Current session | Testing, automation |
Plugin agents/ | Where plugin enabled | Distributed via plugin |
Higher-priority locations override lower when names conflict.
See examples/real-world-agents.md for battle-tested agents including:
A well-designed agent:
Research for this skill was conducted from multiple authoritative sources:
npx claudepluginhub nilpath/nilpath-marketplace --plugin claude-code-toolsClaude Code subagent lifecycle: creation, configuration, evaluation, and troubleshooting. Invoke whenever task involves any interaction with Claude Code subagents — designing, debugging, iterating, or deciding when to delegate work to isolated agent contexts.
Create custom agents for Claude Code including YAML frontmatter, system prompts, tool restrictions, and discovery optimization. Use when creating, building, or designing agents, or when asked about agent creation, subagent configuration, Task tool delegation, or agent best practices.
Guides creating, configuring, and orchestrating Claude Code subagents and Task tool. Covers prompts, tools, models, file structures, and multi-agent workflows.