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,748 @@
1
+ # CC-DevFlow Project Constitution
2
+
3
+ > **Version**: v2.0.0
4
+ > **Effective Date**: 2025-01-10
5
+ > **Last Amended**: 2025-01-10
6
+ > **Status**: Active
7
+ > **Amendment Process**: See Section IX
8
+
9
+ ---
10
+
11
+ ## Preamble
12
+
13
+ This Constitution establishes the **immutable architectural DNA** of the CC-DevFlow project. It serves as the highest authority governing all development activities, ensuring quality, consistency, security, and maintainability across the entire lifecycle.
14
+
15
+ **Constitutional Authority**:
16
+ 1. **Supreme Priority**: Constitutional principles override all other rules and conventions
17
+ 2. **Inviolable**: No agent, process, or individual may violate constitutional principles
18
+ 3. **Persistent**: The Constitution remains effective throughout the project lifecycle
19
+ 4. **Universal**: Applies to all requirements, all stages, all agents
20
+
21
+ ---
22
+
23
+ ## Article I: Quality First (质量至上)
24
+
25
+ **Principle**: Quality is the non-negotiable baseline.
26
+
27
+ ### I.1 Complete Implementation Mandate
28
+
29
+ ```yaml
30
+ NO PARTIAL IMPLEMENTATION:
31
+ Prohibition: Any form of partial implementation or placeholder code
32
+ Requirement: Complete implementation or no implementation
33
+ Examples:
34
+ ❌ Forbidden: "// TODO: Implement this later"
35
+ ❌ Forbidden: "// Simplified for now, will complete in v2"
36
+ ✅ Required: Fully functional, production-ready code
37
+ ```
38
+
39
+ ### I.2 Testing Mandate
40
+
41
+ ```yaml
42
+ MANDATORY TEST COVERAGE:
43
+ Rule: Every function must have corresponding tests
44
+ Coverage Threshold: ≥80%
45
+ Test Types: Unit, Integration, Contract, E2E (as appropriate)
46
+ Verification: Tests must fail first (TDD), then pass
47
+ ```
48
+
49
+ ### I.3 No Simplification Clause
50
+
51
+ ```text
52
+ "This is simplified for now, complete implementation would..."
53
+ ↑ CONSTITUTIONAL VIOLATION - Immediate rejection
54
+ ```
55
+
56
+ ### I.4 Quality Gates
57
+
58
+ All code must pass:
59
+ - [ ] Type checking (TypeScript, Python type hints, etc.)
60
+ - [ ] Linting (ESLint, Pylint, etc.)
61
+ - [ ] Security scanning (no high-severity issues)
62
+ - [ ] Build verification
63
+ - [ ] Documentation completeness
64
+
65
+ **Enforcement**: Pre-push guard (`pre-push-guard.sh`)
66
+
67
+ ---
68
+
69
+ ## Article II: Architectural Consistency (架构一致性)
70
+
71
+ **Principle**: Maintain codebase uniformity and predictability.
72
+
73
+ ### II.1 No Code Duplication
74
+
75
+ ```yaml
76
+ REUSE MANDATE:
77
+ Before Writing New Code:
78
+ 1. Search existing codebase for similar functionality
79
+ 2. Use Read/Grep/Glob tools to find reusable functions
80
+ 3. Prefer function call over copy-paste
81
+
82
+ Violation Examples:
83
+ ❌ Copying validation logic across files
84
+ ❌ Duplicate database connection code
85
+ ❌ Repeated error handling patterns
86
+ ```
87
+
88
+ ### II.2 Consistent Naming
89
+
90
+ ```yaml
91
+ NAMING CONSISTENCY:
92
+ Requirement: Follow existing codebase naming patterns
93
+ Process:
94
+ 1. Read existing files before naming new entities
95
+ 2. Match verb-noun patterns (getUserById, createOrder)
96
+ 3. Match case conventions (camelCase, snake_case)
97
+
98
+ Tools: Use Grep to find naming patterns in codebase
99
+ ```
100
+
101
+ ### II.3 Anti-Over-Engineering
102
+
103
+ ```yaml
104
+ SIMPLICITY MANDATE:
105
+ Prohibited Patterns:
106
+ ❌ BaseController, AbstractService, GenericRepository
107
+ ❌ Factory patterns for simple object creation
108
+ ❌ Middleware layers with single responsibility
109
+ ❌ "Future-proofing" abstractions
110
+
111
+ Required Approach:
112
+ ✅ Direct framework usage (Express, FastAPI, Flask)
113
+ ✅ Solve current problem with simplest solution
114
+ ✅ Refactor when actual need emerges
115
+ ```
116
+
117
+ ### II.4 Single Responsibility
118
+
119
+ ```yaml
120
+ MODULE COHESION:
121
+ Rule: Each module/class/function has ONE reason to change
122
+ File Size Limit: ≤500 lines per file
123
+ Function Length Limit: ≤50 lines per function
124
+
125
+ Violation Indicators:
126
+ - File has multiple unrelated imports
127
+ - Function has multiple if-else branches for different concerns
128
+ - Class name contains "And" or "Manager" or "Helper"
129
+ ```
130
+
131
+ **Enforcement**: Phase -1 Anti-Abstraction Gate (EPIC_TEMPLATE.md)
132
+
133
+ ---
134
+
135
+ ## Article III: Security First (安全优先)
136
+
137
+ **Principle**: Security is foundational, not an afterthought.
138
+
139
+ ### III.1 No Hardcoded Secrets
140
+
141
+ ```yaml
142
+ SECRET MANAGEMENT:
143
+ Prohibited:
144
+ ❌ API_KEY = "sk-abc123..." in source code
145
+ ❌ PASSWORD = "admin123" in config files
146
+ ❌ JWT_SECRET embedded in code
147
+
148
+ Required:
149
+ ✅ Environment variables (.env files, not committed)
150
+ ✅ Secret management services (AWS Secrets Manager, etc.)
151
+ ✅ Configuration injection at runtime
152
+
153
+ Detection: Pre-push guard scans for secret patterns
154
+ ```
155
+
156
+ ### III.2 Input Validation
157
+
158
+ ```yaml
159
+ VALIDATION MANDATE:
160
+ Rule: All external inputs must be validated BEFORE processing
161
+ Scope:
162
+ - User inputs (forms, API requests)
163
+ - File uploads
164
+ - Database query results (防止 SQL injection)
165
+ - Environment variables
166
+
167
+ Validation Types:
168
+ - Type checking
169
+ - Range validation
170
+ - Format validation (regex)
171
+ - Sanitization (XSS prevention)
172
+ ```
173
+
174
+ ### III.3 Principle of Least Privilege
175
+
176
+ ```yaml
177
+ PERMISSION CONTROL:
178
+ Default: Deny all, explicitly allow needed permissions
179
+ File Permissions: Minimal necessary (no 777)
180
+ Database Access: Read-only when possible
181
+ API Scopes: Request minimum required scopes
182
+ ```
183
+
184
+ ### III.4 Secure by Default
185
+
186
+ ```yaml
187
+ DEFAULT SECURITY:
188
+ Examples:
189
+ ✅ HTTPS by default, not HTTP
190
+ ✅ CORS with explicit origin whitelist
191
+ ✅ Authentication required unless explicitly public
192
+ ✅ Rate limiting enabled by default
193
+ ```
194
+
195
+ **Enforcement**: Security-reviewer agent + pre-push security scan
196
+
197
+ ---
198
+
199
+ ## Article IV: Performance Accountability (性能责任)
200
+
201
+ **Principle**: Performance is user experience; proactive optimization required.
202
+
203
+ ### IV.1 No Resource Leaks
204
+
205
+ ```yaml
206
+ RESOURCE MANAGEMENT:
207
+ Mandatory Cleanup:
208
+ - Database connections (use connection pooling)
209
+ - File handles (use with/try-finally)
210
+ - Event listeners (removeEventListener)
211
+ - Timers (clearTimeout, clearInterval)
212
+ - HTTP connections (connection.close())
213
+
214
+ Pattern:
215
+ try:
216
+ resource = acquire_resource()
217
+ use_resource(resource)
218
+ finally:
219
+ resource.close() # MUST execute
220
+ ```
221
+
222
+ ### IV.2 Algorithm Efficiency
223
+
224
+ ```yaml
225
+ COMPLEXITY AWARENESS:
226
+ Before Implementation:
227
+ - Choose appropriate data structure (Array vs Set vs Map)
228
+ - Avoid O(n²) when O(n) exists
229
+ - Use binary search for sorted data
230
+
231
+ Review Triggers:
232
+ - Nested loops over same dataset
233
+ - Repeated database queries in loops
234
+ - Full table scans
235
+ ```
236
+
237
+ ### IV.3 Lazy Loading
238
+
239
+ ```yaml
240
+ ON-DEMAND LOADING:
241
+ Apply To:
242
+ - Large datasets (pagination)
243
+ - Heavy dependencies (dynamic import)
244
+ - Images/media (lazy loading)
245
+ - Database records (streaming)
246
+
247
+ Example:
248
+ ❌ loadAllUsers() # Loads 1M users into memory
249
+ ✅ getUsersPaginated(page, limit) # Loads 50 at a time
250
+ ```
251
+
252
+ ### IV.4 Caching Strategy
253
+
254
+ ```yaml
255
+ INTELLIGENT CACHING:
256
+ When to Cache:
257
+ ✅ Expensive computations with stable inputs
258
+ ✅ External API responses with TTL
259
+ ✅ Database query results (with invalidation)
260
+
261
+ When NOT to Cache:
262
+ ❌ User-specific sensitive data
263
+ ❌ Real-time data requirements
264
+ ❌ Infrequently accessed data
265
+ ```
266
+
267
+ **Enforcement**: Performance profiling in QA stage
268
+
269
+ ---
270
+
271
+ ## Article V: Maintainability (可维护性)
272
+
273
+ **Principle**: Code must be understandable, modifiable, and extensible.
274
+
275
+ ### V.1 No Dead Code
276
+
277
+ ```yaml
278
+ CODE HYGIENE:
279
+ Rule: Use it or delete it, no middle ground
280
+
281
+ Dead Code Patterns:
282
+ ❌ Commented-out code blocks
283
+ ❌ Unused imports
284
+ ❌ Unreachable branches (if false:)
285
+ ❌ Functions with no callers
286
+
287
+ Tools: Use IDE "Find Usages" before writing new code
288
+ ```
289
+
290
+ ### V.2 Separation of Concerns
291
+
292
+ ```yaml
293
+ CLEAR BOUNDARIES:
294
+ Prohibited Mixing:
295
+ ❌ Validation logic inside API handlers
296
+ ❌ Database queries inside UI components
297
+ ❌ Business logic in presentation layer
298
+
299
+ Required Separation:
300
+ ✅ Models (data structure)
301
+ ✅ Services (business logic)
302
+ ✅ Controllers (request handling)
303
+ ✅ Views (presentation)
304
+ ```
305
+
306
+ ### V.3 Documentation
307
+
308
+ ```yaml
309
+ DOCUMENTATION MANDATE:
310
+ Required Documentation:
311
+ - Complex algorithms (why this approach)
312
+ - Business logic (domain rules)
313
+ - Public APIs (parameters, return types, examples)
314
+ - Configuration options
315
+
316
+ Format:
317
+ - Inline comments for WHY, not WHAT
318
+ - Docstrings for public functions
319
+ - README for modules
320
+ ```
321
+
322
+ ### V.4 File Size Limits
323
+
324
+ ```yaml
325
+ SIZE CONSTRAINTS:
326
+ Single File: ≤500 lines (including comments)
327
+ Single Function: ≤50 lines
328
+
329
+ Violation Response:
330
+ - Extract functions/classes to separate files
331
+ - Split by responsibility
332
+ - Use modules for grouping
333
+ ```
334
+
335
+ **Enforcement**: Linting rules + code review
336
+
337
+ ---
338
+
339
+ ## Article VI: Test-First Development (测试优先开发)
340
+
341
+ **Principle**: Tests define behavior; implementation makes tests pass.
342
+
343
+ ### VI.1 TDD Mandate (NON-NEGOTIABLE)
344
+
345
+ ```yaml
346
+ STRICT TDD SEQUENCE:
347
+ Phase 2: Write Tests FIRST ⚠️
348
+ - Contract tests
349
+ - Integration tests
350
+ - E2E tests
351
+ - Unit tests
352
+
353
+ TEST VERIFICATION CHECKPOINT:
354
+ → All tests MUST fail initially
355
+ → If test passes immediately → ERROR (invalid test)
356
+
357
+ Phase 3: Write Implementation
358
+ → Goal: Make tests pass
359
+ → Refactor while keeping tests green
360
+ ```
361
+
362
+ ### VI.2 Test Independence
363
+
364
+ ```yaml
365
+ INDEPENDENT TESTS:
366
+ Rule: Each test must run in isolation
367
+
368
+ Prohibited:
369
+ ❌ Tests depending on execution order
370
+ ❌ Shared mutable state between tests
371
+ ❌ Tests modifying global variables
372
+
373
+ Required:
374
+ ✅ Setup before each test
375
+ ✅ Teardown after each test
376
+ ✅ Mock external dependencies
377
+ ```
378
+
379
+ ### VI.3 Meaningful Tests
380
+
381
+ ```yaml
382
+ TEST QUALITY:
383
+ Prohibited "Cheater Tests":
384
+ ❌ assert True # Always passes
385
+ ❌ assert result is not None # Too weak
386
+ ❌ Mock everything, test nothing
387
+
388
+ Required:
389
+ ✅ Test actual behavior, not implementation
390
+ ✅ Use realistic test data
391
+ ✅ Verify error cases, not just happy path
392
+ ```
393
+
394
+ **Enforcement**: TEST VERIFICATION CHECKPOINT in TASKS.md
395
+
396
+ ---
397
+
398
+ ## Article VII: Simplicity Gate (简单性闸门)
399
+
400
+ **Principle**: Default to simplicity; complexity requires justification.
401
+
402
+ ### VII.1 Project Count Limit
403
+
404
+ ```yaml
405
+ MAXIMUM 3 PROJECTS/MODULES:
406
+ Rule: Use ≤3 distinct projects/services
407
+
408
+ If >3 needed:
409
+ → Must fill Complexity Tracking table in EPIC.md
410
+ → Justify why simpler alternative insufficient
411
+ → Document mitigation strategy
412
+ ```
413
+
414
+ ### VII.2 No Future-Proofing
415
+
416
+ ```yaml
417
+ YAGNI ENFORCEMENT:
418
+ Prohibited:
419
+ ❌ "Reserved interfaces" for future features
420
+ ❌ "Extension points" with no current use
421
+ ❌ "Generic framework" when specific solution exists
422
+ ❌ "Will need this later" abstractions
423
+
424
+ Required:
425
+ ✅ Implement ONLY what current requirement needs
426
+ ✅ Refactor when new requirement emerges
427
+ ```
428
+
429
+ **Enforcement**: Phase -1 Simplicity Gate in EPIC_TEMPLATE.md
430
+
431
+ ---
432
+
433
+ ## Article VIII: Anti-Abstraction (反抽象)
434
+
435
+ **Principle**: Trust frameworks; avoid unnecessary wrapping.
436
+
437
+ ### VIII.1 Direct Framework Usage
438
+
439
+ ```yaml
440
+ FRAMEWORK TRUST:
441
+ Prohibited Wrappers:
442
+ ❌ BaseController extending Express/FastAPI
443
+ ❌ DatabaseService wrapping ORM
444
+ ❌ CacheManager wrapping Redis client
445
+
446
+ Required:
447
+ ✅ Use Express/FastAPI/Flask directly
448
+ ✅ Use ORM (Prisma/SQLAlchemy) directly
449
+ ✅ Use libraries as intended
450
+ ```
451
+
452
+ ### VIII.2 Single Model Representation
453
+
454
+ ```yaml
455
+ ONE ENTITY, ONE REPRESENTATION:
456
+ Prohibited:
457
+ ❌ UserDTO → User Entity → UserViewModel
458
+ ❌ Multiple mappings between layers
459
+
460
+ Required:
461
+ ✅ One User model used across layers
462
+ ✅ Add fields as needed, don't transform
463
+ ```
464
+
465
+ **Enforcement**: Phase -1 Anti-Abstraction Gate in EPIC_TEMPLATE.md
466
+
467
+ ---
468
+
469
+ ## Article IX: Integration-First Testing (集成优先测试)
470
+
471
+ **Principle**: Test with real environments, not mocks.
472
+
473
+ ### IX.1 Contract-First
474
+
475
+ ```yaml
476
+ CONTRACT DEFINITION:
477
+ Sequence:
478
+ 1. Define API contracts BEFORE implementation
479
+ 2. Write contract tests in Phase 2
480
+ 3. Implement to satisfy contracts in Phase 3
481
+
482
+ Tools:
483
+ - OpenAPI specifications
484
+ - GraphQL schemas
485
+ - gRPC proto files
486
+ ```
487
+
488
+ ### IX.2 Real Environment Testing
489
+
490
+ ```yaml
491
+ INTEGRATION TESTING:
492
+ Preferred:
493
+ ✅ Real database (use Docker for local)
494
+ ✅ Real message queue
495
+ ✅ Real cache (Redis)
496
+
497
+ Avoid:
498
+ ❌ Mocking database layer
499
+ ❌ In-memory substitutes (unless testing speed critical)
500
+ ```
501
+
502
+ **Enforcement**: Phase -1 Integration-First Gate in EPIC_TEMPLATE.md
503
+
504
+ ---
505
+
506
+ ## Article X: Requirement Boundary (需求边界)
507
+
508
+ **Principle**: Implement what's requested, nothing more.
509
+
510
+ ### X.1 Forced Clarification
511
+
512
+ ```yaml
513
+ [NEEDS CLARIFICATION] MANDATE:
514
+ Rule: Mark ALL ambiguities explicitly
515
+
516
+ Prohibited:
517
+ ❌ Guessing user intent
518
+ ❌ Adding "helpful" features not requested
519
+ ❌ Assuming technical details
520
+
521
+ Required:
522
+ ✅ Use [NEEDS CLARIFICATION: specific question]
523
+ ✅ Wait for user clarification
524
+ ✅ Document assumptions made
525
+ ```
526
+
527
+ ### X.2 No Speculative Features
528
+
529
+ ```yaml
530
+ ANTI-EXPANSION:
531
+ Prohibited Phrases:
532
+ ❌ "May need in the future..."
533
+ ❌ "Should also add..."
534
+ ❌ "Might want to consider..."
535
+
536
+ Required:
537
+ ✅ Only implement explicitly requested features
538
+ ✅ Focus on current user stories
539
+ ```
540
+
541
+ ### X.3 User Story Independence
542
+
543
+ ```yaml
544
+ STORY ISOLATION:
545
+ Each User Story Must Have:
546
+ - Explicit priority (P1, P2, P3...)
547
+ - Independent Test criteria
548
+ - Standalone deliverability (can ship as MVP)
549
+
550
+ Organization:
551
+ - Tasks organized by user story [US1], [US2], [US3]
552
+ - Each story testable independently
553
+ ```
554
+
555
+ **Enforcement**:
556
+ - PRD anti-expansion validation checklist (prd-writer agent)
557
+ - validate-scope-boundary.sh script
558
+
559
+ ---
560
+
561
+ ## Immutable Constraints
562
+
563
+ ### Workflow Constraints
564
+
565
+ 1. **Standard Flow Mandate**: All development through `/flow-init` → `/flow-prd` → `/flow-epic` → `/flow-dev` → `/flow-qa` → `/flow-release`
566
+ 2. **No Gate Skipping**: Quality gates (Entry/Exit) cannot be bypassed
567
+ 3. **Document-Driven**: Important decisions must be documented
568
+ 4. **Version Control**: All changes through Git
569
+
570
+ ### Agent Behavior Constraints
571
+
572
+ 1. **Main Agent Authority**: Only main agent (Claude) may execute code modifications
573
+ 2. **Research Agent Role**: Research agents (prd-writer, planner, etc.) only analyze and output documents
574
+ 3. **Coordination**: Agents must coordinate via `orchestration_status.json`
575
+ 4. **Error Handling**: Agents must stop and report errors, not ignore
576
+
577
+ ### Technology Choice Constraints
578
+
579
+ 1. **Existing Stack First**: Prefer project's existing technologies
580
+ 2. **Backward Compatibility**: New features must not break existing functionality
581
+ 3. **Dependency Evaluation**: New dependencies require justification
582
+ 4. **Standards Compliance**: Follow industry best practices
583
+
584
+ ---
585
+
586
+ ## Constitutional Violations
587
+
588
+ ### Severity Levels
589
+
590
+ #### Minor Violations
591
+ - **Examples**: Inconsistent code style, missing documentation
592
+ - **Consequence**: Immediate correction required, re-review
593
+
594
+ #### Moderate Violations
595
+ - **Examples**: Partial implementation, missing tests, security risks
596
+ - **Consequence**: Block commit, mandatory fix
597
+
598
+ #### Severe Violations
599
+ - **Examples**: Hardcoded secrets, resource leaks, architectural destruction
600
+ - **Consequence**: Immediate rollback, comprehensive audit
601
+
602
+ ---
603
+
604
+ ## Amendment Process
605
+
606
+ ### Amendment Principles
607
+
608
+ 1. **Cautious Amendment**: Constitutional changes require careful justification
609
+ 2. **Backward Compatible**: Amendments must not break existing commitments
610
+ 3. **Community Consensus**: Major amendments need broad discussion
611
+ 4. **Version Tracking**: All amendments tracked with semantic versioning
612
+
613
+ ### Amendment Procedure
614
+
615
+ ```yaml
616
+ Amendment Workflow:
617
+ 1. Proposal:
618
+ - Submit amendment proposal with rationale
619
+ - Document affected Articles and implications
620
+ - Provide migration strategy
621
+
622
+ 2. Review:
623
+ - Community discussion (minimum 7 days)
624
+ - Impact analysis (compatibility-checker agent)
625
+ - Test amendment in isolated environment
626
+
627
+ 3. Approval:
628
+ - Requires consensus or majority vote
629
+ - Update Constitution version (MAJOR.MINOR.PATCH)
630
+ - Generate Sync Impact Report
631
+
632
+ 4. Propagation:
633
+ - Update all templates referencing amended Articles
634
+ - Update agent instructions
635
+ - Update validation scripts
636
+ - Notify all stakeholders
637
+ ```
638
+
639
+ ### Versioning Scheme
640
+
641
+ ```yaml
642
+ Version Format: MAJOR.MINOR.PATCH
643
+
644
+ MAJOR (e.g., 1.0.0 → 2.0.0):
645
+ - Fundamental principle changes
646
+ - Breaking changes to existing rules
647
+ - Requires full codebase audit
648
+
649
+ MINOR (e.g., 2.0.0 → 2.1.0):
650
+ - New Article additions
651
+ - Non-breaking clarifications
652
+ - Enhanced enforcement mechanisms
653
+
654
+ PATCH (e.g., 2.1.0 → 2.1.1):
655
+ - Typo corrections
656
+ - Example updates
657
+ - Documentation improvements
658
+ ```
659
+
660
+ ---
661
+
662
+ ## Constitutional Enforcement
663
+
664
+ ### Four-Layer Defense System
665
+
666
+ ```text
667
+ Layer 1: Template Hard Constraints
668
+
669
+ - PRD_TEMPLATE.md: ANTI-EXPANSION RULES (Article X)
670
+ - EPIC_TEMPLATE.md: Phase -1 Gates (Articles VII, VIII, IX)
671
+ - TASKS_TEMPLATE.md: TDD enforcement (Article VI)
672
+
673
+ Layer 2: Command-Level Enforcement
674
+
675
+ - /flow-constitution: Update and propagate Constitution
676
+ - /flow-verify: Consistency checking across documents
677
+
678
+ Layer 3: Agent-Level Constraints
679
+
680
+ - prd-writer: Anti-Expansion Validation Checklist
681
+ - planner: Phase -1 Gate Enforcement
682
+ - dev-implementer: TDD Sequence Validation
683
+ - qa-tester: Test Quality Standards
684
+ - security-reviewer: Security Mandate Compliance
685
+
686
+ Layer 4: Validation Scripts
687
+
688
+ - validate-scope-boundary.sh: Boundary compliance
689
+ - validate-constitution.sh: Constitutional compliance
690
+ - pre-push-guard.sh: Pre-commit quality gates
691
+ ```
692
+
693
+ ### Compliance Checklist
694
+
695
+ **Before Code Commit**:
696
+ - [ ] Article I: Complete implementation, no placeholders (Quality First)
697
+ - [ ] Article I: Tests written and passing, coverage ≥80%
698
+ - [ ] Article II: No code duplication, existing code reused (Architectural Consistency)
699
+ - [ ] Article II: Naming follows existing patterns
700
+ - [ ] Article III: No hardcoded secrets (Security First)
701
+ - [ ] Article IV: Resources properly managed, no leaks (Performance Accountability)
702
+ - [ ] Article V: No dead code, clean codebase (Maintainability)
703
+ - [ ] Article VI: TDD sequence followed (Test-First Development)
704
+
705
+ **Before Flow Execution**:
706
+ - [ ] Article VII: ≤3 projects/modules (Simplicity Gate)
707
+ - [ ] Article VIII: No unnecessary abstractions (Anti-Abstraction)
708
+ - [ ] Article IX: Contracts defined first, real environments (Integration-First)
709
+ - [ ] Article X: No speculative features, all ambiguities marked (Requirement Boundary)
710
+
711
+ **Tools**:
712
+ ```bash
713
+ # Automated Constitutional Compliance Check
714
+ bash .claude/scripts/validate-constitution.sh
715
+
716
+ # Scope Boundary Compliance Check
717
+ bash .claude/scripts/validate-scope-boundary.sh
718
+
719
+ # Pre-push Quality Gates
720
+ bash .claude/hooks/pre-push-guard.sh
721
+ ```
722
+
723
+ ---
724
+
725
+ ## Single Source of Truth
726
+
727
+ This Constitution is the **architectural DNA** of CC-DevFlow. All templates, agent instructions, validation scripts, and documentation derive their authority from this document.
728
+
729
+ **Consistency Propagation**: When this Constitution is amended, changes MUST automatically propagate to:
730
+ - `.claude/docs/templates/*.md` (PRD, EPIC, TASKS templates)
731
+ - `.claude/agents/*.md` (All agent instruction files)
732
+ - `.claude/scripts/validate-*.sh` (Validation scripts)
733
+ - `.claude/hooks/*.sh` (Git hooks)
734
+ - `CLAUDE.md` (Project documentation)
735
+
736
+ **Amendment Impact Report**: Use `/flow-constitution --amend` command to generate automatic sync report.
737
+
738
+ ---
739
+
740
+ **Declaration**: This Constitution represents the unwavering commitment of CC-DevFlow to excellence, consistency, and sustainable development. All participants bear the responsibility to uphold and defend these principles.
741
+
742
+ ---
743
+
744
+ *CC-DevFlow Project Constitution - Ensuring Excellence, Rejecting Compromise*
745
+
746
+ **Version History**:
747
+ - v2.0.0 (2025-10-09): Article-based restructure, enforcement mechanisms, amendment process
748
+ - v1.0.0 (2025-01-20): Initial version with five core principles