@curdx/flow 2.3.11 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (210) hide show
  1. package/CHANGELOG.md +21 -34
  2. package/LICENSE +1 -1
  3. package/README.md +28 -79
  4. package/dist/index.mjs +995 -0
  5. package/package.json +33 -42
  6. package/.claude-plugin/marketplace.json +0 -48
  7. package/.claude-plugin/plugin.json +0 -70
  8. package/agent-preamble/preamble.md +0 -314
  9. package/agents/flow-adversary.md +0 -202
  10. package/agents/flow-architect.md +0 -197
  11. package/agents/flow-brownfield-analyst.md +0 -142
  12. package/agents/flow-debugger.md +0 -321
  13. package/agents/flow-edge-hunter.md +0 -288
  14. package/agents/flow-executor.md +0 -269
  15. package/agents/flow-orchestrator.md +0 -145
  16. package/agents/flow-planner.md +0 -246
  17. package/agents/flow-product-designer.md +0 -159
  18. package/agents/flow-qa-engineer.md +0 -282
  19. package/agents/flow-researcher.md +0 -165
  20. package/agents/flow-reviewer.md +0 -303
  21. package/agents/flow-security-auditor.md +0 -401
  22. package/agents/flow-triage-analyst.md +0 -272
  23. package/agents/flow-ui-researcher.md +0 -229
  24. package/agents/flow-ux-designer.md +0 -221
  25. package/agents/flow-verifier.md +0 -349
  26. package/bin/curdx-flow +0 -5
  27. package/bin/curdx-flow.js +0 -54
  28. package/cli/README.md +0 -104
  29. package/cli/doctor-workflow.js +0 -483
  30. package/cli/doctor.js +0 -73
  31. package/cli/help.js +0 -59
  32. package/cli/install-bundled-mcps.js +0 -37
  33. package/cli/install-companions.js +0 -19
  34. package/cli/install-context7-config.js +0 -80
  35. package/cli/install-curdx-plugin.js +0 -96
  36. package/cli/install-language.js +0 -35
  37. package/cli/install-next-steps.js +0 -29
  38. package/cli/install-options.js +0 -9
  39. package/cli/install-paths.js +0 -52
  40. package/cli/install-recommended-plugins.js +0 -104
  41. package/cli/install-required-plugins.js +0 -57
  42. package/cli/install-self-update.js +0 -62
  43. package/cli/install-workflow.js +0 -209
  44. package/cli/install.js +0 -101
  45. package/cli/lib/claude-commands.js +0 -41
  46. package/cli/lib/claude-ops.js +0 -47
  47. package/cli/lib/claude.js +0 -183
  48. package/cli/lib/config.js +0 -24
  49. package/cli/lib/doctor-claude-settings.js +0 -1186
  50. package/cli/lib/doctor-report.js +0 -978
  51. package/cli/lib/doctor-runtime-environment.js +0 -196
  52. package/cli/lib/frontmatter.js +0 -44
  53. package/cli/lib/json-schema.js +0 -57
  54. package/cli/lib/logging.js +0 -25
  55. package/cli/lib/process.js +0 -60
  56. package/cli/lib/prompts.js +0 -135
  57. package/cli/lib/runtime.js +0 -107
  58. package/cli/lib/semver.js +0 -109
  59. package/cli/lib/version.js +0 -12
  60. package/cli/protocols-body.md +0 -22
  61. package/cli/protocols.js +0 -162
  62. package/cli/registry.js +0 -123
  63. package/cli/router.js +0 -49
  64. package/cli/uninstall-actions.js +0 -360
  65. package/cli/uninstall-workflow.js +0 -146
  66. package/cli/uninstall.js +0 -42
  67. package/cli/upgrade-workflow.js +0 -80
  68. package/cli/upgrade.js +0 -91
  69. package/cli/utils.js +0 -40
  70. package/gates/adversarial-review-gate.md +0 -219
  71. package/gates/coverage-audit-gate.md +0 -182
  72. package/gates/devex-gate.md +0 -254
  73. package/gates/edge-case-gate.md +0 -194
  74. package/gates/karpathy-gate.md +0 -130
  75. package/gates/security-gate.md +0 -218
  76. package/gates/tdd-gate.md +0 -182
  77. package/gates/test-quality-gate.md +0 -59
  78. package/gates/verification-gate.md +0 -179
  79. package/hooks/hooks.json +0 -58
  80. package/hooks/scripts/common.sh +0 -46
  81. package/hooks/scripts/inject-karpathy.sh +0 -53
  82. package/hooks/scripts/quick-mode-guard.sh +0 -68
  83. package/hooks/scripts/session-start.sh +0 -90
  84. package/hooks/scripts/stop-watcher.sh +0 -230
  85. package/hooks/scripts/subagent-artifact-guard.sh +0 -159
  86. package/hooks/scripts/subagent-statusline.sh +0 -105
  87. package/knowledge/artifact-output-discipline.md +0 -24
  88. package/knowledge/artifact-summary-contracts.md +0 -50
  89. package/knowledge/atomic-commits.md +0 -262
  90. package/knowledge/claude-code-runtime-contracts.md +0 -219
  91. package/knowledge/epic-decomposition.md +0 -307
  92. package/knowledge/execution-strategies.md +0 -303
  93. package/knowledge/karpathy-guidelines.md +0 -219
  94. package/knowledge/planning-reviews.md +0 -211
  95. package/knowledge/poc-first-workflow.md +0 -223
  96. package/knowledge/review-feedback-intake.md +0 -57
  97. package/knowledge/spec-driven-development.md +0 -180
  98. package/knowledge/systematic-debugging.md +0 -378
  99. package/knowledge/two-stage-review.md +0 -249
  100. package/knowledge/wave-execution.md +0 -403
  101. package/monitors/monitors.json +0 -8
  102. package/monitors/scripts/flow-state-monitor.sh +0 -99
  103. package/output-styles/curdx-evidence-first.md +0 -34
  104. package/schemas/agent-frontmatter.schema.json +0 -63
  105. package/schemas/config.schema.json +0 -134
  106. package/schemas/gate-frontmatter.schema.json +0 -30
  107. package/schemas/hooks.schema.json +0 -115
  108. package/schemas/output-style-frontmatter.schema.json +0 -22
  109. package/schemas/plugin-manifest.schema.json +0 -436
  110. package/schemas/plugin-settings.schema.json +0 -29
  111. package/schemas/skill-frontmatter.schema.json +0 -177
  112. package/schemas/spec-frontmatter.schema.json +0 -42
  113. package/schemas/spec-state.schema.json +0 -147
  114. package/settings.json +0 -7
  115. package/skills/brownfield-index/SKILL.md +0 -53
  116. package/skills/brownfield-index/references/applicability.md +0 -12
  117. package/skills/brownfield-index/references/handoff.md +0 -8
  118. package/skills/brownfield-index/references/index-contract.md +0 -10
  119. package/skills/browser-qa/SKILL.md +0 -39
  120. package/skills/browser-qa/references/handoff.md +0 -6
  121. package/skills/browser-qa/references/prerequisites.md +0 -10
  122. package/skills/browser-qa/references/qa-contract.md +0 -20
  123. package/skills/cancel/SKILL.md +0 -41
  124. package/skills/cancel/references/destructive-mode.md +0 -17
  125. package/skills/cancel/references/reporting.md +0 -18
  126. package/skills/cancel/references/state-recovery.md +0 -30
  127. package/skills/cancel/references/target-resolution.md +0 -7
  128. package/skills/debug/SKILL.md +0 -45
  129. package/skills/debug/references/context-gathering.md +0 -11
  130. package/skills/debug/references/failure-guard.md +0 -25
  131. package/skills/debug/references/intake.md +0 -12
  132. package/skills/debug/references/phase-workflow.md +0 -34
  133. package/skills/debug/references/reporting.md +0 -20
  134. package/skills/epic/SKILL.md +0 -39
  135. package/skills/epic/references/epic-artifacts.md +0 -20
  136. package/skills/epic/references/epic-intake.md +0 -9
  137. package/skills/epic/references/slice-handoff.md +0 -16
  138. package/skills/fast/SKILL.md +0 -62
  139. package/skills/fast/references/applicability.md +0 -25
  140. package/skills/fast/references/clarification.md +0 -20
  141. package/skills/fast/references/execution-contract.md +0 -56
  142. package/skills/help/SKILL.md +0 -55
  143. package/skills/help/references/dispatch.md +0 -20
  144. package/skills/help/references/overview.md +0 -39
  145. package/skills/help/references/troubleshoot.md +0 -47
  146. package/skills/help/references/workflow.md +0 -37
  147. package/skills/implement/SKILL.md +0 -96
  148. package/skills/implement/references/error-recovery.md +0 -36
  149. package/skills/implement/references/linear-execution.md +0 -32
  150. package/skills/implement/references/preflight.md +0 -43
  151. package/skills/implement/references/progress-contract.md +0 -32
  152. package/skills/implement/references/state-init.md +0 -33
  153. package/skills/implement/references/stop-hook-execution.md +0 -36
  154. package/skills/implement/references/strategy-router.md +0 -38
  155. package/skills/implement/references/subagent-execution.md +0 -43
  156. package/skills/implement/references/wave-execution.md +0 -162
  157. package/skills/init/SKILL.md +0 -49
  158. package/skills/init/references/gitignore-and-health.md +0 -26
  159. package/skills/init/references/next-steps.md +0 -22
  160. package/skills/init/references/preflight.md +0 -15
  161. package/skills/init/references/scaffold-contract.md +0 -27
  162. package/skills/review/SKILL.md +0 -82
  163. package/skills/review/references/optional-passes.md +0 -48
  164. package/skills/review/references/preflight.md +0 -38
  165. package/skills/review/references/report-contract.md +0 -49
  166. package/skills/review/references/reporting.md +0 -20
  167. package/skills/review/references/stage-execution.md +0 -32
  168. package/skills/security-audit/SKILL.md +0 -47
  169. package/skills/security-audit/references/audit-contract.md +0 -21
  170. package/skills/security-audit/references/gate-handoff.md +0 -8
  171. package/skills/security-audit/references/scope-and-depth.md +0 -9
  172. package/skills/spec/SKILL.md +0 -100
  173. package/skills/spec/references/artifact-landing.md +0 -31
  174. package/skills/spec/references/phase-execution.md +0 -50
  175. package/skills/spec/references/planning-review.md +0 -31
  176. package/skills/spec/references/preflight-and-routing.md +0 -46
  177. package/skills/spec/references/reporting.md +0 -21
  178. package/skills/start/SKILL.md +0 -84
  179. package/skills/start/references/branch-routing.md +0 -51
  180. package/skills/start/references/mode-semantics.md +0 -12
  181. package/skills/start/references/preflight.md +0 -13
  182. package/skills/start/references/reporting.md +0 -20
  183. package/skills/start/references/state-seeding.md +0 -44
  184. package/skills/start/references/workflow-handoff.md +0 -26
  185. package/skills/status/SKILL.md +0 -41
  186. package/skills/status/references/gather-contract.md +0 -27
  187. package/skills/status/references/health-rules.md +0 -27
  188. package/skills/status/references/output-contract.md +0 -24
  189. package/skills/status/references/preflight.md +0 -10
  190. package/skills/status/references/recovery-hints.md +0 -18
  191. package/skills/ui-sketch/SKILL.md +0 -39
  192. package/skills/ui-sketch/references/brief-intake.md +0 -10
  193. package/skills/ui-sketch/references/iteration-handoff.md +0 -5
  194. package/skills/ui-sketch/references/variant-contract.md +0 -15
  195. package/skills/verify/SKILL.md +0 -56
  196. package/skills/verify/references/evidence-workflow.md +0 -39
  197. package/skills/verify/references/output-contract.md +0 -23
  198. package/skills/verify/references/preflight.md +0 -11
  199. package/skills/verify/references/report-handoff.md +0 -35
  200. package/skills/verify/references/strict-mode.md +0 -12
  201. package/templates/CONTEXT.md.tmpl +0 -53
  202. package/templates/PROJECT.md.tmpl +0 -59
  203. package/templates/ROADMAP.md.tmpl +0 -50
  204. package/templates/STATE.md.tmpl +0 -49
  205. package/templates/config.json.tmpl +0 -51
  206. package/templates/design.md.tmpl +0 -83
  207. package/templates/progress.md.tmpl +0 -77
  208. package/templates/requirements.md.tmpl +0 -76
  209. package/templates/research.md.tmpl +0 -83
  210. package/templates/tasks.md.tmpl +0 -107
@@ -1,194 +0,0 @@
1
- ---
2
- gate: edge-case-gate
3
- category: enterprise-mode
4
- severity: warning
5
- depends_on: []
6
- ---
7
-
8
- # Edge Case Gate — Edge Case Hunter
9
-
10
- > Derived from BMAD-METHOD's "Edge Case Hunter".
11
- >
12
- > **Core**: specifically hunts for **non-happy-path** scenarios. User stories describe the happy path; the real world is full of edge cases.
13
-
14
- ---
15
-
16
- ## Trigger Timing
17
-
18
- - After the requirements phase ends (to supplement edge conditions)
19
- - After the design phase (to check error-path completeness)
20
- - After tests are written (to check whether only the happy path is covered)
21
- - Explicitly requested by /curdx-flow:verify --strict
22
-
23
- ---
24
-
25
- ## 7 Categories
26
-
27
- Systematically inspect the object under review (function / component / API):
28
-
29
- ### 1. Boundary Values
30
-
31
- - 0, -1, 1
32
- - INT_MAX, INT_MIN
33
- - Empty array `[]`, single-element array `[x]`, large array `[x...10000]`
34
- - Empty string `""`, single character `"a"`, extra-long string
35
- - First element / last element / middle element
36
-
37
- ### 2. Nullish
38
-
39
- - `null`
40
- - `undefined`
41
- - Empty object `{}`
42
- - Object with missing fields (key does not exist in JSON)
43
- - Whether default parameters are actually applied
44
-
45
- ### 3. Concurrency
46
-
47
- - Two requests arriving simultaneously
48
- - Write conflicts (optimistic / pessimistic lock)
49
- - Read-modify-write race
50
- - Cache invalidation timing
51
- - Distributed locks
52
-
53
- ### 4. Error Recovery
54
-
55
- - Network outage → retry strategy?
56
- - DB unavailable → circuit breaker?
57
- - Disk full → degrade?
58
- - Permission revoked → graceful exit?
59
- - Dependency service 500 → fallback?
60
-
61
- ### 5. Security
62
-
63
- - SQL/Command/XSS injection
64
- - Unauthorized access (use A's token to access B's resource)
65
- - Sensitive data leakage (logs / error messages / response)
66
- - Rate limiting bypass
67
- - CSRF / session fixation
68
- - Timing attack
69
-
70
- ### 6. Internationalization (I18n)
71
-
72
- - Unicode (emoji, CJK, combining characters)
73
- - RTL (Arabic)
74
- - Time zones (UTC vs local, DST jumps)
75
- - Number formats (decimal point vs comma)
76
- - Sorting (locale-aware collation)
77
-
78
- ### 7. Performance
79
-
80
- - N+1 queries
81
- - Slow queries (missing indexes)
82
- - Large responses (M/G scale)
83
- - Memory leaks (event listeners, closures)
84
- - Deadlocks / long-running transactions
85
-
86
- ---
87
-
88
- ## Required Question Checklist
89
-
90
- For each category, the agent must answer (via sequential-thinking):
91
-
92
- ```
93
- Q1. What inputs/scenarios will this feature encounter for [category]?
94
- Q2. If the input is [extreme value], what will the current implementation do?
95
- Q3. Is there a test covering this scenario?
96
- Q4. If no test, what test should be added to cover it?
97
- ```
98
-
99
- ---
100
-
101
- ## Execution Flow
102
-
103
- ```
104
- Input: object under review (function / component / API) + requirements + tests
105
-
106
- For each category (1-7):
107
- 1. Use sequential-thinking to list every plausible edge scenario for this category — stop when you've covered the real risk surface, don't pad to a quota, don't fabricate scenarios that won't occur in production
108
- 2. Check whether each scenario has corresponding coverage in tests
109
- 3. Add uncovered ones to the "gap list"
110
-
111
- Output: edge-cases.md
112
- ```
113
-
114
- ---
115
-
116
- ## Output Format
117
-
118
- ```markdown
119
- ## Edge Case Hunt Report
120
-
121
- Object under review: src/auth/login.ts + login.test.ts
122
-
123
- ## Covered (✓)
124
-
125
- - Valid email + password → 200 + JWT
126
- - Invalid email format → 400
127
- - Non-existent user → 401
128
- - Wrong password → 401
129
-
130
- ## Gap List (✗)
131
-
132
- ### 1. Boundary Values
133
- - ✗ Extra-long email (>255) may cause DB errors
134
- - Recommendation: test("rejects email >255 chars", ...)
135
- - ✗ Password containing NUL character (bcrypt has historical issue)
136
- - Recommendation: test("handles NUL in password safely", ...)
137
-
138
- ### 2. Nullish
139
- - ✗ email is empty string vs undefined
140
- - Currently: both return 400 (via schema validation), but no test
141
- - Recommendation: explicit test for both cases
142
-
143
- ### 3. Concurrency
144
- - ✗ Same user with 2 concurrent logins
145
- - Risk: token generation uniqueness?
146
- - Recommendation: test("handles concurrent logins", async () => Promise.all([...]))
147
-
148
- ### 4. Error Recovery
149
- - ✗ bcrypt.compare() timeout
150
- - Currently: no timeout, will wait indefinitely
151
- - Recommendation: add Promise.race + timeout test
152
-
153
- ### 5. Security
154
- - ⚠ Error message leak (user enumeration)
155
- - Already reported in adversarial review
156
- - ✗ Timing attack: response time difference between email existing vs not
157
- - Recommendation: run bcrypt.compare() in both cases, test response time difference < 10ms
158
-
159
- ### 6. Internationalization
160
- - ✗ Unicode email (RFC 6531)
161
- - Currently: regex may reject legitimate Unicode emails
162
- - Recommendation: test("accepts unicode email like ñ@example.com")
163
-
164
- ### 7. Performance
165
- - ⚠ bcrypt cost 12 response time (~100ms) not tested
166
- - Recommendation: benchmark test, expect < 200ms P99
167
-
168
- ## Summary
169
-
170
- Covered: 4 scenarios
171
- Gaps: 9 scenarios
172
- Priority ranking: 1 (concurrency) > 4 (timeout) > 7 (timing attack) > others
173
-
174
- Fix recommendations:
175
- - High priority: add 4 tests (concurrency, timeout, timing attack, unicode email)
176
- - Medium priority: add edge-case-tests.test.ts to unify edge-case test management
177
- ```
178
-
179
- ---
180
-
181
- ## Difference from Adversarial Review
182
-
183
- | Dimension | adversarial | edge-case |
184
- |------|-------------|-----------|
185
- | Goal | find **any** issue | find **edge-case** issues |
186
- | Scope | all dimensions (architecture/implementation/...) | inputs / scenarios |
187
- | Style | "attacker perspective" | "extreme case search" |
188
- | Output | issue list + fix recommendations | gap list + test recommendations |
189
-
190
- The two are complementary. Enterprise mode recommends enabling both.
191
-
192
- ---
193
-
194
- _Source: BMAD-METHOD's edge-case-hunter._
@@ -1,130 +0,0 @@
1
- ---
2
- gate: karpathy-gate
3
- category: always-on
4
- severity: blocking
5
- depends_on: []
6
- ---
7
-
8
- # Karpathy Gate — Thinking Baseline Check
9
-
10
- > **Always enabled**. This is the code-level enforcement of L1. Violations block immediately.
11
-
12
- This gate maps to Karpathy's 4 principles. All flow-executor and flow-reviewer agents must enforce it.
13
-
14
- ---
15
-
16
- ## Trigger Timing
17
-
18
- - Before code is written (pre-check)
19
- - Before commit (re-check)
20
- - When `/curdx-flow:review` runs (full review)
21
-
22
- ---
23
-
24
- ## 4 Checks
25
-
26
- ### G1. Think Before Coding
27
-
28
- **Violation patterns**:
29
- - ✗ Code embodies unstated assumptions (e.g. default encoding, default pagination count, default permission scope)
30
- - ✗ User goal has multiple interpretations but the agent picked one without saying so
31
- - ✗ Business-relevant changes (data export, permission modification) were not confirmed with the user
32
-
33
- **Check method**:
34
- 1. Read commit message + change scope
35
- 2. Look in `.progress.md` for "assumption:" entries
36
- 3. If a key assumption is not explicit, mark as violation
37
-
38
- **Auto-fix**: impossible. Report to user.
39
-
40
- ---
41
-
42
- ### G2. Simplicity First
43
-
44
- **Violation patterns**:
45
- - ✗ Introduces an abstraction with only one usage point (Strategy / Factory / Observer used in one place)
46
- - ✗ Code goes beyond task requirements (user asked for `A`, implemented `A` + `B` + `C`)
47
- - ✗ Over-defensive (error handling for cases that obviously won't happen)
48
- - ✗ Premature parameterization (hooks left "in case we need it later")
49
- - ✗ Tests changed to "always pass" to accommodate implementation
50
-
51
- **Check method**:
52
- 1. Cross-reference with the FR list in requirements.md
53
- 2. Check whether the commit's diff scope exceeds the FR description
54
- 3. Scan new classes / interfaces / factories; only reasonable if used in > 1 place
55
-
56
- **Auto-fix**:
57
- - Dispatch flow-adversary agent to review, flag redundant code
58
- - Auto-deletion not allowed (may have reasons); list items and let the user decide
59
-
60
- ---
61
-
62
- ### G3. Surgical Changes
63
-
64
- **Violation patterns**:
65
- - ✗ Task only modifies `auth/login.ts`, but the commit contains changes in `utils/`
66
- - ✗ Task is to add a feature, but the commit contains "incidental" refactoring
67
- - ✗ Changed comments, quotes, or indentation unrelated to the task
68
- - ✗ Deleted pre-existing (not self-caused) "dead code"
69
-
70
- **Check method**:
71
- 1. Read the Files field in tasks.md
72
- 2. Compare to the commit's changed files
73
- 3. If there is a difference (commit changed files not in Files), mark as violation
74
-
75
- **Auto-fix**:
76
- - Dispatch flow-executor to extract the "incidental changes" into a separate commit
77
- - Or roll back and redo
78
-
79
- ---
80
-
81
- ### G4. Goal-Driven Execution
82
-
83
- **Violation patterns**:
84
- - ✗ Commit message contains "should", "probably", "seems", "fixed" without verification evidence
85
- - ✗ The `Verify` field is skipped (claiming complete without running)
86
- - ✗ Tests were deleted instead of fixed (turning green into gray)
87
- - ✗ Claims "done" but AC-X.Y still cannot be verified via curl
88
-
89
- **Check method**:
90
- 1. Grep commit messages for forbidden words
91
- 2. Check .progress.md for Verify output records
92
- 3. For each AC, confirm that an automated verification path can be found
93
-
94
- **Auto-fix**:
95
- - Trigger flow-verifier to run reverse verification
96
- - If AC is not met, send back for rework (dispatch flow-executor to fix)
97
-
98
- ---
99
-
100
- ## Violation Levels
101
-
102
- | Violation | Level | Block? |
103
- |------|------|-------|
104
- | G1 (unstated assumption) | Medium | warning, require user confirmation |
105
- | G2 (over-engineering) | Medium | warning + suggest simplification |
106
- | G3 (surgical failure) | High | **block**, must split the commit |
107
- | G4 (no evidence) | High | **block**, must run verification |
108
-
109
- ---
110
-
111
- ## Output Format
112
-
113
- ```markdown
114
- ## Karpathy Gate Check Result
115
-
116
- [G1] Think Before Coding: ✓ pass (3 explicit assumption records)
117
- [G2] Simplicity First: ⚠ warning — src/auth/login-strategy.ts has a single-use Strategy pattern
118
- [G3] Surgical Changes: ✗ violated — commit abc123 contains accidental changes in utils/
119
- [G4] Goal-Driven: ✓ pass (all ACs have verification records)
120
-
121
- Blockers: 1
122
- Warnings: 1
123
-
124
- Fix recommendations:
125
- G3: git reset HEAD~1, split commit abc123 into 2 atomic commits
126
- ```
127
-
128
- ---
129
-
130
- _Applied to: all agent preamble.md has this built in; this file contains the detailed rules for concrete checks._
@@ -1,218 +0,0 @@
1
- ---
2
- gate: security-gate
3
- category: enterprise-mode
4
- severity: blocking
5
- depends_on: []
6
- ---
7
-
8
- # Security Gate — Security Baseline Enforcement
9
-
10
- > Enabled by default in Enterprise mode. Violating "high-risk" items blocks release.
11
-
12
- ---
13
-
14
- ## Trigger Timing
15
-
16
- - When the `security-audit` skill runs
17
- - Before human PR/release handoff, after `/curdx-flow:verify` and `/curdx-flow:review`
18
- - When committing specs involving auth / payments / PII
19
-
20
- ---
21
-
22
- ## Core Red Lines (high-risk, blocking)
23
-
24
- ### SR-01: Hardcoded Credentials
25
-
26
- Scan:
27
- ```bash
28
- grep -rnE "(api[_-]?key|secret|password|token)[[:space:]]*[:=][[:space:]]*['\"][^'\"]{12,}" src/
29
- ```
30
-
31
- Hit → block release + force rotate credential.
32
-
33
- ### SR-02: SQL/Command Injection Points
34
-
35
- ```bash
36
- # String-concatenated SQL
37
- grep -rn "db.query.*\${.*req\." src/
38
- grep -rn "execute.*\${.*user" src/
39
-
40
- # Command injection
41
- grep -rn "exec.*\${\|spawn.*\${" src/
42
- ```
43
-
44
- Hit → block, must switch to parameterized queries or shell escape.
45
-
46
- ### SR-03: XSS Injection Points
47
-
48
- ```bash
49
- grep -rn "innerHTML\|dangerouslySetInnerHTML" src/
50
- ```
51
-
52
- Hit → must review data source. If it comes from user input without sanitization → block.
53
-
54
- ### SR-04: Sensitive Data in Logs
55
-
56
- ```bash
57
- grep -rnE "(console|logger)\.(log|info|warn|error).*(password|token|secret|creditCard|ssn)" src/
58
- ```
59
-
60
- Hit → block, switch to a redact wrapper.
61
-
62
- ### SR-05: Secret Management
63
-
64
- - JWT secret / DB password must be env variables
65
- - Validate at startup (fail fast)
66
- - Must not fall back to default values
67
-
68
- ---
69
-
70
- ## Warning Items (non-blocking, must fix)
71
-
72
- ### SW-01: Error Message Leaks Existence
73
-
74
- ```
75
- "User not found" vs "Wrong password"
76
- ```
77
-
78
- Different messages = can be enumerated. Recommend unifying to "Invalid credentials".
79
-
80
- ### SW-02: Timing Attack
81
-
82
- Response-time differences leak information. bcrypt should run even for unknown users (using a fake hash).
83
-
84
- ### SW-03: CORS Too Permissive
85
-
86
- `Access-Control-Allow-Origin: *` must be fixed before release.
87
-
88
- ### SW-04: Rate Limiting Missing
89
-
90
- Login, registration, and password-reset paths without rate limit → can be brute-forced.
91
-
92
- ### SW-05: Dependency CVE
93
-
94
- `npm audit` reports high/critical → must upgrade or exempt.
95
-
96
- ---
97
-
98
- ## Mandatory Items (Enterprise default requirements)
99
-
100
- ### SM-01: All APIs Have Authorization
101
-
102
- Not "public" by default. New endpoints default to `requireAuth`.
103
-
104
- ### SM-02: User Data Isolation
105
-
106
- `WHERE user_id = ?` must use the current session's user_id; cannot trust the frontend parameter.
107
-
108
- ### SM-03: HTTPS Enforced
109
-
110
- Production environment only accepts HTTPS. HTTP requests → 301 to HTTPS.
111
-
112
- ### SM-04: Cookie Security Flags
113
-
114
- - HttpOnly (prevent XSS reads)
115
- - Secure (HTTPS only)
116
- - SameSite=Strict/Lax (prevent CSRF)
117
-
118
- ### SM-05: Password Storage
119
-
120
- - Must be bcrypt/argon2 (not md5/sha)
121
- - cost factor ≥ 12
122
-
123
- ---
124
-
125
- ## Checking Methods
126
-
127
- ### Automated Scan
128
-
129
- ```bash
130
- # Run all scans
131
- bash scripts/security-scan.sh # provided by project (if available)
132
-
133
- # Or use flow-security-auditor agent via the `security-audit` skill
134
- # (or say "audit for security issues")
135
- ```
136
-
137
- ### Dependency CVE
138
-
139
- ```bash
140
- npm audit --audit-level=high
141
- # or
142
- pnpm audit
143
- ```
144
-
145
- ### Manual Review (design layer)
146
-
147
- - Check if AD-NN in design.md has security relevance
148
- - Check NFR-S in requirements.md
149
- - Threat modeling (STRIDE)
150
-
151
- ---
152
-
153
- ## Violation Handling
154
-
155
- ### Blocking Items
156
-
157
- - If SR-01 ~ SR-05 are found → block immediately; do not hand off for PR/release
158
- - Must fix or explicitly exempt (record in STATE.md as tech debt + commitment to fix before release)
159
-
160
- ### Warning Items
161
-
162
- - If SW-01 ~ SW-05 are found → warning, non-blocking
163
- - But record in `security-debt.md`
164
- - Re-check in the next audit
165
-
166
- ### Mandatory Items
167
-
168
- - Missing SM-01 ~ SM-05 → warning (new features), blocking (production paths)
169
-
170
- ---
171
-
172
- ## Exemption Path
173
-
174
- If you truly need to skip a security check:
175
-
176
- 1. Record in `.flow/STATE.md`:
177
- ```markdown
178
- ## Security Exemptions
179
- - D-SEC-01 | 2026-04-19 | temporarily hardcoding JWT_SECRET in dev environment
180
- - Exemption scope: dev environment only
181
- - Risk owner: wdx
182
- - Fix commitment: migrate to env before 2026-04-26
183
- ```
184
-
185
- 2. Explicitly mention in PR description
186
-
187
- 3. Next audit must re-check whether it has been fixed
188
-
189
- ---
190
-
191
- ## Output Format
192
-
193
- ```markdown
194
- ## Security Gate Report
195
-
196
- Scan: commits abc..xyz + npm audit
197
- Time: YYYY-MM-DD
198
-
199
- ### Blockers (SR): 1
200
- - [SR-04] src/auth/login.ts:60 — logger records password field
201
-
202
- ### Warnings (SW): 2
203
- - [SW-01] Inconsistent login error messages → enumerable
204
- - [SW-05] axios 1.5.0 has CVE → `npm install axios@^1.6.0`
205
-
206
- ### Mandatory (SM): all satisfied
207
-
208
- Verdict: BLOCKED (1 SR)
209
-
210
- Fix list:
211
- 1. SR-04: wrap logger with redactPassword() (blocking, required)
212
- 2. SW-01: unify error messages (recommended)
213
- 3. SW-05: upgrade axios (recommended)
214
- ```
215
-
216
- ---
217
-
218
- _source: OWASP Top 10 + STRIDE + accumulated project experience._
package/gates/tdd-gate.md DELETED
@@ -1,182 +0,0 @@
1
- ---
2
- gate: tdd-gate
3
- category: standard-mode
4
- severity: blocking
5
- depends_on: []
6
- ---
7
-
8
- # TDD Gate — Red/Green/Yellow Cycle Enforcement
9
-
10
- > **Iron rule**: NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST.
11
-
12
- ---
13
-
14
- ## Trigger Timing
15
-
16
- - All tasks in Phase 3 (Testing)
17
- - Production code changes outside the POC phase
18
- - Tasks explicitly marked `[RED]` / `[GREEN]` / `[YELLOW]`
19
-
20
- ---
21
-
22
- ## Applicability
23
-
24
- ✓ **TDD enforced**:
25
- - Adding production logic (business rules, algorithms, data transformations)
26
- - Modifying existing logic (even one line)
27
- - Bug fixes (must have a failing test that reproduces the bug)
28
-
29
- ⊘ **Exemptible from TDD**:
30
- - POC phase (Phase 1 of POC-First)
31
- - Pure configuration changes (`.json` / `.yaml`)
32
- - Documentation (`.md`)
33
- - Formatting (does not change behavior)
34
- - Dependency upgrades (only modify package.json, unless major version)
35
-
36
- ---
37
-
38
- ## RED → GREEN → YELLOW Enforcement Rules
39
-
40
- ### RED (failing test)
41
-
42
- **Rules**:
43
- - The test **must actually fail** before continuing
44
- - "I wrote the test but haven't run it" is not allowed
45
- - "The test passes as soon as written" is not allowed (this means it doesn't actually test anything)
46
-
47
- **Check**:
48
- ```bash
49
- # Expect a non-zero exit code
50
- npm test -- <test-file>
51
- echo "Exit: $?" # must be non-0
52
- ```
53
-
54
- **Commit format**: `test(scope): red - <what the test verifies>`
55
-
56
- **Violations**:
57
- - ✗ Wrote the test but didn't run it (no fresh evidence)
58
- - ✗ Test passes the first time it runs
59
- - ✗ Started writing implementation before writing the test
60
-
61
- ---
62
-
63
- ### GREEN (minimal implementation)
64
-
65
- **Rules**:
66
- - Write the **least code** needed to pass the RED test
67
- - Don't think about elegance, abstraction, or extensibility
68
- - Focus on making the test pass
69
-
70
- **Check**:
71
- ```bash
72
- npm test -- <test-file>
73
- echo "Exit: $?" # must be 0
74
- ```
75
-
76
- **Commit format**: `feat(scope): green - <what was implemented>`
77
-
78
- **Violations**:
79
- - ✗ Added functionality beyond what makes the test pass
80
- - ✗ Did abstraction and implementation at the same time
81
- - ✗ Other tests also pass but those tests were written outside this cycle
82
-
83
- ---
84
-
85
- ### YELLOW (refactor)
86
-
87
- **Rules**:
88
- - Clean up GREEN-phase code; **tests must still pass**
89
- - No new behavior
90
- - No new tests
91
-
92
- **Check**:
93
- ```bash
94
- # Tests run before and after, both exit 0
95
- npm test -- <test-file>
96
- ```
97
-
98
- **Commit format**: `refactor(scope): yellow - <what was cleaned up>`
99
-
100
- **Violations**:
101
- - ✗ Test fails during YELLOW (means behavior changed)
102
- - ✗ YELLOW added new functionality
103
- - ✗ Deleted hard-to-change code (violates surgical changes)
104
-
105
- ---
106
-
107
- ## Reasons to Refuse (agent must reject these excuses)
108
-
109
- | Excuse | Agent Response |
110
- |------|---------|
111
- | "This is too simple to test" | Simple code can break too. Write a minimal test. |
112
- | "Write code first, test later" | After-the-fact tests miss edge cases. Go back to RED. |
113
- | "I already tested manually" | No automation record means no regression. Write an automated test. |
114
- | "Existing code has no tests, I won't either" | Coverage only goes up or down. New code must at least cover the new logic. |
115
- | "Time pressure" | fast mode or /curdx-flow:fast can exempt. Otherwise go through full TDD. |
116
-
117
- ---
118
-
119
- ## Exemption Path (explicit)
120
-
121
- If you really need to skip TDD, you must:
122
-
123
- 1. Mark in `.flow/CONTEXT.md` or `.state.json`
124
- 2. Provide an exemption reason
125
- 3. Add a "tech debt" entry to `.flow/STATE.md`, with a commitment to fix later
126
-
127
- ```markdown
128
- # STATE.md
129
- ## Tech Debt
130
- - D-TDD-01 | 2026-04-19 | auth-system's refresh-token module skipped TDD
131
- - Reason: urgent hotfix, CI takes 1 hour to complete
132
- - Commitment: add tests next sprint, deadline 2026-04-26
133
- ```
134
-
135
- No exemption record → TDD enforced.
136
-
137
- ---
138
-
139
- ## Checking Methods
140
-
141
- ### flow-reviewer's Stage 2 invokes this gate
142
-
143
- Scan git log; for each `feat(xxx):` commit:
144
- 1. Find the preceding `test(xxx): red -` commit
145
- 2. If none, that feat violates TDD
146
- 3. Exception: commit message contains `[skip-tdd]` and a corresponding record exists in STATE.md
147
-
148
- ### Coverage Check (auxiliary)
149
-
150
- ```bash
151
- npm test -- --coverage
152
- # Line coverage for new code must be ≥ 80%
153
- # Uncovered lines must be explained in STATE.md
154
- ```
155
-
156
- ---
157
-
158
- ## Output Format
159
-
160
- ```markdown
161
- ## TDD Gate Check Result
162
-
163
- Scan range: commits abc123..def456
164
- Feat commits: 5
165
- Test commits (red): 4
166
-
167
- [T1] commit abc123 "feat(auth): add login endpoint"
168
- Preceding RED: ✓ commit 789xyz "test(auth): red - login endpoint tests"
169
- Verdict: compliant
170
-
171
- [T2] commit def456 "feat(auth): add password hashing"
172
- Preceding RED: ✗ no preceding test commit
173
- Verdict: violation
174
- Exception check: no [skip-tdd] marker, no STATE.md exemption
175
- Block: yes
176
-
177
- Violations: 1
178
- Compliant: 4
179
-
180
- Fix recommendations:
181
- T2: add test test(auth): red - password hashing, verify it fails, then redo GREEN
182
- ```