서브에이전트
작업별 워크플로우를 위한 독립 컨텍스트를 가진 특화된 AI 어시스턴트
서브에이전트란?
서브에이전트는 자체 컨텍스트 윈도우, 도구 접근 권한, 특화된 지시를 가진 독립적인 Claude 인스턴스입니다. 코드를 탐색하고, 계획을 실행하고, 백그라운드에서 실행하고, 메인 세션의 컨텍스트를 소비하지 않고 요약된 결과를 반환할 수 있습니다.
Specific Purpose
Each subagent has a defined expertise area
Own Context Window
Separate from main conversation
Configurable Tools
Specific tool access per subagent
Custom System Prompt
Tailored instructions for each agent
New Subagent Features
Async Subagents
Run subagents asynchronously with Ctrl+B backgrounding
Context Fork
Use context: fork in skill frontmatter for isolated execution
Agent Hooks
Define PreToolUse, PostToolUse, and Stop hooks in agent frontmatter
Disable Agents
Use Task(AgentName) syntax in disallowedTools to disable specific agents
내장 서브에이전트
Explore
Fast, read-only agent for searching and analyzing codebases
Model: Haiku (fast)
Tools: Read-only
Plan
Research agent used in plan mode to gather context
Model: Inherits
Tools: Read-only
general-purpose
Capable agent for complex, multi-step tasks
Model: Inherits
Tools: All tools
에이전트 Frontmatter 필드
| Field | Description | Example |
|---|---|---|
| model | Override model selection | opus, sonnet, haiku, inherit |
| skills | Enable specific skills | ["code-review", "testing"] |
| hooks | Define agent-specific hooks | ["pre-review"] |
| permissionMode | Permission handling mode | inherit, default, bypassPermissions |
| apiKeyEnvVar | Custom API key env variable | CUSTOM_API_KEY |
| enableUndo | Enable undo capability | true, false |
| tools | Restrict available tools | ["Read", "Edit", "Bash"] |
--- model: opus skills: - code-review hooks: - security-check permissionMode: inherit tools: - Read - Edit - Grep ---
Quick Start
1. Open Subagents Interface
/agents2. Create New Agent
Choose "Create New Agent" and select project-level or user-level
3. Define the Agent
- Describe the agent's purpose
- Select tools to grant access
- Customize the system prompt
4. Use Your Agent
> code-reviewer 서브에이전트로 내 코드를 검토해줘서브에이전트 예시
코드 리뷰어
Reviews code for quality, security, and best practices
Tools: Read, Grep, Glob, Bash
디버거
Analyzes errors and implements fixes
Tools: Read, Edit, Bash, Grep
Test Automation
Creates and runs tests automatically
Tools: Read, Write, Bash
Best Practices
Design Focused Agents
Create subagents with single, clear responsibilities
Write Detailed Prompts
Include specific instructions and examples
Limit Tool Access
Only grant necessary tools for better security
Version Control
Check project subagents into version control