@curdx/flow 1.1.3 → 1.1.5

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 (100) hide show
  1. package/.claude-plugin/marketplace.json +25 -0
  2. package/.claude-plugin/plugin.json +43 -0
  3. package/CHANGELOG.md +279 -0
  4. package/agent-preamble/preamble.md +214 -0
  5. package/agents/flow-adversary.md +216 -0
  6. package/agents/flow-architect.md +190 -0
  7. package/agents/flow-debugger.md +325 -0
  8. package/agents/flow-edge-hunter.md +273 -0
  9. package/agents/flow-executor.md +246 -0
  10. package/agents/flow-planner.md +204 -0
  11. package/agents/flow-product-designer.md +146 -0
  12. package/agents/flow-qa-engineer.md +276 -0
  13. package/agents/flow-researcher.md +155 -0
  14. package/agents/flow-reviewer.md +280 -0
  15. package/agents/flow-security-auditor.md +398 -0
  16. package/agents/flow-triage-analyst.md +290 -0
  17. package/agents/flow-ui-researcher.md +227 -0
  18. package/agents/flow-ux-designer.md +247 -0
  19. package/agents/flow-verifier.md +283 -0
  20. package/agents/persona-amelia.md +128 -0
  21. package/agents/persona-david.md +141 -0
  22. package/agents/persona-emma.md +179 -0
  23. package/agents/persona-john.md +105 -0
  24. package/agents/persona-mary.md +95 -0
  25. package/agents/persona-oliver.md +136 -0
  26. package/agents/persona-rachel.md +126 -0
  27. package/agents/persona-serena.md +175 -0
  28. package/agents/persona-winston.md +117 -0
  29. package/bin/curdx-flow.js +5 -2
  30. package/cli/init.js +18 -2
  31. package/cli/install.js +44 -5
  32. package/commands/audit.md +170 -0
  33. package/commands/autoplan.md +184 -0
  34. package/commands/debug.md +199 -0
  35. package/commands/design.md +155 -0
  36. package/commands/discuss.md +162 -0
  37. package/commands/doctor.md +124 -0
  38. package/commands/fast.md +128 -0
  39. package/commands/help.md +119 -0
  40. package/commands/implement.md +381 -0
  41. package/commands/index.md +261 -0
  42. package/commands/init.md +105 -0
  43. package/commands/install-deps.md +128 -0
  44. package/commands/party.md +241 -0
  45. package/commands/plan-ceo.md +117 -0
  46. package/commands/plan-design.md +107 -0
  47. package/commands/plan-dx.md +104 -0
  48. package/commands/plan-eng.md +108 -0
  49. package/commands/qa.md +118 -0
  50. package/commands/requirements.md +146 -0
  51. package/commands/research.md +141 -0
  52. package/commands/review.md +168 -0
  53. package/commands/security.md +109 -0
  54. package/commands/sketch.md +118 -0
  55. package/commands/spec.md +135 -0
  56. package/commands/spike.md +181 -0
  57. package/commands/start.md +189 -0
  58. package/commands/status.md +139 -0
  59. package/commands/switch.md +95 -0
  60. package/commands/tasks.md +189 -0
  61. package/commands/triage.md +160 -0
  62. package/commands/verify.md +124 -0
  63. package/gates/adversarial-review-gate.md +219 -0
  64. package/gates/coverage-audit-gate.md +184 -0
  65. package/gates/devex-gate.md +255 -0
  66. package/gates/edge-case-gate.md +194 -0
  67. package/gates/karpathy-gate.md +130 -0
  68. package/gates/security-gate.md +218 -0
  69. package/gates/tdd-gate.md +188 -0
  70. package/gates/verification-gate.md +183 -0
  71. package/hooks/hooks.json +56 -0
  72. package/hooks/scripts/fail-tracker.sh +31 -0
  73. package/hooks/scripts/inject-karpathy.sh +52 -0
  74. package/hooks/scripts/quick-mode-guard.sh +64 -0
  75. package/hooks/scripts/session-start.sh +76 -0
  76. package/hooks/scripts/stop-watcher.sh +166 -0
  77. package/knowledge/atomic-commits.md +262 -0
  78. package/knowledge/epic-decomposition.md +307 -0
  79. package/knowledge/execution-strategies.md +278 -0
  80. package/knowledge/karpathy-guidelines.md +219 -0
  81. package/knowledge/planning-reviews.md +211 -0
  82. package/knowledge/poc-first-workflow.md +227 -0
  83. package/knowledge/spec-driven-development.md +183 -0
  84. package/knowledge/systematic-debugging.md +384 -0
  85. package/knowledge/two-stage-review.md +233 -0
  86. package/knowledge/wave-execution.md +387 -0
  87. package/package.json +13 -2
  88. package/schemas/config.schema.json +100 -0
  89. package/schemas/spec-frontmatter.schema.json +42 -0
  90. package/schemas/spec-state.schema.json +117 -0
  91. package/templates/CONTEXT.md.tmpl +53 -0
  92. package/templates/PROJECT.md.tmpl +59 -0
  93. package/templates/ROADMAP.md.tmpl +50 -0
  94. package/templates/STATE.md.tmpl +49 -0
  95. package/templates/config.json.tmpl +48 -0
  96. package/templates/design.md.tmpl +163 -0
  97. package/templates/progress.md.tmpl +58 -0
  98. package/templates/requirements.md.tmpl +94 -0
  99. package/templates/research.md.tmpl +114 -0
  100. package/templates/tasks.md.tmpl +141 -0
@@ -0,0 +1,100 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "https://curdx-flow.dev/schemas/config.schema.json",
4
+ "title": "CurDX-Flow Project Config",
5
+ "description": "Schema for .flow/config.json",
6
+ "type": "object",
7
+ "required": ["version", "mode"],
8
+ "properties": {
9
+ "$schema": { "type": "string" },
10
+ "version": {
11
+ "type": "string",
12
+ "const": "1.0"
13
+ },
14
+ "mode": {
15
+ "type": "string",
16
+ "enum": ["sketch", "fast", "standard", "enterprise", "autonomous"],
17
+ "description": "Default workflow depth for this project"
18
+ },
19
+ "execution": {
20
+ "type": "object",
21
+ "properties": {
22
+ "strategy": {
23
+ "type": "string",
24
+ "enum": ["auto", "subagent", "stop-hook", "wave", "linear"],
25
+ "default": "auto"
26
+ },
27
+ "max_parallel": {
28
+ "type": "integer",
29
+ "minimum": 1,
30
+ "maximum": 20,
31
+ "default": 5
32
+ },
33
+ "subagent_threshold": {
34
+ "type": "integer",
35
+ "minimum": 1,
36
+ "default": 8,
37
+ "description": "Task count above which subagent strategy is preferred"
38
+ }
39
+ }
40
+ },
41
+ "gates": {
42
+ "type": "object",
43
+ "description": "Which quality gates to enable. Gate definitions live in gates/*.md (Phase 3)",
44
+ "properties": {
45
+ "always_on": {
46
+ "type": "array",
47
+ "items": { "type": "string" },
48
+ "default": ["karpathy-gate", "verification-gate"]
49
+ },
50
+ "standard_mode": {
51
+ "type": "array",
52
+ "items": { "type": "string" }
53
+ },
54
+ "enterprise_mode": {
55
+ "type": "array",
56
+ "items": { "type": "string" }
57
+ }
58
+ }
59
+ },
60
+ "specs": {
61
+ "type": "object",
62
+ "properties": {
63
+ "directories": {
64
+ "type": "array",
65
+ "items": { "type": "string" },
66
+ "default": ["./.flow/specs"],
67
+ "description": "Monorepo-friendly: multiple spec directories supported"
68
+ },
69
+ "default_task_size": {
70
+ "type": "string",
71
+ "enum": ["fine", "coarse"],
72
+ "default": "fine"
73
+ }
74
+ }
75
+ },
76
+ "addons": {
77
+ "type": "object",
78
+ "properties": {
79
+ "pua": {
80
+ "type": "object",
81
+ "properties": {
82
+ "enabled": { "type": "boolean", "default": false },
83
+ "style": {
84
+ "type": "string",
85
+ "enum": ["alibaba", "bytedance", "huawei", "tencent", "baidu", "pdd", "meituan", "jd", "xiaomi", "netflix", "musk", "jobs", "amazon"]
86
+ },
87
+ "auto_trigger": {
88
+ "type": "string",
89
+ "enum": ["on-failure", "always", "manual"]
90
+ }
91
+ }
92
+ }
93
+ }
94
+ },
95
+ "created": {
96
+ "type": "string",
97
+ "format": "date"
98
+ }
99
+ }
100
+ }
@@ -0,0 +1,42 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "https://curdx-flow.dev/schemas/spec-frontmatter.schema.json",
4
+ "title": "CurDX-Flow Spec Document Frontmatter",
5
+ "description": "YAML frontmatter at the top of research.md / requirements.md / design.md / tasks.md",
6
+ "type": "object",
7
+ "required": ["spec", "phase", "created", "version"],
8
+ "properties": {
9
+ "spec": {
10
+ "type": "string",
11
+ "pattern": "^[a-z0-9][a-z0-9-]*$"
12
+ },
13
+ "phase": {
14
+ "type": "string",
15
+ "enum": ["research", "requirements", "design", "tasks"]
16
+ },
17
+ "created": {
18
+ "type": "string",
19
+ "format": "date"
20
+ },
21
+ "version": {
22
+ "type": "string",
23
+ "pattern": "^[0-9]+\\.[0-9]+$"
24
+ },
25
+ "status": {
26
+ "type": "string",
27
+ "enum": ["in_progress", "approved", "frozen", "superseded"]
28
+ },
29
+ "depends_on": {
30
+ "oneOf": [
31
+ { "type": "string" },
32
+ { "type": "array", "items": { "type": "string" } }
33
+ ],
34
+ "description": "Other spec files this one depends on (e.g. design.md depends on requirements.md)"
35
+ },
36
+ "task_size": {
37
+ "type": "string",
38
+ "enum": ["fine", "coarse"],
39
+ "description": "Only in tasks.md"
40
+ }
41
+ }
42
+ }
@@ -0,0 +1,117 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "https://curdx-flow.dev/schemas/spec-state.schema.json",
4
+ "title": "CurDX-Flow Spec State",
5
+ "description": "Schema for .flow/specs/<name>/.state.json — tracks phase progress across sessions",
6
+ "type": "object",
7
+ "required": ["version", "spec_name", "phase"],
8
+ "properties": {
9
+ "version": {
10
+ "type": "string",
11
+ "const": "1.0"
12
+ },
13
+ "spec_name": {
14
+ "type": "string",
15
+ "pattern": "^[a-z0-9][a-z0-9-]*$",
16
+ "description": "Kebab-case identifier matching the directory name"
17
+ },
18
+ "goal": {
19
+ "type": "string",
20
+ "description": "One-sentence goal from /flow-start"
21
+ },
22
+ "mode": {
23
+ "type": "string",
24
+ "enum": ["sketch", "fast", "standard", "enterprise", "autonomous"],
25
+ "default": "standard"
26
+ },
27
+ "strategy": {
28
+ "type": "string",
29
+ "enum": ["auto", "subagent", "stop-hook", "wave", "linear"],
30
+ "default": "auto"
31
+ },
32
+ "phase": {
33
+ "type": "string",
34
+ "enum": [
35
+ "research",
36
+ "requirements",
37
+ "design",
38
+ "tasks",
39
+ "execute",
40
+ "verify",
41
+ "review",
42
+ "ship",
43
+ "completed"
44
+ ]
45
+ },
46
+ "phase_status": {
47
+ "type": "object",
48
+ "properties": {
49
+ "research": { "$ref": "#/definitions/phaseStatus" },
50
+ "requirements": { "$ref": "#/definitions/phaseStatus" },
51
+ "design": { "$ref": "#/definitions/phaseStatus" },
52
+ "tasks": { "$ref": "#/definitions/phaseStatus" },
53
+ "execute": { "$ref": "#/definitions/phaseStatus" },
54
+ "verify": { "$ref": "#/definitions/phaseStatus" },
55
+ "review": { "$ref": "#/definitions/phaseStatus" },
56
+ "ship": { "$ref": "#/definitions/phaseStatus" }
57
+ }
58
+ },
59
+ "execute_state": {
60
+ "type": "object",
61
+ "description": "Runtime state for Phase 2 (execution engine, post-Phase 1)",
62
+ "properties": {
63
+ "poc_complete": { "type": "boolean" },
64
+ "refactor_complete": { "type": "boolean" },
65
+ "test_complete": { "type": "boolean" },
66
+ "quality_gate_complete": { "type": "boolean" },
67
+ "task_index": { "type": "integer", "minimum": 0 },
68
+ "total_tasks": { "type": "integer", "minimum": 0 },
69
+ "task_iteration": { "type": "integer", "minimum": 1 },
70
+ "global_iteration": { "type": "integer", "minimum": 1 },
71
+ "failed_attempts": { "type": "integer", "minimum": 0 }
72
+ }
73
+ },
74
+ "decisions": {
75
+ "type": "array",
76
+ "description": "Decisions locked in this spec (mirror of what's in STATE.md)",
77
+ "items": {
78
+ "type": "object",
79
+ "required": ["id", "decision"],
80
+ "properties": {
81
+ "id": {
82
+ "type": "string",
83
+ "pattern": "^D-[0-9]{2,}$"
84
+ },
85
+ "decision": { "type": "string" },
86
+ "rationale": { "type": "string" },
87
+ "timestamp": {
88
+ "type": "string",
89
+ "format": "date-time"
90
+ }
91
+ }
92
+ }
93
+ },
94
+ "gates_enabled": {
95
+ "type": "array",
96
+ "items": { "type": "string" }
97
+ },
98
+ "agents_active": {
99
+ "type": "array",
100
+ "items": { "type": "string" }
101
+ },
102
+ "created": {
103
+ "type": "string",
104
+ "format": "date"
105
+ },
106
+ "updated": {
107
+ "type": "string",
108
+ "format": "date-time"
109
+ }
110
+ },
111
+ "definitions": {
112
+ "phaseStatus": {
113
+ "type": "string",
114
+ "enum": ["not_started", "in_progress", "completed", "skipped", "failed"]
115
+ }
116
+ }
117
+ }
@@ -0,0 +1,53 @@
1
+ # {{PROJECT_NAME}} — User Preferences and Decisions
2
+
3
+ > CurDX-Flow Context — your coding, design, and interaction preferences. Agents read this to understand your taste.
4
+
5
+ ---
6
+
7
+ ## Code Style Preferences
8
+
9
+ - **Indentation**: <!-- 2 spaces / 4 spaces / Tab -->
10
+ - **Quotes**: <!-- single / double -->
11
+ - **Semicolons**: <!-- always / never / asi -->
12
+ - **Naming**: <!-- camelCase / snake_case / PascalCase -->
13
+ - **Comment density**: <!-- minimal / when non-obvious / generous -->
14
+
15
+ ## Architecture Preferences
16
+
17
+ - **Error handling**: <!-- try/catch / Result type / panics -->
18
+ - **Async pattern**: <!-- async/await / promises / callbacks -->
19
+ - **Dependency injection**: <!-- constructor / service locator / none -->
20
+ - **Testing style**: <!-- TDD / test-after / integration-heavy -->
21
+
22
+ ## UI/UX Preferences
23
+
24
+ - **Design style**: <!-- minimalist / brutalist / corporate / playful -->
25
+ - **Color scheme**: <!-- light / dark / auto / specific palette -->
26
+ - **Typography**: <!-- system / Inter / Space Grotesk / other -->
27
+ - **Density**: <!-- spacious / compact / mixed -->
28
+ - **Animation**: <!-- none / purposeful / expressive -->
29
+
30
+ ## Communication Preferences
31
+
32
+ - **Language**: <!-- Simplified Chinese / English / bilingual -->
33
+ - **Verbosity**: <!-- terse / balanced / verbose -->
34
+ - **Explanation depth**: <!-- surface / mechanism / first-principles -->
35
+ - **When to ask**: <!-- ask at any fork / only on major decisions / be autonomous -->
36
+
37
+ ## Tooling Preferences
38
+
39
+ - **Package manager**: <!-- npm / pnpm / yarn / bun -->
40
+ - **Runtime**: <!-- node / bun / deno -->
41
+ - **Test framework**: <!-- vitest / jest / other -->
42
+ - **Linter**: <!-- eslint / biome / other -->
43
+ - **Commit convention**: <!-- conventional / gitmoji / free -->
44
+
45
+ ## Special Requirements
46
+
47
+ <!-- Rules specific to this project -->
48
+
49
+ - TODO:
50
+
51
+ ---
52
+
53
+ _Generated by `/flow-init` on {{CREATED_DATE}}. Update to match your actual preferences._
@@ -0,0 +1,59 @@
1
+ # {{PROJECT_NAME}}
2
+
3
+ > CurDX-Flow project vision — 500 lines max, loaded on every session
4
+
5
+ ---
6
+
7
+ ## One-line Description
8
+
9
+ <!-- In one sentence, state what this project is, for whom, and what problem it solves -->
10
+
11
+ TODO: fill in the one-line description of the project
12
+
13
+ ## Why This Project Exists
14
+
15
+ <!-- Background, motivation, pain points to solve -->
16
+
17
+ TODO:
18
+
19
+ ## Core Users
20
+
21
+ <!-- Who will use it? Their typical scenarios? -->
22
+
23
+ TODO:
24
+
25
+ ## Success Criteria
26
+
27
+ <!-- 3-5 verifiable metrics (e.g. "first response < 100ms", "weekly active users > 1000") -->
28
+
29
+ 1. TODO:
30
+ 2. TODO:
31
+ 3. TODO:
32
+
33
+ ## Tech Stack (with Rationale)
34
+
35
+ <!-- Write the reasoning for each choice to avoid future second-guessing -->
36
+
37
+ | Layer | Choice | Rationale |
38
+ |---|-----|------|
39
+ | Frontend | TODO | TODO |
40
+ | Backend | TODO | TODO |
41
+ | Database | TODO | TODO |
42
+ | Deployment | TODO | TODO |
43
+
44
+ ## Out of Scope (Scope Guard)
45
+
46
+ <!-- Explicitly list what does not belong in this project, to prevent scope creep -->
47
+
48
+ - ✗ TODO:
49
+ - ✗ TODO:
50
+
51
+ ## Constraints
52
+
53
+ <!-- Budget, time, team size, compliance, etc. -->
54
+
55
+ - TODO:
56
+
57
+ ---
58
+
59
+ _Generated by `/flow-init` on {{CREATED_DATE}}. Maintainer: {{USER_NAME}}_
@@ -0,0 +1,50 @@
1
+ # {{PROJECT_NAME}} — Roadmap
2
+
3
+ > CurDX-Flow ROADMAP — phase plan and success criteria. Works alongside `.flow/specs/*`: ROADMAP sets direction, specs handle concrete implementation.
4
+
5
+ ---
6
+
7
+ ## Current Version: v0.1 (MVP)
8
+
9
+ **Goal**: <!-- one sentence -->
10
+
11
+ TODO: describe the minimum viable product to deliver in v0.1.
12
+
13
+ ### Success Criteria (v0.1)
14
+
15
+ <!-- Must be verifiable -->
16
+
17
+ - [ ] TODO:
18
+ - [ ] TODO:
19
+ - [ ] TODO:
20
+
21
+ ### Phases
22
+
23
+ <!-- List in development order -->
24
+
25
+ #### Phase 1 — TODO
26
+ - Goal:
27
+ - Related spec: `specs/<name>`
28
+ - Completion criteria:
29
+
30
+ #### Phase 2 — TODO
31
+ - Goal:
32
+ - Completion criteria:
33
+
34
+ ---
35
+
36
+ ## Next Version: v0.2
37
+
38
+ **Theme**: TODO
39
+
40
+ No details yet.
41
+
42
+ ---
43
+
44
+ ## Vision (12 months)
45
+
46
+ TODO: describe what this project should look like one year from now.
47
+
48
+ ---
49
+
50
+ _Initialized on {{CREATED_DATE}}. The roadmap is a statement of intent, not a commitment._
@@ -0,0 +1,49 @@
1
+ # {{PROJECT_NAME}} — Cross-Session State
2
+
3
+ > CurDX-Flow STATE — explicit decision log + important context. Agents read this file at the start of every session.
4
+ >
5
+ > Division of labor with claude-mem: claude-mem captures everything automatically; STATE.md only records **decisions you and the agent explicitly agreed on**.
6
+
7
+ ---
8
+
9
+ ## Key Decisions
10
+
11
+ <!--
12
+ Format: D-NN | YYYY-MM-DD | decision | why
13
+ Once a decision is recorded, subsequent agents must explicitly note "I challenge D-NN" before violating it.
14
+ -->
15
+
16
+ <!-- Example (delete on init):
17
+ - **D-01** | 2026-04-19 | Use JWT instead of session cookie | Support cross-origin SPA
18
+ - **D-02** | 2026-04-19 | bcrypt cost factor = 12 | Balance 10K QPS performance with security
19
+ -->
20
+
21
+ No decisions yet.
22
+
23
+ ## Blockers
24
+
25
+ <!-- Items currently blocking progress, and who/what is being waited on -->
26
+
27
+ No blockers.
28
+
29
+ ## Open Questions
30
+
31
+ <!-- Questions that need user answers or investigation -->
32
+
33
+ None yet.
34
+
35
+ ## Important Context
36
+
37
+ <!-- Long-standing context the agent should remember, not quite at "decision" level -->
38
+
39
+ None yet.
40
+
41
+ ## Milestones
42
+
43
+ <!-- Project-level major milestones -->
44
+
45
+ None yet.
46
+
47
+ ---
48
+
49
+ _Initialized on {{CREATED_DATE}}. This file will grow as the project evolves._
@@ -0,0 +1,48 @@
1
+ {
2
+ "$schema": "https://raw.githubusercontent.com/wdx/curdx-flow/main/schemas/config.schema.json",
3
+ "version": "1.0",
4
+ "mode": "standard",
5
+ "_mode_options": "sketch | fast | standard | enterprise | autonomous",
6
+
7
+ "execution": {
8
+ "strategy": "auto",
9
+ "_strategy_options": "auto | subagent | stop-hook | wave | linear",
10
+ "max_parallel": 5,
11
+ "subagent_threshold": 8
12
+ },
13
+
14
+ "gates": {
15
+ "always_on": [
16
+ "karpathy-gate",
17
+ "verification-gate"
18
+ ],
19
+ "standard_mode": [
20
+ "tdd-gate",
21
+ "coverage-audit-gate",
22
+ "simplicity-gate"
23
+ ],
24
+ "enterprise_mode": [
25
+ "adversarial-review-gate",
26
+ "edge-case-gate",
27
+ "hard-gate",
28
+ "security-gate"
29
+ ]
30
+ },
31
+
32
+ "specs": {
33
+ "directories": ["./.flow/specs"],
34
+ "default_task_size": "fine",
35
+ "_task_size_options": "fine (40-60 tasks) | coarse (10-20 tasks)"
36
+ },
37
+
38
+ "addons": {
39
+ "pua": {
40
+ "enabled": false,
41
+ "style": "alibaba",
42
+ "_style_options": "alibaba | bytedance | huawei | tencent | baidu | pdd | meituan | jd | xiaomi | netflix | musk | jobs | amazon",
43
+ "auto_trigger": "on-failure"
44
+ }
45
+ },
46
+
47
+ "created": "{{CREATED_DATE}}"
48
+ }
@@ -0,0 +1,163 @@
1
+ ---
2
+ spec: {{SPEC_NAME}}
3
+ phase: design
4
+ created: {{CREATED_DATE}}
5
+ version: 1.0
6
+ status: in_progress
7
+ depends_on: requirements.md
8
+ ---
9
+
10
+ # Technical Design: {{SPEC_NAME}}
11
+
12
+ > Conclusions from the flow-architect agent using at least 8 rounds of `sequential-thinking` reasoning.
13
+ > This document freezes the technical choices. Subsequent tasks / implementation strictly follow this design.
14
+
15
+ ---
16
+
17
+ ## Design Overview (one paragraph)
18
+
19
+ <!-- One-sentence summary of the architecture -->
20
+
21
+ ## Architecture Decisions
22
+
23
+ <!-- Each major decision gets an ID and is written to the decisions array in .flow/STATE.md -->
24
+
25
+ ### AD-01: ...
26
+ - **Decision**: Use X instead of Y
27
+ - **Rationale**: ...
28
+ - **Trade-off**: Accepted [downside] in exchange for [upside]
29
+ - **sequentialthinking rounds**: rounds 3-5
30
+
31
+ ### AD-02: ...
32
+
33
+ ## System Architecture Diagram
34
+
35
+ ```mermaid
36
+ flowchart TB
37
+ <!-- actual data flow generated by flow-architect -->
38
+ User[User] --> API[API Gateway]
39
+ API --> Auth[Auth Service]
40
+ Auth --> DB[(Database)]
41
+ ```
42
+
43
+ ## Component Design
44
+
45
+ <!-- Each component is independently testable. Interfaces are explicit. -->
46
+
47
+ ### Component: {{COMP_NAME_1}}
48
+ - **Responsibility**: ...
49
+ - **Input**:
50
+ ```ts
51
+ interface Input {
52
+ field: Type;
53
+ }
54
+ ```
55
+ - **Output**:
56
+ ```ts
57
+ interface Output {
58
+ field: Type;
59
+ }
60
+ ```
61
+ - **Dependencies**: Component X, Library Y
62
+ - **Errors**:
63
+ - `ErrorCode.X` — when ... happens
64
+ - `ErrorCode.Y` — when ... happens
65
+
66
+ ### Component: {{COMP_NAME_2}}
67
+ <!-- ... -->
68
+
69
+ ## Data Model
70
+
71
+ <!-- Database schema / data structures -->
72
+
73
+ ### Entity: ...
74
+ ```sql
75
+ CREATE TABLE ... (
76
+ id UUID PRIMARY KEY,
77
+ ...
78
+ );
79
+ ```
80
+
81
+ ### Or TypeScript types:
82
+ ```ts
83
+ interface Entity {
84
+ id: string;
85
+ ...
86
+ }
87
+ ```
88
+
89
+ ## State Machine (if applicable)
90
+
91
+ ```mermaid
92
+ stateDiagram-v2
93
+ [*] --> Pending
94
+ Pending --> Active: approve
95
+ Pending --> Rejected: reject
96
+ Active --> Completed: finish
97
+ ```
98
+
99
+ ## Error Path Design
100
+
101
+ <!-- Full flow on failure -->
102
+
103
+ | Scenario | Upstream Behavior | System Response | User-visible |
104
+ |-----|--------|---------|---------|
105
+ | DB connection lost | retry 3 times | return 503 | "Temporarily unavailable, retry in 1 minute" |
106
+ | Rate limit hit | none | return 429 | "Too many requests, retry in 60 seconds" |
107
+
108
+ ## API Contract
109
+
110
+ <!-- If this is an API project -->
111
+
112
+ ```yaml
113
+ POST /api/v1/...
114
+ Request:
115
+ body:
116
+ field: string
117
+ Response:
118
+ 200:
119
+ body:
120
+ field: string
121
+ 400:
122
+ body:
123
+ error: string
124
+ ```
125
+
126
+ ## Test Matrix
127
+
128
+ | Layer | Coverage | Tool |
129
+ |---|-----|------|
130
+ | Unit | All pure functions | vitest |
131
+ | Integration | Between components | vitest + supertest |
132
+ | E2E | Complete user flows | playwright / chrome-devtools MCP |
133
+
134
+ ### Key Test Scenarios
135
+ 1. Happy path: ...
136
+ 2. Edge case 1: ...
137
+ 3. Error recovery: ...
138
+
139
+ ## Suggested Implementation Order
140
+
141
+ <!-- Reference for decomposition in the tasks phase -->
142
+
143
+ 1. Build skeleton first (Component A → empty implementation)
144
+ 2. Then wire up the real logic (core logic of Component A)
145
+ 3. Connect DB (persistence for Component A)
146
+ 4. Then do Component B ...
147
+
148
+ ## Risks and Mitigations
149
+
150
+ | Risk | Level | Mitigation |
151
+ |-----|-----|------|
152
+ | ... | medium | ... |
153
+
154
+ ## Defer to Implementation
155
+
156
+ <!-- Decisions not worth spending time on in the design phase -->
157
+
158
+ - Logging library choice → reuse project's existing one during implementation
159
+ - Caching strategy → no caching initially, adjust based on data after launch
160
+
161
+ ---
162
+
163
+ _Generated by flow-architect agent on {{CREATED_DATE}}. After user reviews and approves AD-01~N, proceed to the tasks phase._