jun-claude-code 0.0.11 → 0.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +122 -83
- package/dist/cli.js +40 -0
- package/dist/copy.js +92 -11
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -1
- package/dist/init-context.d.ts +4 -0
- package/dist/init-context.js +143 -0
- package/dist/init-project.js +4 -4
- package/dist/validate.d.ts +4 -0
- package/dist/validate.js +105 -0
- package/package.json +2 -2
- package/{.claude → templates/global}/CLAUDE.md +50 -21
- package/{.claude → templates/global}/agents/architect.md +23 -11
- package/{.claude → templates/global}/agents/code-reviewer.md +17 -7
- package/{.claude → templates/global}/agents/code-writer.md +27 -15
- package/{.claude → templates/global}/agents/context-collector.md +11 -3
- package/{.claude → templates/global}/agents/context-manager.md +21 -9
- package/{.claude → templates/global}/agents/designer.md +32 -20
- package/{.claude → templates/global}/agents/director.md +43 -31
- package/{.claude → templates/global}/agents/explore.md +13 -5
- package/{.claude → templates/global}/agents/git-manager.md +39 -22
- package/{.claude → templates/global}/agents/impact-analyzer.md +17 -7
- package/{.claude → templates/global}/agents/qa-tester.md +22 -8
- package/{.claude → templates/global}/agents/simple-code-writer.md +13 -5
- package/{.claude → templates/global}/agents/task-planner.md +18 -10
- package/{.claude → templates/global}/hooks/skill-forced.sh +56 -56
- package/{.claude → templates/global}/hooks/workflow-enforced.sh +49 -31
- package/{.claude → templates/global}/skills/Backend/SKILL.md +38 -9
- package/{.claude → templates/global}/skills/Coding/SKILL.md +69 -29
- package/{.claude → templates/global}/skills/Director/SKILL.md +9 -5
- package/{.claude → templates/global}/skills/Documentation/SKILL.md +68 -1
- package/{.claude → templates/global}/skills/Git/SKILL.md +8 -4
- package/{.claude → templates/global}/skills/Git/git.md +60 -28
- package/{.claude → templates/global}/skills/Git/pr-apply.md +18 -6
- package/{.claude → templates/global}/skills/Git/pr-review.md +4 -0
- package/templates/global/skills/PromptStructuring/SKILL.md +67 -0
- package/templates/global/skills/PromptStructuring/positive-phrasing.md +206 -0
- package/templates/global/skills/PromptStructuring/xml-tags.md +330 -0
- package/{.claude → templates/global}/skills/React/SKILL.md +28 -8
- package/{.claude → templates/global}/skills/React/react-hook-form.md +20 -12
- package/{.claude → templates/global}/skills/React/tailwind-styled.md +29 -7
- package/{.claude → templates/global}/skills/React/tanstack-router.md +21 -9
- package/templates/project/agents/context-generator.md +66 -0
- package/{.claude → templates/project}/agents/project-task-manager.md +19 -7
- package/templates/project/skills/ContextGeneration/SKILL.md +160 -0
- package/templates/project/workflows/context-gen.yml +75 -0
- /package/{.claude → templates/global}/settings.json +0 -0
- /package/{.claude → templates/project}/hooks/task-loader.sh +0 -0
- /package/{.claude → templates/project}/project.env.example +0 -0
|
@@ -8,22 +8,24 @@ color: green
|
|
|
8
8
|
|
|
9
9
|
# Task Planner Agent
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
## 핵심 원칙
|
|
11
|
+
<role>
|
|
14
12
|
|
|
15
|
-
|
|
16
|
-
구체적이지 않은 부분은 반드시 사용자에게 질문하여 명확히 한 후 작업합니다.
|
|
13
|
+
TaskList를 생성하고 코드 수정 계획을 작성하는 전문 Agent입니다.
|
|
17
14
|
|
|
18
|
-
|
|
15
|
+
**애매한 요구사항은 반드시 사용자에게 확인한 후 진행합니다.**
|
|
16
|
+
구체적이지 않은 부분은 질문하여 명확히 한 후 작업합니다.
|
|
19
17
|
|
|
20
18
|
1. **요구사항 분석**: 사용자 요청의 명확성 검증
|
|
21
19
|
2. **명확화 질문**: 애매한 부분에 대한 적극적 질문
|
|
22
20
|
3. **TaskList 생성**: 작업을 작은 단위로 분해
|
|
23
21
|
4. **코드 수정 계획**: 파일별 변경사항 정리
|
|
24
22
|
|
|
23
|
+
</role>
|
|
24
|
+
|
|
25
25
|
---
|
|
26
26
|
|
|
27
|
+
<instructions>
|
|
28
|
+
|
|
27
29
|
## Phase 1: 요구사항 명확화 (필수)
|
|
28
30
|
|
|
29
31
|
### 체크리스트 - 아래 항목이 명확한가?
|
|
@@ -125,9 +127,11 @@ TaskList를 생성하고 코드 수정 계획을 작성하는 전문 Agent입니
|
|
|
125
127
|
...
|
|
126
128
|
```
|
|
127
129
|
|
|
130
|
+
</instructions>
|
|
131
|
+
|
|
128
132
|
---
|
|
129
133
|
|
|
130
|
-
|
|
134
|
+
<output_format>
|
|
131
135
|
|
|
132
136
|
```markdown
|
|
133
137
|
# Task Planning 결과
|
|
@@ -151,10 +155,14 @@ TaskList를 생성하고 코드 수정 계획을 작성하는 전문 Agent입니
|
|
|
151
155
|
- impact-analyzer Agent로 사이드이펙트 검증 권장
|
|
152
156
|
```
|
|
153
157
|
|
|
158
|
+
</output_format>
|
|
159
|
+
|
|
154
160
|
---
|
|
155
161
|
|
|
156
|
-
|
|
162
|
+
<constraints>
|
|
157
163
|
|
|
158
|
-
-
|
|
159
|
-
-
|
|
164
|
+
- **불확실한 사항은 확인 후 진행**: 애매한 요구사항은 반드시 사용자에게 질문
|
|
165
|
+
- **필요한 범위만 계획**: 현재 작업에 필요한 만큼만 계획 수립
|
|
160
166
|
- **유연성 유지**: 구현 중 발견되는 사항은 계획 수정 가능
|
|
167
|
+
|
|
168
|
+
</constraints>
|
|
@@ -14,71 +14,65 @@ echo "✅ [Hook] Skill/Agent 평가 프로토콜 실행됨"
|
|
|
14
14
|
cat << 'EOF'
|
|
15
15
|
MANDATORY SKILL & AGENT EVALUATION PROTOCOL
|
|
16
16
|
|
|
17
|
-
작업을 시작하기 전에
|
|
17
|
+
작업을 시작하기 전에 아래 단계를 순서대로 완료하세요:
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
<delegation_rules>
|
|
20
|
+
|
|
21
|
+
## CONTEXT 절약 원칙 (최우선)
|
|
22
22
|
|
|
23
23
|
Main Agent의 Context Window는 제한적입니다.
|
|
24
|
-
**Subagent가 할 수 있는 작업은
|
|
25
|
-
|
|
26
|
-
###
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
|
34
|
-
|
|
35
|
-
|
|
|
36
|
-
|
|
|
37
|
-
|
|
|
38
|
-
|
|
|
39
|
-
| Git
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
- Main Agent에서 직접 Glob/Grep으로 여러 파일 탐색
|
|
44
|
-
- Main Agent에서 직접 여러 파일 Read (2개 이상)
|
|
45
|
-
- Main Agent에서 복잡한 분석/계획 수행
|
|
46
|
-
- Main Agent에서 3개 이상 파일 수정
|
|
47
|
-
- **Main Agent에서 직접 Git 명령어 실행 (git add, commit, push 등)**
|
|
48
|
-
- **Main Agent에서 직접 코드 수정 (Edit/Write로 코드 파일 수정 금지)**
|
|
49
|
-
|
|
50
|
-
### ✅ Main Agent 허용 작업 (이것만 직접 수행)
|
|
24
|
+
**Subagent가 할 수 있는 작업은 Subagent에 위임하세요.**
|
|
25
|
+
|
|
26
|
+
### Subagent 전담 작업
|
|
27
|
+
|
|
28
|
+
아래 PART 2의 "사용 가능한 Agents" 목록에서 각 Agent의 description을 확인하고,
|
|
29
|
+
작업에 적합한 Agent에 위임하세요. 각 Agent의 description에 위임 이유가 포함되어 있습니다.
|
|
30
|
+
|
|
31
|
+
### Subagent 전용 작업
|
|
32
|
+
|
|
33
|
+
| 작업 | 전담 Agent |
|
|
34
|
+
|------|-----------|
|
|
35
|
+
| 파일 탐색 (Glob/Grep) | explore Agent가 전담 |
|
|
36
|
+
| 2개 이상 파일 읽기 | explore/context-collector가 전담 |
|
|
37
|
+
| 복잡한 분석/계획 | task-planner에 위임 |
|
|
38
|
+
| 파일 수정 (3개 이상) | code-writer가 전담 |
|
|
39
|
+
| Git 명령어 실행 (git add, commit, push 등) | git-manager에 위임 |
|
|
40
|
+
| 코드 수정 (Edit/Write) | code-writer/simple-code-writer에 위임 |
|
|
41
|
+
|
|
42
|
+
### Main Agent 전담 작업
|
|
51
43
|
|
|
52
44
|
- 사용자와 대화/질문 응답
|
|
53
45
|
- Task 흐름 관리 (TaskCreate, TaskUpdate, TaskList)
|
|
54
46
|
- Subagent 호출 및 결과 전달
|
|
55
|
-
- 단순 명령 실행 (Bash) -
|
|
47
|
+
- 단순 명령 실행 (Bash) - **Git/코드수정은 Subagent 전담**
|
|
56
48
|
|
|
57
|
-
###
|
|
49
|
+
### Git 작업은 git-manager 전담
|
|
58
50
|
|
|
59
|
-
**모든 Git 작업은 `git-manager` Agent에
|
|
51
|
+
**모든 Git 작업은 `git-manager` Agent에 위임하세요.**
|
|
60
52
|
|
|
61
53
|
\`\`\`
|
|
62
54
|
Task(subagent_type="git-manager", prompt="현재 변경사항을 커밋해줘")
|
|
63
55
|
Task(subagent_type="git-manager", prompt="PR을 생성해줘")
|
|
64
56
|
\`\`\`
|
|
65
57
|
|
|
66
|
-
| Git 작업 |
|
|
58
|
+
| Git 작업 | 전담 여부 | 이유 |
|
|
67
59
|
|----------|----------|------|
|
|
68
|
-
| 단순 커밋 |
|
|
69
|
-
| PR 생성 |
|
|
70
|
-
| 브랜치 관리 |
|
|
60
|
+
| 단순 커밋 | **전담** | 커밋 규칙 자동 준수 |
|
|
61
|
+
| PR 생성 | **전담** | PR 템플릿 자동 적용 |
|
|
62
|
+
| 브랜치 관리 | **전담** | 안전 규칙 자동 적용 |
|
|
71
63
|
|
|
72
|
-
###
|
|
64
|
+
### 왜 Subagent를 사용해야 하는가?
|
|
73
65
|
|
|
74
66
|
1. **Context 절약**: Subagent의 탐색/분석 결과는 요약되어 Main에 전달
|
|
75
67
|
2. **대화 지속성**: Main Context가 절약되어 더 긴 대화 가능
|
|
76
68
|
3. **전문성**: 각 Agent는 특정 작업에 최적화됨
|
|
77
69
|
4. **병렬 처리**: 여러 Agent를 동시에 실행 가능
|
|
78
70
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
71
|
+
</delegation_rules>
|
|
72
|
+
|
|
73
|
+
<phase name="Skill 평가">
|
|
74
|
+
|
|
75
|
+
## PART 1: SKILL 평가
|
|
82
76
|
|
|
83
77
|
Step 1 - Skill 평가: 각 Skill에 대해 다음을 명시하세요:
|
|
84
78
|
- Skill 이름
|
|
@@ -91,6 +85,7 @@ Step 2 - Skill 활성화: YES로 표시된 모든 Skill의 SKILL.md를 읽으세
|
|
|
91
85
|
|
|
92
86
|
### 사용 가능한 Skills (자동 탐색됨)
|
|
93
87
|
|
|
88
|
+
</phase>
|
|
94
89
|
EOF
|
|
95
90
|
|
|
96
91
|
# skills 폴더에서 SKILL.md 파일들의 frontmatter 자동 탐색
|
|
@@ -129,20 +124,22 @@ done
|
|
|
129
124
|
|
|
130
125
|
cat << 'EOF'
|
|
131
126
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
127
|
+
<phase name="Context 확인">
|
|
128
|
+
|
|
129
|
+
## PART 1.5: CONTEXT 확인 (Subagent 위임 권장)
|
|
135
130
|
|
|
136
131
|
**권장:** Context 확인은 `context-collector` Agent에 위임하세요.
|
|
137
|
-
|
|
132
|
+
여러 파일을 직접 읽는 대신, Subagent가 요약하여 전달합니다.
|
|
138
133
|
|
|
139
134
|
```
|
|
140
135
|
Task(subagent_type="context-collector", prompt="[작업 설명]에 필요한 Context를 수집하고 요약해줘")
|
|
141
136
|
```
|
|
142
137
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
138
|
+
</phase>
|
|
139
|
+
|
|
140
|
+
<phase name="Agent 평가">
|
|
141
|
+
|
|
142
|
+
## PART 2: AGENT 평가 (Context 절약 핵심)
|
|
146
143
|
|
|
147
144
|
Step 3 - Agent 평가: 각 Agent에 대해 다음을 명시하세요:
|
|
148
145
|
- Agent 이름
|
|
@@ -156,6 +153,7 @@ Step 4 - Agent 활용: YES로 표시된 Agent는 Task 도구로 호출하세요.
|
|
|
156
153
|
|
|
157
154
|
### 사용 가능한 Agents (자동 탐색됨)
|
|
158
155
|
|
|
156
|
+
</phase>
|
|
159
157
|
EOF
|
|
160
158
|
|
|
161
159
|
# agents 폴더에서 agent 파일들의 frontmatter 자동 탐색
|
|
@@ -196,19 +194,21 @@ done
|
|
|
196
194
|
|
|
197
195
|
cat << 'EOF'
|
|
198
196
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
197
|
+
<phase name="구현">
|
|
198
|
+
|
|
199
|
+
## PART 3: 구현
|
|
202
200
|
|
|
203
|
-
Step 5 - 구현: 모든 관련 Skill 확인 및 Agent 호출
|
|
201
|
+
Step 5 - 구현: 모든 관련 Skill 확인 및 Agent 호출 후에 구현을 시작하세요.
|
|
204
202
|
|
|
205
203
|
---
|
|
206
204
|
|
|
207
|
-
###
|
|
205
|
+
### 핵심 원칙
|
|
208
206
|
|
|
209
|
-
- **탐색 작업은
|
|
210
|
-
- **구현 후
|
|
207
|
+
- **탐색 작업은 Subagent 전담**: Main Context 절약
|
|
208
|
+
- **구현 후 검증 수행**: code-reviewer + qa-tester
|
|
211
209
|
- **단순 작업은 예외**: 설정 파일 수정, 오타 수정은 직접 처리 가능
|
|
212
210
|
|
|
213
211
|
지금 바로 모든 사용 가능한 Skill과 Agent를 평가하세요.
|
|
212
|
+
|
|
213
|
+
</phase>
|
|
214
214
|
EOF
|
|
@@ -12,16 +12,16 @@ PROJECT_CLAUDE_DIR="$(pwd)/.claude"
|
|
|
12
12
|
echo "✅ [Hook] 워크플로우 순서 강제 프로토콜 실행됨"
|
|
13
13
|
|
|
14
14
|
cat << 'EOF'
|
|
15
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
16
15
|
MANDATORY WORKFLOW SEQUENCE PROTOCOL
|
|
17
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
18
16
|
|
|
19
|
-
코드 작업 시
|
|
20
|
-
각 Phase를
|
|
17
|
+
코드 작업 시 아래 Phase 순서를 따르세요.
|
|
18
|
+
각 Phase를 순서대로 완료한 후 다음 Phase로 진행하세요.
|
|
21
19
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
<phase name="계획">
|
|
21
|
+
|
|
22
|
+
## PHASE 1: 계획 (Planning) - 구현 전 필수
|
|
23
|
+
|
|
24
|
+
<checklist>
|
|
25
25
|
|
|
26
26
|
### Step 1.1: Context 수집
|
|
27
27
|
|
|
@@ -47,15 +47,21 @@ PHASE 1: 계획 (Planning) - 구현 전 필수
|
|
|
47
47
|
- [ ] 각 파일의 변경 내용 요약
|
|
48
48
|
- [ ] 예상되는 영향 범위
|
|
49
49
|
|
|
50
|
-
### Step 1.4: 사용자 Confirm 받기
|
|
50
|
+
### Step 1.4: 사용자 Confirm 받기 -- 필수
|
|
51
51
|
|
|
52
52
|
중요: 계획을 사용자에게 보여주고 승인받은 후에만 구현 진행
|
|
53
53
|
- ExitPlanMode 사용 (Plan Mode인 경우)
|
|
54
54
|
- 또는 계획 내용을 명시적으로 보여주고 확인 요청
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
</checklist>
|
|
57
|
+
|
|
58
|
+
</phase>
|
|
59
|
+
|
|
60
|
+
<phase name="검증">
|
|
61
|
+
|
|
62
|
+
## PHASE 2: 검증 (Validation) - 구현 전 필수
|
|
63
|
+
|
|
64
|
+
<checklist>
|
|
59
65
|
|
|
60
66
|
### Step 2.1: 사이드이펙트 검증
|
|
61
67
|
|
|
@@ -66,27 +72,39 @@ PHASE 2: 검증 (Validation) - 구현 전 필수
|
|
|
66
72
|
|
|
67
73
|
도구: impact-analyzer Agent (복잡한 경우)
|
|
68
74
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
75
|
+
</checklist>
|
|
76
|
+
|
|
77
|
+
</phase>
|
|
78
|
+
|
|
79
|
+
<phase name="구현">
|
|
80
|
+
|
|
81
|
+
## PHASE 3: 구현 (Implementation)
|
|
82
|
+
|
|
83
|
+
<checklist>
|
|
72
84
|
|
|
73
85
|
### Step 3.1: 작은 단위로 코드 수정
|
|
74
86
|
|
|
75
87
|
필수 원칙:
|
|
76
88
|
- [ ] 독립적으로 빌드 가능한 단위로 작업
|
|
77
89
|
- [ ] 한 번에 하나의 기능/수정만 진행
|
|
78
|
-
- [ ] 빌드
|
|
90
|
+
- [ ] 빌드 가능 상태를 유지
|
|
79
91
|
|
|
80
92
|
### Step 3.2: 단위별 커밋
|
|
81
93
|
|
|
82
94
|
필수 규칙:
|
|
83
|
-
- [ ] 수정한 파일만
|
|
95
|
+
- [ ] 수정한 파일만 개별 지정하여 git add
|
|
84
96
|
- [ ] 명확한 커밋 메시지 작성 (Git Skill 참조)
|
|
85
97
|
- [ ] 커밋 단위: 하나의 논리적 변경
|
|
86
98
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
99
|
+
</checklist>
|
|
100
|
+
|
|
101
|
+
</phase>
|
|
102
|
+
|
|
103
|
+
<phase name="리뷰">
|
|
104
|
+
|
|
105
|
+
## PHASE 4: 리뷰 (Review) - 구현 후 필수
|
|
106
|
+
|
|
107
|
+
<checklist>
|
|
90
108
|
|
|
91
109
|
### Step 4.1: Self Code Review
|
|
92
110
|
|
|
@@ -102,18 +120,20 @@ PHASE 4: 리뷰 (Review) - 구현 후 필수
|
|
|
102
120
|
필수 확인:
|
|
103
121
|
- [ ] 원래 요청사항이 모두 충족되었는지 확인
|
|
104
122
|
- [ ] 예상한 동작이 구현되었는지 확인
|
|
105
|
-
- [ ]
|
|
123
|
+
- [ ] 모든 엣지케이스가 처리되었는지 점검
|
|
124
|
+
|
|
125
|
+
</checklist>
|
|
106
126
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
127
|
+
</phase>
|
|
128
|
+
|
|
129
|
+
### 워크플로우 요약
|
|
110
130
|
|
|
111
131
|
┌─────────────────────────────────────────────────────────────┐
|
|
112
132
|
│ PHASE 1: 계획 │
|
|
113
133
|
│ ├─ 1.1 Context 수집 │
|
|
114
134
|
│ ├─ 1.2 TaskList 생성 │
|
|
115
135
|
│ ├─ 1.3 수정 계획 작성 │
|
|
116
|
-
│ └─ 1.4 사용자 Confirm
|
|
136
|
+
│ └─ 1.4 사용자 Confirm │
|
|
117
137
|
│ ↓ │
|
|
118
138
|
│ PHASE 2: 검증 │
|
|
119
139
|
│ └─ 2.1 사이드이펙트 검증 (Code Flow, UserFlow) │
|
|
@@ -127,9 +147,9 @@ PHASE 4: 리뷰 (Review) - 구현 후 필수
|
|
|
127
147
|
│ └─ 4.2 Task 완료 검증 │
|
|
128
148
|
└─────────────────────────────────────────────────────────────┘
|
|
129
149
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
### 참조 가능한 Skills (자동 탐색됨)
|
|
133
153
|
|
|
134
154
|
EOF
|
|
135
155
|
|
|
@@ -169,9 +189,7 @@ done
|
|
|
169
189
|
|
|
170
190
|
cat << 'EOF'
|
|
171
191
|
|
|
172
|
-
|
|
173
|
-
예외 상황
|
|
174
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
192
|
+
### 예외 상황
|
|
175
193
|
|
|
176
194
|
다음의 경우 Phase를 축소/생략 가능:
|
|
177
195
|
- 단순 오타 수정
|
|
@@ -179,5 +197,5 @@ cat << 'EOF'
|
|
|
179
197
|
- 1-2줄 변경
|
|
180
198
|
- 사용자가 명시적으로 빠른 수정 요청
|
|
181
199
|
|
|
182
|
-
그 외 모든 코드 작업은
|
|
200
|
+
그 외 모든 코드 작업은 위 순서를 따르세요.
|
|
183
201
|
EOF
|
|
@@ -7,6 +7,8 @@ estimated_tokens: ~400
|
|
|
7
7
|
|
|
8
8
|
# 백엔드 개발 원칙
|
|
9
9
|
|
|
10
|
+
<rules>
|
|
11
|
+
|
|
10
12
|
## 레이어 간 객체 변환 규칙
|
|
11
13
|
|
|
12
14
|
> **객체 변환은 필요한 시점에 해당 레이어에서 수행한다.**
|
|
@@ -15,12 +17,16 @@ estimated_tokens: ~400
|
|
|
15
17
|
|
|
16
18
|
| 레이어 | 입력 | 출력 | 변환 책임 |
|
|
17
19
|
|--------|------|------|----------|
|
|
18
|
-
| **Controller** | Request DTO | Response DTO/Schema | Entity
|
|
19
|
-
| **Service** | DTO (그대로 사용) | Entity 또는 일반 객체 | DTO
|
|
20
|
+
| **Controller** | Request DTO | Response DTO/Schema | Entity -> Response 변환 |
|
|
21
|
+
| **Service** | DTO (그대로 사용) | Entity 또는 일반 객체 | DTO -> Entity 변환 (필요시) |
|
|
20
22
|
| **Repository** | Entity | Entity | 없음 |
|
|
21
23
|
|
|
22
|
-
|
|
24
|
+
</rules>
|
|
25
|
+
|
|
26
|
+
### Controller -> Service 호출
|
|
23
27
|
|
|
28
|
+
<examples>
|
|
29
|
+
<example type="bad">
|
|
24
30
|
```typescript
|
|
25
31
|
// ❌ Controller에서 미리 Entity로 변환
|
|
26
32
|
@Post()
|
|
@@ -30,13 +36,18 @@ async create(@Body() dto: CreateUserDto) {
|
|
|
30
36
|
entity.email = dto.email;
|
|
31
37
|
return this.userService.create(entity); // Entity 전달
|
|
32
38
|
}
|
|
33
|
-
|
|
39
|
+
```
|
|
40
|
+
</example>
|
|
41
|
+
<example type="good">
|
|
42
|
+
```typescript
|
|
34
43
|
// ✅ DTO 그대로 전달
|
|
35
44
|
@Post()
|
|
36
45
|
async create(@Body() dto: CreateUserDto) {
|
|
37
46
|
return this.userService.create(dto); // DTO 전달
|
|
38
47
|
}
|
|
39
48
|
```
|
|
49
|
+
</example>
|
|
50
|
+
</examples>
|
|
40
51
|
|
|
41
52
|
### Service 내부 처리
|
|
42
53
|
|
|
@@ -55,7 +66,7 @@ async create(dto: CreateUserDto) {
|
|
|
55
66
|
}
|
|
56
67
|
```
|
|
57
68
|
|
|
58
|
-
### Service
|
|
69
|
+
### Service -> Controller 반환
|
|
59
70
|
|
|
60
71
|
```typescript
|
|
61
72
|
// ✅ Service: Entity 또는 일반 객체 반환
|
|
@@ -79,9 +90,11 @@ async findOne(@Param('id') id: number) {
|
|
|
79
90
|
|
|
80
91
|
---
|
|
81
92
|
|
|
93
|
+
<rules>
|
|
94
|
+
|
|
82
95
|
## TypeORM 사용 규칙
|
|
83
96
|
|
|
84
|
-
> **find 메서드를 기본으로 사용하고, QueryBuilder는
|
|
97
|
+
> **find 메서드를 기본으로 사용하고, QueryBuilder는 필요한 경우에만 사용한다.**
|
|
85
98
|
|
|
86
99
|
### find 메서드 우선 사용
|
|
87
100
|
|
|
@@ -115,6 +128,10 @@ const users = await this.userRepository.find({
|
|
|
115
128
|
| **복잡한 서브쿼리** | 중첩 쿼리 |
|
|
116
129
|
| **복잡한 JOIN 조건** | ON 절 커스텀 |
|
|
117
130
|
|
|
131
|
+
</rules>
|
|
132
|
+
|
|
133
|
+
<examples>
|
|
134
|
+
<example type="good">
|
|
118
135
|
```typescript
|
|
119
136
|
// ✅ QueryBuilder 허용: groupBy + getRawMany
|
|
120
137
|
const stats = await this.orderRepository
|
|
@@ -124,24 +141,36 @@ const stats = await this.orderRepository
|
|
|
124
141
|
.addSelect('SUM(order.amount)', 'total')
|
|
125
142
|
.groupBy('order.status')
|
|
126
143
|
.getRawMany();
|
|
127
|
-
|
|
144
|
+
```
|
|
145
|
+
</example>
|
|
146
|
+
<example type="bad">
|
|
147
|
+
```typescript
|
|
128
148
|
// ❌ 불필요한 QueryBuilder 사용
|
|
129
149
|
const user = await this.userRepository
|
|
130
150
|
.createQueryBuilder('user')
|
|
131
151
|
.where('user.id = :id', { id })
|
|
132
152
|
.getOne();
|
|
133
|
-
|
|
153
|
+
```
|
|
154
|
+
</example>
|
|
155
|
+
<example type="good">
|
|
156
|
+
```typescript
|
|
134
157
|
// ✅ find로 대체
|
|
135
158
|
const user = await this.userRepository.findOneBy({ id });
|
|
136
159
|
```
|
|
160
|
+
</example>
|
|
161
|
+
</examples>
|
|
137
162
|
|
|
138
163
|
---
|
|
139
164
|
|
|
165
|
+
<checklist>
|
|
166
|
+
|
|
140
167
|
## 체크리스트
|
|
141
168
|
|
|
142
|
-
- [ ] Controller에서
|
|
169
|
+
- [ ] Controller에서 DTO를 그대로 Service에 전달하는가? (Entity 변환은 Service에서)
|
|
143
170
|
- [ ] Service에서 Entity가 필요한 시점에 변환하는가?
|
|
144
171
|
- [ ] Service의 return은 Entity 또는 일반 객체인가?
|
|
145
172
|
- [ ] Controller에서 Response DTO/Schema로 변환하는가?
|
|
146
173
|
- [ ] TypeORM find 메서드를 우선 사용하는가?
|
|
147
174
|
- [ ] QueryBuilder는 groupBy, getRawMany 등 필요한 경우에만 사용하는가?
|
|
175
|
+
|
|
176
|
+
</checklist>
|