First understand the project's rules/skills/agent settings, and review from a corresponding expert perspective. If the user specifies the scope of improvements, spawn an Agent Team and make edits in parallel.
Overall Flow
Phase 1: 컨텍스트 탐색 → 전문가 패널 구성 → 리뷰 → 사용자 전달
── 사용자 검토 (개선 범위 지정) ──
Phase 2: 범위 확정 → TeamCreate → 병렬 개선 → 완료 보고
Phase 1: Code Review
Step 1. Explore Project Context
View changes before understand the project settings.
Exploration targets (in order):
| Priority | Path | What to identify |
|---|---|---|
| 1 | CLAUDE.md, .claude/CLAUDE.md |
Project overview, core rules, conventions |
| 2 | .claude/settings.json |
Allowed tools, permission settings |
| 3 | .claude/skills/*/SKILL.md (frontmatter만) |
List of skills used by the project |
| 4 | .claude/agents/*/AGENT.md (frontmatter만) |
Registered agent roles |
| 5 | Project root configuration files | package.json, pyproject.toml, go.mod etc. → determine language/framework |
| 6 | lint/format settings | .eslintrc, ruff.toml, .prettierrc etc. → code style rules |
Deliverable: Project profile summary
프로젝트 프로파일:
- 언어/프레임워크: {감지 결과}
- 핵심 규칙: {CLAUDE.md에서 추출한 규칙들}
- 코드 스타일: {lint/format 설정 요약}
- 등록된 스킬: {스킬 목록}
- 등록된 에이전트: {에이전트 목록}
Step 2. Configure Expert Panel
Based on the project profile, dynamically determine the expert perspectivesto participate in the review.
Expert panel configuration guide reference.
Default perspectives (always included):
- Project rule compliance — whether project-specific rules such as CLAUDE.md, lint settings, etc. are violated
- Correctness — logic errors, error handling, edge cases
Conditional perspectives (added depending on the profile):
- Web framework detected → add security perspective
- DB/ORM detected → add data layer perspective
- Test framework detected → add test coverage perspective
- etc. (see references for details)
Step 3. Analyze Changes
Determine the diff range according to the following priorities.
3-1. Determine Diff Range
| Priority | Condition | diff range |
|---|---|---|
| 1 | User specifies commit/tag | git diff <ref>..HEAD |
| 2 | Feature branch (non-default branch) | git diff $(git merge-base <base> HEAD)..HEAD |
| 3 | Fallback | Ask the user |
Automatic base branch detection (used in Priority 2):
# 존재하는 첫 번째 브랜치를 베이스로 사용
for base in origin/dev origin/develop origin/main; do
git rev-parse --verify "$base" &>/dev/null && break
done
Determine default branch: dev, develop, main, master If it is one of these, consider it the default branch.
3-2. Extract TICKET_ID
git branch --show-current
Extract TICKET_ID pattern from branch name:
feature/ABC-123-desc→ABC-123fix/PROJ-456→PROJ-456ABC-123-some-desc→ABC-123- Pattern:
[A-Z]+-[0-9]+(first match) - On failure → ask the user
3-3. Collect Changes
git diff {범위} --name-only # 변경 파일 목록
git diff {범위} # 전체 diff
git log {범위} --oneline # 커밋 히스토리 (컨텍스트 파악용)
Step 4. Perform Review
Review the changed code from each expert perspective.
Review principles:
- Project context first — Judge based on this project's rules/conventions rather than generalities
- Specify the issue location precisely (file:line)
- Provide the rationale for why it is a problem
- Suggest an improvement direction, but specific fix code is handled in Phase 2
Issue severity:
| Severity | Criteria |
|---|---|
| CRITICAL | Causes security vulnerabilities, data loss, or system failures |
| MAJOR | Functional errors, violations of core project rules, or severe performance degradation |
| MEDIUM | Code quality, convention inconsistencies, or maintenance difficulties |
| LOW | Minor improvements, style |
Step 5. Save and deliver the review document
Path: .ai/tasks/{TICKET_ID}/review.md
Format: Review document template
If an existing file exists, review-01.md, review-02.mdincrement the version.
Deliver to the user:
📋 코드 리뷰 완료
📄 문서: .ai/tasks/{TICKET_ID}/review.md
프로젝트 컨텍스트: {언어}, {프레임워크}, {핵심 규칙 요약}
리뷰 관점: {적용된 전문가 목록}
| 등급 | 건수 |
|------|------|
| 🔴 CRITICAL | N |
| 🟠 MAJOR | N |
| 🟡 MEDIUM | N |
| 🟢 LOW | N |
주요 이슈:
1. src/auth.ts:45 — [보안] 사용자 입력 검증 누락
2. src/service.ts:120 — [프로젝트 규칙] CLAUDE.md의 에러 처리 규칙 미준수
...
개선을 진행하려면 범위를 지정해주세요.
예: "CRITICAL 전부", "1, 3번", "전부"
Phase 2: Team improvement
When the user specifies a scope, spawn an Agent Team.
Step 1. Confirm scope and group tasks
Group the target issues by file:
- Same file / dependent files → one Task
- Independent files → separate Tasks
- Maximum 5 Workers
Step 2. Team SPAWN
Team spawn detailed guide refer to.
Perform the following procedure in order .
2-1. Create team
TeamCreate Call the tool.
| Parameters | 값 |
|---|---|
team_name |
"review-{TICKET_ID}" |
description |
"{TICKET_ID} 코드 리뷰 이슈 개선" |
2-2. Create tasks
For each issue group, TaskCreate Call the tool. Create all tasks simultaneously .
| Parameters | 값 |
|---|---|
subject |
"개선: {파일명} ({이슈 수}건)" |
description |
Project context + assigned files + list of issues to fix |
activeForm |
"{파일명} 개선 중" |
2-3. Spawn Workers
As many times as the number of issue groups, Task Call the tool to spawn Workers. Spawn all Workers simultaneously .
| Parameters | 값 |
|---|---|
subagent_type |
"general-purpose" |
team_name |
"review-{TICKET_ID}" |
name |
"refactor-worker-{N}" (numbered starting from 1) |
description |
"코드 개선 Worker {N}" |
mode |
"bypassPermissions" |
prompt |
Worker prompt (see below) |
Content that must be included in the Worker prompt:
- Project rules/conventions (core rules extracted from CLAUDE.md)
- Assigned files and issue list (all issues in the relevant group from the review document)
- Improvement direction for each issue
- Work procedure instructions (TaskList → TaskUpdate in_progress → edit files → report to leader via SendMessage → TaskUpdate completed)
- Rule to modify only assigned files
For the detailed Worker prompt template, Team spawn detailed guiderefer to.
2-4. Assign tasks
When a Worker is spawned, TaskUpdate assign a Task to each Worker with the tool.
| Parameters | 값 |
|---|---|
taskId |
The corresponding task ID |
owner |
"refactor-worker-{N}" (same as Worker name) |
2-5. Waiting for Completion
When Workers complete their tasks, SendMessagereport the results to. They are received automatically.
Wait until reports from all Workers have arrived.
Step 3. Cleanup and Reporting
3-1. Terminating Workers
Request termination from all Workers using the SendMessage tool.
| Parameters | 값 |
|---|---|
type |
"shutdown_request" |
recipient |
"refactor-worker-{N}" |
content |
"작업 완료. 종료합니다." |
3-2. Deleting the Team
After all Workers have terminated, TeamDelete call the tool.
3-3. Completion Report
✅ 개선 완료
수정된 이슈: N/M건
수정된 파일:
- src/auth.ts: 2건 (입력 검증 추가, 에러 처리 규칙 적용)
- ...
팀 정리 완료. 커밋하시려면 말씀해주세요.