์ง๋ ๊ธ์์๋ Tool Use๊ฐ ๋ฌด์์ด๊ณ ์ด๋ป๊ฒ ๋์ํ๋์ง ์์๋ณด์๋ค. ์ด๋ฒ ๊ธ์์๋ subagent๊ฐ Tool Use ์์์ ์ด๋ป๊ฒ ๋์ํ๋์ง ์์๋ณผ ๊ฒ์ด๋ค.
Tool Use ์ ๋ฆฌ
Subagent ์ค๋ช
์ ์์ Tool Use๋ฅผ ๊ฐ๋จํ ์ ๋ฆฌํด๋ณด๊ณ ๋์ด๊ฐ์.
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๋ฉ์ธ ๋ฉ์์ง ๋ฃจํ โ
โ โ
โ โโโโโโโโ request โโโโโโโโโโโ API call โโโโโโโ โ
โ โ User โ โโโโโโโโโโโโโโบ โ Agent โ โโโโโโโโโโโโโบ โ LLM โ โ
โ โ โ โโโโโโโโโโโโโโ โ โ โโโโโโโโโโโโโ โ โ โ
โ โโโโโโโโ response โ โ tool_use โโโโโโโ โ
โ โ โ โ โ
โ โ โผ โ โ
โ โโโโโโโโโโโโโโโโ โ
โ โ Tools โ โ
โ โ (Bash, Read, โ โ
โ โ Glob, ...) โ โ
โ โโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Tool Use๋ LLM์ด ์ธ๋ถ ๋๊ตฌ๋ฅผ ํธ์ถํ ์ ์๊ฒ ํด์ฃผ๋ ๋ฉ์ปค๋์ฆ์ด๋ค. Agent๋ LLM์๊ฒ ์ฌ์ฉ ๊ฐ๋ฅํ ๋๊ตฌ ๋ชฉ๋ก์ ์ ๊ณตํ๊ณ LLM์ ํ์ํ ๋ tool_use ์๋ต์ ๋ฐํํ๋ค. Agent๋ ํด๋น ๋๊ตฌ๋ฅผ ์คํํ๊ณ ๊ฒฐ๊ณผ๋ฅผ ๋ค์ LLM์๊ฒ ์ ๋ฌํ๋ค. ์ด ๊ณผ์ ์ด ๋ฐ๋ณต๋๋ฉด์ ๋ณต์กํ ์์
์ ์ํํ๋ค.
Subagent๋?
Subagent๋ ํน์ ์์
์ ํนํ๋ AI ์์ด์ ํธ๋ค. ๊ฐ subagent๋ ์์ ๋ง์ ์ปจํ
์คํธ ์๋์ฐ์์ ๋
๋ฆฝ์ ์ผ๋ก ์๋ํ๋ฉฐ ์๋ฃ๋๋ฉด ๊ฒฐ๊ณผ๋ฅผ ๋ฉ์ธ ์์ด์ ํธ์๊ฒ ๋ฐํํ๋ค.
Claude Code์์ subagent๋ Task๋ผ๋ ๋๊ตฌ๋ก ๊ตฌํ๋์ด ์๋ค. ๋ฉ์ธ ์์ด์ ํธ์ ์์คํ
ํ๋กฌํํธ์๋ Task ๋๊ตฌ์ description์ผ๋ก ์ฌ์ฉ ๊ฐ๋ฅํ ๋ชจ๋ subagent ๋ชฉ๋ก๊ณผ ๊ฐ๊ฐ์ ์ฉ๋๊ฐ ํฌํจ๋๋ค. ๋ฉ์ธ ์์ด์ ํธ๋ ์ด description์ ์ฐธ๊ณ ํ์ฌ ์ ์ ํ subagent๋ฅผ ์ ํํ๋ค. ์๋ฅผ ๋ค์ด "์ฝ๋๋ฒ ์ด์ค ๊ตฌ์กฐ ํ์
"์ด ํ์ํ๋ฉด Explore๋ฅผ, "๋ฐ์ดํฐ๋ฒ ์ด์ค ์คํค๋ง ์ค๊ณ"๊ฐ ํ์ํ๋ฉด database-schema-architect๋ฅผ ํธ์ถํ๋ค.
Subagent์ ๊ตฌ์กฐ
Subagent๋ ๋งํฌ๋ค์ด ํ์ผ๋ก ์ ์๋๊ณ YAML frontmatter์ ๋ค์๊ณผ ๊ฐ์ ์ค์ ์ ํฌํจํ๋ค.
---
name: code-reviewer
description: Expert code review specialist. Use immediately after writing or modifying code.
tools: Read, Grep, Glob, Bash
model: sonnet
---
You are a senior code reviewer ensuring high standards of code quality and security.
When invoked:
1. Run git diff to see recent changes
2. Focus on modified files
3. Begin review immediately
Review checklist:
- Code is simple and readable
- Functions and variables are well-named
...
๊ฐ ํ๋์ ์ญํ ์ ๋ค์๊ณผ ๊ฐ๋ค:
| ํ๋ |
์ค๋ช
|
name |
subagent์ ๊ณ ์ ์๋ณ์ |
description |
์ธ์ ์ด subagent๋ฅผ ์ฌ์ฉํด์ผ ํ๋์ง ์ค๋ช
|
tools |
์ด subagent๊ฐ ์ฌ์ฉํ ์ ์๋ ๋๊ตฌ ๋ชฉ๋ก |
model |
์ฌ์ฉํ ๋ชจ๋ธ (sonnet, opus, haiku ๋๋ inherit) |
YAML frontmatter ์๋์ ๋งํฌ๋ค์ด ๋ณธ๋ฌธ์ด subagent์ ์์คํ
ํ๋กฌํํธ๊ฐ ๋๋ค. ์ด ํ๋กฌํํธ๋ subagent๊ฐ ํธ์ถ๋ ๋ API ์์ฒญ์ system ํ๋์ ์ฃผ์
๋์ด subagent์ ํ๋์ ์ ์ํ๋ค.
์ด subagent ์ ์๋ ๋ฉ์ธ ์์ด์ ํธ์ ์์คํ
ํ๋กฌํํธ์ ์๋ tools ์น์
์ Task ๋๊ตฌ ์ค๋ช
์ ํฌํจ๋๋ค:
{
"name": "Task",
"description": "Launch a new agent to handle complex, multi-step tasks autonomously.
Available agent types and the tools they have access to:
- Explore: Fast agent specialized for exploring codebases. (Tools: All tools)
- Plan: Software architect agent for designing implementation plans. (Tools: All tools)
- database-schema-architect: Use this agent when you need to design database schemas...
...
"
}
Task ๋๊ตฌ์ input schema๋ ๋ค์๊ณผ ๊ฐ๋ค:
{
"type": "object",
"properties": {
"subagent_type": {
"type": "string",
"description": "The type of subagent to launch"
},
"prompt": {
"type": "string",
"description": "The task to delegate to the subagent"
},
"description": {
"type": "string",
"description": "Short description of what the agent will do"
}
}
}
subagent_type: ํธ์ถํ subagent ์ข
๋ฅ (Explore, Plan, general-purpose ๋ฑ)
prompt: subagent์๊ฒ ์ ๋ฌํ ์์
์ง์. ์ด ๋ด์ฉ์ด subagent์ user ๋ฉ์์ง๊ฐ ๋๋ค
description: 3-5๋จ์ด์ ์งง์ ์์ฝ. ๋ก๊ทธ๋ UI์ ํ์๋๋ค
Subagent ํธ์ถ ๊ณผ์
์ค์ ๋ฉ์์ง ํ๋ฆ์ ํตํด subagent๊ฐ ์ด๋ป๊ฒ ๋์ํ๋์ง ์ดํด๋ณด์.
1๋จ๊ณ: ๋ฉ์ธ ์์ด์ ํธ๊ฐ Task ๋๊ตฌ ํธ์ถ
์ฌ์ฉ์๊ฐ "์ ๋ฌผ์ ์ฃผ๊ณ ๋ฐ๋ ๊ธฐ๋ฅ์ ์ํ entity ์ค๊ณ"๋ฅผ ์์ฒญํ๋ค๊ณ ํ์. ๋ฉ์ธ ์์ด์ ํธ(Opus 4.5)๋ ๋จผ์ ์ฝ๋๋ฒ ์ด์ค๋ฅผ ํ์ํด์ผ ํ๋ค๊ณ ํ๋จํ๊ณ Explorer subagent๋ฅผ ํธ์ถํ๋ค:
{
"content": [
{
"type": "thinking",
"thinking": "์ฌ์ฉ์๊ฐ ์ ๋ฌผ์ ์ฃผ๊ณ ๋ฐ๋ ๊ธฐ๋ฅ์ ์ํ entity ์ค๊ณ๋ฅผ ์์ฒญํ์ต๋๋ค. Plan mode๊ฐ ํ์ฑํ๋์ด ์์ผ๋ฏ๋ก, ๋จผ์ ์ฝ๋๋ฒ ์ด์ค๋ฅผ ํ์ํ์ฌ ๊ธฐ์กด ๊ตฌ์กฐ๋ฅผ ์ดํดํด์ผ ํฉ๋๋ค.\n\nPhase 1์ ๋ฐ๋ผ:\n1. ๊ธฐ์กด entity ๊ตฌ์กฐ์ ํจํด์ ์ดํดํ๊ธฐ ์ํด Explore agent๋ฅผ ์ฌ์ฉ\n2. ์ ๋ฌผ ๊ด๋ จ ๊ธฐ์กด ๊ตฌํ์ด ์๋์ง ํ์ธ\n3. ์ฌ์ฉ์์ ์์ดํ
๊ด๋ จ entity๊ฐ ์ด๋ป๊ฒ ๊ตฌ์ฑ๋์ด ์๋์ง ํ์
\n\n๋จผ์ Explore agent๋ฅผ ์ฌ์ฉํ์ฌ ๊ธฐ์กด entity ๊ตฌ์กฐ๋ฅผ ํ์
ํ๊ฒ ์ต๋๋ค."
},
{
"type": "text",
"text": "์ ๋ฌผ ์ฃผ๊ณ ๋ฐ๊ธฐ ๊ธฐ๋ฅ์ ์ํ entity ์ค๊ณ๋ฅผ ์์ํ๊ฒ ์ต๋๋ค. ๋จผ์ ๊ธฐ์กด ์ฝ๋๋ฒ ์ด์ค์ entity ๊ตฌ์กฐ์ ๊ด๋ จ ํจํด์ ํ์ํ๊ฒ ์ต๋๋ค."
},
{
"type": "tool_use",
"id": "toolu_01QjShG7gnF36vLgGKCWBNjg",
"name": "Task",
"input": {
"subagent_type": "Explore",
"prompt": "์ด NestJS TypeScript ํ๋ก์ ํธ์์ entity ๊ตฌ์กฐ๋ฅผ ํ์ํด์ฃผ์ธ์:\n\n1. ๊ธฐ์กด entity ํ์ผ๋ค์ ์์น์ ๊ตฌ์กฐ ํ์
...",
"description": "Entity ๊ตฌ์กฐ ํ์"
}
}
]
}
thinking ๋ธ๋ก์์ ๋ฉ์ธ ์์ด์ ํธ๋ ํ์ฌ ์ํฉ(Plan mode ํ์ฑํ)์ ํ์
ํ๊ณ Explore agent๋ฅผ ์ ํํ ์ด์ ๋ฅผ ๋ช
์์ ์ผ๋ก ์ถ๋ก ํ๋ค.
2๋จ๊ณ: ์๋ก์ด ๋ฉ์์ง ๋ฃจํ์์ Subagent ์คํ
Agent๋ Task ๋๊ตฌ ํธ์ถ์ ๋ฐ์ผ๋ฉด ์์ ํ ์๋ก์ด ๋ฉ์์ง ๋ฃจํ๋ฅผ ์์ํ๋ค. ์ด ๋ ์์์ ๋ณด์๋ YAML frontmatter ํ๋จ์ ๋งํฌ๋ค์ด ๋ณธ๋ฌธ์ด subagent ์ ์ฉ ์์คํ
ํ๋กฌํํธ๋ก ์ฃผ์
๋๋ค.
{
"model": "claude-haiku-4-5-20251001",
"system": [
{
"type": "text",
"text": "You are Claude Code, Anthropic's official CLI for Claude."
},
{
"type": "text",
"text": "You are a file search specialist for Claude Code...
=== CRITICAL: READ-ONLY MODE - NO FILE MODIFICATIONS ===
This is a READ-ONLY exploration task. You are STRICTLY PROHIBITED from:
- Creating new files
- Modifying existing files
- Deleting files
...
Your strengths:
- Rapidly finding files using glob patterns
- Searching code and text with powerful regex patterns
- Reading and analyzing file contents
..."
}
],
"messages": [
{
"role": "user",
"content": "<system-reminder>\nAs you answer the user's questions, you can use the following context:\n# claudeMd\nCodebase and user instructions are ... <system-reminder>"
},
{
"role": "user",
"content": "์ด NestJS TypeScript ํ๋ก์ ํธ์์ entity ๊ตฌ์กฐ๋ฅผ ํ์ํด์ฃผ์ธ์..."
}
],
"tools": [
{"name": "Bash", ...},
{"name": "Glob", ...},
{"name": "Grep", ...},
{"name": "Read", ...}
]
}
- ๋ชจ๋ธ: Explorer๋ ๋น ๋ฅธ ํ์์ ์ํด Haiku 4.5๋ฅผ ์ฌ์ฉํ๋ค (๋ฉ์ธ์ Opus 4.5)
- ์์คํ
ํ๋กฌํํธ: ์ฝ๊ธฐ ์ ์ฉ ๋ชจ๋๋ก ์ ํ๋ ์ ์ฉ ํ๋กฌํํธ๊ฐ ์ฃผ์
๋๋ค
- ๋๊ตฌ ์ ํ: ๋ฉ์ธ ์์ด์ ํธ๊ฐ ๊ฐ์ง ๋ชจ๋ ๋๊ตฌ๊ฐ ์๋, ํ์์ ํ์ํ ๋๊ตฌ๋ง ์ ๊ณต๋๋ค
- CLAUDE.md ์ ๋ฌ: ํ๋ก์ ํธ์
CLAUDE.md ๋ด์ฉ์ด user ๋ฉ์์ง์ <system-reminder> ํ๊ทธ ์์ ํฌํจ๋์ด ์ ๋ฌ๋๋ค. ๋ฐ๋ผ์ subagent๋ ํ๋ก์ ํธ ์ปจ๋ฒค์
์ ๋ฐ๋ฅธ๋ค
- ๋ฉ์์ง: ๋ฉ์ธ ์์ด์ ํธ์ prompt๊ฐ user ๋ฉ์์ง๋ก ์ ๋ฌ๋๋ค
3๋จ๊ณ: Subagent์ ๋๊ตฌ ์ฌ์ฉ
Subagent๋ ์์ ๋ง์ ๋ฉ์์ง ๋ฃจํ์์ ๋๊ตฌ๋ฅผ ์ฌ์ฉํ๋ค:
{
"content": [
{
"type": "text",
"text": "์ด NestJS ํ๋ก์ ํธ์ entity ๊ตฌ์กฐ๋ฅผ ์ฒ ์ ํ๊ฒ ํ์ํ๊ฒ ์ต๋๋ค."
},
{
"type": "tool_use",
"id": "toolu_01VHysdohmuy9r58aVdcUQRh",
"name": "Glob",
"input": {
"pattern": "**/*.entity.ts"
}
},
{
"type": "tool_use",
"id": "toolu_01QYrMBhzbXpExYwgCFM7MLb",
"name": "Bash",
"input": {
"command": "find /Volumes/project/src -type f -name \"*.ts\" | grep -E \"(entity|entities)\" | head -20",
"description": "Find entity files in src directory"
}
}
]
}
Explorer subagent๋ ๋ ๊ฐ์ ๋๊ตฌ๋ฅผ ๋ณ๋ ฌ๋ก ํธ์ถํ๋ค. Glob์ผ๋ก entity ํ์ผ ํจํด์ ์ฐพ๊ณ Bash๋ก ๋๋ ํ ๋ฆฌ๋ฅผ ํ์ํ๋ค. ์ด ๊ณผ์ ์ด ๋ฐ๋ณต๋๋ฉด์ subagent๋ ํ์ํ ์ ๋ณด๋ฅผ ์์งํ๋ค.
4๋จ๊ณ: Subagent ์๋ฃ ๋ฐ ๊ฒฐ๊ณผ ๋ฐํ
Subagent๊ฐ ํ์์ ์๋ฃํ๋ฉด ์์งํ ์ ๋ณด๋ฅผ ์ ๋ฆฌํ์ฌ ์ต์ข
์๋ต์ ๋ฐํํ๋ค. ์ด ์๋ต์ ๋ฉ์ธ ์์ด์ ํธ์ Task ๋๊ตฌ ํธ์ถ์ ๋ํ tool_result๋ก ์ ๋ฌ๋๋ค:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๋ฉ์ธ ๋ฉ์์ง ๋ฃจํ โ
โ โ
โ User โโโบ Agent โโโบ LLM(Opus) โ
โ โ โ
โ โผ tool_use: Task โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Subagent ๋ฉ์์ง ๋ฃจํ (Explorer) โ โ
โ โ โ โ
โ โ prompt โโโบ Agent โโโบ LLM(Haiku) โ โ
โ โ โ โ โ
โ โ โผ tool_use โ โ
โ โ โโโโโโโโโโโ โ โ
โ โ โ Glob โ โ โ
โ โ โ Bash โ โ โ
โ โ โ Read โ โ โ
โ โ โโโโโโโโโโโ โ โ
โ โ โ โ โ
โ โ โผ โ โ
โ โ ์ต์ข
์๋ต โ โ
โ โโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ โ
โ โผ tool_result โ
โ Agent ๊ณ์ ์งํ โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๋ฉ์ธ ์์ด์ ํธ๋ Explorer์ ์กฐ์ฌ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํ์ผ๋ก ๋ค์ ๋จ๊ณ(์: database-schema-architect ํธ์ถ)๋ฅผ ์งํํ๋ค.
๋ง๋ฌด๋ฆฌ
์ง๊ธ๊น์ง subagent์ ๋์ ๋ฐฉ์์ ๋ํด์ ์์๋ณด์๋ค. ํต์ฌ์ ์ ๋ฆฌํ๋ฉด:
Subagent๋ Tool Use๋ค. ๋ฉ์ธ ์์ด์ ํธ๊ฐ Task ๋๊ตฌ๋ฅผ ํธ์ถํ๋ฉด, ์๋ก์ด ๋ฉ์์ง ๋ฃจํ๊ฐ ์์ฑ๋์ด ์ ์ฉ ์์คํ
ํ๋กฌํํธ์ ์ ํ๋ ๋๊ตฌ๋ก ์์
์ ์ํํ๋ค.
์ ์ฌ์ฉํ๋๊ฐ?
- ์ปจํ
์คํธ ๋ถ๋ฆฌ: ํ์/๋ถ์ ๊ณผ์ ์ด ๋ฉ์ธ ๋ํ๋ฅผ ์ค์ผ์ํค์ง ์๋๋ค
- ์ ๋ฌธํ: ๊ฐ subagent๊ฐ ํน์ ์์
์ ์ต์ ํ๋ ํ๋กฌํํธ์ ๋๊ตฌ๋ฅผ ๊ฐ์ง๋ค
- ํจ์จ์ฑ: ๋ชฉ์ ์ ๋ง๊ฒ ๊ฐ๋ฒผ์ด ๋ชจ๋ธ(Haiku)์ด๋ ๋ฌด๊ฑฐ์ด ๋ชจ๋ธ(Opus)์ ์ทจ์ฌ์ ํ
์ฃผ์ํ ์ :
- Subagent๋ ๋ฉ์ธ ๋ํ ํ์คํ ๋ฆฌ๋ฅผ ๋ชจ๋ฅธ๋ค. ํ์ํ ์ ๋ณด๋ Task์ prompt์ ๋ช
์ํด์ผ ํ๋ค (๋จ,
CLAUDE.md๋ ์๋ ์ ๋ฌ๋จ)
- Subagent๋ subagent๋ฅผ ํธ์ถํ ์ ์๋ค (๋ฌดํ ์ค์ฒฉ ๋ฐฉ์ง๋ฅผ ์ํด Task ๋๊ตฌ๋ฅผ ์ฌ์ฉํ์ง ์๋๋ค.)
- ๊ฐ ํธ์ถ์ ์๋ก์ด ์ปจํ
์คํธ์์ ์์ํ๋ค (๋จ, resume ํ๋ผ๋ฏธํฐ๋ก ์ด์ ๋ํ ์ด์ด๊ฐ๊ธฐ ๊ฐ๋ฅ)
๊ฒฐ๊ตญ subagent๋ Tool Use ํจํด์ ํ์ฅ์ด๋ค. ๋จ์ํ Function Call์ด๋ผ๋ฉด ์ฝ๋ ์คํ ๊ฒฐ๊ณผ๋ฅผ ํ
์คํธ๋ก ๋ฐํํ์ง๋ง subagent๋ ๋ณ๋์ ๋ฉ์์ง ๋ฃจํ์์ LLM์ด ์์ฑํ ํ
์คํธ๋ฅผ ๋ฐํํ๋ค๋ ์ฐจ์ด๋ง ์๋ค. ๋ฉ์ธ ์์ด์ ํธ ์
์ฅ์์๋ ๋ ๋ค tool_result๋ก ๋ฐ๋ ํ
์คํธ์ผ ๋ฟ์ด๋ค.
Read more โ