create-ai-project 1.13.0 → 1.14.0
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/.claude/agents-en/code-verifier.md +192 -0
- package/.claude/agents-en/document-reviewer.md +146 -35
- package/.claude/agents-en/investigator.md +67 -40
- package/.claude/agents-en/prd-creator.md +37 -14
- package/.claude/agents-en/scope-discoverer.md +229 -0
- package/.claude/agents-en/solver.md +16 -1
- package/.claude/agents-en/verifier.md +28 -4
- package/.claude/agents-ja/code-verifier.md +192 -0
- package/.claude/agents-ja/document-reviewer.md +158 -43
- package/.claude/agents-ja/investigator.md +67 -40
- package/.claude/agents-ja/prd-creator.md +45 -15
- package/.claude/agents-ja/scope-discoverer.md +229 -0
- package/.claude/agents-ja/solver.md +17 -2
- package/.claude/agents-ja/verifier.md +29 -5
- package/.claude/commands-en/diagnose.md +57 -20
- package/.claude/commands-en/reverse-engineer.md +301 -0
- package/.claude/commands-ja/diagnose.md +57 -20
- package/.claude/commands-ja/reverse-engineer.md +301 -0
- package/README.ja.md +28 -1
- package/README.md +27 -1
- package/package.json +1 -1
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: reverse-engineer
|
|
3
|
+
description: Generate PRD and Design Docs from existing codebase through discovery, generation, verification, and review workflow
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
**Command Context**: Reverse engineering workflow to create documentation from existing code
|
|
7
|
+
|
|
8
|
+
Target: $ARGUMENTS
|
|
9
|
+
|
|
10
|
+
**TodoWrite**: Register phases first, then steps within each phase as you enter it.
|
|
11
|
+
|
|
12
|
+
## Step 0: Initial Configuration
|
|
13
|
+
|
|
14
|
+
### 0.1 Scope Confirmation
|
|
15
|
+
|
|
16
|
+
Use AskUserQuestion to confirm:
|
|
17
|
+
1. **Target path**: Which directory/module to document
|
|
18
|
+
2. **Depth**: PRD only, or PRD + Design Docs
|
|
19
|
+
3. **Reference Architecture**: layered / mvc / clean / hexagonal / none
|
|
20
|
+
4. **Human review**: Yes (recommended) / No (fully autonomous)
|
|
21
|
+
|
|
22
|
+
### 0.2 Output Configuration
|
|
23
|
+
|
|
24
|
+
- PRD output: `docs/prd/` or existing PRD directory
|
|
25
|
+
- Design Doc output: `docs/design/` or existing design directory
|
|
26
|
+
- Verify directories exist, create if needed
|
|
27
|
+
|
|
28
|
+
## Workflow Overview
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
Phase 1: PRD Generation
|
|
32
|
+
Step 1: Scope Discovery (all units)
|
|
33
|
+
Step 2-5: Per-unit loop (Generation → Verification → Review → Revision)
|
|
34
|
+
|
|
35
|
+
Phase 2: Design Doc Generation (if requested)
|
|
36
|
+
Step 6: Scope Discovery (all components per PRD)
|
|
37
|
+
Step 7-10: Per-component loop (Generation → Verification → Review → Revision)
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
**Context Passing**: Pass structured JSON output between steps. Use `$STEP_N_OUTPUT` placeholder notation.
|
|
41
|
+
|
|
42
|
+
## Phase 1: PRD Generation
|
|
43
|
+
|
|
44
|
+
**Register in TodoWrite**:
|
|
45
|
+
- Step 1: PRD Scope Discovery
|
|
46
|
+
- Per-unit processing (Steps 2-5 for each unit)
|
|
47
|
+
|
|
48
|
+
### Step 1: PRD Scope Discovery
|
|
49
|
+
|
|
50
|
+
**Task invocation**:
|
|
51
|
+
```
|
|
52
|
+
subagent_type: scope-discoverer
|
|
53
|
+
prompt: |
|
|
54
|
+
Discover PRD targets in the codebase.
|
|
55
|
+
|
|
56
|
+
scope_type: prd
|
|
57
|
+
target_path: $USER_TARGET_PATH
|
|
58
|
+
reference_architecture: $USER_RA_CHOICE
|
|
59
|
+
focus_area: $USER_FOCUS_AREA (if specified)
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
**Store output as**: `$STEP_1_OUTPUT`
|
|
63
|
+
|
|
64
|
+
**Quality Gate**:
|
|
65
|
+
- At least one PRD unit discovered → proceed
|
|
66
|
+
- No units discovered → ask user for hints
|
|
67
|
+
|
|
68
|
+
**Human Review Point** (if enabled): Present discovered units for confirmation.
|
|
69
|
+
|
|
70
|
+
### Step 2-5: Per-Unit Processing
|
|
71
|
+
|
|
72
|
+
**Complete Steps 2→3→4→5 for each unit before proceeding to the next unit.**
|
|
73
|
+
|
|
74
|
+
#### Step 2: PRD Generation
|
|
75
|
+
|
|
76
|
+
**Task invocation**:
|
|
77
|
+
```
|
|
78
|
+
subagent_type: prd-creator
|
|
79
|
+
prompt: |
|
|
80
|
+
Create reverse-engineered PRD for the following feature.
|
|
81
|
+
|
|
82
|
+
Operation Mode: reverse-engineer
|
|
83
|
+
External Scope Provided: true
|
|
84
|
+
|
|
85
|
+
Feature: $UNIT_NAME (from $STEP_1_OUTPUT)
|
|
86
|
+
Description: $UNIT_DESCRIPTION
|
|
87
|
+
Related Files: $UNIT_RELATED_FILES
|
|
88
|
+
Entry Points: $UNIT_ENTRY_POINTS
|
|
89
|
+
|
|
90
|
+
Skip independent scope discovery. Use provided scope data.
|
|
91
|
+
Create final version PRD based on code investigation within specified scope.
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
**Store output as**: `$STEP_2_OUTPUT` (PRD path)
|
|
95
|
+
|
|
96
|
+
#### Step 3: Code Verification
|
|
97
|
+
|
|
98
|
+
**Task invocation**:
|
|
99
|
+
```
|
|
100
|
+
subagent_type: code-verifier
|
|
101
|
+
prompt: |
|
|
102
|
+
Verify consistency between PRD and code implementation.
|
|
103
|
+
|
|
104
|
+
doc_type: prd
|
|
105
|
+
document_path: $STEP_2_OUTPUT
|
|
106
|
+
code_paths: $UNIT_RELATED_FILES (from $STEP_1_OUTPUT)
|
|
107
|
+
verbose: false
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
**Store output as**: `$STEP_3_OUTPUT`
|
|
111
|
+
|
|
112
|
+
**Quality Gate**:
|
|
113
|
+
- consistencyScore >= 70 → proceed to review
|
|
114
|
+
- consistencyScore < 70 → flag for detailed review
|
|
115
|
+
|
|
116
|
+
#### Step 4: Review
|
|
117
|
+
|
|
118
|
+
**Required Input**: $STEP_3_OUTPUT (verification JSON from Step 3)
|
|
119
|
+
|
|
120
|
+
**Task invocation**:
|
|
121
|
+
```
|
|
122
|
+
subagent_type: document-reviewer
|
|
123
|
+
prompt: |
|
|
124
|
+
Review the following PRD considering code verification findings.
|
|
125
|
+
|
|
126
|
+
doc_type: PRD
|
|
127
|
+
target: $STEP_2_OUTPUT
|
|
128
|
+
mode: composite
|
|
129
|
+
|
|
130
|
+
## Code Verification Results
|
|
131
|
+
$STEP_3_OUTPUT
|
|
132
|
+
|
|
133
|
+
## Additional Review Focus
|
|
134
|
+
- Alignment between PRD claims and verification evidence
|
|
135
|
+
- Resolution recommendations for each discrepancy
|
|
136
|
+
- Completeness of undocumented feature coverage
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
**Store output as**: `$STEP_4_OUTPUT`
|
|
140
|
+
|
|
141
|
+
#### Step 5: Revision (conditional)
|
|
142
|
+
|
|
143
|
+
**Trigger Conditions** (any one of the following):
|
|
144
|
+
- Review status is "Needs Revision" or "Rejected"
|
|
145
|
+
- Critical discrepancies exist in `$STEP_3_OUTPUT`
|
|
146
|
+
- consistencyScore < 70
|
|
147
|
+
|
|
148
|
+
**Task invocation**:
|
|
149
|
+
```
|
|
150
|
+
subagent_type: prd-creator
|
|
151
|
+
prompt: |
|
|
152
|
+
Update PRD based on review feedback.
|
|
153
|
+
|
|
154
|
+
Operation Mode: update
|
|
155
|
+
Existing PRD: $STEP_2_OUTPUT
|
|
156
|
+
|
|
157
|
+
## Review Feedback
|
|
158
|
+
$STEP_4_OUTPUT
|
|
159
|
+
|
|
160
|
+
## Discrepancies to Address
|
|
161
|
+
(Extract critical and major discrepancies from $STEP_3_OUTPUT)
|
|
162
|
+
|
|
163
|
+
Apply corrections and improvements.
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
**Loop Control**: Maximum 2 revision cycles. After 2 cycles, flag for human review regardless of status.
|
|
167
|
+
|
|
168
|
+
#### Unit Completion
|
|
169
|
+
|
|
170
|
+
- [ ] Review status is "Approved" or "Approved with Conditions"
|
|
171
|
+
- [ ] Human review passed (if enabled in Step 0)
|
|
172
|
+
|
|
173
|
+
**Next**: Proceed to next unit. After all units → Phase 2.
|
|
174
|
+
|
|
175
|
+
## Phase 2: Design Doc Generation
|
|
176
|
+
|
|
177
|
+
*Execute only if Design Docs were requested in Step 0*
|
|
178
|
+
|
|
179
|
+
**Register in TodoWrite**:
|
|
180
|
+
- Step 6: Design Doc Scope Discovery
|
|
181
|
+
- Per-component processing (Steps 7-10 for each component)
|
|
182
|
+
|
|
183
|
+
### Step 6: Design Doc Scope Discovery
|
|
184
|
+
|
|
185
|
+
For each approved PRD:
|
|
186
|
+
|
|
187
|
+
**Task invocation**:
|
|
188
|
+
```
|
|
189
|
+
subagent_type: scope-discoverer
|
|
190
|
+
prompt: |
|
|
191
|
+
Discover Design Doc targets within PRD scope.
|
|
192
|
+
|
|
193
|
+
scope_type: design-doc
|
|
194
|
+
existing_prd: $APPROVED_PRD_PATH
|
|
195
|
+
target_path: $PRD_RELATED_PATHS
|
|
196
|
+
reference_architecture: $USER_RA_CHOICE
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
**Store output as**: `$STEP_6_OUTPUT`
|
|
200
|
+
|
|
201
|
+
**Quality Gate**:
|
|
202
|
+
- At least one component discovered → proceed
|
|
203
|
+
- No components → ask user for hints
|
|
204
|
+
|
|
205
|
+
### Step 7-10: Per-Component Processing
|
|
206
|
+
|
|
207
|
+
**Complete Steps 7→8→9→10 for each component before proceeding to the next component.**
|
|
208
|
+
|
|
209
|
+
#### Step 7: Design Doc Generation
|
|
210
|
+
|
|
211
|
+
**Task invocation**:
|
|
212
|
+
```
|
|
213
|
+
subagent_type: technical-designer
|
|
214
|
+
prompt: |
|
|
215
|
+
Create Design Doc for the following component based on existing code.
|
|
216
|
+
|
|
217
|
+
Operation Mode: create
|
|
218
|
+
|
|
219
|
+
Component: $COMPONENT_NAME (from $STEP_6_OUTPUT)
|
|
220
|
+
Responsibility: $COMPONENT_RESPONSIBILITY
|
|
221
|
+
Primary Files: $COMPONENT_PRIMARY_FILES
|
|
222
|
+
Public Interfaces: $COMPONENT_PUBLIC_INTERFACES
|
|
223
|
+
Dependencies: $COMPONENT_DEPENDENCIES
|
|
224
|
+
|
|
225
|
+
Parent PRD: $APPROVED_PRD_PATH
|
|
226
|
+
|
|
227
|
+
Document current architecture. Do not propose changes.
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
**Store output as**: `$STEP_7_OUTPUT`
|
|
231
|
+
|
|
232
|
+
#### Step 8: Code Verification
|
|
233
|
+
|
|
234
|
+
**Task invocation**:
|
|
235
|
+
```
|
|
236
|
+
subagent_type: code-verifier
|
|
237
|
+
prompt: |
|
|
238
|
+
Verify consistency between Design Doc and code implementation.
|
|
239
|
+
|
|
240
|
+
doc_type: design-doc
|
|
241
|
+
document_path: $STEP_7_OUTPUT
|
|
242
|
+
code_paths: $COMPONENT_PRIMARY_FILES
|
|
243
|
+
verbose: false
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
**Store output as**: `$STEP_8_OUTPUT`
|
|
247
|
+
|
|
248
|
+
#### Step 9: Review
|
|
249
|
+
|
|
250
|
+
**Required Input**: $STEP_8_OUTPUT (verification JSON from Step 8)
|
|
251
|
+
|
|
252
|
+
**Task invocation**:
|
|
253
|
+
```
|
|
254
|
+
subagent_type: document-reviewer
|
|
255
|
+
prompt: |
|
|
256
|
+
Review the following Design Doc considering code verification findings.
|
|
257
|
+
|
|
258
|
+
doc_type: DesignDoc
|
|
259
|
+
target: $STEP_7_OUTPUT
|
|
260
|
+
mode: composite
|
|
261
|
+
|
|
262
|
+
## Code Verification Results
|
|
263
|
+
$STEP_8_OUTPUT
|
|
264
|
+
|
|
265
|
+
## Parent PRD
|
|
266
|
+
$APPROVED_PRD_PATH
|
|
267
|
+
|
|
268
|
+
## Additional Review Focus
|
|
269
|
+
- Technical accuracy of documented interfaces
|
|
270
|
+
- Consistency with parent PRD scope
|
|
271
|
+
- Completeness of component boundary definitions
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
**Store output as**: `$STEP_9_OUTPUT`
|
|
275
|
+
|
|
276
|
+
#### Step 10: Revision (conditional)
|
|
277
|
+
|
|
278
|
+
Same logic as Step 5, using technical-designer with update mode.
|
|
279
|
+
|
|
280
|
+
#### Component Completion
|
|
281
|
+
|
|
282
|
+
- [ ] Review status is "Approved" or "Approved with Conditions"
|
|
283
|
+
- [ ] Human review passed (if enabled in Step 0)
|
|
284
|
+
|
|
285
|
+
**Next**: Proceed to next component. After all components → Final Report.
|
|
286
|
+
|
|
287
|
+
## Final Report
|
|
288
|
+
|
|
289
|
+
Output summary including:
|
|
290
|
+
- Generated documents table (Type, Name, Consistency Score, Review Status)
|
|
291
|
+
- Action items (critical discrepancies, undocumented features, flagged items)
|
|
292
|
+
- Next steps checklist
|
|
293
|
+
|
|
294
|
+
## Error Handling
|
|
295
|
+
|
|
296
|
+
| Error | Action |
|
|
297
|
+
|-------|--------|
|
|
298
|
+
| Discovery finds nothing | Ask user for project structure hints |
|
|
299
|
+
| Generation fails | Log failure, continue with other units, report in summary |
|
|
300
|
+
| consistencyScore < 50 | Flag for mandatory human review, do not auto-approve |
|
|
301
|
+
| Review rejects after 2 revisions | Stop loop, flag for human intervention |
|
|
@@ -8,20 +8,47 @@ description: 問題を調査し、検証を経て解決策を導出する
|
|
|
8
8
|
|
|
9
9
|
**TodoWrite登録**: 実行ステップをTodoWriteに登録し、計画的にタスクを進める
|
|
10
10
|
|
|
11
|
+
## ステップ0: 問題の構造化(investigator呼び出し前)
|
|
12
|
+
|
|
13
|
+
### 0.1 問題タイプの判定
|
|
14
|
+
|
|
15
|
+
| タイプ | 判断基準 |
|
|
16
|
+
|--------|---------|
|
|
17
|
+
| 変更失敗 | 問題発生の前に何らかの変更があったことが示唆されている |
|
|
18
|
+
| 新規発見 | 変更との関連が示唆されていない |
|
|
19
|
+
|
|
20
|
+
判断に迷う場合は「問題発生の直前に何か変更しましたか?」とユーザーに確認。
|
|
21
|
+
|
|
22
|
+
### 0.2 変更失敗の場合の情報補完
|
|
23
|
+
|
|
24
|
+
以下が不明な場合、**AskUserQuestionで質問**してから次に進む:
|
|
25
|
+
- 何を変更したか(原因変更)
|
|
26
|
+
- 何が壊れたか(影響箇所)
|
|
27
|
+
- 両者の関係(共通コンポーネント等)
|
|
28
|
+
|
|
29
|
+
### 0.3 investigatorプロンプトへの反映
|
|
30
|
+
|
|
31
|
+
**変更失敗の場合、以下を必須調査項目としてプロンプトに含める**:
|
|
32
|
+
1. 原因変更の内容を詳細に分析
|
|
33
|
+
2. 原因変更と影響箇所の共通点を特定
|
|
34
|
+
3. 原因変更が正しい修正か新たなバグかを判定し、判定結果に基づいて比較基準を選択
|
|
35
|
+
|
|
11
36
|
## 診断フロー概要
|
|
12
37
|
|
|
13
38
|
```
|
|
14
|
-
問題 →
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
39
|
+
問題 → 調査 → 品質判定 → [検証] → 解決策導出
|
|
40
|
+
↓
|
|
41
|
+
単純な場合は
|
|
42
|
+
検証スキップ
|
|
18
43
|
```
|
|
19
44
|
|
|
20
45
|
**コンテキスト分離**: 各ステップには構造化JSON出力のみを渡す。思考過程は引き継がない。
|
|
21
46
|
|
|
22
47
|
## 実行ステップ
|
|
23
48
|
|
|
24
|
-
|
|
49
|
+
以下をTodoWriteに登録して実行:
|
|
50
|
+
|
|
51
|
+
### ステップ1: 調査(investigator)
|
|
25
52
|
|
|
26
53
|
**Taskツールでの呼び出し**:
|
|
27
54
|
```
|
|
@@ -31,46 +58,55 @@ prompt: 以下の現象について、関連する情報を網羅的に収集し
|
|
|
31
58
|
現象: [ユーザーが報告した問題]
|
|
32
59
|
```
|
|
33
60
|
|
|
34
|
-
**期待される出力**:
|
|
61
|
+
**期待される出力**: 証拠マトリクス、比較分析結果、因果追跡結果、未探索領域のリスト、調査の限界
|
|
62
|
+
|
|
63
|
+
### ステップ2: 品質判定・検証判断
|
|
64
|
+
|
|
65
|
+
調査出力を確認し判定:
|
|
35
66
|
|
|
36
|
-
|
|
67
|
+
**調査品質チェック**(出力JSONに以下が含まれているか):
|
|
68
|
+
- [ ] comparisonAnalysis
|
|
69
|
+
- [ ] 各仮説にcausalChain(停止条件に到達)
|
|
70
|
+
- [ ] 各仮説にcauseCategory
|
|
37
71
|
|
|
38
|
-
|
|
72
|
+
**品質不足の場合**: 不足項目を指定して調査を再実行
|
|
39
73
|
|
|
40
|
-
|
|
74
|
+
**検証実行条件(1つでも該当)**:
|
|
41
75
|
- 2つ以上の仮説が同程度の証拠を持つ
|
|
42
76
|
- 直接証拠がなく間接証拠のみ
|
|
43
77
|
- 未探索領域が2つ以上ある
|
|
44
78
|
- 仮説に反証する証拠が存在する
|
|
45
79
|
- 問題が過去に再発している
|
|
80
|
+
- impactAnalysis.impactScopeに3件以上の該当箇所がある
|
|
81
|
+
- impactAnalysis.recurrenceRiskがhigh
|
|
46
82
|
|
|
47
|
-
|
|
83
|
+
**検証スキップ条件(すべて該当)**:
|
|
48
84
|
- 1つの仮説が明らかに優勢(直接証拠あり、反証なし)
|
|
49
85
|
- 未探索領域がほぼない
|
|
50
86
|
- 単発の問題(再発履歴なし)
|
|
51
87
|
|
|
52
|
-
|
|
88
|
+
判定結果をユーザーに報告し、検証をスキップする場合は理由を説明。
|
|
53
89
|
|
|
54
|
-
### ステップ3:
|
|
90
|
+
### ステップ3: 検証(verifier)※複雑な問題の場合
|
|
55
91
|
|
|
56
92
|
**Taskツールでの呼び出し**:
|
|
57
93
|
```
|
|
58
94
|
subagent_type: verifier
|
|
59
95
|
prompt: 以下の調査結果を検証してください。
|
|
60
96
|
|
|
61
|
-
調査結果: [
|
|
97
|
+
調査結果: [調査のJSON出力]
|
|
62
98
|
```
|
|
63
99
|
|
|
64
100
|
**期待される出力**: 代替仮説(最低3つ)、Devil's Advocate評価、最終結論、信頼度
|
|
65
101
|
|
|
66
|
-
### ステップ4:
|
|
102
|
+
### ステップ4: 解決策導出(solver)
|
|
67
103
|
|
|
68
104
|
**Taskツールでの呼び出し**:
|
|
69
105
|
```
|
|
70
106
|
subagent_type: solver
|
|
71
107
|
prompt: 以下の検証済み結論に基づいて、解決策を導出してください。
|
|
72
108
|
|
|
73
|
-
結論: [
|
|
109
|
+
結論: [検証または調査の結論部分]
|
|
74
110
|
信頼度: [high/medium/low]
|
|
75
111
|
```
|
|
76
112
|
|
|
@@ -116,8 +152,9 @@ prompt: 以下の検証済み結論に基づいて、解決策を導出してく
|
|
|
116
152
|
|
|
117
153
|
## 完了条件
|
|
118
154
|
|
|
119
|
-
- [ ]
|
|
120
|
-
- [ ]
|
|
121
|
-
- [ ]
|
|
122
|
-
- [ ]
|
|
123
|
-
- [ ]
|
|
155
|
+
- [ ] 調査を実行し、証拠マトリクス・比較分析・因果追跡を取得した
|
|
156
|
+
- [ ] 調査品質チェックを行い、不足があれば再実行した
|
|
157
|
+
- [ ] 検証判断を行い、結果をユーザーに報告した
|
|
158
|
+
- [ ] (複雑な場合)検証を実行した
|
|
159
|
+
- [ ] 解決策導出を実行した
|
|
160
|
+
- [ ] 最終レポートをユーザーに提示した
|