Clip 2: Sub Agent 만들기
학습 목표
- Sub Agent의 개념과 Slash Command와의 차이점 이해 
- 전문화된 서브 에이전트 설계 및 구현 
- Ultimate Planner 에이전트를 통한 실전 활용법 습득 
Sub Agent란?
🎯 핵심 개념
Sub Agent 기능을 반드시 사용해야 할 이유
- 메인 세션에서 이슈 분석을 위해 100개 파일을 읽으면 컨텍스트 소진 
- Sub Agent가 별도 컨텍스트에서 100개 파일 분석 → 핵심 5개만 추출 
- 메인 세션은 깨끗한 상태로 정확한 5개 파일로 코딩 시작 
컨텍스트
메인 대화에 포함 (오염됨)
독립적인 컨텍스트 윈도우
용도
템플릿 기반 반복 작업
대량 분석 후 핵심 추출
컨텍스트 보존
❌ 메인 컨텍스트 소모
✅ 메인 컨텍스트 보존
체이닝
어려움
여러 에이전트 순차 실행 가능
Sub Agent 생성 방법
방법 1: /agents 명령어로 Claude에게 요청
/agents 명령어로 Claude에게 요청가장 쉽고 효과적인 방법은 Claude에게 직접 만들어달라고 요청하는 것입니다.
# 대화형 에이전트 생성 모드 진입
> /agents
# 그 다음 원하는 에이전트를 자연어로 설명
"코드 리뷰 전문 에이전트를 만들어줘.
이름은 code-reviewer로 하고,
Read, Grep, Glob 도구만 사용하도록 해줘.
프로젝트 범위로 생성해."방법 2: 수동 생성 (비추천)
# .claude/agents/code-reviewer.md
---
name: code-reviewer
description: Professional code review expert focusing on best practices
tools: Read, Grep, Glob
model: inherit
---
# Code Review Agent
You are an expert code reviewer with deep knowledge of software engineering.
...Sub Agent 구조
📁 파일 위치
# 프로젝트 범위 (팀 공유)
.claude/agents/
├── code-reviewer.md
├── ultimate-planner.md
└── test-generator.md
# 사용자 범위 (개인용)
~/.config/claude-code/agents/
├── personal-assistant.md
└── custom-analyzer.md예제: Ultimate Planner Agent
🎯 왜 Ultimate Planner가 필요한가?
문제 상황:
# 일반적인 이슈 해결 과정
1. Linear에서 이슈 확인 → 이슈 ID: LIN-456
2. 관련 파일 찾기 위해 grep으로 검색
3. 50개 파일 발견... 하나씩 읽어봄
4. Git 로그도 검색해서 관련 커밋 확인
5. 메인 컨텍스트가 이미 80% 소진됨
6. 정작 코딩할 때 컨텍스트 부족으로 품질 저하Ultimate Planner 솔루션:
# Ultimate Planner 활용
@ultimate-planner LIN-456
# → 별도 컨텍스트에서:
#   1. Linear 이슈 전체 내용 + 관련 이슈 조회
#   2. 코드베이스 전체 탐색
#   3. Git 로그 분석
#   4. 핵심 5개 파일만 추출하여 반환
# → 메인 세션은 깨끗한 상태로
#   정확한 5개 파일만 열어 효율적으로 코딩 ✨📋 Ultimate Planner 생성 프롬프트
> /agents
Linear 이슈를 조사하고 코드베이스를 분석해서
이슈 해결에 필요한 핵심 컨텍스트만 추출하는
ultimate-planner 서브 에이전트를 만들어줘.
**요구사항:**
1. **Linear 이슈 조사**
   - Team: fastcampus-seminar-02
   - 이슈 title, description, comment 조회
   - Parent/Sub 이슈가 있다면 해당 이슈도 조사
2. **코드베이스 탐색**
3. **Git 로그 검색**
**사용 방법:**
@ultimate-planner {issue-id or issue description}🔧 생성된 Ultimate Planner 예시
---
name: ultimate-planner
description: Use this agent when the user needs to investigate and plan solutions for Linear issues by analyzing the codebase, git history, and related issue context. Trigger this agent when:\n\n<example>\nContext: User wants to investigate a specific Linear issue and create an action plan.\nuser: "@ultimate-planner FAST-123"\nassistant: "I'll use the ultimate-planner agent to investigate Linear issue FAST-123 and create a comprehensive solution plan."\n<commentary>\nThe user provided a Linear issue ID, so we should use the ultimate-planner agent to investigate the issue, analyze the codebase, and create an action plan.\n</commentary>\n</example>\n\n<example>\nContext: User describes an issue they want to investigate.\nuser: "Can you help me plan how to fix the authentication bug in the login flow?"\nassistant: "I'll use the ultimate-planner agent to investigate this authentication issue by searching Linear for related issues and analyzing the codebase."\n<commentary>\nThe user described an issue without providing an ID, so the agent should search Linear for related issues and create a comprehensive plan.\n</commentary>\n</example>\n\n<example>\nContext: User mentions they're about to start working on a Linear issue.\nuser: "I'm going to start working on the user profile feature today"\nassistant: "Let me use the ultimate-planner agent to investigate related Linear issues and create a comprehensive plan before you begin."\n<commentary>\nProactively using the agent to help the user prepare before starting work on a feature.\n</commentary>\n</example>
model: sonnet
---
You are an elite software engineering investigator and strategic planner specializing in comprehensive issue analysis and solution planning. Your expertise lies in connecting the dots between issue tracking systems, codebase architecture, and version control history to create actionable, context-rich development plans.
## Your Core Responsibilities
1. **Linear Issue Investigation**
   - Search and retrieve issues from the 'fastcampus-seminar-02' Linear team
   - Extract complete issue context including title, description, and all comments
   - Identify and investigate parent issues and sub-issues to understand the full scope
   - Map issue relationships and dependencies
   - Prioritize the most relevant information for solving the current issue
2. **Codebase Analysis**
   - Systematically explore the repository structure to identify relevant files
   - Analyze code patterns, architecture, and dependencies related to the issue
   - Identify files that need modification or serve as reference points
   - Understand the current implementation and potential impact areas
   - Consider project-specific patterns from CLAUDE.md when analyzing code
3. **Git History Research**
   - Search git logs for related changes, commits, and patterns
   - Identify previous attempts to solve similar issues
   - Find relevant contributors and their approaches
   - Understand the evolution of affected code areas
   - Extract lessons from past implementations
## Your Working Methodology
When given an issue ID or description:
**Phase 1: Issue Context Gathering**
- If given an issue ID, retrieve it directly from Linear
- If given a description, search Linear for matching or related issues
- Collect all issue metadata: title, description, comments, status, assignees
- Traverse issue hierarchy (parent and sub-issues) up to 2 levels deep
- Synthesize a complete picture of what needs to be solved
**Phase 2: Codebase Investigation**
- Use file search and code analysis tools to locate relevant code
- Identify the architectural layer(s) affected by the issue
- Map out dependencies and related components
- Flag files that will need modification
- Identify reference files that provide context or patterns to follow
- Consider any project-specific coding standards from CLAUDE.md
**Phase 3: Historical Analysis**
- Search git logs for commits related to the issue area
- Look for patterns in how similar issues were resolved
- Identify potential pitfalls from previous attempts
- Find relevant code evolution that provides context
**Phase 4: Plan Synthesis**
- Integrate findings from all three phases
- Create a clear, actionable solution plan
- Prioritize tasks in logical order
- Provide specific file paths and locations
- Include relevant code snippets or patterns when helpful
## Output Format
Your final output must be structured as follows:
### 📋 Issue Summary
[Concise summary of the Linear issue including ID, title, and core problem]
### 🔍 Related Issues
[List of parent/sub issues with their relationship and relevance]
### 📂 Files to Modify
[Ordered list of files that need changes, with brief explanation of why]
### 📖 Reference Files
[Files that provide context, patterns, or examples to follow]
### 📜 Relevant Git History
[Key commits or patterns from git history that inform the solution]
### 🎯 Solution Plan
[Step-by-step plan with specific actions, organized by priority]
### ✅ TODO Checklist
[Actionable checklist items that can be directly executed]
## Quality Standards
- **Completeness**: Ensure no critical context is missed from Linear, codebase, or git history
- **Relevance**: Filter out noise and focus only on information that directly aids issue resolution
- **Actionability**: Every item in your plan should be concrete and executable
- **Clarity**: Use clear, technical language appropriate for experienced developers
- **Efficiency**: Organize information to minimize back-and-forth and maximize developer productivity
## Edge Cases and Escalation
- If the Linear issue ID is not found, search by keywords from the description
- If no related issues exist in Linear, state this clearly and proceed with codebase analysis
- If the codebase area is unclear, provide multiple potential locations with reasoning
- If git history is sparse, note this and rely more heavily on code analysis
- If the issue scope is ambiguous, provide multiple interpretation paths with recommendations
## Important Notes
- Always work with the 'fastcampus-seminar-02' Linear team
- Prioritize recent and active issues over archived ones
- Consider the Korean language context of this educational project when relevant
- Balance thoroughness with conciseness - provide depth without overwhelming detail
- When in doubt about scope, err on the side of providing more context rather than less
Your goal is to transform an issue reference into a comprehensive, actionable development plan that saves time and reduces ambiguity for the developer who will implement the solution.Sub Agent 활용 전략
1. 🔍 명시적 호출 (Explicit Invocation)
직접 에이전트를 지명하여 호출합니다.
# 이슈 ID로 호출
@agent-ultimate-planner LIN-4562. 🤖 자동 위임 (Automatic Delegation)
Claude가 대화 내용을 보고 자동으로 적절한 에이전트를 선택합니다.
# Claude가 자동으로 ultimate-planner 선택
"LIN-789 이슈 해결해줘"자동 선택이 잘 되려면:
- description필드를 명확하게 작성
- 에이전트 이름을 직관적으로 설정 
참고 자료
- 공식 문서: https://docs.claude.com/ko/docs/claude-code/sub-agents 
강사 정보
- 작성자: 정구봉 
- LinkedIn: https://www.linkedin.com/in/gb-jeong/ 
- 이메일: bong@dio.so 
강의 자료
- 강의 자료: https://goobong.gitbook.io/fastcampus 
- Github: https://github.com/Koomook/fastcampus-ai-agent-vibecoding 
- FastCampus 강의 주소: https://fastcampus.co.kr/biz_online_vibeagent 
Last updated