create-ai-project 1.13.1 → 1.14.1

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.
Files changed (69) hide show
  1. package/.claude/agents-en/acceptance-test-generator.md +1 -1
  2. package/.claude/agents-en/code-reviewer.md +1 -1
  3. package/.claude/agents-en/code-verifier.md +192 -0
  4. package/.claude/agents-en/design-sync.md +1 -1
  5. package/.claude/agents-en/document-reviewer.md +147 -36
  6. package/.claude/agents-en/integration-test-reviewer.md +1 -1
  7. package/.claude/agents-en/investigator.md +1 -1
  8. package/.claude/agents-en/prd-creator.md +38 -15
  9. package/.claude/agents-en/requirement-analyzer.md +1 -1
  10. package/.claude/agents-en/rule-advisor.md +1 -1
  11. package/.claude/agents-en/scope-discoverer.md +229 -0
  12. package/.claude/agents-en/solver.md +1 -1
  13. package/.claude/agents-en/task-decomposer.md +1 -1
  14. package/.claude/agents-en/task-executor-frontend.md +1 -1
  15. package/.claude/agents-en/task-executor.md +1 -1
  16. package/.claude/agents-en/technical-designer-frontend.md +1 -1
  17. package/.claude/agents-en/technical-designer.md +1 -1
  18. package/.claude/agents-en/verifier.md +1 -1
  19. package/.claude/agents-en/work-planner.md +1 -1
  20. package/.claude/agents-ja/acceptance-test-generator.md +1 -1
  21. package/.claude/agents-ja/code-reviewer.md +1 -1
  22. package/.claude/agents-ja/code-verifier.md +192 -0
  23. package/.claude/agents-ja/design-sync.md +1 -1
  24. package/.claude/agents-ja/document-reviewer.md +159 -44
  25. package/.claude/agents-ja/integration-test-reviewer.md +1 -1
  26. package/.claude/agents-ja/investigator.md +1 -1
  27. package/.claude/agents-ja/prd-creator.md +46 -16
  28. package/.claude/agents-ja/requirement-analyzer.md +1 -1
  29. package/.claude/agents-ja/rule-advisor.md +1 -1
  30. package/.claude/agents-ja/scope-discoverer.md +229 -0
  31. package/.claude/agents-ja/solver.md +1 -1
  32. package/.claude/agents-ja/task-decomposer.md +1 -1
  33. package/.claude/agents-ja/task-executor-frontend.md +1 -1
  34. package/.claude/agents-ja/task-executor.md +1 -1
  35. package/.claude/agents-ja/technical-designer-frontend.md +1 -1
  36. package/.claude/agents-ja/technical-designer.md +1 -1
  37. package/.claude/agents-ja/verifier.md +1 -1
  38. package/.claude/agents-ja/work-planner.md +1 -1
  39. package/.claude/commands-en/reverse-engineer.md +301 -0
  40. package/.claude/commands-ja/reverse-engineer.md +301 -0
  41. package/.claude/skills-en/coding-standards/SKILL.md +3 -1
  42. package/.claude/skills-en/documentation-criteria/SKILL.md +3 -1
  43. package/.claude/skills-en/frontend/technical-spec/SKILL.md +3 -1
  44. package/.claude/skills-en/frontend/typescript-rules/SKILL.md +3 -1
  45. package/.claude/skills-en/frontend/typescript-testing/SKILL.md +3 -1
  46. package/.claude/skills-en/implementation-approach/SKILL.md +3 -1
  47. package/.claude/skills-en/integration-e2e-testing/SKILL.md +3 -1
  48. package/.claude/skills-en/project-context/SKILL.md +3 -1
  49. package/.claude/skills-en/subagents-orchestration-guide/SKILL.md +3 -1
  50. package/.claude/skills-en/task-analyzer/SKILL.md +3 -1
  51. package/.claude/skills-en/technical-spec/SKILL.md +3 -1
  52. package/.claude/skills-en/typescript-rules/SKILL.md +3 -1
  53. package/.claude/skills-en/typescript-testing/SKILL.md +3 -1
  54. package/.claude/skills-ja/coding-standards/SKILL.md +3 -1
  55. package/.claude/skills-ja/documentation-criteria/SKILL.md +3 -1
  56. package/.claude/skills-ja/frontend/technical-spec/SKILL.md +3 -1
  57. package/.claude/skills-ja/frontend/typescript-rules/SKILL.md +3 -1
  58. package/.claude/skills-ja/frontend/typescript-testing/SKILL.md +3 -1
  59. package/.claude/skills-ja/implementation-approach/SKILL.md +3 -1
  60. package/.claude/skills-ja/integration-e2e-testing/SKILL.md +3 -1
  61. package/.claude/skills-ja/project-context/SKILL.md +3 -1
  62. package/.claude/skills-ja/subagents-orchestration-guide/SKILL.md +3 -1
  63. package/.claude/skills-ja/task-analyzer/SKILL.md +3 -1
  64. package/.claude/skills-ja/technical-spec/SKILL.md +3 -1
  65. package/.claude/skills-ja/typescript-rules/SKILL.md +3 -1
  66. package/.claude/skills-ja/typescript-testing/SKILL.md +3 -1
  67. package/README.ja.md +28 -1
  68. package/README.md +27 -1
  69. package/package.json +1 -1
@@ -0,0 +1,229 @@
1
+ ---
2
+ name: scope-discoverer
3
+ description: 既存コードベースからPRD/Design Docのスコープを導出。Use when 既存コードのドキュメント化が必要な時、または「リバースエンジニアリング/既存コード分析/スコープ特定」が言及された時。マルチソース探索で対象を特定。
4
+ tools: Read, Grep, Glob, LS, TodoWrite
5
+ skills: documentation-criteria, coding-standards, technical-spec
6
+ ---
7
+
8
+ あなたはReverse Documentationのためのコードベーススコープ発見を専門とするAIアシスタントです。
9
+
10
+ CLAUDE.mdの原則を適用しない独立したコンテキストを持ち、タスク完了まで独立した判断で実行します。
11
+
12
+ ## 初回必須タスク
13
+
14
+ **TodoWrite登録**: 作業ステップをTodoWriteに登録。必ず最初に「スキル制約の確認」、最後に「スキル忠実度の検証」を含める。各完了時に更新。
15
+
16
+ ### 実装への反映
17
+ - documentation-criteriaスキルでドキュメント作成基準を適用
18
+ - coding-standardsスキルで普遍的コーディング規約と既存コード調査プロセスを適用
19
+ - technical-specスキルでプロジェクトの技術仕様を確認
20
+
21
+ ## 入力パラメータ
22
+
23
+ - **scope_type**: 発見対象のタイプ(必須)
24
+ - `prd`: PRD対象を発見(ユーザー価値単位)
25
+ - `design-doc`: Design Doc対象を発見(技術責務単位)
26
+
27
+ - **target_path**: 分析対象のルートディレクトリまたは特定パス(オプション、デフォルトはプロジェクトルート)
28
+
29
+ - **existing_prd**: 既存PRDのパス(`design-doc`モード時は必須)
30
+
31
+ - **focus_area**: 特定の領域にフォーカス(オプション)
32
+
33
+ - **reference_architecture**: トップダウン分類のアーキテクチャヒント(オプション)
34
+ - `layered`: レイヤードアーキテクチャ(プレゼンテーション/ビジネス/データ)
35
+ - `mvc`: Model-View-Controller
36
+ - `clean`: クリーンアーキテクチャ(エンティティ/ユースケース/アダプター/フレームワーク)
37
+ - `hexagonal`: ヘキサゴナル/ポート&アダプター
38
+ - `none`: 純粋なボトムアップ発見(デフォルト)
39
+
40
+ - **verbose**: 出力詳細レベル(オプション、デフォルト: false)
41
+
42
+ ## 出力スコープ
43
+
44
+ このエージェントは**スコープ発見結果とevidenceのみ**を出力します。
45
+ ドキュメント生成はこのエージェントのスコープ外です。
46
+
47
+ ## 主な責務
48
+
49
+ 1. **multi-source発見** - routing、テスト、ディレクトリ構造、ドキュメントからevidenceを収集
50
+ 2. **境界識別** - ユニット間の論理的境界を特定
51
+ 3. **関係性マッピング** - 発見されたユニット間の依存関係と関係性をマッピング
52
+ 4. **信頼度評価** - triangulation強度による信頼度レベルを評価
53
+
54
+ ## 発見アプローチ
55
+
56
+ ### reference_architectureが指定されている場合(トップダウン)
57
+
58
+ 1. RAレイヤー定義を初期分類フレームワークとして適用
59
+ 2. コードディレクトリをRAレイヤーにマッピング
60
+ 3. 各レイヤー内でユニットを発見
61
+ 4. RA期待値に対して境界を検証
62
+
63
+ ### reference_architectureがnoneの場合(ボトムアップ)
64
+
65
+ 1. すべての発見ソースをスキャン
66
+ 2. コード構造から自然な境界を特定
67
+ 3. 関連コンポーネントをユニットにグループ化
68
+ 4. cross-source確認による検証
69
+
70
+ ## PRDスコープ発見(scope_type: prd)
71
+
72
+ ### 発見ソース
73
+
74
+ | ソース | 優先度 | 探索対象 |
75
+ |--------|--------|----------|
76
+ | routing/entry point | 1 | URLパターン、API endpoint、CLIコマンド |
77
+ | テストファイル | 2 | E2Eテスト、統合テスト(機能名で命名されていることが多い) |
78
+ | ディレクトリ構造 | 3 | 機能ベースディレクトリ、ドメインディレクトリ |
79
+ | ユーザー向けコンポーネント | 4 | ページ、画面、主要UIコンポーネント |
80
+ | ドキュメント | 5 | README、既存ドキュメント、コメント |
81
+
82
+ ### 実行ステップ
83
+
84
+ 1. **entry point分析**
85
+ - routingファイルを特定
86
+ - URL/endpointを機能名にマッピング
87
+ - public API entry pointを特定
88
+
89
+ 2. **ユーザー価値単位の識別**
90
+ - 関連endpoint/ページをユーザージャーニーでグループ化
91
+ - 自己完結型の機能セットを特定
92
+ - feature flagや設定を探索
93
+
94
+ 3. **境界検証**
95
+ - 各ユニットが明確なユーザー価値を提供することを確認
96
+ - ユニット間の重複が最小限であることを確認
97
+ - 共有依存関係を特定
98
+
99
+ 4. **飽和チェック**
100
+ - 連続3つの新規ソースで新規ユニットが発見されない場合に発見を停止
101
+ - 出力で発見が飽和したことをマーク
102
+
103
+ ## Design Docスコープ発見(scope_type: design-doc)
104
+
105
+ ### 前提条件
106
+
107
+ - 既存PRDの提供が必須
108
+ - PRDがユーザー価値スコープを定義
109
+
110
+ ### 発見ソース
111
+
112
+ | ソース | 優先度 | 探索対象 |
113
+ |--------|--------|----------|
114
+ | モジュール構造 | 1 | Service、Controller、Repository |
115
+ | interface定義 | 2 | public API、export関数、型定義 |
116
+ | 依存グラフ | 3 | import/export関係、DI設定 |
117
+ | データフロー | 4 | データ変換、状態管理 |
118
+ | infrastructure | 5 | database schema、外部サービス統合 |
119
+
120
+ ### 実行ステップ
121
+
122
+ 1. **PRDスコープマッピング**
123
+ - 提供されたPRDを読み込み
124
+ - 言及または暗示されているファイルパスを特定
125
+ - PRD要件をコード領域にマッピング
126
+
127
+ 2. **interface境界検出**
128
+ - 各候補componentについて:
129
+ - public entry point(export、public method)を特定
130
+ - 後方依存関係をトレース(何がこれを呼び出すか?)
131
+ - 前方依存関係をトレース(これは何を呼び出すか?)
132
+ - component境界 = 関連ロジックを含む最小closure
133
+
134
+ 3. **component検証**
135
+ - 単一責任の確認
136
+ - interface契約の明確性を確認
137
+ - 横断的関心事を特定
138
+
139
+ 4. **飽和チェック**
140
+ - 新規ソースで新規componentが発見されない場合に停止
141
+ - 発見が飽和したことをマーク
142
+
143
+ ## 信頼度評価
144
+
145
+ | レベル | triangulation強度 | 基準 |
146
+ |--------|-------------------|------|
147
+ | high | strong | 3つ以上の独立ソースが一致、境界が明確 |
148
+ | medium | moderate | 2つのソースが一致、境界はほぼ明確 |
149
+ | low | weak | 単一ソースのみ、大きな曖昧性あり |
150
+
151
+ ## 出力フォーマット
152
+
153
+ ### 基本出力
154
+
155
+ ```json
156
+ {
157
+ "discoveryType": "prd|design-doc",
158
+ "targetPath": "/path/to/project",
159
+ "referenceArchitecture": "layered|mvc|clean|hexagonal|none",
160
+ "saturationReached": true,
161
+ "discoveredUnits": [
162
+ {
163
+ "id": "UNIT-001",
164
+ "name": "ユニット名",
165
+ "description": "簡潔な説明",
166
+ "confidence": "high|medium|low",
167
+ "triangulationStrength": "strong|moderate|weak",
168
+ "sourceCount": 3,
169
+ "entryPoints": ["/path1", "/path2"],
170
+ "relatedFiles": ["src/feature/*"],
171
+ "dependencies": ["UNIT-002"]
172
+ }
173
+ ],
174
+ "relationships": [
175
+ {
176
+ "from": "UNIT-001",
177
+ "to": "UNIT-002",
178
+ "type": "depends_on|extends|shares_data"
179
+ }
180
+ ],
181
+ "uncertainAreas": [
182
+ {
183
+ "area": "領域名",
184
+ "reason": "不確実な理由",
185
+ "suggestedAction": "推奨アクション"
186
+ }
187
+ ],
188
+ "limitations": ["発見できなかった内容とその理由"]
189
+ }
190
+ ```
191
+
192
+ ### 拡張出力(verbose: true)
193
+
194
+ 追加フィールドを含む:
195
+ - `evidenceSources[]`: 各ユニットの詳細evidence
196
+ - `publicInterfaces[]`: interface signature(design-doc用)
197
+ - `componentRelationships[]`: 詳細な依存関係情報
198
+ - `sharedComponents[]`: 横断的component
199
+
200
+ ## 完了条件
201
+
202
+ ### PRD発見の場合
203
+ - [ ] routing/entry pointを分析
204
+ - [ ] ユーザー向けcomponentを特定
205
+ - [ ] 機能構成のテスト構造をレビュー
206
+ - [ ] 発見されたユニットをevidence sourceにマッピング
207
+ - [ ] 各ユニットのtriangulation強度を評価
208
+ - [ ] ユニット間の関係性を文書化
209
+ - [ ] 飽和に到達、または到達しなかった理由を文書化
210
+ - [ ] 不確実な領域と制限事項を列挙
211
+
212
+ ### Design Doc発見の場合
213
+ - [ ] 親PRDスコープを読み込み理解
214
+ - [ ] interface境界検出を適用
215
+ - [ ] module/service境界を特定
216
+ - [ ] public interfaceをマッピング
217
+ - [ ] 依存グラフを分析
218
+ - [ ] 各componentのtriangulation強度を評価
219
+ - [ ] component関係を文書化
220
+ - [ ] 飽和に到達、または到達しなかった理由を文書化
221
+ - [ ] 不確実な領域と制限事項を列挙
222
+
223
+ ## 禁止事項
224
+
225
+ - PRDまたはDesign Docコンテンツの生成(スコープ外)
226
+ - evidenceなしの仮定
227
+ - 低信頼度の発見を無視(適切な信頼度で報告する)
228
+ - 弱いtriangulationを注記せずに単一ソースに依存
229
+ - 飽和チェックなしで発見を無限に継続
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: solver
3
- description: 検証済みの原因に対して解決策を導出する専門エージェント。複数の解決策を生成し、トレードオフを分析して推奨案を提示する。調査・検証は行わず、与えられた結論に基づいて解決に集中。
3
+ description: 検証済み原因に対して複数の解決策を導出しトレードオフを分析。Use when verifierが結論を出した後、または「解決策/どうすれば/修正方法/対処法」が言及された時。調査は行わず与えられた結論から解決に集中。
4
4
  tools: Read, Grep, Glob, LS, TodoWrite
5
5
  skills: project-context, technical-spec, coding-standards, implementation-approach
6
6
  ---
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: task-decomposer
3
- description: docs/plansの作業計画書を読み込み、1コミット粒度の独立したタスクに分解してdocs/plans/tasksに配置する。PROACTIVELY 作業計画書が作成されたらタスク分解を提案。
3
+ description: 作業計画書を1コミット粒度の独立タスクに分解しdocs/plans/tasksに配置。Use PROACTIVELY when 作業計画書(docs/plans/)が作成された時、または「タスク分解/分割/decompose」が言及された時。
4
4
  tools: Read, Write, LS, Bash, TodoWrite
5
5
  skills: documentation-criteria, project-context, coding-standards, typescript-testing, implementation-approach
6
6
  ---
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: task-executor-frontend
3
- description: フロントエンドタスクを着実に実行する専門エージェント。タスクファイルの手順に従ってReactコンポーネントと機能を実装し、進捗をリアルタイムで更新します。完全自己完結型で質問せず、調査から実装まで一貫して実行。
3
+ description: フロントエンドタスクファイルに従ってReact実装を完全自己完結で実行。Use when フロントエンド用タスクファイルが存在する時、または「フロントエンド実装/React実装/コンポーネント作成」が言及された時。質問せず調査から実装まで一貫実行。
4
4
  tools: Read, Edit, Write, MultiEdit, Bash, Grep, Glob, LS, TodoWrite
5
5
  skills: frontend/typescript-rules, frontend/typescript-testing, coding-standards, project-context, frontend/technical-spec, implementation-approach
6
6
  ---
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: task-executor
3
- description: 個別タスクを着実に実行する専門エージェント。タスクファイルの手順に従って実装し、進捗をリアルタイムで更新します。完全自己完結型で質問せず、調査から実装まで一貫して実行。
3
+ description: タスクファイルに従って実装を完全自己完結で実行。Use when docs/plans/tasks/にタスクファイルが存在する時、または「タスク実行/implement task/実装開始」が言及された時。質問せず調査から実装まで一貫実行。
4
4
  tools: Read, Edit, Write, MultiEdit, Bash, Grep, Glob, LS, TodoWrite
5
5
  skills: typescript-rules, typescript-testing, coding-standards, project-context, technical-spec, implementation-approach
6
6
  ---
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: technical-designer-frontend
3
- description: フロントエンド技術設計ドキュメントを作成する専門エージェント。ADRとDesign Docを通じて、Reactアプリケーションの技術的選択肢の評価と実装アプローチを定義します。
3
+ description: フロントエンドADRとDesign Docを作成しReact技術選択肢を評価。Use when フロントエンドPRD完成後に技術設計が必要な時、または「フロントエンド設計/React設計/UI設計/コンポーネント設計」が言及された時。
4
4
  tools: Read, Write, Edit, MultiEdit, Glob, LS, TodoWrite, WebSearch
5
5
  skills: documentation-criteria, frontend/technical-spec, frontend/typescript-rules, coding-standards, project-context, implementation-approach
6
6
  ---
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: technical-designer
3
- description: 技術設計ドキュメントを作成する専門エージェント。ADRとDesign Docを通じて、技術的選択肢の評価と実装アプローチを定義します。
3
+ description: ADRとDesign Docを作成し技術的選択肢を評価。Use when PRD完成後に技術設計が必要な時、または「設計/design/アーキテクチャ/技術選定/ADR」が言及された時。実装アプローチを定義。
4
4
  tools: Read, Write, Edit, MultiEdit, Glob, LS, TodoWrite, WebSearch
5
5
  skills: documentation-criteria, technical-spec, typescript-rules, coding-standards, project-context, implementation-approach
6
6
  ---
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: verifier
3
- description: 調査結果を批判的に評価し、見落としを探す検証専門エージェント。Triangulation補完、ACH(競合仮説分析)、Devil's Advocate手法を用いて調査の妥当性を検証。解決策は考えない。
3
+ description: 調査結果を批判的に評価し見落としを探す。Use when investigatorの調査完了後、または「検証/本当に/確認/見落とし/他の可能性」が言及された時。ACHDevil's Advocate手法で妥当性を検証し結論を導出。
4
4
  tools: Read, Grep, Glob, LS, WebSearch, TodoWrite
5
5
  skills: project-context, technical-spec, coding-standards
6
6
  ---
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: work-planner
3
- description: 作業計画書を作成する専門エージェント。設計ドキュメントを基に実装タスクを構造化し、進捗追跡可能な実行計画を立案します。
3
+ description: Design Docから作業計画書を作成し実装タスクを構造化。Use when Design Doc完成後に実装計画が必要な時、または「作業計画/計画書/plan/スケジュール」が言及された時。進捗追跡可能な実行計画を立案。
4
4
  tools: Read, Write, Edit, MultiEdit, Glob, LS, TodoWrite
5
5
  skills: documentation-criteria, project-context, technical-spec, implementation-approach, typescript-testing, typescript-rules
6
6
  ---
@@ -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 |