@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,184 @@
1
+ ---
2
+ name: autoplan
3
+ description: Automatic planning review — run CEO / Engineering / Design / DX reviews in parallel and aggregate findings.
4
+ argument-hint: "[spec-name]"
5
+ allowed-tools: [Read, Write, Bash, Task]
6
+ ---
7
+
8
+ # Flow Autoplan — Automatic Planning Review
9
+
10
+ @${CLAUDE_PLUGIN_ROOT}/knowledge/planning-reviews.md
11
+
12
+ Run 4 Planning Reviews **in parallel** and aggregate the results.
13
+
14
+ ## When to use
15
+
16
+ - Production-grade features (not prototypes)
17
+ - Design is done, before entering tasks
18
+ - Want to ensure "multi-perspective coverage without omission"
19
+
20
+ ## When not to use
21
+
22
+ - MVP / prototype (use /curdx-flow:tasks directly)
23
+ - Pure backend (skip Design Review)
24
+ - Small changes (a single Review is enough)
25
+
26
+ ## Step 1: Prerequisites
27
+
28
+ ```bash
29
+ SPEC_NAME="${ARGUMENTS:-$(cat .flow/.active-spec 2>/dev/null)}"
30
+ [ -z "$SPEC_NAME" ] && { echo "❌ No active spec"; exit 1; }
31
+
32
+ DIR=".flow/specs/$SPEC_NAME"
33
+ for f in requirements.md design.md; do
34
+ [ ! -f "$DIR/$f" ] && { echo "❌ Missing $f"; exit 1; }
35
+ done
36
+ ```
37
+
38
+ ## Step 2: Decide how many Reviews are needed
39
+
40
+ ```bash
41
+ # Pure backend spec → skip Design Review
42
+ HAS_UI=0
43
+ grep -qE "(UI|UX|interface|frontend)" "$DIR"/*.md && HAS_UI=1
44
+
45
+ if [ $HAS_UI -eq 1 ]; then
46
+ REVIEWS=(ceo eng design dx)
47
+ else
48
+ REVIEWS=(ceo eng dx)
49
+ echo "ℹ Pure backend spec, skipping Design Review"
50
+ fi
51
+ ```
52
+
53
+ ## Step 3: Dispatch in parallel (key: multiple Tasks in a single message)
54
+
55
+ **In the same response**, invoke multiple Task tools to run in parallel:
56
+
57
+ ```
58
+ Task (CEO Review):
59
+ subagent_type: general-purpose
60
+ description: "CEO: $SPEC_NAME"
61
+ prompt: <same content as /curdx-flow:plan-ceo Task prompt>
62
+
63
+ Task (Engineering Review):
64
+ ... same as /curdx-flow:plan-eng ...
65
+
66
+ Task (Design Review, if HAS_UI=1):
67
+ ... same as /curdx-flow:plan-design ...
68
+
69
+ Task (DX Review):
70
+ ... same as /curdx-flow:plan-dx ...
71
+ ```
72
+
73
+ **Do not** dispatch across multiple messages (that would run serially, not in parallel).
74
+
75
+ ## Step 4: Wait for all returns + aggregate
76
+
77
+ Read each review report:
78
+
79
+ ```bash
80
+ CEO_REPORT="$DIR/plan-review-ceo.md"
81
+ ENG_REPORT="$DIR/plan-review-eng.md"
82
+ DESIGN_REPORT="$DIR/plan-review-design.md" # may not exist
83
+ DX_REPORT="$DIR/plan-review-dx.md"
84
+ ```
85
+
86
+ ## Step 5: Generate aggregated report
87
+
88
+ ```markdown
89
+ # Auto Plan Review: $SPEC_NAME
90
+
91
+ Generated: YYYY-MM-DD
92
+ Ran: CEO + Engineering + Design + DX (parallel)
93
+
94
+ ## Summary
95
+
96
+ | Review | Verdict | Findings |
97
+ |--------|---------|----------|
98
+ | CEO | APPROVED_WITH_CONCERNS | 2 |
99
+ | Eng | NEEDS_REVISION | 5 |
100
+ | Design | APPROVED | 1 |
101
+ | DX | 50/80 (pass) | 3 |
102
+
103
+ ## Blocking items (must fix)
104
+
105
+ 1. **[Eng] AD-03 missing fallback strategy**
106
+ - Location: design.md AD-03
107
+ - Risk: no fallback during production incident
108
+ - Suggestion: add AD-04 "fall back to in-memory cache when Redis is unavailable"
109
+
110
+ 2. **[CEO] Scope too large**
111
+ - Observation: current design includes 4 sub-features; MVP needs only 2
112
+ - Suggestion: trim to MVP (drop sub-features C / D, record as "v2 feature")
113
+
114
+ ## Warnings (recommended to fix)
115
+
116
+ 1. [Eng] AD-01 trade-off explanation not detailed enough
117
+ 2. [CEO] ROI not quantified
118
+ 3. [Design] error message strategy missing
119
+ 4. [DX] comment strategy not mentioned
120
+ 5. [DX] test naming convention unspecified
121
+
122
+ ## Observations
123
+
124
+ - Overall project design quality: medium
125
+ - Largest risk: missing fallback for AD-03
126
+
127
+ ## Suggested fix path
128
+
129
+ Suggested order (blocking first, warnings later):
130
+ 1. /curdx-flow:design re-discuss AD-03 + scope
131
+ 2. Add error message strategy in design.md
132
+ 3. Add comments / testing strategy sections
133
+ 4. Re-run /curdx-flow:autoplan to confirm
134
+ 5. After pass → /curdx-flow:tasks
135
+ ```
136
+
137
+ ## Step 6: Write aggregation + update .state
138
+
139
+ ```bash
140
+ AUTO_REPORT="$DIR/plan-review-auto.md"
141
+ # write aggregated content
142
+
143
+ # update state
144
+ python3 <<PY
145
+ import json
146
+ s = json.load(open('$DIR/.state.json'))
147
+ s.setdefault('plan_reviews', {})
148
+ s['plan_reviews']['last_run'] = '$(date +%Y-%m-%d)'
149
+ s['plan_reviews']['blocking'] = 2 # tallied from the report
150
+ s['plan_reviews']['warning'] = 5
151
+ json.dump(s, open('$DIR/.state.json','w'), indent=2, ensure_ascii=False)
152
+ PY
153
+ ```
154
+
155
+ ## Step 7: Output
156
+
157
+ ```
158
+ ✓ Auto Plan Review complete
159
+
160
+ Ran 4 reviews (parallel):
161
+ CEO: APPROVED_WITH_CONCERNS (2 concerns)
162
+ Eng: NEEDS_REVISION (5 issues)
163
+ Design: APPROVED (1 minor)
164
+ DX: 50/80 pass (3 issues)
165
+
166
+ Aggregate:
167
+ Blocking: 2
168
+ Warnings: 5
169
+
170
+ Overall verdict: NEEDS_REVISION
171
+
172
+ Aggregated report: .flow/specs/$SPEC_NAME/plan-review-auto.md
173
+
174
+ Next steps:
175
+ - Read the "Blocking items" section of the report
176
+ - After fixing → /curdx-flow:autoplan for re-review
177
+ - After pass → /curdx-flow:tasks
178
+ ```
179
+
180
+ ## Error recovery
181
+
182
+ - A Review fails → continue with the others; mark missing ones during aggregation
183
+ - All 4 fail → possibly design.md is corrupt; check then re-run
184
+ - Parallel timeout → reduce concurrency (run each review manually)
@@ -0,0 +1,199 @@
1
+ ---
2
+ name: debug
3
+ description: Systematic debugging — 4-phase methodology (root cause → pattern → hypothesis → fix); ≥3 failures triggers architectural questioning. Dispatches flow-debugger (David).
4
+ argument-hint: "\"<bug description>\""
5
+ allowed-tools: [Read, Write, Edit, Bash, Task, Grep, Glob]
6
+ ---
7
+
8
+ # Flow Debug — Systematic Debugging
9
+
10
+ @${CLAUDE_PLUGIN_ROOT}/knowledge/systematic-debugging.md
11
+
12
+ Dispatches the `flow-debugger` (David) agent to perform systematic 4-phase debugging.
13
+
14
+ ## When to use
15
+
16
+ - Clearly defined bug (with error message / reproduction steps)
17
+ - Tests suddenly failing
18
+ - Weird production behavior
19
+ - Tasks repeatedly failed by flow-executor
20
+
21
+ ## When not to use
22
+
23
+ - Still in coding phase → use the normal flow-executor flow
24
+ - Question needs investigation → use /curdx-flow:spike
25
+ - Performance issue needing benchmarks → performance tuning is not debug
26
+
27
+ ## Step 1: Parse bug description
28
+
29
+ ```bash
30
+ BUG_DESC="$ARGUMENTS"
31
+ [ -z "$BUG_DESC" ] && { echo "Usage: /curdx-flow:debug \"<bug description>\""; exit 1; }
32
+ ```
33
+
34
+ ## Step 2: Collect prerequisites (main agent, no dispatch)
35
+
36
+ Before dispatching David, the main agent (you) collects first:
37
+
38
+ ```bash
39
+ # 1. Recent commit history (bug may be introduced by a new commit)
40
+ git log --oneline -20
41
+
42
+ # 2. Current modifications (uncommitted)
43
+ git status
44
+ git diff --stat
45
+
46
+ # 3. If there is an active spec, read it
47
+ ACTIVE=$(cat .flow/.active-spec 2>/dev/null)
48
+ ```
49
+
50
+ ## Step 3: Dispatch flow-debugger (David)
51
+
52
+ ```
53
+ Task:
54
+ subagent_type: general-purpose
55
+ description: "Debug: $BUG_DESC"
56
+ prompt: |
57
+ You are the flow-debugger agent (David). Full definition:
58
+ ${CLAUDE_PLUGIN_ROOT}/agents/flow-debugger.md
59
+
60
+ Methodology knowledge base:
61
+ ${CLAUDE_PLUGIN_ROOT}/knowledge/systematic-debugging.md
62
+
63
+ Bug description:
64
+ $BUG_DESC
65
+
66
+ Workspace:
67
+ $(pwd)
68
+
69
+ Prerequisites:
70
+ - Recent commits: $(git log --oneline -10)
71
+ - Current diff: $(git status --short)
72
+ - Active spec: $ACTIVE
73
+ - Spec directory (if any): .flow/specs/$ACTIVE/
74
+
75
+ Mandatory 4 phases:
76
+
77
+ Phase 1: Root-cause investigation
78
+ - Read the error carefully (stack trace + message + location)
79
+ - Build a minimal reproduction
80
+ - Check recent changes
81
+ - Trace the data flow
82
+ - **By the end of Phase 1 you must state the root cause in one sentence; "maybe it's..." is not allowed**
83
+
84
+ Phase 2: Pattern analysis
85
+ - Find working examples
86
+ - Pinpoint the difference
87
+ - Decide isolated case vs systemic
88
+
89
+ Phase 3: Hypothesis & testing
90
+ - Single hypothesis
91
+ - Minimal test (verify in memory, don't commit)
92
+ - If confirmed, enter Phase 4; if disproved → return to Phase 1
93
+
94
+ Phase 4: Implement the fix
95
+ - Write a failing test
96
+ - Test actually fails (commit: test(scope): red - ...)
97
+ - Fix the root cause (not the symptom)
98
+ - Test passes (commit: fix(scope): green - ...)
99
+ - Full regression test passes
100
+ - Sweep for other isolated cases identified in Phase 2 and fix together
101
+
102
+ **3-failure guard**:
103
+ If Phase 4 has tried 3 different approaches and all failed, **stop**.
104
+ Do not try a 4th. Report back to me:
105
+ - The 3 approaches tried
106
+ - Why each failed
107
+ - Possible root issue (architecture / dependency / data)
108
+ - Recommend user intervention
109
+
110
+ Forbidden:
111
+ - Prayer-driven programming (retry 10 times)
112
+ - "Maybe it's..." as a root cause
113
+ - A fix without a failing test
114
+ - Bypassing the root cause (adding null check / try-catch to mask it)
115
+ - Fixing multiple things at once (adds variables)
116
+
117
+ Output to me a brief:
118
+ - Phase 1 root-cause statement
119
+ - Phase 2 pattern-analysis conclusion
120
+ - Phase 3 hypothesis + verification
121
+ - Phase 4 fix commits
122
+ - Learnings (suggestions to append to .progress.md)
123
+ ```
124
+
125
+ ## Step 4: Report to user
126
+
127
+ ```
128
+ ✓ Debug complete
129
+
130
+ Root cause: <Phase 1 conclusion>
131
+ Pattern: <Phase 2 conclusion>
132
+
133
+ Fix commits:
134
+ - <hash>: test - failing test
135
+ - <hash>: fix - root-cause fix
136
+ - <hash>: (additional) fixed N similar issues
137
+
138
+ Verification:
139
+ - Failing test now PASS ✓
140
+ - Full test suite has no regressions ✓
141
+
142
+ 📝 Learnings (can be appended to .progress.md):
143
+ - <lesson 1>
144
+ - <lesson 2>
145
+
146
+ Next steps:
147
+ - Review commits
148
+ - If the active spec has .progress.md, consider appending learnings
149
+ ```
150
+
151
+ ## Special case: 3 failures
152
+
153
+ If David reports 3 failures:
154
+
155
+ ```
156
+ ⚠ Systematic debugging failed (3 attempts)
157
+
158
+ Attempts:
159
+ 1. <method 1>: <why failed>
160
+ 2. <method 2>: <why failed>
161
+ 3. <method 3>: <why failed>
162
+
163
+ Possible root issues:
164
+ - Wrong architectural assumption
165
+ - Dependency version / compatibility
166
+ - Data-layer issue
167
+
168
+ Suggestions:
169
+ - Review David's detailed report analysis
170
+ - /curdx-flow:party winston david "what architectural issue does this bug hint at?"
171
+ - Or temporarily @ts-ignore / skip test and record as tech debt in STATE.md
172
+ ```
173
+
174
+ ## Forbidden
175
+
176
+ - ✗ Omitting the bug description
177
+ - ✗ Expecting "one-shot fix" (debug is a process, not an event)
178
+ - ✗ Skipping David and editing code yourself (loses the systematic methodology)
179
+ - ✗ Accepting "maybe it's..." as a root cause
180
+
181
+ ## Relationship to other commands
182
+
183
+ - `/curdx-flow:debug`: for **existing bugs**
184
+ - `/curdx-flow:implement`: may encounter bugs, but flow-executor retries 5 times itself before considering `/curdx-flow:debug`
185
+ - `/curdx-flow:verify`: finding a "false implementation" counts as a bug, can spawn `/curdx-flow:debug`
186
+
187
+ ## Typical scenarios
188
+
189
+ ```
190
+ Scenario 1: Test suddenly failing
191
+ You: "npm test keeps failing a specific test lately but I can't tell why"
192
+ /curdx-flow:debug "login test in auth.test.ts fails in CI but passes locally"
193
+
194
+ Scenario 2: Production bug
195
+ /curdx-flow:debug "production environment returns 500 for some API, stack trace: ..."
196
+
197
+ Scenario 3: Bug introduced by refactor
198
+ /curdx-flow:debug "login broken after refactor of auth module; pre-refactor version works"
199
+ ```
@@ -0,0 +1,155 @@
1
+ ---
2
+ name: design
3
+ description: Run the design phase — dispatch the flow-architect agent to do 8+ rounds of sequential-thinking, producing design.md
4
+ argument-hint: "[spec-name]"
5
+ allowed-tools: [Read, Write, Bash, Task]
6
+ ---
7
+
8
+ # Design Phase
9
+
10
+ Dispatch the `flow-architect` agent to do architectural design. This is the phase that **freezes technology choices**.
11
+
12
+ ## Step 1: Parse + prerequisite checks
13
+
14
+ ```bash
15
+ SPEC_NAME="${ARGUMENTS:-$(cat .flow/.active-spec 2>/dev/null)}"
16
+
17
+ [ -z "$SPEC_NAME" ] && { echo "❌ Please run /curdx-flow:start first"; exit 1; }
18
+
19
+ DIR=".flow/specs/$SPEC_NAME"
20
+ [ ! -f "$DIR/research.md" ] && { echo "❌ Missing research.md. Run /curdx-flow:research first"; exit 1; }
21
+ [ ! -f "$DIR/requirements.md" ] && { echo "❌ Missing requirements.md. Run /curdx-flow:requirements first"; exit 1; }
22
+ ```
23
+
24
+ ## Step 2: Update state
25
+
26
+ ```python
27
+ import json
28
+ p = f'.flow/specs/{SPEC_NAME}/.state.json'
29
+ s = json.load(open(p))
30
+ s.setdefault('phase_status',{})['design']='in_progress'
31
+ s['phase']='design'
32
+ json.dump(s, open(p,'w'), indent=2, ensure_ascii=False)
33
+ ```
34
+
35
+ ## Step 3: Dispatch flow-architect
36
+
37
+ ```
38
+ Task:
39
+ subagent_type: general-purpose
40
+ description: "Architectural design $SPEC_NAME"
41
+ prompt: |
42
+ You are the flow-architect agent. The full definition is at:
43
+ ${CLAUDE_PLUGIN_ROOT}/agents/flow-architect.md
44
+
45
+ Prerequisites (must read):
46
+ - .flow/specs/$SPEC_NAME/research.md
47
+ - .flow/specs/$SPEC_NAME/requirements.md
48
+ - .flow/PROJECT.md
49
+ - .flow/STATE.md
50
+
51
+ Template:
52
+ ${CLAUDE_PLUGIN_ROOT}/templates/design.md.tmpl
53
+
54
+ Knowledge base:
55
+ - ${CLAUDE_PLUGIN_ROOT}/knowledge/spec-driven-development.md (especially Phase 3)
56
+
57
+ Output:
58
+ .flow/specs/$SPEC_NAME/design.md
59
+
60
+ **Key rules**:
61
+ 1. Must call mcp__sequential-thinking__sequentialthinking **at least 8 rounds**
62
+ - Rounds 1-2: constraint identification
63
+ - Rounds 3-4: option A
64
+ - Rounds 5-6: option B
65
+ - Round 7: selection
66
+ - Round 8+: rebuttal
67
+
68
+ 2. Every library must be verified with mcp__context7__:
69
+ - resolve-library-id
70
+ - query-docs
71
+
72
+ 3. Assign AD-NN to each architectural decision
73
+ - Include the sequentialthinking source round number
74
+ - Include trade-off explanation
75
+
76
+ 4. Project-level decisions must be synced to .flow/STATE.md (D-NN)
77
+
78
+ 5. Must draw ≥1 mermaid diagram
79
+
80
+ 6. Every component must have a TypeScript interface or equivalent type definition
81
+
82
+ 7. Every NFR must have a corresponding design point in the design
83
+
84
+ Success criteria:
85
+ - sequential-thinking ≥ 8 rounds (round count reflected in AD references)
86
+ - AD ≥ 3
87
+ - Every FR has a component responsible for it in the design
88
+ - Every NFR has a response
89
+ - Error paths cover the edge-condition table in requirements.md
90
+
91
+ Forbidden:
92
+ - Choosing tech from memory
93
+ - Describing interfaces in natural language
94
+ - Omitting error paths
95
+ - Modifying requirements.md
96
+
97
+ When done, return a brief: core ADs, tech stack, component count, D-NN synced to STATE.md.
98
+ ```
99
+
100
+ ## Step 4: Validate output
101
+
102
+ ```bash
103
+ DESIGN=".flow/specs/$SPEC_NAME/design.md"
104
+
105
+ # Required sections
106
+ for sec in "Architectural Decisions" "System Architecture Diagram" "Component Design" "Error Paths"; do
107
+ grep -q "$sec" "$DESIGN" || echo "⚠ Missing section: $sec"
108
+ done
109
+
110
+ # AD count
111
+ AD_COUNT=$(grep -c "^### AD-" "$DESIGN" || echo 0)
112
+ [ "$AD_COUNT" -lt 3 ] && echo "⚠ Fewer than 3 architectural decisions (design may not be deep enough)"
113
+
114
+ # mermaid diagram
115
+ grep -q "mermaid" "$DESIGN" || echo "⚠ No mermaid diagram found"
116
+
117
+ # sequential-thinking reference
118
+ grep -q "sequentialthinking" "$DESIGN" || echo "⚠ No sequential-thinking round reference in ADs"
119
+ ```
120
+
121
+ ## Step 5: STATE.md sync check
122
+
123
+ ```bash
124
+ # The agent should have appended project-level decisions to STATE.md
125
+ # Here we just check whether an append happened
126
+ if ! git diff --quiet .flow/STATE.md 2>/dev/null; then
127
+ echo "✓ STATE.md updated"
128
+ else
129
+ echo "ℹ STATE.md unchanged (this spec may have no project-level decisions)"
130
+ fi
131
+ ```
132
+
133
+ ## Step 6: Output
134
+
135
+ ```
136
+ ✓ design phase complete
137
+
138
+ File: .flow/specs/$SPEC_NAME/design.md
139
+ Architectural decisions: N ADs
140
+ Project-level decisions: M synced to STATE.md
141
+ Components: K
142
+
143
+ **⚠ Design frozen**: once in tasks phase, any architecture change requires returning to /curdx-flow:design and bumping the version.
144
+
145
+ Next steps:
146
+ - Review design.md (especially the AD-NN entries)
147
+ - If you disagree with a decision, write "Challenge AD-NN: reason" in STATE.md, then re-run /curdx-flow:design
148
+ - /curdx-flow:tasks — enter task breakdown
149
+ ```
150
+
151
+ ## Error recovery
152
+
153
+ - sequential-thinking MCP unavailable → agent uses inline `<thinking>` blocks; quality may drop, suggest fixing the MCP then re-running
154
+ - context7 unavailable → supplement with WebSearch; tech pitfall detection will be weaker
155
+ - Agent produced fewer than 3 ADs → design may be too shallow; re-run emphasizing "at least 3 ADs"
@@ -0,0 +1,162 @@
1
+ ---
2
+ name: discuss
3
+ description: Pre-implementation discussion — capture the user's key decisions (D-NN) for the spec, written to .progress.md and STATE.md. Stop the AI from "silently assuming".
4
+ argument-hint: "[spec-name]"
5
+ allowed-tools: [Read, Write, Edit, AskUserQuestion, Bash]
6
+ ---
7
+
8
+ # Flow Discuss — Decision Locking
9
+
10
+ Before implementation, align with the user on **key decisions** (D-NN format) so the downstream implementer does not have to guess user preferences.
11
+
12
+ ## When to use
13
+
14
+ - design is done but before tasks (freeze decisions into tasks)
15
+ - before implementation (give executor explicit guidance)
16
+ - user wants to adjust direction halfway through a spec (add decisions)
17
+
18
+ ## Step 1: Prerequisites
19
+
20
+ ```bash
21
+ SPEC_NAME="${ARGUMENTS:-$(cat .flow/.active-spec 2>/dev/null)}"
22
+ [ -z "$SPEC_NAME" ] && { echo "❌ No active spec"; exit 1; }
23
+
24
+ DIR=".flow/specs/$SPEC_NAME"
25
+ [ ! -f "$DIR/design.md" ] && { echo "❌ Missing design.md. Run /curdx-flow:design first"; exit 1; }
26
+ ```
27
+
28
+ ## Step 2: Identify open decisions
29
+
30
+ Read the open questions in design.md + requirements.md:
31
+
32
+ ```bash
33
+ # Find open-questions sections in design / requirements
34
+ sed -n '/## Open Questions/,/^##/p' "$DIR/design.md" 2>/dev/null
35
+ sed -n '/## Open Questions/,/^##/p' "$DIR/requirements.md" 2>/dev/null
36
+ ```
37
+
38
+ Also scan unresolved TODO / FIXME:
39
+
40
+ ```bash
41
+ grep -i "TBD\|TODO\|pending\|FIXME" "$DIR/"*.md
42
+ ```
43
+
44
+ ## Step 3: Interactive questioning (key)
45
+
46
+ For each open decision, capture the user's choice via AskUserQuestion:
47
+
48
+ ```
49
+ AskUserQuestion:
50
+ Question: "How to store user data"
51
+ Options:
52
+ - A: PostgreSQL (relational, already used in the project)
53
+ - B: MongoDB (flexible schema, needs a new dependency)
54
+ - C: Do not decide yet (defer to actual implementation)
55
+ ```
56
+
57
+ **Forbidden**:
58
+ - The agent guesses the answer itself
59
+ - Merging multiple open questions into one ask (user can't answer all)
60
+
61
+ **Supported**:
62
+ - User picks "C: do not decide yet" → record as `D-NN: deferred, decide at implementation time`
63
+ - User wants to add rationale → append to the D-NN rationale
64
+ - User proposes a new direction (not in the options) → record and tag "user-originated"
65
+
66
+ ## Step 4: Assign D-NN
67
+
68
+ Read existing STATE.md to get the largest D number:
69
+
70
+ ```python
71
+ import re
72
+ content = open('.flow/STATE.md').read()
73
+ existing = re.findall(r'D-(\d+)', content)
74
+ next_n = max([int(x) for x in existing] + [0]) + 1
75
+ ```
76
+
77
+ For each new decision:
78
+ - Project-level impact (e.g., "the whole project uses PostgreSQL") → D-NN (append to STATE.md)
79
+ - Spec-level impact (e.g., "this spec uses bcrypt cost 12") → append to the spec's .progress.md
80
+
81
+ ## Step 5: Append to STATE.md
82
+
83
+ ```markdown
84
+ ## New decisions (append to the Decisions section of .flow/STATE.md)
85
+
86
+ - **D-07** | 2026-04-19 | auth-system spec decides to use JWT + Redis blocklist | supports cross-domain SPA; token revocation via Redis
87
+ - **D-08** | 2026-04-19 | All user data uses PostgreSQL | already used in the project; avoid introducing a new dependency
88
+ ```
89
+
90
+ **Append only, never modify existing D-NN.** (Once a decision is locked, do not change it.)
91
+
92
+ ## Step 6: Append to .progress.md
93
+
94
+ ```markdown
95
+ # .flow/specs/$SPEC_NAME/.progress.md
96
+
97
+ ## Decisions Made Here (from /curdx-flow:discuss YYYY-MM-DD)
98
+
99
+ - **D-07**: JWT + Redis blocklist
100
+ - Project-level → synced to STATE.md
101
+ - **D-08**: PostgreSQL for user data
102
+ - Project-level → synced to STATE.md
103
+ - **D-local-01**: bcrypt cost factor 12 (spec-level)
104
+ - Rationale: balance performance (100ms) and security
105
+ - No need to sync to STATE.md
106
+ ```
107
+
108
+ Project-level use the global D-NN numbering; spec-level use `D-local-NN` without taking a global number.
109
+
110
+ ## Step 7: Update tasks.md references (if already generated)
111
+
112
+ If tasks.md already exists, append `_Decisions: D-NN` reference to each task (so the executor knows which decision the task must follow).
113
+
114
+ If tasks.md has not been generated, a later `/curdx-flow:tasks` will generate based on these decisions.
115
+
116
+ ## Step 8: Output to user
117
+
118
+ ```
119
+ ✓ Discuss complete: $SPEC_NAME
120
+
121
+ Captured decisions:
122
+ Project-level (D-NN):
123
+ • D-07: JWT + Redis blocklist
124
+ • D-08: PostgreSQL for user data
125
+
126
+ Spec-level (D-local-NN):
127
+ • D-local-01: bcrypt cost factor 12
128
+
129
+ Written to:
130
+ • .flow/STATE.md (D-07, D-08)
131
+ • .flow/specs/$SPEC_NAME/.progress.md (all)
132
+
133
+ These decisions will be honored by flow-executor during subsequent execution without re-asking.
134
+
135
+ Next steps:
136
+ - If tasks.md is already generated → /curdx-flow:implement
137
+ - If not → /curdx-flow:tasks (will automatically reference these decisions)
138
+ ```
139
+
140
+ ## Forbidden
141
+
142
+ - ✗ Agent guessing the user's choice
143
+ - ✗ Asking open questions in bulk (must use AskUserQuestion one by one)
144
+ - ✗ Modifying existing D-NN (append only)
145
+ - ✗ Putting spec-level decisions in STATE.md (only project-level)
146
+
147
+ ## Principles
148
+
149
+ ### Discuss ≠ clarifying requirements
150
+
151
+ - **Discuss**: design exists; now decide execution details (e.g., "which DB")
152
+ - **Clarifying requirements**: should be done in the requirements phase
153
+
154
+ If discuss reveals that the requirements themselves are unclear → return to /curdx-flow:requirements.
155
+
156
+ ### A decision is a contract
157
+
158
+ Once a D-NN is written to STATE.md, all subsequent related code must reference the D-NN. To violate it, explicit challenge is required:
159
+
160
+ ```
161
+ Comment or PR description: "Challenge D-07: using session rather than JWT here because X"
162
+ ```