subagents-vs-skills
Research Date: 2025-11-04
Overview
Claude Code provides two distinct extensibility mechanisms for specialized capabilities: Sub-Agents and Skills. While they may seem similar at first glance, they serve different purposes and operate in fundamentally different ways.
Sub-Agents
What They Are
Sub-agents are specialized AI assistants that Claude Code can delegate tasks to. Think of them as independent AI personalities, each with their own:
- Separate context window
- Custom system prompt
- Configurable tool access
- Specific domain expertise
Key Characteristics
Delegation Model: Sub-agents operate as separate entities that handle tasks independently and return results to the main conversation.
Invocation: Can be triggered in two ways:
- Automatically - Claude decides when a task matches a sub-agent’s expertise
- Explicitly - User or Claude requests a specific sub-agent by name
Configuration: Defined as Markdown files with YAML frontmatter stored in:
.claude/agents/(project-level, team-shared)~/.claude/agents/(user-level, personal)
Configuration Structure
---name: agent-identifierdescription: When and why this agent should be usedtools: Tool1, Tool2, Tool3 # Optional - restricts tool accessmodel: sonnet # Optional - defaults to sonnet---
System prompt describing the agent's role and behaviorUse Cases
- Specialized expertise: Code review, debugging, security analysis
- Context preservation: Keeps main conversation focused on high-level objectives
- Security: Grant specific tools only to specific sub-agents
- Reusability: Share configured sub-agents across projects and teams
- Complex workflows: Parallel processing of independent tasks
Examples
- Code reviewer that analyzes PRs
- Test generator that creates comprehensive test suites
- Diagram generator that creates architecture visualizations
- Collaboration analyst that tracks development patterns
Skills
What They Are
Skills are modular capabilities that extend Claude’s functionality through organized folders containing:
- A
SKILL.mdfile defining the skill - Optional supporting resources (scripts, templates, etc.)
Key Characteristics
Invocation Model: Skills are model-invoked - Claude autonomously decides when to use them based on context and the skill’s description. This is a critical difference from:
- Slash commands (user-invoked with
/command) - Sub-agents (explicitly or automatically delegated)
Discovery: Claude automatically discovers and activates skills when they’re contextually relevant to your request.
Storage Locations:
~/.claude/skills/- Personal skills for individual workflows.claude/skills/- Project skills shared with teams via git- Plugin skills - Bundled with installed plugins
Configuration Structure
# SKILL.md structure---description: Critical field that helps Claude discover when to use the skill---
Detailed instructions on how to execute the skillUse Cases
- Team collaboration: Share expertise across teams via git
- Workflow automation: Reduce repetitive prompting for common tasks
- Capability extension: Customize Claude for specific workflows
- Complex problem-solving: Compose multiple skills together
- Consistent patterns: Enforce team conventions automatically
Examples
- PDF processing skill that extracts and analyzes content
- Database migration skill that handles schema changes
- Documentation generation that follows team standards
- API endpoint creation following architectural patterns
Key Differences
| Aspect | Sub-Agents | Skills | Slash Commands |
|---|---|---|---|
| Nature | Separate AI assistants | Modular capabilities | User-defined prompts |
| Invocation | Explicit or automatic delegation | Automatic discovery by Claude | User types /command |
| Context | Own separate context window | Uses main conversation context | Uses main conversation context |
| Autonomy | Fully autonomous entities | Capabilities within main Claude | Expands to prompt |
| Tool Access | Can be restricted per agent | Uses available tools in context | Can specify allowed tools |
| Model | Can specify different models | Uses current session model | Can specify model |
| Can Invoke | ❌ Nothing (leaf nodes) | ✅ Sub-agents & skills | ✅ Sub-agents & skills |
| Return Value | Returns complete result | Executes within conversation | Expands to full prompt |
| Best For | Complex, independent tasks | Workflow automation & patterns | User workflows & shortcuts |
When to Use Which?
Choose Sub-Agents When:
- Task requires specialized, isolated expertise
- You need parallel processing of independent work
- Security requires restricted tool access
- Task needs its own context window to avoid cluttering main conversation
- You want to specify a different model for specific tasks
- Building reusable AI personalities for your team
Choose Skills When:
- Automating repetitive workflows
- Encoding team conventions and patterns
- Extending Claude’s capabilities for specific domains
- Creating discoverable, composable capabilities
- Reducing need to repeat similar prompts
- Building expertise library for team collaboration
Integration Patterns
Commands and skills can orchestrate sub-agents (but sub-agents cannot call other sub-agents or skills):
Pattern 1: Command Orchestration
- User invokes command (
/build-feature) - Command delegates to sub-agents for specialized work
- Sub-agents execute in isolated contexts
- Results return to command which continues the workflow
Example: A /build-api command might delegate to a “code-generator” sub-agent for implementation, then to a “test-generator” sub-agent for tests.
Pattern 2: Skill Orchestration
- Claude discovers skill based on user request
- Skill invokes sub-agents for specialized processing
- Sub-agents process their respective tasks
- Results return to skill which completes the workflow
Example: A “feature-implementation” skill might invoke a “test-generator” sub-agent to create comprehensive tests, then continue with implementation.
Pattern 3: Skill Composition
- Skill A is discovered for a task
- Skill A invokes Skill B for a sub-task
- Both skills collaborate to complete the workflow
Example: An “api-endpoint” skill might invoke a “validation-pattern” skill to ensure proper input validation.
Configuration Examples
Sub-Agent Example
---name: security-auditordescription: Performs security analysis on code changes, checking for OWASP vulnerabilitiestools: Read, Grep, Glob, WebFetchmodel: sonnet---
You are a security expert focused on identifying vulnerabilities.Analyze code for: SQL injection, XSS, CSRF, authentication issues...Skill Example
---description: Generate REST API endpoints following team architecture patterns---
# API Endpoint Generation Skill
When generating API endpoints:1. Check existing patterns in src/api/2. Follow team conventions for error handling3. Include input validation4. Add comprehensive tests5. Update API documentationReferences
Can Sub-Agents Use Skills or Other Sub-Agents?
TL;DR: No. Based on testing, sub-agents CANNOT execute skills or other sub-agents.
Tested Behavior (2025-11-04)
Sub-Agents CANNOT execute:
- ❌ Other sub-agents
- ❌ Skills
Commands CAN execute:
- ✅ Sub-agents (via Task tool)
- ✅ Skills (via Skill tool)
Skills CAN execute:
- ✅ Other sub-agents (via Task tool)
- ✅ Other skills (via Skill tool)
Architecture Hierarchy
┌─────────────────────────────────────┐│ Main Claude Conversation ││ - Can invoke commands (/) ││ - Can invoke skills (auto) ││ - Can invoke sub-agents (Task) │└─────────────────────────────────────┘ │ ├──────────────────┬──────────────────┐ │ │ │ ┌────▼────┐ ┌──────▼──────┐ ┌─────▼──────┐ │Commands │ │ Skills │ │ Sub-Agents │ │ (/) │ │ (auto-disc) │ │ (Task) │ └────┬────┘ └──────┬──────┘ └─────┬──────┘ │ │ │ │ Can invoke: │ Can invoke: │ Can invoke: │ • Sub-agents ✅ │ • Sub-agents ✅ │ • Nothing ❌ │ • Skills ✅ │ • Skills ✅ │ └──────────────────┴──────────────────┘What This Means
Sub-Agents are “Leaf Nodes”:
- Sub-agents are terminal executors in the call hierarchy
- They handle tasks independently but cannot delegate further
- They have access to basic tools (Read, Write, Bash, Grep, etc.) but not orchestration tools (Task, Skill)
Commands and Skills are “Orchestrators”:
- Both can compose workflows by delegating to sub-agents and skills
- They sit higher in the execution hierarchy
- They enable complex multi-step automation
Practical Implications
❌ This Won’t Work:
# Sub-agent trying to use skills---name: feature-builderdescription: Build complete featurestools: Read, Write, Skill # Skill tool won't work in sub-agents---✅ This Will Work:
<!-- Slash command that orchestrates -->---description: Build complete features---
Use the "api-pattern" skill to get team conventions.Then delegate to the "code-generator" sub-agent to implement.Finally use the "test-generator" sub-agent to create tests.Corrected Integration Patterns
Pattern 1: Command → Sub-Agent
User types: /build-feature auth ↓Command executes ↓Delegates to "feature-builder" sub-agent ↓Sub-agent implements using basic tools ↓Returns to command → Returns to userPattern 2: Skill → Sub-Agent
Main Claude detects need for feature implementation ↓Discovers "feature-implementation" skill ↓Skill orchestrates by delegating to sub-agents ↓Sub-agents execute their specialized tasks ↓Returns to skill → Returns to main ClaudePattern 3: Command → Skill → Sub-Agent
User types: /complex-workflow ↓Command invokes skill for orchestration logic ↓Skill delegates to multiple sub-agents ↓Sub-agents execute in parallel/sequence ↓Results flow back through skill → command → userDesign Implications
For Sub-Agents:
- Keep them focused and specialized
- Don’t expect them to orchestrate complex workflows
- Use them as expert executors for specific tasks
- Provide clear, complete system prompts
For Orchestration (use Commands or Skills):
- Use commands for user-invoked workflows
- Use skills for auto-discovered patterns
- Both can compose multiple sub-agents
- Both can leverage other skills
Why This Design Makes Sense
- Separation of Concerns: Sub-agents focus on execution; commands/skills handle orchestration
- Prevents Recursion Issues: Avoids infinite loops of agents calling agents
- Clear Hierarchy: Simpler mental model for building workflows
- Context Management: Prevents deeply nested contexts
- Performance: Limits the depth of agent delegation chains
Notes
- Description is critical: For both sub-agents and skills, the description field determines when they’re activated
- Tool restriction: Sub-agents can have restricted tool access for security; skills use whatever tools are available
- Context management: Sub-agents help manage context by processing tasks separately
- Team sharing: Both can be shared via git in project directories
- Plugins: Can bundle both sub-agents and skills for distribution
- Execution hierarchy: Sub-agents are leaf nodes and CANNOT invoke skills or other sub-agents (tested 2025-11-04)
- Orchestration: Use commands or skills when you need to compose multiple sub-agents or skills together