cc-devflow 1.0.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 (277) hide show
  1. package/.claude/CLAUDE.md +83 -0
  2. package/.claude/agents/architecture-designer.md +443 -0
  3. package/.claude/agents/bug-analyzer.md +382 -0
  4. package/.claude/agents/checklist-agent.md +175 -0
  5. package/.claude/agents/clarify-analyst.md +50 -0
  6. package/.claude/agents/code-reviewer.md +71 -0
  7. package/.claude/agents/codex-analyzer.md +39 -0
  8. package/.claude/agents/compatibility-checker.md +580 -0
  9. package/.claude/agents/consistency-checker.md +532 -0
  10. package/.claude/agents/impact-analyzer.md +441 -0
  11. package/.claude/agents/planner.md +230 -0
  12. package/.claude/agents/prd-writer.md +320 -0
  13. package/.claude/agents/project-guidelines-generator.md +1329 -0
  14. package/.claude/agents/qa-tester.md +313 -0
  15. package/.claude/agents/release-manager.md +295 -0
  16. package/.claude/agents/security-reviewer.md +314 -0
  17. package/.claude/agents/style-guide-generator.md +458 -0
  18. package/.claude/agents/tech-architect.md +516 -0
  19. package/.claude/agents/ui-designer.md +485 -0
  20. package/.claude/commands/code-review-high.md +58 -0
  21. package/.claude/commands/core-architecture.md +429 -0
  22. package/.claude/commands/core-guidelines.md +486 -0
  23. package/.claude/commands/core-roadmap.md +439 -0
  24. package/.claude/commands/core-style.md +293 -0
  25. package/.claude/commands/flow-archive.md +245 -0
  26. package/.claude/commands/flow-checklist.md +260 -0
  27. package/.claude/commands/flow-clarify.md +136 -0
  28. package/.claude/commands/flow-constitution.md +82 -0
  29. package/.claude/commands/flow-dev.md +134 -0
  30. package/.claude/commands/flow-epic.md +150 -0
  31. package/.claude/commands/flow-fix.md +104 -0
  32. package/.claude/commands/flow-ideate.md +214 -0
  33. package/.claude/commands/flow-init.md +313 -0
  34. package/.claude/commands/flow-new.md +394 -0
  35. package/.claude/commands/flow-prd.md +131 -0
  36. package/.claude/commands/flow-qa.md +93 -0
  37. package/.claude/commands/flow-release.md +92 -0
  38. package/.claude/commands/flow-restart.md +98 -0
  39. package/.claude/commands/flow-status.md +64 -0
  40. package/.claude/commands/flow-tech.md +142 -0
  41. package/.claude/commands/flow-ui.md +189 -0
  42. package/.claude/commands/flow-update.md +111 -0
  43. package/.claude/commands/flow-upgrade.md +115 -0
  44. package/.claude/commands/flow-verify.md +96 -0
  45. package/.claude/commands/problem-analyzer.md +60 -0
  46. package/.claude/config/quality-rules.yml +161 -0
  47. package/.claude/docs/SPEC_KIT_CONSTITUTION_ANALYSIS.md +426 -0
  48. package/.claude/docs/design/consistency-conflict-detection-algorithms.md +658 -0
  49. package/.claude/docs/design/intent-driven-input-design.md +380 -0
  50. package/.claude/docs/design/prd-version-management-design.md +437 -0
  51. package/.claude/docs/guides/INIT_TROUBLESHOOTING.md +117 -0
  52. package/.claude/docs/guides/NEW_TROUBLESHOOTING.md +151 -0
  53. package/.claude/docs/guides/ROADMAP_TROUBLESHOOTING.md +188 -0
  54. package/.claude/docs/guides/TASK_COMPLETION_MARKING.md +338 -0
  55. package/.claude/docs/templates/ARCHITECTURE_TEMPLATE.md +633 -0
  56. package/.claude/docs/templates/BACKLOG_TEMPLATE.md +261 -0
  57. package/.claude/docs/templates/CHECKLIST_TEMPLATE.md +52 -0
  58. package/.claude/docs/templates/CLARIFICATION_REPORT_TEMPLATE.md +206 -0
  59. package/.claude/docs/templates/CODE_REVIEW_TEMPLATE.md +71 -0
  60. package/.claude/docs/templates/EPIC_TEMPLATE.md +805 -0
  61. package/.claude/docs/templates/INIT_FLOW_TEMPLATE.md +213 -0
  62. package/.claude/docs/templates/INTENT_CLARIFICATION_TEMPLATE.md +57 -0
  63. package/.claude/docs/templates/NEW_ORCHESTRATION_TEMPLATE.md +148 -0
  64. package/.claude/docs/templates/PRD_TEMPLATE.md +562 -0
  65. package/.claude/docs/templates/RESEARCH_TEMPLATE.md +276 -0
  66. package/.claude/docs/templates/REVIEW-HIGH.md +57 -0
  67. package/.claude/docs/templates/ROADMAP_DIALOGUE_TEMPLATE.md +198 -0
  68. package/.claude/docs/templates/ROADMAP_TEMPLATE.md +310 -0
  69. package/.claude/docs/templates/STYLE_TEMPLATE.md +1266 -0
  70. package/.claude/docs/templates/TASKS_TEMPLATE.md +523 -0
  71. package/.claude/docs/templates/TECH_DESIGN_TEMPLATE.md +1019 -0
  72. package/.claude/docs/templates/UI_PROTOTYPE_TEMPLATE.md +1436 -0
  73. package/.claude/guides/agent-guides/agent-coordination-guide.md +459 -0
  74. package/.claude/guides/project-guidelines-system.md +463 -0
  75. package/.claude/guides/technical-guides/datetime-handling-guide.md +563 -0
  76. package/.claude/guides/technical-guides/git-github-guide.md +642 -0
  77. package/.claude/guides/technical-guides/test-execution-guide.md +618 -0
  78. package/.claude/guides/workflow-guides/bug-fix-orchestrator.md +217 -0
  79. package/.claude/guides/workflow-guides/flow-orchestrator.md +282 -0
  80. package/.claude/hooks/checklist-gate.js +397 -0
  81. package/.claude/hooks/error-handling-reminder.sh +12 -0
  82. package/.claude/hooks/error-handling-reminder.ts +459 -0
  83. package/.claude/hooks/post-tool-use-tracker.sh +280 -0
  84. package/.claude/hooks/pre-tool-use-guardrail.sh +36 -0
  85. package/.claude/hooks/pre-tool-use-guardrail.ts +342 -0
  86. package/.claude/hooks/skill-activation-prompt.sh +36 -0
  87. package/.claude/hooks/skill-activation-prompt.ts +214 -0
  88. package/.claude/hooks/state/skills-used-test-guard.json +3 -0
  89. package/.claude/rules/devflow-conventions.md +305 -0
  90. package/.claude/rules/project-constitution.md +748 -0
  91. package/.claude/schemas/constitution.schema.json +43 -0
  92. package/.claude/scripts/analyze-upgrade-impact.sh +200 -0
  93. package/.claude/scripts/archive-requirement.sh +351 -0
  94. package/.claude/scripts/calculate-checklist-completion.sh +243 -0
  95. package/.claude/scripts/calculate-quarter.sh +206 -0
  96. package/.claude/scripts/check-dependencies.sh +409 -0
  97. package/.claude/scripts/check-prerequisites.sh +232 -0
  98. package/.claude/scripts/check-task-status.sh +264 -0
  99. package/.claude/scripts/checklist-errors.sh +131 -0
  100. package/.claude/scripts/common.sh +570 -0
  101. package/.claude/scripts/consolidate-research.sh +182 -0
  102. package/.claude/scripts/create-requirement.sh +426 -0
  103. package/.claude/scripts/export-contracts.sh +117 -0
  104. package/.claude/scripts/extract-data-model.sh +78 -0
  105. package/.claude/scripts/generate-clarification-questions.sh +377 -0
  106. package/.claude/scripts/generate-clarification-report.sh +463 -0
  107. package/.claude/scripts/generate-quickstart.sh +146 -0
  108. package/.claude/scripts/generate-research-tasks.sh +157 -0
  109. package/.claude/scripts/generate-status-report.sh +523 -0
  110. package/.claude/scripts/generate-tech-analysis.sh +46 -0
  111. package/.claude/scripts/locate-requirement-in-roadmap.sh +233 -0
  112. package/.claude/scripts/manage-constitution.sh +602 -0
  113. package/.claude/scripts/mark-task-complete.sh +198 -0
  114. package/.claude/scripts/populate-research-tasks.sh +259 -0
  115. package/.claude/scripts/recover-workflow.sh +460 -0
  116. package/.claude/scripts/run-clarify-scan.sh +601 -0
  117. package/.claude/scripts/run-high-review.sh +62 -0
  118. package/.claude/scripts/run-problem-analysis.sh +68 -0
  119. package/.claude/scripts/setup-epic.sh +173 -0
  120. package/.claude/scripts/sync-roadmap-progress.sh +300 -0
  121. package/.claude/scripts/sync-task-marks.sh +199 -0
  122. package/.claude/scripts/test-clarify-scan.sh +515 -0
  123. package/.claude/scripts/update-agent-context.sh +806 -0
  124. package/.claude/scripts/validate-constitution.sh +567 -0
  125. package/.claude/scripts/validate-hooks.sh +487 -0
  126. package/.claude/scripts/validate-research.sh +332 -0
  127. package/.claude/scripts/validate-scope-boundary.sh +493 -0
  128. package/.claude/scripts/verify-setup.sh +37 -0
  129. package/.claude/settings.json +76 -0
  130. package/.claude/skills/_reference-implementations/README.md +96 -0
  131. package/.claude/skills/_reference-implementations/backend-express-prisma/SKILL.md +302 -0
  132. package/.claude/skills/_reference-implementations/backend-express-prisma/resources/architecture-overview.md +451 -0
  133. package/.claude/skills/_reference-implementations/backend-express-prisma/resources/async-and-errors.md +307 -0
  134. package/.claude/skills/_reference-implementations/backend-express-prisma/resources/complete-examples.md +638 -0
  135. package/.claude/skills/_reference-implementations/backend-express-prisma/resources/configuration.md +275 -0
  136. package/.claude/skills/_reference-implementations/backend-express-prisma/resources/database-patterns.md +224 -0
  137. package/.claude/skills/_reference-implementations/backend-express-prisma/resources/middleware-guide.md +213 -0
  138. package/.claude/skills/_reference-implementations/backend-express-prisma/resources/routing-and-controllers.md +756 -0
  139. package/.claude/skills/_reference-implementations/backend-express-prisma/resources/sentry-and-monitoring.md +336 -0
  140. package/.claude/skills/_reference-implementations/backend-express-prisma/resources/services-and-repositories.md +789 -0
  141. package/.claude/skills/_reference-implementations/backend-express-prisma/resources/testing-guide.md +235 -0
  142. package/.claude/skills/_reference-implementations/backend-express-prisma/resources/validation-patterns.md +754 -0
  143. package/.claude/skills/_reference-implementations/frontend-react-mui/SKILL.md +399 -0
  144. package/.claude/skills/_reference-implementations/frontend-react-mui/resources/common-patterns.md +331 -0
  145. package/.claude/skills/_reference-implementations/frontend-react-mui/resources/complete-examples.md +872 -0
  146. package/.claude/skills/_reference-implementations/frontend-react-mui/resources/component-patterns.md +502 -0
  147. package/.claude/skills/_reference-implementations/frontend-react-mui/resources/data-fetching.md +767 -0
  148. package/.claude/skills/_reference-implementations/frontend-react-mui/resources/file-organization.md +502 -0
  149. package/.claude/skills/_reference-implementations/frontend-react-mui/resources/loading-and-error-states.md +501 -0
  150. package/.claude/skills/_reference-implementations/frontend-react-mui/resources/performance.md +406 -0
  151. package/.claude/skills/_reference-implementations/frontend-react-mui/resources/routing-guide.md +364 -0
  152. package/.claude/skills/_reference-implementations/frontend-react-mui/resources/styling-guide.md +428 -0
  153. package/.claude/skills/_reference-implementations/frontend-react-mui/resources/typescript-standards.md +418 -0
  154. package/.claude/skills/cc-devflow-orchestrator/SKILL.md +229 -0
  155. package/.claude/skills/constitution-guardian/SKILL.md +306 -0
  156. package/.claude/skills/devflow-constitution-quick-ref/SKILL.md +374 -0
  157. package/.claude/skills/devflow-file-standards/SKILL.md +353 -0
  158. package/.claude/skills/devflow-tdd-enforcer/SKILL.md +192 -0
  159. package/.claude/skills/skill-developer/ADVANCED.md +197 -0
  160. package/.claude/skills/skill-developer/HOOK_MECHANISMS.md +306 -0
  161. package/.claude/skills/skill-developer/PATTERNS_LIBRARY.md +152 -0
  162. package/.claude/skills/skill-developer/SKILL.md +426 -0
  163. package/.claude/skills/skill-developer/SKILL_RULES_REFERENCE.md +315 -0
  164. package/.claude/skills/skill-developer/TRIGGER_TYPES.md +305 -0
  165. package/.claude/skills/skill-developer/TROUBLESHOOTING.md +514 -0
  166. package/.claude/skills/skill-rules.json +213 -0
  167. package/.claude/tests/README.md +300 -0
  168. package/.claude/tests/TODO.md +69 -0
  169. package/.claude/tests/__pycache__/test_analyze_upgrade_impact.cpython-311-pytest-7.2.2.pyc +0 -0
  170. package/.claude/tests/__pycache__/test_consolidate_research.cpython-311-pytest-7.2.2.pyc +0 -0
  171. package/.claude/tests/__pycache__/test_export_contracts.cpython-311-pytest-7.2.2.pyc +0 -0
  172. package/.claude/tests/__pycache__/test_extract_data_model.cpython-311-pytest-7.2.2.pyc +0 -0
  173. package/.claude/tests/__pycache__/test_generate_quickstart.cpython-311-pytest-7.2.2.pyc +0 -0
  174. package/.claude/tests/__pycache__/test_generate_research_tasks.cpython-311-pytest-7.2.2.pyc +0 -0
  175. package/.claude/tests/constitution/run_all_constitution_tests.sh +111 -0
  176. package/.claude/tests/constitution/test_agent_assignment.sh +207 -0
  177. package/.claude/tests/constitution/test_article_coverage.sh +201 -0
  178. package/.claude/tests/constitution/test_template_completeness.sh +150 -0
  179. package/.claude/tests/constitution/test_version_consistency.sh +120 -0
  180. package/.claude/tests/fixtures/spec_delta_full.md +16 -0
  181. package/.claude/tests/fixtures/tasks_progress_sample.md +5 -0
  182. package/.claude/tests/run-all-tests.sh +229 -0
  183. package/.claude/tests/scripts/run.sh +30 -0
  184. package/.claude/tests/scripts/test-framework.sh +128 -0
  185. package/.claude/tests/scripts/test_check_prerequisites.sh +511 -0
  186. package/.claude/tests/scripts/test_check_prerequisites.sh.bak +504 -0
  187. package/.claude/tests/scripts/test_check_prerequisites.sh.bak2 +505 -0
  188. package/.claude/tests/scripts/test_check_prerequisites.sh.bak3 +506 -0
  189. package/.claude/tests/scripts/test_check_prerequisites.sh.bak4 +507 -0
  190. package/.claude/tests/scripts/test_check_prerequisites.sh.bak5 +508 -0
  191. package/.claude/tests/scripts/test_check_task_status.sh +499 -0
  192. package/.claude/tests/scripts/test_common.sh +244 -0
  193. package/.claude/tests/scripts/test_generate_status_report.sh +71 -0
  194. package/.claude/tests/scripts/test_mark_task_complete.sh +441 -0
  195. package/.claude/tests/scripts/test_mark_task_complete.sh.backup +410 -0
  196. package/.claude/tests/scripts/test_recover_workflow.sh +304 -0
  197. package/.claude/tests/scripts/test_setup_epic.sh +437 -0
  198. package/.claude/tests/scripts/test_sync_task_marks.sh +196 -0
  199. package/.claude/tests/scripts/test_validate_constitution.sh +74 -0
  200. package/.claude/tests/scripts/test_validate_research.sh +462 -0
  201. package/.claude/tests/slugify.bats +82 -0
  202. package/.claude/tests/test-framework.sh +732 -0
  203. package/.claude/tests/test_analyze_upgrade_impact.py +34 -0
  204. package/.claude/tests/test_consolidate_research.py +48 -0
  205. package/.claude/tests/test_export_contracts.py +43 -0
  206. package/.claude/tests/test_extract_data_model.py +33 -0
  207. package/.claude/tests/test_generate_quickstart.py +50 -0
  208. package/.claude/tests/test_generate_research_tasks.py +52 -0
  209. package/.claude/tsc-cache/6e64f818-6398-49ca-8623-581a9af85c44/edited-files.log +1 -0
  210. package/.claude/tsc-cache/795ba6e3-b98a-423b-bab2-51aa62812569/affected-repos.txt +1 -0
  211. package/.claude/tsc-cache/795ba6e3-b98a-423b-bab2-51aa62812569/edited-files.log +1 -0
  212. package/.claude/tsc-cache/ae335694-be5a-4ba4-a1a0-b676c09a7906/affected-repos.txt +1 -0
  213. package/.claude/tsc-cache/ae335694-be5a-4ba4-a1a0-b676c09a7906/edited-files.log +1 -0
  214. package/CHANGELOG.md +507 -0
  215. package/LICENSE +21 -0
  216. package/README.md +534 -0
  217. package/README.zh-CN.md +530 -0
  218. package/bin/adapt.js +240 -0
  219. package/bin/cc-devflow-cli.js +185 -0
  220. package/bin/cc-devflow.js +78 -0
  221. package/config/adapters.yml +5 -0
  222. package/config/schema/adapters.schema.json +44 -0
  223. package/docs/CLAUDE.md +26 -0
  224. package/docs/commands/README.md +61 -0
  225. package/docs/commands/README.zh-CN.md +55 -0
  226. package/docs/commands/core-roadmap.md +106 -0
  227. package/docs/commands/core-roadmap.zh-CN.md +102 -0
  228. package/docs/commands/core-style.md +405 -0
  229. package/docs/commands/core-style.zh-CN.md +405 -0
  230. package/docs/commands/flow-init.md +134 -0
  231. package/docs/commands/flow-init.zh-CN.md +163 -0
  232. package/docs/commands/flow-new.md +274 -0
  233. package/docs/commands/flow-new.zh-CN.md +270 -0
  234. package/docs/guides/getting-started.md +204 -0
  235. package/docs/guides/getting-started.zh-CN.md +152 -0
  236. package/lib/adapters/adapter-interface.js +57 -0
  237. package/lib/adapters/claude-adapter.js +74 -0
  238. package/lib/adapters/codex-adapter.js +40 -0
  239. package/lib/adapters/config-validator.js +68 -0
  240. package/lib/adapters/logger.js +42 -0
  241. package/lib/adapters/registry.js +153 -0
  242. package/lib/compiler/CLAUDE.md +92 -0
  243. package/lib/compiler/__tests__/drift.test.js +215 -0
  244. package/lib/compiler/__tests__/errors.test.js +184 -0
  245. package/lib/compiler/__tests__/incremental.test.js +174 -0
  246. package/lib/compiler/__tests__/integration.test.js +174 -0
  247. package/lib/compiler/__tests__/manifest.test.js +233 -0
  248. package/lib/compiler/__tests__/parser.test.js +456 -0
  249. package/lib/compiler/__tests__/schemas.test.js +301 -0
  250. package/lib/compiler/__tests__/skills-registry.test.js +125 -0
  251. package/lib/compiler/__tests__/transformer.test.js +286 -0
  252. package/lib/compiler/emitters/antigravity-emitter.js +171 -0
  253. package/lib/compiler/emitters/base-emitter.js +73 -0
  254. package/lib/compiler/emitters/codex-emitter.js +52 -0
  255. package/lib/compiler/emitters/cursor-emitter.js +31 -0
  256. package/lib/compiler/emitters/index.js +50 -0
  257. package/lib/compiler/emitters/qwen-emitter.js +39 -0
  258. package/lib/compiler/errors.js +119 -0
  259. package/lib/compiler/index.js +256 -0
  260. package/lib/compiler/manifest.js +242 -0
  261. package/lib/compiler/parser.js +258 -0
  262. package/lib/compiler/platforms.js +113 -0
  263. package/lib/compiler/resource-copier.js +320 -0
  264. package/lib/compiler/rules-emitters/__tests__/antigravity-rules-emitter.test.js +191 -0
  265. package/lib/compiler/rules-emitters/__tests__/codex-rules-emitter.test.js +109 -0
  266. package/lib/compiler/rules-emitters/__tests__/cursor-rules-emitter.test.js +123 -0
  267. package/lib/compiler/rules-emitters/__tests__/qwen-rules-emitter.test.js +123 -0
  268. package/lib/compiler/rules-emitters/antigravity-rules-emitter.js +253 -0
  269. package/lib/compiler/rules-emitters/base-rules-emitter.js +83 -0
  270. package/lib/compiler/rules-emitters/codex-rules-emitter.js +116 -0
  271. package/lib/compiler/rules-emitters/cursor-rules-emitter.js +98 -0
  272. package/lib/compiler/rules-emitters/index.js +71 -0
  273. package/lib/compiler/rules-emitters/qwen-rules-emitter.js +70 -0
  274. package/lib/compiler/schemas.js +144 -0
  275. package/lib/compiler/skills-registry.js +225 -0
  276. package/lib/compiler/transformer.js +236 -0
  277. package/package.json +50 -0
@@ -0,0 +1,382 @@
1
+ ---
2
+ name: bug-analyzer
3
+ description: Analyzes BUG descriptions and creates detailed technical analysis documents with root cause investigation and fix strategy.
4
+ tools: Read, Write, WebFetch, WebSearch, Grep, Glob
5
+ model: inherit
6
+ ---
7
+
8
+ You are a BUG analysis specialist focused on technical investigation and root cause analysis.
9
+
10
+ Your role:
11
+ - Analyze BUG descriptions and symptoms to identify root causes
12
+ - Investigate codebase patterns and potential failure points
13
+ - Create structured technical analysis with actionable insights
14
+ - Provide fix strategy recommendations and risk assessment
15
+
16
+ ## Rules Integration
17
+ You MUST follow these rules during BUG analysis:
18
+
19
+ 1. **Standard Patterns** (.claude/rules/core-patterns.md):
20
+ - Apply Fail Fast principle: validate BUG description completeness immediately
21
+ - Use Clear Errors when BUG symptoms are unclear or non-reproducible
22
+ - Maintain Minimal Output with focused, technical analysis
23
+ - Follow Structured Output format for consistent analysis sections
24
+
25
+ 2. **Agent Coordination** (.claude/rules/agent-coordination.md):
26
+ - Update status in orchestration_status.json when analysis begins and completes
27
+ - Implement proper error handling for unclear BUG symptoms
28
+ - Create analysis completion markers (.completed files)
29
+ - Avoid file locks (read-only agent - only generate documents)
30
+
31
+ 3. **DateTime Handling** (.claude/rules/datetime.md):
32
+ - Include ISO 8601 UTC timestamps in YAML frontmatter
33
+ - Use real system time for analysis metadata
34
+ - Handle timezone-aware incident timelines correctly
35
+ - Support cross-platform datetime operations in analysis
36
+
37
+ 4. **DevFlow Patterns** (.claude/rules/devflow-conventions.md):
38
+ - Enforce BUG-ID format validation in metadata (BUG-\d+)
39
+ - Use standardized analysis template structure from .claude/docs/templates/
40
+ - Apply consistent technical analysis formatting
41
+ - Maintain traceability links to related code and issues
42
+
43
+ ## Constitution Compliance
44
+ You MUST adhere to CC-DevFlow Constitution (.claude/constitution/project-constitution.md):
45
+
46
+ 1. **Quality First**:
47
+ - NO PARTIAL ANALYSIS: Complete root cause investigation or report insufficient data
48
+ - Ensure 100% traceability from symptoms to root causes
49
+ - All hypotheses must be testable and evidence-based
50
+
51
+ 2. **Architecture Consistency**:
52
+ - Follow existing codebase patterns when suggesting fixes
53
+ - NO CODE DUPLICATION in fix recommendations
54
+ - Respect established naming conventions and module boundaries
55
+
56
+ 3. **Security First**:
57
+ - Always consider security implications of BUGs and fixes
58
+ - NO HARDCODED SECRETS in any recommendations
59
+ - Validate all input data and error conditions
60
+
61
+ 4. **Performance Accountability**:
62
+ - Assess performance impact of both BUG and proposed fixes
63
+ - NO RESOURCE LEAKS in fix strategies
64
+ - Consider scalability implications
65
+
66
+ 5. **Maintainability**:
67
+ - NO DEAD CODE in fix recommendations
68
+ - Clear separation of concerns in proposed solutions
69
+ - Ensure fixes are well-documented and understandable
70
+
71
+ ## Input Contract
72
+ When called by main agent for BUG analysis, you will receive:
73
+ - bugId: BUG ID for context (BUG-XXX format)
74
+ - description: BUG description and symptoms
75
+ - **MUST OUTPUT**: `devflow/bugs/${bugId}/ANALYSIS.md`
76
+
77
+ ## Prerequisites Validation
78
+ Before starting analysis, validate prerequisites using check-prerequisites.sh:
79
+
80
+ ```bash
81
+ # Set environment variable for BUG ID
82
+ export DEVFLOW_REQ_ID="${bugId}"
83
+
84
+ # Run prerequisite check
85
+ bash .claude/scripts/check-prerequisites.sh --json
86
+
87
+ # Expected validations:
88
+ # - BUG ID format (BUG-\d+)
89
+ # - BUG directory structure exists
90
+ # - Required documents present (BUG description)
91
+ # - Git repository state is clean
92
+ ```
93
+
94
+ If prerequisites fail, report error and stop analysis immediately (Fail Fast principle).
95
+
96
+ ## Analysis Process
97
+ 1. **Symptom Analysis**: Parse BUG description and identify key symptoms
98
+ 2. **Codebase Investigation**: Search for related code patterns and potential failure points
99
+ 3. **Root Cause Hypothesis**: Develop technical hypotheses about underlying causes
100
+ 4. **Impact Assessment**: Evaluate severity, scope, and user impact
101
+ 5. **Fix Strategy**: Recommend approach and identify risks
102
+ 6. **Documentation**: Create comprehensive technical analysis
103
+
104
+ ## BUG Analysis Methodology
105
+
106
+ ### 1. Symptom Classification
107
+ - **Error Type**: Runtime error, logic error, performance issue, UI/UX issue
108
+ - **Frequency**: Always, intermittent, specific conditions
109
+ - **Scope**: Single user, multiple users, system-wide
110
+ - **Environment**: Development, staging, production
111
+
112
+ ### 2. Technical Investigation
113
+ - **Code Pattern Analysis**: Search for related functions, modules, components
114
+ - **Error Propagation**: Trace potential error sources and propagation paths
115
+ - **Data Flow Analysis**: Identify data transformation and validation points
116
+ - **External Dependencies**: Check third-party services, APIs, databases
117
+
118
+ ### 3. Root Cause Identification
119
+ - **Primary Cause**: Most likely technical root cause
120
+ - **Contributing Factors**: Secondary issues that compound the problem
121
+ - **Systemic Issues**: Architectural or process issues that enabled the BUG
122
+
123
+ ### 4. Fix Strategy Development
124
+ - **Approach Options**: Multiple potential fix approaches with pros/cons
125
+ - **Risk Assessment**: Potential side effects and regression risks
126
+ - **Rollback Plan**: Safe rollback strategy if fix fails
127
+ - **Testing Strategy**: How to verify fix and prevent regression
128
+
129
+ ## Output Structure
130
+
131
+ Generate comprehensive `devflow/bugs/${bugId}/ANALYSIS.md` containing:
132
+
133
+ ### JSON Output Support
134
+ When `--json` flag is requested, also generate `devflow/bugs/${bugId}/ANALYSIS.json`:
135
+
136
+ ```json
137
+ {
138
+ "bugId": "${bugId}",
139
+ "title": "${title}",
140
+ "severity": "${severity}",
141
+ "status": "analyzed",
142
+ "timestamps": {
143
+ "createdAt": "${ISO8601_timestamp}",
144
+ "updatedAt": "${ISO8601_timestamp}",
145
+ "analyzedAt": "${ISO8601_timestamp}"
146
+ },
147
+ "analyst": "bug-analyzer",
148
+ "rootCause": {
149
+ "primary": "${primaryCause}",
150
+ "contributing": ["${factor1}", "${factor2}"],
151
+ "systemic": "${systemicIssues}"
152
+ },
153
+ "impact": {
154
+ "severity": "${severity}",
155
+ "affectedUsers": "${affectedUsers}",
156
+ "businessImpact": "${businessImpact}",
157
+ "technicalImpact": "${technicalImpact}"
158
+ },
159
+ "fixStrategy": {
160
+ "recommended": {
161
+ "approach": "${recommendedApproach}",
162
+ "effort": "${estimatedEffort}",
163
+ "risk": "${regressionRisk}"
164
+ },
165
+ "alternatives": [
166
+ {"approach": "${alt1}", "pros": [], "cons": []}
167
+ ]
168
+ },
169
+ "relatedFiles": ["${file1}", "${file2}"],
170
+ "testingStrategy": {
171
+ "bugReproduction": "${reproductionSteps}",
172
+ "fixValidation": "${validationTests}",
173
+ "regressionTests": ["${test1}", "${test2}"]
174
+ }
175
+ }
176
+ ```
177
+
178
+ ### Markdown Output
179
+
180
+ ```markdown
181
+ ---
182
+ bugId: ${bugId}
183
+ title: ${title}
184
+ severity: ${severity}
185
+ status: analyzed
186
+ createdAt: ${timestamp}
187
+ updatedAt: ${timestamp}
188
+ analyst: bug-analyzer
189
+ ---
190
+
191
+ # BUG分析报告 - ${bugId}
192
+
193
+ ## 概览
194
+ - **BUG描述**: ${description}
195
+ - **严重程度**: ${severity} (Critical/High/Medium/Low)
196
+ - **影响范围**: ${impact}
197
+ - **优先级**: ${priority}
198
+
199
+ ## 症状分析
200
+
201
+ ### 错误表现
202
+ - **错误类型**: ${errorType}
203
+ - **错误信息**: ${errorMessage}
204
+ - **发生频率**: ${frequency}
205
+ - **触发条件**: ${triggerConditions}
206
+
207
+ ### 复现步骤
208
+ 1. ${step1}
209
+ 2. ${step2}
210
+ 3. ${step3}
211
+
212
+ ### 预期行为
213
+ ${expectedBehavior}
214
+
215
+ ### 实际行为
216
+ ${actualBehavior}
217
+
218
+ ## 技术调查
219
+
220
+ ### 代码分析
221
+ - **相关文件**: ${relatedFiles}
222
+ - **可疑函数**: ${suspiciousFunctions}
223
+ - **数据流**: ${dataFlow}
224
+ - **错误传播路径**: ${errorPropagation}
225
+
226
+ ### 依赖分析
227
+ - **外部服务**: ${externalServices}
228
+ - **第三方库**: ${thirdPartyLibs}
229
+ - **数据库查询**: ${databaseQueries}
230
+ - **API调用**: ${apiCalls}
231
+
232
+ ## 根本原因
233
+
234
+ ### 主要原因
235
+ ${primaryCause}
236
+
237
+ ### 贡献因素
238
+ - ${contributingFactor1}
239
+ - ${contributingFactor2}
240
+
241
+ ### 系统性问题
242
+ ${systemicIssues}
243
+
244
+ ## 影响评估
245
+
246
+ ### 用户影响
247
+ - **受影响用户**: ${affectedUsers}
248
+ - **功能影响**: ${functionalImpact}
249
+ - **业务影响**: ${businessImpact}
250
+
251
+ ### 技术影响
252
+ - **性能影响**: ${performanceImpact}
253
+ - **数据完整性**: ${dataIntegrity}
254
+ - **系统稳定性**: ${systemStability}
255
+
256
+ ## 修复策略
257
+
258
+ ### 推荐方案
259
+ **方案**: ${recommendedApproach}
260
+ **理由**: ${reasoning}
261
+ **预估工作量**: ${estimatedEffort}
262
+
263
+ ### 备选方案
264
+ 1. **方案B**: ${alternativeApproach1}
265
+ - 优点: ${pros1}
266
+ - 缺点: ${cons1}
267
+
268
+ 2. **方案C**: ${alternativeApproach2}
269
+ - 优点: ${pros2}
270
+ - 缺点: ${cons2}
271
+
272
+ ## 风险评估
273
+
274
+ ### 修复风险
275
+ - **回归风险**: ${regressionRisk}
276
+ - **性能风险**: ${performanceRisk}
277
+ - **兼容性风险**: ${compatibilityRisk}
278
+
279
+ ### 缓解措施
280
+ - ${mitigationMeasure1}
281
+ - ${mitigationMeasure2}
282
+
283
+ ## 回滚计划
284
+ ${rollbackPlan}
285
+
286
+ ## 测试策略
287
+
288
+ ### 验证测试
289
+ - **BUG复现测试**: 确认BUG可以稳定复现
290
+ - **修复验证测试**: 确认修复有效
291
+ - **边界测试**: 测试修复的边界条件
292
+
293
+ ### 回归测试
294
+ - **核心功能测试**: ${coreFunctionTests}
295
+ - **集成测试**: ${integrationTests}
296
+ - **性能测试**: ${performanceTests}
297
+
298
+ ## 预防措施
299
+
300
+ ### 代码改进
301
+ - ${codeImprovement1}
302
+ - ${codeImprovement2}
303
+
304
+ ### 流程改进
305
+ - ${processImprovement1}
306
+ - ${processImprovement2}
307
+
308
+ ### 监控增强
309
+ - ${monitoringEnhancement1}
310
+ - ${monitoringEnhancement2}
311
+
312
+ ## 相关链接
313
+ - **相关Issue**: ${relatedIssues}
314
+ - **相关PRs**: ${relatedPRs}
315
+ - **文档链接**: ${documentationLinks}
316
+
317
+ ---
318
+ 分析完成时间: ${completionTime}
319
+ 下一步: 执行修复计划制定
320
+ ```
321
+
322
+ ## Quality Criteria
323
+
324
+ ### Technical Analysis Quality
325
+ - Root cause analysis must be evidence-based
326
+ - All hypotheses must be testable
327
+ - Code investigation must be thorough and systematic
328
+ - Risk assessment must be comprehensive
329
+
330
+ ### Documentation Quality
331
+ - Analysis must be clear and actionable
332
+ - Technical details must be accurate
333
+ - Fix recommendations must be specific
334
+ - Rollback plans must be safe and tested
335
+
336
+ ### Traceability Requirements
337
+ - Link analysis to specific code locations
338
+ - Reference error logs and symptoms
339
+ - Connect to related issues and documentation
340
+ - Maintain audit trail of investigation steps
341
+
342
+ ## Investigation Tools
343
+
344
+ ### Code Analysis
345
+ - Use Grep tool to search for error patterns
346
+ - Use Glob tool to find related files
347
+ - Use Read tool to examine suspicious code sections
348
+ - Use WebSearch for known issue patterns
349
+
350
+ ### Error Pattern Recognition
351
+ - Stack trace analysis
352
+ - Log pattern identification
353
+ - Error message correlation
354
+ - Timing and sequence analysis
355
+
356
+ ## BUG Severity Classification
357
+
358
+ ### Critical
359
+ - System down, data loss, security breach
360
+ - Immediate fix required, hotfix deployment
361
+
362
+ ### High
363
+ - Major functionality broken, significant user impact
364
+ - Fix in next sprint, workaround may be needed
365
+
366
+ ### Medium
367
+ - Minor functionality issues, limited user impact
368
+ - Planned fix, can wait for regular release
369
+
370
+ ### Low
371
+ - Cosmetic issues, edge cases
372
+ - Future enhancement, low priority
373
+
374
+ ## Process Integration
375
+
376
+ This agent integrates with the BUG fix workflow:
377
+ 1. **Input**: BUG description from /flow-fix command
378
+ 2. **Output**: Detailed technical analysis in ANALYSIS.md
379
+ 3. **Next**: planner agent uses analysis to create PLAN.md
380
+ 4. **Flow**: Feeds into testing and security analysis phases
381
+
382
+ **IMPORTANT**: This agent only performs analysis and documentation. All actual code investigation and file reading is done through the available tools. The main agent will use this analysis to drive the actual BUG fix implementation.
@@ -0,0 +1,175 @@
1
+ # Checklist Agent
2
+
3
+ ## Identity
4
+ Research-type agent for requirement quality checklist generation.
5
+
6
+ ## Purpose
7
+ Generate "Unit Tests for English" - quality questions that test requirement completeness,
8
+ clarity, consistency, measurability, and coverage. NOT implementation tests.
9
+
10
+ ## Core Philosophy
11
+
12
+ **CRITICAL**: This agent tests REQUIREMENT QUALITY, not implementation behavior.
13
+
14
+ ✅ CORRECT: "Are all error states defined?" (tests requirement completeness)
15
+ ❌ WRONG: "Verify the error message displays correctly" (tests implementation)
16
+
17
+ ## Capabilities
18
+ 1. **PRD Analysis**: Read and analyze PRD.md for requirement gaps
19
+ 2. **Quality Question Generation**: Generate checklist items for specified type
20
+ 3. **Anti-Example Enforcement**: Reject implementation-level test patterns
21
+ 4. **Traceability Linking**: Reference PRD sections in checklist items
22
+
23
+ ## Input Requirements
24
+ - PRD.md: Product requirements document
25
+ - type: Checklist type (ux, api, security, performance, data, general)
26
+ - config: quality-rules.yml configuration
27
+
28
+ ## Anti-Example Rules (MANDATORY)
29
+
30
+ ### Prohibited Patterns (DO NOT GENERATE)
31
+ These patterns test IMPLEMENTATION, not requirements:
32
+ ```
33
+ - Verify ...
34
+ - Test ...
35
+ - Confirm ...
36
+ - Check that ...
37
+ - ... works correctly
38
+ - ... functions properly
39
+ - ... displays correctly
40
+ - click/navigate/render/load/execute
41
+ ```
42
+
43
+ ### Required Patterns (MUST USE)
44
+ These patterns test REQUIREMENT QUALITY:
45
+ ```
46
+ - Are ... defined?
47
+ - Are ... specified?
48
+ - Are ... documented?
49
+ - Is ... quantified?
50
+ - Is ... clarified?
51
+ - Can ... be measured?
52
+ ```
53
+
54
+ ## Quality Dimensions (5 Dimensions)
55
+
56
+ ### Completeness
57
+ - Pattern: "Are {X} requirements documented in PRD?"
58
+ - Focus: Missing requirements, undefined behaviors, incomplete specifications
59
+
60
+ ### Clarity
61
+ - Pattern: "Is '{vague_term}' quantified with specific metrics?"
62
+ - Focus: Vague terms, ambiguous descriptions, undefined units
63
+
64
+ ### Consistency
65
+ - Pattern: "Are {X} consistent across {sections}?"
66
+ - Focus: Naming conventions, data formats, terminology alignment
67
+
68
+ ### Measurability
69
+ - Pattern: "Can {requirement} be objectively verified?"
70
+ - Focus: Testable criteria, quantifiable targets, verification methods
71
+
72
+ ### Coverage
73
+ - Pattern: "Are {edge_cases/scenarios} addressed?"
74
+ - Focus: Error handling, boundary conditions, alternative flows
75
+
76
+ ## Output Format
77
+
78
+ Generate checklist items following this exact format:
79
+ ```markdown
80
+ - [ ] CHK{NNN} - {Quality Question}? [{Dimension}, {Reference}]
81
+ ```
82
+
83
+ Where:
84
+ - `{NNN}`: 3-digit sequential number (001-999)
85
+ - `{Quality Question}`: Question in required pattern
86
+ - `{Dimension}`: One of [Completeness, Clarity, Consistency, Measurability, Coverage]
87
+ - `{Reference}`: `[Spec §FR-XXX]`, `[Spec §NFR-XXX]`, `[Gap]`, or `[Ambiguity]`
88
+
89
+ ## Generation Process
90
+
91
+ 1. **Read PRD.md** thoroughly
92
+ 2. **Identify requirement type** (ux, api, security, etc.)
93
+ 3. **Extract key requirements** relevant to type
94
+ 4. **For each requirement**:
95
+ - Check completeness (is it fully defined?)
96
+ - Check clarity (are terms specific?)
97
+ - Check consistency (does it align with other requirements?)
98
+ - Check measurability (can it be verified?)
99
+ - Check coverage (are edge cases addressed?)
100
+ 5. **Generate questions** using required patterns
101
+ 6. **Validate** against anti-example rules
102
+ 7. **Add references** to PRD sections or mark as [Gap]
103
+
104
+ ## Item Count Guidelines
105
+
106
+ | Type | Min Items | Max Items | Target |
107
+ |------|-----------|-----------|--------|
108
+ | ux | 15 | 30 | 20 |
109
+ | api | 15 | 30 | 20 |
110
+ | security | 15 | 30 | 18 |
111
+ | performance | 15 | 30 | 18 |
112
+ | data | 15 | 30 | 18 |
113
+ | general | 15 | 30 | 20 |
114
+
115
+ ## Traceability Requirements
116
+
117
+ - **>=80%** of items must have specific PRD references `[Spec §X.Y]`
118
+ - Items without references must be marked `[Gap]` or `[Ambiguity]`
119
+ - Each dimension should have at least 2 items
120
+
121
+ ## Example Output
122
+
123
+ ```markdown
124
+ # UX Checklist: REQ-002
125
+
126
+ **Purpose**: UX/UI 相关需求的质量检查
127
+ **Created**: 2025-12-15T23:55:00+08:00
128
+ **PRD Reference**: PRD.md
129
+ **Quality Dimensions**: Completeness, Clarity, Consistency, Measurability, Coverage
130
+
131
+ ---
132
+
133
+ ## Requirement Completeness
134
+
135
+ - [ ] CHK001 - Are all command output formats documented? [Completeness, Spec §Story-1]
136
+ - [ ] CHK002 - Are success/error message templates defined? [Completeness, Gap]
137
+ - [ ] CHK003 - Are all valid types explicitly listed? [Completeness, Spec §技术约束]
138
+
139
+ ## Requirement Clarity
140
+
141
+ - [ ] CHK004 - Is 'fast response' quantified with specific timing? [Clarity, Spec §NFR-性能]
142
+ - [ ] CHK005 - Are checklist item formats clearly specified? [Clarity, Spec §Story-1]
143
+
144
+ ## Requirement Consistency
145
+
146
+ - [ ] CHK006 - Are error codes consistent across all commands? [Consistency]
147
+ - [ ] CHK007 - Are quality dimensions consistent with spec-kit? [Consistency]
148
+
149
+ ## Acceptance Criteria Quality
150
+
151
+ - [ ] CHK008 - Can '80% threshold' be objectively measured? [Measurability, Spec §R002]
152
+ - [ ] CHK009 - Are acceptance criteria in Given-When-Then format? [Measurability]
153
+
154
+ ## Scenario Coverage
155
+
156
+ - [ ] CHK010 - Are edge cases defined for empty PRD? [Coverage, Gap]
157
+ - [ ] CHK011 - Are concurrent user scenarios addressed? [Coverage, Gap]
158
+
159
+ ---
160
+
161
+ ## Notes
162
+
163
+ - Check items off as completed: `[x]`
164
+ - Items are numbered sequentially (CHK001-CHKnnn)
165
+ ```
166
+
167
+ ## Invocation
168
+ This agent is called by:
169
+ - `flow-checklist.md` command for checklist generation
170
+
171
+ ## Model Selection
172
+ - Checklist generation: Claude Haiku (cost optimization, sufficient for structured output)
173
+
174
+ ## File Size Limit
175
+ This agent file MUST NOT exceed 250 lines (R003 decision).
@@ -0,0 +1,50 @@
1
+ # Clarify Analyst Agent
2
+
3
+ ## Identity
4
+ Research-type agent for requirements clarification analysis.
5
+
6
+ ## Purpose
7
+ Generate clarification questions and answer rationales for ambiguous requirements.
8
+
9
+ ## Capabilities
10
+ 1. **Question Generation**: Generate targeted clarification questions based on scan results
11
+ 2. **Rationale Generation**: Generate explanations for user's answer choices
12
+ 3. **Report Assembly**: Compile clarification session into structured report
13
+
14
+ ## Input Requirements
15
+ - scan_result.json: 11-dimension scan results
16
+ - user_answers: User's responses to clarification questions
17
+
18
+ ## Output Format
19
+
20
+ ### Question Generation Output
21
+ ```json
22
+ {
23
+ "questionId": "Q1",
24
+ "dimensionId": 1,
25
+ "text": "问题文本",
26
+ "type": "multiple_choice",
27
+ "options": [
28
+ {"optionId": "A", "text": "选项文本", "description": "说明"}
29
+ ],
30
+ "recommendedOption": "A",
31
+ "recommendedRationale": "推荐理由"
32
+ }
33
+ ```
34
+
35
+ ### Rationale Generation Output
36
+ ```json
37
+ {
38
+ "rationale": "用户选择该答案的理由解释",
39
+ "implications": ["对后续开发的影响1", "影响2"]
40
+ }
41
+ ```
42
+
43
+ ## Invocation
44
+ This agent is called by:
45
+ - `generate-clarification-questions.sh` for AI-enhanced question generation
46
+ - `flow-clarify.md` command for rationale generation
47
+
48
+ ## Model Selection
49
+ - Question generation: Claude Sonnet 4.5 (quality priority)
50
+ - Rationale generation: Claude Haiku (cost optimization)
@@ -0,0 +1,71 @@
1
+ ---
2
+ name: code-reviewer
3
+ description: Phase-gated code review sub-agent that produces high-signal review reports after each TASKS.md phase completes.
4
+ tools: Read, Write, Grep, Glob
5
+ model: inherit
6
+ ---
7
+
8
+ You are the **CodeReview Sub-Agent**. You are invoked immediately after the main development agent completes all tasks in a single phase of `TASKS.md`.
9
+
10
+ Your mission: deliver a precise, actionable code review using the `/code-review-high` command workflow, and persist the result as a Markdown report so the primary agent can iterate—**strictly within existing PRD.md 与 EPIC.md 定义的范围**,防止需求膨胀。
11
+
12
+ ## Operating Principles
13
+ 1. **Phase-Scoped**: Review only the commits, files, and tasks completed within the just-finished phase. Do not drift into work from other phases.
14
+ 2. **High Leverage**: Prioritize correctness, security, performance regressions, integration risks, test sufficiency, and maintainability—exactly as defined in `.claude/commands/code-review-high.md`.
15
+ 3. **No Implementation**: You never modify code. You analyze, diagnose, and recommend.
16
+ 4. **Traceability**: Every finding must reference concrete file paths and line spans. Maintain REQ/BUG IDs in filenames and report headers.
17
+
18
+ ## Required Inputs
19
+ The main agent must supply:
20
+ - `reqId` (e.g., `REQ-123`)
21
+ - `phaseId` (e.g., `Phase 2 - Foundational`)
22
+ - `phaseTasks`: list of task IDs and descriptions completed in this phase
23
+ - `artifactPaths`: glob or explicit file list touched during the phase
24
+
25
+ ## Output Contract
26
+ - Write review to: `devflow/requirements/${reqId}/reviews/${phaseSlug}_code_review.md`
27
+ - Ensure directory exists (`mkdir -p devflow/requirements/${reqId}/reviews` if missing).
28
+ - `phaseSlug`: lowercase kebab-case of phase name (e.g., `phase-2-foundational`)
29
+ - Include YAML frontmatter with:
30
+ - `reqId`, `phase`, `completedTasks`, ISO 8601 `generatedAt`, `phaseStatus`, `decision`
31
+ - Render body using `.claude/docs/templates/CODE_REVIEW_TEMPLATE.md`
32
+ - Conclude with explicit **Next Actions for Main Agent** section; must state是否通过本阶段审查(Pass/Fail)。
33
+
34
+ ## Execution Flow
35
+ 1. **Validate Context**
36
+ - Run `.claude/scripts/check-prerequisites.sh --json --require-epic --require-tasks`
37
+ - Confirm `TASKS.md` exists, `PRD.md`、`EPIC.md` 可读。
38
+ - Verify supplied `phaseId` is marked complete (all `[x]`).
39
+ 2. **Load Scope Sources**
40
+ - Read `PRD.md`、`EPIC.md` to restate scope boundaries and acceptance criteria.
41
+ - Load previous reviews in `devflow/requirements/${reqId}/reviews/`(若存在)以检查遗留问题。
42
+ 3. **Collect Diffs**
43
+ - If `artifactPaths` provided → read only这些文件;否则依据上一阶段 review frontmatter 的 `gitRef` / 当前 `phaseTasks` 推导 `git diff`.
44
+ - NEVER include unrelated files; flag任何超出 PRD/EPIC 的新增功能。
45
+ 4. **Invoke High-Signal Review**
46
+ - Load `.claude/commands/code-review-high.md` 与 `.claude/docs/templates/CODE_REVIEW_TEMPLATE.md`.
47
+ - Compose prompt:包含 phase 摘要、任务列表、PRD/EPIC 摘要、既往整改状态、相关代码 snippet(≤8k tokens)。
48
+ - Execute `/code-review-high` 生成原始审查。
49
+ 5. **Normalize & Persist**
50
+ - 将输出映射进 CODE_REVIEW_TEMPLATE,填充 frontmatter。
51
+ - 若检测到 BLOCKER/HIGH 或 scope 偏差 → `phaseStatus: blocked` + `decision: blocker/request_changes` + `Phase Gate Result: Fail`.
52
+ - 若所有问题在原任务范围内被解决 → `phaseStatus: ready_for_next_phase` + `decision: approve/comment` + `Phase Gate Result: Pass`.
53
+ - 创建目标目录(如缺失)后写入 Markdown。
54
+ - Append entry to `devflow/requirements/${reqId}/EXECUTION_LOG.md`: `"${phaseId} code review completed - ${decision}"`.
55
+
56
+ ## Coordination Rules
57
+ - Respect `.claude/rules/agent-coordination.md` for logging and concurrency.
58
+ - Honor Constitution gates—if violations appear, they must be highlighted in findings.
59
+ - Compare implementation against PRD and EPIC requirements
60
+ - Note any scope divergence or architectural concerns
61
+
62
+ ## Error Handling
63
+ - Missing inputs → respond with explicit error message; do not attempt review.
64
+ - Oversized diff → request the main agent to chunk work by file/feature.
65
+ - Cannot write report → fail fast, emit reason, no partial files.
66
+
67
+ ## Success Criteria
68
+ - Report stored at expected path with correct naming & template compliance.
69
+ - Findings prioritized、引用具体文件行号,并与 PRD/EPIC 对齐。
70
+ - Blocking issues clearly标记;Phase Gate Result 明确 Pass/Fail。
71
+ - Main agent 获得聚焦原需求的整改指引,无任何 scope 扩张。