cc-devflow 2.4.6 → 4.1.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.
Files changed (191) hide show
  1. package/.claude/CLAUDE.md +1065 -48
  2. package/.claude/agents/dev-implementer.md +195 -0
  3. package/.claude/commands/{flow-archive.md → flow/archive.md} +46 -11
  4. package/.claude/commands/flow/context.md +150 -0
  5. package/.claude/commands/flow/delta.md +245 -0
  6. package/.claude/commands/{flow-dev.md → flow/dev.md} +112 -11
  7. package/.claude/commands/flow/init.md +45 -0
  8. package/.claude/commands/flow/quality.md +159 -0
  9. package/.claude/commands/flow/spec.md +186 -0
  10. package/.claude/commands/flow/workspace.md +146 -0
  11. package/.claude/commands/{cancel-ralph.md → util/cancel-ralph.md} +1 -0
  12. package/.claude/config/quality-gates.yml +305 -0
  13. package/.claude/docs/guides/TEAM_MODE_GUIDE.md +313 -0
  14. package/.claude/docs/templates/DELTA_SPEC_TEMPLATE.md +91 -0
  15. package/.claude/docs/templates/DESIGN_DECISIONS_TEMPLATE.md +151 -0
  16. package/.claude/docs/templates/JOURNAL_TEMPLATE.md +75 -0
  17. package/.claude/docs/templates/_shared/CLAUDE.md +36 -0
  18. package/.claude/docs/templates/_shared/CONSTITUTION_CHECK.md +125 -0
  19. package/.claude/docs/templates/_shared/VALIDATION_CHECKLIST.md +187 -0
  20. package/.claude/docs/templates/_shared/YAML_FRONTMATTER.md +164 -0
  21. package/.claude/docs/templates/context/dev.jsonl.template +6 -0
  22. package/.claude/docs/templates/context/epic.jsonl.template +5 -0
  23. package/.claude/docs/templates/context/prd.jsonl.template +4 -0
  24. package/.claude/docs/templates/context/research.jsonl.template +4 -0
  25. package/.claude/docs/templates/context/review.jsonl.template +5 -0
  26. package/.claude/docs/templates/context/tech.jsonl.template +5 -0
  27. package/.claude/hooks/CLAUDE.md +342 -0
  28. package/.claude/hooks/inject-agent-context.ts +480 -0
  29. package/.claude/hooks/inject-skill-context.ts +359 -0
  30. package/.claude/hooks/ralph-loop.ts +931 -0
  31. package/.claude/hooks/task-completed-hook.ts +593 -0
  32. package/.claude/hooks/teammate-idle-hook.ts +690 -0
  33. package/.claude/hooks/types/team-types.d.ts +238 -0
  34. package/.claude/rules/devflow-conventions.md +82 -9
  35. package/.claude/scripts/archive-requirement.sh +44 -1
  36. package/.claude/scripts/common.sh +670 -3
  37. package/.claude/scripts/delta-parser.ts +527 -0
  38. package/.claude/scripts/detect-file-conflicts.sh +151 -0
  39. package/.claude/scripts/flow-context-add.sh +134 -0
  40. package/.claude/scripts/flow-context-init.sh +133 -0
  41. package/.claude/scripts/flow-context-validate.sh +144 -0
  42. package/.claude/scripts/flow-delta-apply.sh +297 -0
  43. package/.claude/scripts/flow-delta-archive.sh +71 -0
  44. package/.claude/scripts/flow-delta-create.sh +202 -0
  45. package/.claude/scripts/flow-delta-list.sh +142 -0
  46. package/.claude/scripts/flow-delta-status.sh +235 -0
  47. package/.claude/scripts/flow-quality-full.sh +184 -0
  48. package/.claude/scripts/flow-quality-quick.sh +64 -0
  49. package/.claude/scripts/flow-workspace-init.sh +117 -0
  50. package/.claude/scripts/flow-workspace-record.sh +164 -0
  51. package/.claude/scripts/flow-workspace-start.sh +88 -0
  52. package/.claude/scripts/get-workflow-status.sh +415 -0
  53. package/.claude/scripts/parse-task-dependencies.js +334 -0
  54. package/.claude/scripts/record-quality-error.sh +165 -0
  55. package/.claude/scripts/run-quality-gates.sh +242 -0
  56. package/.claude/scripts/team-dev-init.sh +319 -0
  57. package/.claude/scripts/team-state-recovery.sh +229 -0
  58. package/.claude/scripts/workflow-status.ts +433 -0
  59. package/.claude/settings.json +19 -0
  60. package/.claude/skills/cc-devflow-orchestrator/SKILL.md +85 -200
  61. package/.claude/skills/domain/using-git-worktrees/SKILL.md +252 -0
  62. package/.claude/skills/domain/using-git-worktrees/assets/SHELL_ALIASES.md +133 -0
  63. package/.claude/skills/domain/using-git-worktrees/context.jsonl +4 -0
  64. package/.claude/skills/domain/using-git-worktrees/scripts/worktree-cleanup.sh +218 -0
  65. package/.claude/skills/domain/using-git-worktrees/scripts/worktree-create.sh +232 -0
  66. package/.claude/skills/domain/using-git-worktrees/scripts/worktree-list.sh +130 -0
  67. package/.claude/skills/domain/using-git-worktrees/scripts/worktree-status.sh +140 -0
  68. package/.claude/skills/domain/using-git-worktrees/scripts/worktree-switch.sh +70 -0
  69. package/.claude/skills/skill-rules.json +72 -1
  70. package/.claude/skills/utility/journey-checker/SKILL.md +199 -0
  71. package/.claude/skills/utility/journey-checker/pressure-scenarios.md +164 -0
  72. package/.claude/skills/utility/skill-creator/LICENSE.txt +202 -0
  73. package/.claude/skills/utility/skill-creator/SKILL.md +356 -0
  74. package/.claude/skills/utility/skill-creator/references/output-patterns.md +82 -0
  75. package/.claude/skills/utility/skill-creator/references/workflows.md +28 -0
  76. package/.claude/skills/utility/skill-creator/scripts/init_skill.py +303 -0
  77. package/.claude/skills/utility/skill-creator/scripts/package_skill.py +110 -0
  78. package/.claude/skills/utility/skill-creator/scripts/quick_validate.py +95 -0
  79. package/.claude/skills/workflow/flow-dev/CLAUDE.md +78 -0
  80. package/.claude/skills/workflow/flow-dev/SKILL.md +96 -0
  81. package/.claude/skills/workflow/flow-dev/assets/IMPLEMENTATION_PLAN_TEMPLATE.md +71 -0
  82. package/.claude/skills/workflow/flow-dev/context.jsonl +8 -0
  83. package/.claude/skills/workflow/flow-dev/dev-implementer.jsonl +8 -0
  84. package/.claude/skills/workflow/flow-dev/scripts/entry-gate.sh +116 -0
  85. package/.claude/skills/workflow/flow-dev/scripts/exit-gate.sh +101 -0
  86. package/.claude/skills/workflow/flow-dev/scripts/task-orchestrator.sh +106 -0
  87. package/.claude/skills/workflow/flow-fix/SKILL.md +105 -0
  88. package/.claude/skills/workflow/flow-fix/context.jsonl +6 -0
  89. package/.claude/skills/workflow/flow-fix/references/bug-analyzer.md +381 -0
  90. package/.claude/skills/workflow/flow-init/SKILL.md +211 -0
  91. package/.claude/skills/workflow/flow-init/assets/BRAINSTORM_TEMPLATE.md +148 -0
  92. package/.claude/skills/workflow/flow-init/assets/INIT_FLOW_TEMPLATE.md +198 -0
  93. package/.claude/skills/workflow/flow-init/assets/RESEARCH_TEMPLATE.md +276 -0
  94. package/.claude/skills/workflow/flow-init/context.jsonl +5 -0
  95. package/.claude/skills/workflow/flow-init/references/flow-researcher.md +132 -0
  96. package/.claude/skills/workflow/flow-init/scripts/check-prerequisites.sh +232 -0
  97. package/.claude/skills/workflow/flow-init/scripts/consolidate-research.sh +182 -0
  98. package/.claude/skills/workflow/flow-init/scripts/create-requirement.sh +515 -0
  99. package/.claude/skills/workflow/flow-init/scripts/generate-research-tasks.sh +157 -0
  100. package/.claude/skills/workflow/flow-init/scripts/populate-research-tasks.sh +284 -0
  101. package/.claude/skills/workflow/flow-init/scripts/validate-research.sh +332 -0
  102. package/.claude/skills/workflow/flow-quality/SKILL.md +94 -0
  103. package/.claude/skills/workflow/flow-quality/context.jsonl +6 -0
  104. package/.claude/skills/workflow/flow-quality/references/code-quality-reviewer.md +205 -0
  105. package/.claude/skills/workflow/flow-quality/references/qa-tester.md +313 -0
  106. package/.claude/skills/workflow/flow-quality/references/security-reviewer.md +314 -0
  107. package/.claude/skills/workflow/flow-quality/references/spec-reviewer.md +221 -0
  108. package/.claude/skills/workflow/flow-release/SKILL.md +126 -0
  109. package/.claude/skills/workflow/flow-release/context.jsonl +7 -0
  110. package/.claude/skills/workflow/flow-release/references/release-manager.md +295 -0
  111. package/.claude/skills/workflow/flow-spec/CLAUDE.md +103 -0
  112. package/.claude/skills/workflow/flow-spec/SKILL.md +545 -0
  113. package/.claude/skills/workflow/flow-spec/context.jsonl +7 -0
  114. package/.claude/skills/workflow/flow-spec/scripts/entry-gate.sh +194 -0
  115. package/.claude/skills/workflow/flow-spec/scripts/exit-gate.sh +244 -0
  116. package/.claude/skills/workflow/flow-spec/scripts/parallel-orchestrator.sh +205 -0
  117. package/.claude/skills/workflow/flow-spec/scripts/team-communication.sh +353 -0
  118. package/.claude/skills/workflow/flow-spec/scripts/team-init.sh +195 -0
  119. package/.claude/skills/workflow/flow-spec/scripts/test-team-mode.sh +496 -0
  120. package/.claude/skills/workflow/flow-spec/team-config.json +165 -0
  121. package/.claude/skills/workflow.yaml +417 -0
  122. package/CHANGELOG.md +254 -0
  123. package/README.md +193 -33
  124. package/README.zh-CN.md +206 -46
  125. package/lib/compiler/CLAUDE.md +77 -46
  126. package/lib/compiler/__tests__/multi-module-emitters.test.js +508 -0
  127. package/lib/compiler/context-expander.js +179 -0
  128. package/lib/compiler/emitters/antigravity-emitter.js +195 -5
  129. package/lib/compiler/emitters/base-emitter.js +217 -2
  130. package/lib/compiler/emitters/codex-emitter.js +200 -4
  131. package/lib/compiler/emitters/cursor-emitter.js +307 -3
  132. package/lib/compiler/emitters/qwen-emitter.js +196 -4
  133. package/lib/compiler/index.js +197 -2
  134. package/lib/compiler/platforms.js +270 -21
  135. package/package.json +1 -1
  136. package/.claude/commands/flow-epic.md +0 -183
  137. package/.claude/commands/flow-init.md +0 -370
  138. package/.claude/commands/flow-prd.md +0 -144
  139. package/.claude/commands/flow-qa.md +0 -93
  140. package/.claude/commands/flow-review.md +0 -257
  141. package/.claude/commands/flow-tech.md +0 -142
  142. package/.claude/commands/flow-ui.md +0 -189
  143. package/.claude/skills/file-header-guardian/SKILL.md +0 -56
  144. package/.claude/skills/skill-developer/ADVANCED.md +0 -197
  145. package/.claude/skills/skill-developer/HOOK_MECHANISMS.md +0 -306
  146. package/.claude/skills/skill-developer/PATTERNS_LIBRARY.md +0 -152
  147. package/.claude/skills/skill-developer/SKILL.md +0 -426
  148. package/.claude/skills/skill-developer/SKILL_RULES_REFERENCE.md +0 -315
  149. package/.claude/skills/skill-developer/TRIGGER_TYPES.md +0 -305
  150. package/.claude/skills/skill-developer/TROUBLESHOOTING.md +0 -514
  151. package/.claude/skills/writing-skills/SKILL.md +0 -655
  152. package/.claude/skills/writing-skills/anthropic-best-practices.md +0 -1150
  153. package/.claude/skills/writing-skills/examples/CLAUDE_MD_TESTING.md +0 -189
  154. package/.claude/skills/writing-skills/graphviz-conventions.dot +0 -172
  155. package/.claude/skills/writing-skills/persuasion-principles.md +0 -187
  156. package/.claude/skills/writing-skills/render-graphs.js +0 -168
  157. package/.claude/skills/writing-skills/testing-skills-with-subagents.md +0 -384
  158. package/.claude/tsc-cache/795ba6e3-b98a-423b-bab2-51aa62812569/affected-repos.txt +0 -1
  159. package/.claude/tsc-cache/ae335694-be5a-4ba4-a1a0-b676c09a7906/affected-repos.txt +0 -1
  160. /package/.claude/commands/{core-architecture.md → core/architecture.md} +0 -0
  161. /package/.claude/commands/{core-guidelines.md → core/guidelines.md} +0 -0
  162. /package/.claude/commands/{core-roadmap.md → core/roadmap.md} +0 -0
  163. /package/.claude/commands/{core-style.md → core/style.md} +0 -0
  164. /package/.claude/commands/{flow-checklist.md → flow/checklist.md} +0 -0
  165. /package/.claude/commands/{flow-clarify.md → flow/clarify.md} +0 -0
  166. /package/.claude/commands/{flow-constitution.md → flow/constitution.md} +0 -0
  167. /package/.claude/commands/{flow-fix.md → flow/fix.md} +0 -0
  168. /package/.claude/commands/{flow-ideate.md → flow/ideate.md} +0 -0
  169. /package/.claude/commands/{flow-new.md → flow/new.md} +0 -0
  170. /package/.claude/commands/{flow-release.md → flow/release.md} +0 -0
  171. /package/.claude/commands/{flow-restart.md → flow/restart.md} +0 -0
  172. /package/.claude/commands/{flow-status.md → flow/status.md} +0 -0
  173. /package/.claude/commands/{flow-update.md → flow/update.md} +0 -0
  174. /package/.claude/commands/{flow-upgrade.md → flow/upgrade.md} +0 -0
  175. /package/.claude/commands/{flow-verify.md → flow/verify.md} +0 -0
  176. /package/.claude/commands/{code-review-high.md → util/code-review.md} +0 -0
  177. /package/.claude/commands/{git-commit.md → util/git-commit.md} +0 -0
  178. /package/.claude/commands/{problem-analyzer.md → util/problem-analyzer.md} +0 -0
  179. /package/.claude/skills/{flow-attention-refresh → domain/attention-refresh}/SKILL.md +0 -0
  180. /package/.claude/skills/{flow-brainstorming → domain/brainstorming}/SKILL.md +0 -0
  181. /package/.claude/skills/{flow-debugging → domain/debugging}/SKILL.md +0 -0
  182. /package/.claude/skills/{flow-finishing-branch → domain/finishing-branch}/SKILL.md +0 -0
  183. /package/.claude/skills/{flow-receiving-review → domain/receiving-review}/SKILL.md +0 -0
  184. /package/.claude/skills/{flow-tdd → domain/tdd}/SKILL.md +0 -0
  185. /package/.claude/skills/{verification-before-completion → domain/verification}/SKILL.md +0 -0
  186. /package/.claude/skills/{constitution-guardian → guardrail/constitution-guardian}/SKILL.md +0 -0
  187. /package/.claude/skills/{devflow-tdd-enforcer → guardrail/tdd-enforcer}/SKILL.md +0 -0
  188. /package/.claude/skills/{devflow-constitution-quick-ref → utility/constitution-quick-ref}/SKILL.md +0 -0
  189. /package/.claude/skills/{devflow-file-standards → utility/file-standards}/SKILL.md +0 -0
  190. /package/.claude/skills/{fractal-docs-generator → utility/fractal-docs}/SKILL.md +0 -0
  191. /package/.claude/skills/{npm-release → utility/npm-release}/SKILL.md +0 -0
@@ -0,0 +1,148 @@
1
+ ---
2
+ req_id: "{REQ_ID}"
3
+ title: "{TITLE}"
4
+ created_at: "{ISO8601_TIMESTAMP}"
5
+ brainstorm_version: "1.0"
6
+ status: "draft"
7
+ ---
8
+
9
+ # {REQ_ID} Brainstorm Record
10
+
11
+ > **[PROTOCOL]**: 后续所有开发必须与本文档保持一致。如有偏离,需更新本文档并说明原因。
12
+
13
+ ## 原始需求(用户原话)
14
+
15
+ > {用户的原始描述,一字不改,保留所有细节}
16
+
17
+ ## 核心问题定义
18
+
19
+ ### 解决什么问题?
20
+
21
+ {一句话定义核心问题,例如:"用户无法在移动端完成支付"}
22
+
23
+ ### 为谁解决?
24
+
25
+ {用户画像,例如:"日均活跃用户 10,000+,年龄 25-45,移动端为主"}
26
+
27
+ ### 现状痛点
28
+
29
+ - {痛点1:具体描述,包含数据或用户反馈}
30
+ - {痛点2}
31
+ - {痛点3}
32
+
33
+ ## 成功标准
34
+
35
+ ### 如何判断需求完成?(验收标准)
36
+
37
+ - [ ] {可度量的标准1,例如:"支付成功率 ≥ 95%"}
38
+ - [ ] {可度量的标准2}
39
+ - [ ] {可度量的标准3}
40
+
41
+ ### 如何判断需求成功?(业务指标)
42
+
43
+ - {业务指标1,例如:"订单转化率提升 10%"}
44
+ - {业务指标2}
45
+
46
+ ## 约束条件
47
+
48
+ | 类型 | 约束 | 原因 |
49
+ |------|------|------|
50
+ | 技术 | {约束,例如:"必须兼容 iOS 12+"} | {原因} |
51
+ | 时间 | {约束,例如:"2 周内上线"} | {原因} |
52
+ | 资源 | {约束,例如:"1 前端 + 1 后端"} | {原因} |
53
+ | 安全 | {约束,例如:"敏感数据需加密"} | {原因} |
54
+ | 法规 | {约束,例如:"符合 GDPR"} | {原因} |
55
+
56
+ ## 方案探索
57
+
58
+ ### 方案 A: {名称} ⭐ 推荐
59
+
60
+ **描述**:
61
+ {方案概述,100-200 字}
62
+
63
+ **优势**:
64
+ - {优势1}
65
+ - {优势2}
66
+
67
+ **劣势**:
68
+ - {劣势1}
69
+ - {劣势2}
70
+
71
+ **适用场景**:
72
+ {何时选择这个方案}
73
+
74
+ **实现要点**:
75
+ 1. {关键步骤1}
76
+ 2. {关键步骤2}
77
+
78
+ ---
79
+
80
+ ### 方案 B: {名称}
81
+
82
+ **描述**:
83
+ {方案概述}
84
+
85
+ **优势**:
86
+ - {优势1}
87
+
88
+ **劣势**:
89
+ - {劣势1}
90
+
91
+ **适用场景**:
92
+ {何时选择这个方案}
93
+
94
+ ---
95
+
96
+ ### 方案 C: {名称}
97
+
98
+ **描述**:
99
+ {方案概述}
100
+
101
+ **优势**:
102
+ - {优势1}
103
+
104
+ **劣势**:
105
+ - {劣势1}
106
+
107
+ **适用场景**:
108
+ {何时选择这个方案}
109
+
110
+ ## 最终决策
111
+
112
+ **选定方案**: 方案 {X}
113
+
114
+ **选择理由**:
115
+ {为什么选这个方案,而非其他方案}
116
+
117
+ **否决理由**:
118
+ - 方案 {Y}: {为什么不选}
119
+ - 方案 {Z}: {为什么不选}
120
+
121
+ ## 关键决策记录
122
+
123
+ | 决策点 | 决策 | 理由 | 日期 |
124
+ |--------|------|------|------|
125
+ | {问题1} | {选择} | {为什么} | {YYYY-MM-DD} |
126
+ | {问题2} | {选择} | {为什么} | {YYYY-MM-DD} |
127
+
128
+ ## 风险识别
129
+
130
+ | 风险 | 概率 | 影响 | 缓解策略 |
131
+ |------|------|------|----------|
132
+ | {风险1} | 高/中/低 | 高/中/低 | {应对措施} |
133
+ | {风险2} | 高/中/低 | 高/中/低 | {应对措施} |
134
+
135
+ ## 变更历史
136
+
137
+ | 版本 | 日期 | 变更内容 | 变更原因 |
138
+ |------|------|----------|----------|
139
+ | 1.0 | {YYYY-MM-DD} | 初始版本 | 头脑风暴完成 |
140
+
141
+ ---
142
+
143
+ **⚠️ 追溯声明**:
144
+ 本文档是 {REQ_ID} 的「北极星」。后续 PRD、EPIC、TASKS、实现都必须与本文档保持一致。
145
+ 如发现偏离,必须:
146
+ 1. 确认偏离原因
147
+ 2. 更新本文档
148
+ 3. 记录变更历史
@@ -0,0 +1,198 @@
1
+ # Flow-Init Execution Flow Template
2
+
3
+ > Detailed stages for `/flow-init` requirement initialization
4
+
5
+ <!-- ============================================================
6
+ 调用上下文声明 (Invocation Context Declaration)
7
+ ============================================================
8
+
9
+ 本模板由 `/flow-init` 命令通过 {TEMPLATE:flow} 引用加载。
10
+
11
+ 模板中的 {SCRIPT:xxx} 占位符引用 flow-init.md 头文件中的 scripts 定义:
12
+ ```yaml
13
+ # 来源: .claude/commands/flow-init.md 头文件
14
+ scripts:
15
+ create: .claude/scripts/create-requirement.sh
16
+ prereq: .claude/scripts/check-prerequisites.sh
17
+ research_tasks: .claude/scripts/generate-research-tasks.sh
18
+ populate_tasks: .claude/scripts/populate-research-tasks.sh
19
+ consolidate: .claude/scripts/consolidate-research.sh
20
+ validate_research: .claude/scripts/validate-research.sh
21
+ ```
22
+
23
+ 占位符解析:
24
+ - {SCRIPT:prereq} → bash .claude/scripts/check-prerequisites.sh
25
+ - {SCRIPT:create} → bash .claude/scripts/create-requirement.sh
26
+ - {SCRIPT:research_tasks} → bash .claude/scripts/generate-research-tasks.sh
27
+ - {SCRIPT:populate_tasks} → bash .claude/scripts/populate-research-tasks.sh
28
+ - {SCRIPT:consolidate} → bash .claude/scripts/consolidate-research.sh
29
+ - {SCRIPT:validate_research} → bash .claude/scripts/validate-research.sh
30
+ ============================================================ -->
31
+
32
+ ---
33
+
34
+ ## Stage 1: Entry Gate (参数验证)
35
+
36
+ ```bash
37
+ # 1. 解析参数
38
+ REQ_ID|TITLE|PLAN_URLS → 验证 REQ_ID 格式: ^(REQ|BUG)-[0-9]+$
39
+ → 若 TITLE 含中文/非ASCII,使用模型意译生成 BRANCH_TITLE_EN(英文语义翻译,禁止拼音/音译)
40
+ → BRANCH_TITLE_EN 仅用于分支名,文档标题仍使用原始 TITLE
41
+ → 若意译不确定或未生成 ASCII 结果,向用户确认英文分支标题
42
+
43
+ # 2. 前置条件检查
44
+ bash {SCRIPT:prereq} --json --paths-only
45
+ → Git 状态干净 + devflow/ 目录存在
46
+
47
+ # 3. 目录唯一性检查
48
+ → 确认 devflow/requirements/${REQ_ID}/ 不存在
49
+ ```
50
+
51
+ ---
52
+
53
+ ## Stage 1.2: Git Branch Creation
54
+
55
+ ```bash
56
+ # 创建功能分支
57
+ Requirements: feature/${REQ_ID}-${slug(BRANCH_TITLE_EN)}
58
+ Bug Fixes: bugfix/${BUG_ID}-${slug(BRANCH_TITLE_EN)}
59
+
60
+ # BRANCH_TITLE_EN = TITLE 的英文意译 (语义为准,非拼音,使用模型意译)
61
+ # slug() = lowercase, replace spaces/special chars with hyphens
62
+ ```
63
+
64
+ ---
65
+
66
+ ## Stage 1.5: Context Loading (路线图与架构)
67
+
68
+ **目标**: 理解需求在项目中的位置
69
+
70
+ ```bash
71
+ # 检查 ROADMAP.md 和 ARCHITECTURE.md
72
+ → 如果存在: 加载上下文,展示需求位置
73
+ → 如果不存在: 提示可选运行 /core-roadmap (不阻塞执行)
74
+ ```
75
+
76
+ ---
77
+
78
+ ## Stage 2: Directory Initialization
79
+
80
+ ```bash
81
+ # 创建需求目录
82
+ bash {SCRIPT:create} "${REQ_ID}" --title "${TITLE}" --branch-title "${BRANCH_TITLE_EN}" --json
83
+
84
+ → 若未生成 BRANCH_TITLE_EN,则省略 --branch-title
85
+
86
+ # 生成文件
87
+ devflow/requirements/${REQ_ID}/
88
+ ├── README.md
89
+ ├── EXECUTION_LOG.md
90
+ ├── orchestration_status.json
91
+ └── research/ (空目录)
92
+ ```
93
+
94
+ ---
95
+
96
+ ## Stage 2.5: Research (Subagent Mandatory)
97
+
98
+ **目标**: 研究默认必跑,但研究过程必须“隔离上下文”。
99
+
100
+ **规则**: 大内容写入 `research/`,主会话只保留路径引用与决策摘要。
101
+
102
+ ### Mandatory: Call `flow-researcher` Subagent
103
+
104
+ ```
105
+ Task tool call:
106
+ subagent_type: "flow-researcher"
107
+ prompt: (JSON) reqId/reqDir/title/planUrls/contextFiles
108
+ ```
109
+
110
+ **产物** (由 subagent 写入):
111
+ - `research/internal/codebase-overview.md`
112
+ - `research/mcp/$(date +%Y%m%d)/**`
113
+ - `research/research-summary.md`
114
+ - `research/tasks.json`
115
+ - `research/research.md`
116
+
117
+ ---
118
+
119
+ ## Stage 2.6: Research Consolidation
120
+
121
+ > 该阶段由 `flow-researcher` subagent 执行(含 tasks 生成/回填/整合/校验)。
122
+
123
+ ---
124
+
125
+
126
+
127
+ ## Stage 3: README Generation
128
+
129
+ ```bash
130
+ # 生成工作流指南
131
+ → devflow/requirements/${REQ_ID}/README.md
132
+ → 包含: 需求概述、工作流步骤、检查清单
133
+ ```
134
+
135
+ ---
136
+
137
+ ## Stage 4: Exit Gate (5-Level Quality Check)
138
+
139
+ ### Level 1: File Existence Check
140
+ ```bash
141
+ → 验证所有必需文件已创建
142
+ ```
143
+
144
+ ### Level 2: Research.md Structure Validation
145
+ ```bash
146
+ bash {SCRIPT:validate_research} "${REQ_DIR}" --strict
147
+ → 检查 research.md 结构
148
+ ```
149
+
150
+ ### Level 3: Research.md Content Quality
151
+ ```bash
152
+ → 无 TODO/FIXME/{{PLACEHOLDER}} 标记
153
+ → 每个 Decision block 完整
154
+ ```
155
+
156
+ ### Level 4: Research Tasks Validation
157
+ ```bash
158
+ → 验证 tasks.json 格式和内容
159
+ ```
160
+
161
+ ### Level 5: Git & Status & Constitution
162
+ ```bash
163
+ → Git 分支创建成功
164
+ → orchestration_status.json 正确
165
+ → Constitution 符合性检查
166
+ ```
167
+
168
+ ---
169
+
170
+ ## Output Structure
171
+
172
+ ```
173
+ devflow/requirements/${REQ_ID}/
174
+ ├── README.md
175
+ ├── research/
176
+ │ ├── internal/
177
+ │ │ └── codebase-overview.md
178
+ │ ├── mcp/
179
+ │ │ └── $(date +%Y%m%d)/
180
+ │ │ ├── official/
181
+ │ │ ├── guides/
182
+ │ │ ├── tutorials/
183
+ │ │ └── examples/
184
+ │ ├── research.md
185
+ │ ├── research-summary.md
186
+ │ └── tasks.json
187
+ ├── EXECUTION_LOG.md
188
+ └── orchestration_status.json
189
+ ```
190
+
191
+ **Git**:
192
+ - Branch: `feature/${REQ_ID}-${slug(BRANCH_TITLE_EN)}`
193
+ - Status: orchestration_status.json.status = "initialized"
194
+ - Phase: orchestration_status.json.phase = "planning"
195
+
196
+ ---
197
+
198
+ **Last Updated**: 2025-12-19
@@ -0,0 +1,276 @@
1
+ # Research Summary — {FEATURE_NAME}
2
+
3
+ > **Purpose**: Document all technical decisions made during requirement initialization
4
+ > **Owner**: prd-writer / planner agents
5
+ > **Status**: Living document (updated until PRD finalized)
6
+ > **Template Version**: v1.0.0
7
+ > **Constitution Compliance**: Article X.1 (Forced Clarification), Article X.2 (No Speculation)
8
+
9
+ Generated: {GENERATED_AT}
10
+
11
+ ---
12
+
13
+ ## Decisions
14
+
15
+ ### R001 — {TOPIC_DESCRIPTION}
16
+ - **Decision**: {技术选型或架构决策}
17
+ - **Rationale**:
18
+ - {理由 1: 必须明确说明为什么选择这个方案}
19
+ - {理由 2: 至少提供 2 条理由,证明决策经过深思熟虑}
20
+ - {理由 3 (可选): 更多支持性论据}
21
+ - **Alternatives Considered**:
22
+ - {替代方案 1}: {简要评估 - 为什么不选择}
23
+ - {替代方案 2}: {简要评估 - 优缺点对比}
24
+ - **Source**: {来源: PRD.md:42 或 Tech-Choice:Frontend Framework}
25
+
26
+ ### R002 — {TOPIC_DESCRIPTION}
27
+ - **Decision**: {实际选择的技术/方案}
28
+ - **Rationale**:
29
+ - {业务需求匹配度}
30
+ - {技术优势或团队熟悉度}
31
+ - **Alternatives Considered**:
32
+ - {对比方案}: {不选择的原因}
33
+ - **Source**: {来源}
34
+
35
+ ---
36
+
37
+ ## Unresolved Questions
38
+
39
+ > ⚠️ 使用 `[NEEDS CLARIFICATION]` 标记所有待澄清问题
40
+ > 📌 每个问题必须包含: Context (上下文) + Impact (影响) + Blocked Tasks (阻塞任务)
41
+
42
+ - **[NEEDS CLARIFICATION]**: {具体问题描述}
43
+ - **Context**: {为什么需要澄清这个问题}
44
+ - **Impact**: {不澄清会影响哪些决策或实现}
45
+ - **Blocked Tasks**: {哪些任务被阻塞 - 如 data-model.md, API contracts}
46
+
47
+ ---
48
+
49
+ ## Source Library
50
+
51
+ > **说明**: 列出所有研究材料的相对路径(相对于 REQ_DIR)
52
+
53
+ ### Internal Codebase Research
54
+ - `research/internal/codebase-overview.md` - 现有代码库结构和可复用模块
55
+ - `research/internal/testing-strategy.md` - 现有测试框架和模式
56
+
57
+ ### External Research Materials (MCP)
58
+ - `research/mcp/20250126/official/nextjs-docs.md` - Next.js 14 官方文档(App Router)
59
+ - `research/mcp/20250126/guides/prisma-best-practices.md` - Prisma ORM 最佳实践
60
+ - `research/mcp/20250126/security/auth0-vs-clerk.md` - 认证方案对比
61
+
62
+ ### Manual Research Notes
63
+ - `research/manual/database-benchmarks.md` - 性能基准测试结果
64
+ - `research/manual/team-feedback.md` - 团队技术偏好调研
65
+
66
+ ---
67
+
68
+ ## Research Completion Checklist
69
+
70
+ > ✅ 使用此清单验证 research.md 是否完整且符合规范
71
+
72
+ ### Structure Validation
73
+ - [ ] 包含 "## Decisions" 章节
74
+ - [ ] 至少有 1 个 Decision block (### R001, R002, ...)
75
+ - [ ] 包含 "## Source Library" 章节
76
+
77
+ ### Content Quality
78
+ - [ ] 每个 Decision block 包含 Decision/Rationale/Alternatives 三部分
79
+ - [ ] Rationale 至少 2 条理由(不能是单行敷衍)
80
+ - [ ] Alternatives 至少 1 个具体方案(不能是 "无" 或 "未评估")
81
+ - [ ] 无 TODO 标记
82
+ - [ ] 无 {{PLACEHOLDER}} 占位符
83
+ - [ ] 无 FIXME/XXX 标记
84
+
85
+ ### Constitution Compliance
86
+ - [ ] Article X.1: 所有 NEEDS CLARIFICATION 已明确标记
87
+ - [ ] Article X.2: 无推测性语言("可能"/"未来"/"预留")
88
+ - [ ] Article I.1: 无部分实现标记("暂时"/"临时"/"简化版")
89
+
90
+ ### Source Traceability
91
+ - [ ] 每个 Decision 有明确的 Source 字段
92
+ - [ ] Source Library 列出所有研究材料路径
93
+ - [ ] 研究材料文件实际存在于 research/ 目录
94
+
95
+ ---
96
+
97
+ ## Usage Instructions
98
+
99
+ ### For AI Agents (prd-writer, planner)
100
+
101
+ 1. **Initialize from Template**:
102
+ ```bash
103
+ cp .claude/docs/templates/RESEARCH_TEMPLATE.md \
104
+ devflow/requirements/${REQ_ID}/research/research.md
105
+ ```
106
+
107
+ 2. **Fill Template Variables**:
108
+ - Replace `{FEATURE_NAME}` with actual feature title
109
+ - Replace `{GENERATED_AT}` with ISO 8601 UTC timestamp
110
+ - Replace all `{PLACEHOLDERS}` with actual content
111
+
112
+ 3. **Populate Decisions**:
113
+ - Read `research/tasks.json` for research task list
114
+ - For each task, create a Decision block
115
+ - Ensure Decision/Rationale/Alternatives are complete
116
+
117
+ 4. **Validate Before Saving**:
118
+ ```bash
119
+ bash .claude/scripts/validate-research.sh ${REQ_DIR} --strict
120
+ ```
121
+
122
+ ### For Human Developers
123
+
124
+ 1. **Manual Research Workflow**:
125
+ ```bash
126
+ # 1. Run flow-init (generates tasks.json)
127
+ /flow-init "REQ-123|Feature Name"
128
+
129
+ # 2. Research each task
130
+ # - Check existing codebase
131
+ # - Search official docs (use MCP)
132
+ # - Benchmark alternatives
133
+
134
+ # 3. Update tasks.json with findings
135
+ # - Add decision, rationale, alternatives fields
136
+ # - Update status to "completed"
137
+
138
+ # 4. Consolidate findings
139
+ bash .claude/scripts/consolidate-research.sh devflow/requirements/REQ-123
140
+
141
+ # 5. Validate
142
+ bash .claude/scripts/validate-research.sh devflow/requirements/REQ-123 --strict
143
+ ```
144
+
145
+ 2. **Direct Editing**:
146
+ - Copy this template to `research/research.md`
147
+ - Fill in decisions based on your research
148
+ - Run validation script before proceeding to /flow-prd
149
+
150
+ ---
151
+
152
+ ## Example: Complete Decision Block
153
+
154
+ ```markdown
155
+ ### R003 — Research authentication strategy for User Management System
156
+ - **Decision**: Auth0 with Next.js Middleware integration
157
+ - **Rationale**:
158
+ - Native support for Next.js App Router middleware authentication
159
+ - Pre-built UI components reduce frontend development time
160
+ - SaaS model eliminates need for auth infrastructure maintenance
161
+ - Compliance certifications (SOC 2, GDPR) included in Pro plan
162
+ - **Alternatives Considered**:
163
+ - Clerk: Similar features but higher pricing at scale (>10k users)
164
+ - NextAuth.js: Open-source but requires self-hosting and security audits
165
+ - AWS Cognito: Lower cost but complex integration with Next.js middleware
166
+ - Custom JWT: Maximum flexibility but significant security risk and dev time
167
+ - **Source**: PRD.md:89 (User Story US-002: User Authentication)
168
+ ```
169
+
170
+ ---
171
+
172
+ ## Anti-Patterns (避免这些错误)
173
+
174
+ ### ❌ Bad Example 1: 敷衍的 Rationale
175
+ ```markdown
176
+ ### R001 — Database choice
177
+ - Decision: PostgreSQL
178
+ - Rationale: 好用
179
+ - Alternatives: MySQL
180
+ ```
181
+ **问题**: Rationale 太简单,没有说明为什么好用。Alternatives 没有对比分析。
182
+
183
+ ### ❌ Bad Example 2: 包含 TODO
184
+ ```markdown
185
+ ### R001 — Database choice
186
+ - Decision: TODO - fill decision outcome
187
+ - Rationale: TODO - explain why
188
+ - Alternatives: TODO - list alternatives
189
+ ```
190
+ **问题**: 未完成的研究,validate-research.sh 会拒绝。
191
+
192
+ ### ❌ Bad Example 3: 推测性语言
193
+ ```markdown
194
+ ### R001 — Database choice
195
+ - Decision: PostgreSQL
196
+ - Rationale:
197
+ - 未来可能需要复杂查询
198
+ - 预留扩展性支持分片
199
+ ```
200
+ **问题**: "未来可能"/"预留" 违反 Article X.2 (No Speculation)。
201
+
202
+ ### ✅ Good Example: 完整且符合规范
203
+ ```markdown
204
+ ### R001 — Research database choice for E-commerce Platform
205
+ - **Decision**: PostgreSQL 15 with Prisma ORM
206
+ - **Rationale**:
207
+ - PRD requires ACID transactions for order processing (US-005)
208
+ - Prisma provides type-safe database access aligned with TypeScript stack
209
+ - Team has 3 years PostgreSQL production experience (reduces onboarding time)
210
+ - Native JSON support needed for product catalog flexible attributes (US-012)
211
+ - **Alternatives Considered**:
212
+ - MongoDB: No ACID transactions, unsuitable for financial operations
213
+ - MySQL: Weaker JSON support, no partial indexes (needed for US-012)
214
+ - Supabase: Vendor lock-in concerns, enterprise pricing unclear
215
+ - **Source**: PRD.md:42 (User Story US-005: Order Processing)
216
+ ```
217
+
218
+ ---
219
+
220
+ ## Troubleshooting
221
+
222
+ ### Q: consolidate-research.sh 生成的 research.md 全是 TODO,怎么办?
223
+
224
+ **A**: 这说明 `research/tasks.json` 缺少 `decision/rationale/alternatives` 字段。
225
+
226
+ **解决方案 1** (推荐): 手动填充 tasks.json
227
+ ```json
228
+ {
229
+ "tasks": [
230
+ {
231
+ "id": "R001",
232
+ "prompt": "Research database choice",
233
+ "status": "completed",
234
+ "decision": "PostgreSQL 15 with Prisma ORM",
235
+ "rationale": "ACID compliance, type-safe access, team experience",
236
+ "alternatives": "MongoDB (no ACID), MySQL (weaker JSON support)",
237
+ "source": "PRD.md:42"
238
+ }
239
+ ]
240
+ }
241
+ ```
242
+
243
+ **解决方案 2**: 直接编辑 research.md,参考此模板格式。
244
+
245
+ **解决方案 3**: 跳过 consolidate-research.sh,完全手动创建 research.md。
246
+
247
+ ### Q: validate-research.sh 报错 "No Decision blocks found",但我有内容?
248
+
249
+ **A**: Decision block 必须符合格式 `### R001 —` (三个 #,空格,R + 数字,空格,破折号)。
250
+
251
+ **正确格式**:
252
+ ```markdown
253
+ ### R001 — Topic description
254
+ ```
255
+
256
+ **错误格式**:
257
+ ```markdown
258
+ ## R001 Topic # ❌ 两个 # 不对
259
+ ### R1 - Topic # ❌ 破折号是 - 不是 —
260
+ ### Decision 1 # ❌ 没有 R00X 编号
261
+ ```
262
+
263
+ ### Q: 我的 research.md 很长,可以拆分吗?
264
+
265
+ **A**: 不建议拆分。research.md 是单一真相源 (Single Source of Truth)。
266
+ - 如果决策太多(>20 个),考虑需求是否过大,应拆分为多个 REQ-ID。
267
+ - 详细研究材料放在 `research/internal/` 或 `research/mcp/`,research.md 只记录决策摘要。
268
+
269
+ ---
270
+
271
+ **Maintained By**: CC-DevFlow Team
272
+ **Last Updated**: 2025-01-26
273
+ **Related Docs**:
274
+ - [flow-init.md](../../commands/flow-init.md) - 需求初始化流程
275
+ - [validate-research.sh](../../scripts/validate-research.sh) - 验证脚本
276
+ - [flow-init-optimization-plan.md](../../../flow-init-optimization-plan.md) - 优化方案
@@ -0,0 +1,5 @@
1
+ {"file": ".claude/rules/project-constitution.md", "reason": "Quality rules and constraints"}
2
+ {"file": "devflow/ROADMAP.md", "reason": "Project roadmap context", "optional": true}
3
+ {"file": "devflow/ARCHITECTURE.md", "reason": "Architecture context", "optional": true}
4
+ {"file": "devflow/spec/frontend/index.md", "reason": "Frontend conventions", "optional": true}
5
+ {"file": "devflow/spec/backend/index.md", "reason": "Backend conventions", "optional": true}