Creating and Managing Sub-agents in Claude Code. Design agent personas, define proactive triggers, set tool permissions, structure agent files...
| Field | Value |
|---|---|
| Version | 1.0.0 |
| Tier | Ops |
| Auto-load | When creating or managing sub-agents |
Sub-agent μμ± λ° κ΄λ¦¬λ₯Ό μν μ 체 κ°μ΄λλ₯Ό μ 곡ν©λλ€. Agent persona μ€κ³, proactive trigger μ μ, tool κΆν μ€μ , agent νμΌ κ΅¬μ‘°ν λ°©λ²μ λ€λ£Ήλλ€.
Sub-agents are specialized Claude instances with independent context, custom prompts, and restricted tool access. They handle deep analysis, parallel work, and autonomous tasks.
Location: .claude/agents/
---
name: agent-name
description: Use PROACTIVELY for [specific trigger conditions]
tools: Read, Write, Edit, Glob, Grep, Bash(git:*)
model: sonnet
---
# Agent Name β Specialist Role
Brief description of agent expertise.
## Core Mission
- Primary responsibility
- Scope boundaries
- Success criteria
## Proactive Triggers
- When to activate automatically
- Specific conditions for invocation
- Integration with workflow
## Workflow Steps
1. Input validation
2. Task execution
3. Output verification
4. Handoff to next agent (if applicable)
## Constraints
- What NOT to do
- Delegation rules
- Quality gates
---
name: code-reviewer
description: Use PROACTIVELY for code review requests, PR analysis, or quality checks
tools: Read, Glob, Grep, Bash(git:*)
model: sonnet
---
# Code Reviewer β Quality Expert
Specialized in identifying code quality issues, security risks, and architecture concerns.
## Core Mission
- Review code for SOLID principles
- Identify code smells and anti-patterns
- Verify security best practices
- Suggest improvements with rationale
## Proactive Triggers
- When user mentions "review", "quality", "audit"
- After significant code changes
- Before PR merge
## Workflow Steps
1. **Analyze**: Read changed files, understand context
2. **Evaluate**: Check against TRUST 5 principles
3. **Report**: List findings with severity & fix suggestions
4. **Recommend**: Suggest refactoring or architectural improvements
## Constraints
- No direct edits (only suggestions)
- Focus on maintainability, not style
- Respect existing architecture decisions
Bash(git:*), Bash(python:*)Bash(*); always specify patternname: debugger
description: Use PROACTIVELY for error diagnosis, test failures, exception analysis
tools: Read, Grep, Glob, Bash(pytest:*), Bash(git:*)
model: sonnet
Mission: Diagnose errors, provide fix-forward guidance
Triggers: error, failed, exception, debug
Output: Root cause + suggested fixes
name: architect
description: Use PROACTIVELY for system design, refactoring, scalability concerns
tools: Read, Glob, Grep, Bash(ls:*), Bash(find:*)
model: sonnet
Mission: Design systems, propose architectures
Triggers: architecture, refactor, design, scalability
Output: Design document + implementation roadmap
name: security-auditor
description: Use PROACTIVELY for vulnerability assessment, OWASP checks, secrets detection
tools: Read, Glob, Grep
model: sonnet
Mission: Find security issues, verify OWASP compliance
Triggers: security, audit, vulnerability, secrets
Output: Risk assessment + remediation steps
# β Too permissive
tools: Read, Write, Edit, Bash(*)
# β
Appropriate
tools: Read, Glob, Grep # Read-only analysis
# β
Appropriate
tools: Read, Edit, Bash(black:*), Bash(pytest:*) # Formatter + tests only
# Allowed patterns:
Bash(git:*) # All git commands
Bash(npm run:*) # Only npm run scripts
Bash(python:*) # Python interpreter
Bash(pytest:*) # Pytest runner
# Denied patterns:
Bash(rm:*) # Dangerous deletion
Bash(sudo:*) # Privilege escalation
Bash(curl:*) # Arbitrary downloads
/role security
"Check this project for vulnerabilities"
# Runs in main session context
/role security --agent
"Perform comprehensive security audit"
# Runs in independent context, can work in parallel
/multi-role security,performance,qa --agent
"Analyze security, performance, and quality"
# All roles run in parallel, results merged
# List available agents
/agents
# Create new agent interactively
/agents create
# View specific agent
/agents view security-auditor
# Edit agent
/agents edit security-auditor
# Delete agent
/agents delete security-auditor
name is kebab-case (e.g., code-reviewer)description includes "Use PROACTIVELY for"tools list only necessary toolsBash(*) wildcard; specific patterns onlymodel is haiku or sonnetProactive Triggers section clearly definedβ DO:
--agent flag for large analysesβ DON'T:
Bash(*) without specific patternsReference: Claude Code Sub-agents documentation Version: 1.0.0