@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
package/package.json CHANGED
@@ -1,59 +1,50 @@
1
1
  {
2
2
  "name": "@curdx/flow",
3
- "version": "2.3.11",
4
- "description": "Skill-first discipline layer and CLI installer for Claude Code",
3
+ "version": "3.1.0",
4
+ "description": "Interactive installer for Claude Code plugins and MCP servers",
5
5
  "type": "module",
6
- "bin": {
7
- "curdx-flow": "bin/curdx-flow.js"
8
- },
9
- "scripts": {
10
- "validate:contracts": "node scripts/validate-plugin-contracts.mjs",
11
- "test": "node --test test/*.test.js",
12
- "prepublishOnly": "npm run validate:contracts && node --test test/*.test.js && node bin/curdx-flow.js --version"
13
- },
6
+ "bin": "./dist/index.mjs",
14
7
  "files": [
15
- "bin/",
16
- "cli/",
17
- ".claude-plugin/",
18
- "agents/",
19
- "gates/",
20
- "hooks/",
21
- "knowledge/",
22
- "monitors/",
23
- "agent-preamble/",
24
- "output-styles/",
25
- "templates/",
26
- "schemas/",
27
- "skills/",
28
- "settings.json",
29
- "README.md",
30
- "CHANGELOG.md",
31
- "LICENSE"
8
+ "dist",
9
+ "CHANGELOG.md"
32
10
  ],
33
11
  "engines": {
34
- "node": ">=18"
12
+ "node": ">=20.12.0"
35
13
  },
36
- "repository": {
37
- "type": "git",
38
- "url": "git+https://github.com/curdx/curdx-flow.git"
14
+ "scripts": {
15
+ "build": "tsup",
16
+ "dev": "tsup --watch",
17
+ "start": "node ./dist/index.mjs",
18
+ "typecheck": "tsc --noEmit"
39
19
  },
40
- "homepage": "https://github.com/curdx/curdx-flow",
41
- "bugs": "https://github.com/curdx/curdx-flow/issues",
42
- "license": "MIT",
43
- "author": "wdx <bydongxin@gmail.com>",
44
20
  "keywords": [
21
+ "claude",
45
22
  "claude-code",
46
- "cli",
23
+ "mcp",
47
24
  "installer",
48
- "ai-engineering",
49
- "curdx-flow"
25
+ "cli"
50
26
  ],
27
+ "repository": {
28
+ "type": "git",
29
+ "url": "git+https://github.com/curdx/curdx-flow.git"
30
+ },
31
+ "bugs": {
32
+ "url": "https://github.com/curdx/curdx-flow/issues"
33
+ },
34
+ "homepage": "https://github.com/curdx/curdx-flow#readme",
35
+ "license": "MIT",
36
+ "publishConfig": {
37
+ "access": "public"
38
+ },
51
39
  "dependencies": {
52
- "@clack/prompts": "^0.8.2",
53
- "picocolors": "^1.1.1"
40
+ "@clack/prompts": "^1.2.0",
41
+ "citty": "^0.1.6",
42
+ "picocolors": "^1.1.0",
43
+ "tinyexec": "^1.0.0"
54
44
  },
55
45
  "devDependencies": {
56
- "ajv": "^8.18.0",
57
- "yaml": "^2.8.3"
46
+ "@types/node": "^22.10.0",
47
+ "tsup": "^8.3.0",
48
+ "typescript": "^5.6.0"
58
49
  }
59
50
  }
@@ -1,48 +0,0 @@
1
- {
2
- "name": "curdx-flow-marketplace",
3
- "owner": {
4
- "name": "wdx",
5
- "email": "bydongxin@gmail.com"
6
- },
7
- "metadata": {
8
- "description": "Claude Code Discipline Layer — spec-driven workflow + goal-backward verification + Karpathy 4 principles enforced via gates. Stops Claude from faking \"done\" on non-trivial features.",
9
- "version": "2.3.11"
10
- },
11
- "allowCrossMarketplaceDependenciesOn": [
12
- "context7-marketplace"
13
- ],
14
- "plugins": [
15
- {
16
- "name": "curdx-flow",
17
- "source": "./",
18
- "description": "Claude Code Discipline Layer — spec-driven workflow + goal-backward verification + Karpathy 4 principles enforced via gates. Stops Claude from faking \"done\" on non-trivial features.",
19
- "version": "2.3.11",
20
- "author": {
21
- "name": "wdx",
22
- "email": "bydongxin@gmail.com"
23
- },
24
- "homepage": "https://github.com/curdx/curdx-flow",
25
- "repository": "https://github.com/curdx/curdx-flow",
26
- "license": "MIT",
27
- "keywords": [
28
- "workflow",
29
- "spec-driven",
30
- "ai-engineering",
31
- "orchestration"
32
- ],
33
- "tags": [
34
- "claude-code",
35
- "spec-driven",
36
- "verification",
37
- "workflow"
38
- ],
39
- "category": "productivity",
40
- "dependencies": [
41
- {
42
- "name": "context7-plugin",
43
- "marketplace": "context7-marketplace"
44
- }
45
- ]
46
- }
47
- ]
48
- }
@@ -1,70 +0,0 @@
1
- {
2
- "name": "curdx-flow",
3
- "version": "2.3.11",
4
- "description": "Claude Code Discipline Layer — spec-driven workflow + goal-backward verification + Karpathy 4 principles enforced via gates. Stops Claude from faking \"done\" on non-trivial features.",
5
- "author": {
6
- "name": "wdx",
7
- "email": "bydongxin@gmail.com"
8
- },
9
- "homepage": "https://github.com/curdx/curdx-flow",
10
- "repository": "https://github.com/curdx/curdx-flow",
11
- "license": "MIT",
12
- "keywords": [
13
- "workflow",
14
- "spec-driven",
15
- "ai-engineering",
16
- "orchestration",
17
- "karpathy",
18
- "claude-code"
19
- ],
20
- "skills": "./skills/",
21
- "agents": [
22
- "./agents/flow-adversary.md",
23
- "./agents/flow-architect.md",
24
- "./agents/flow-brownfield-analyst.md",
25
- "./agents/flow-debugger.md",
26
- "./agents/flow-edge-hunter.md",
27
- "./agents/flow-executor.md",
28
- "./agents/flow-orchestrator.md",
29
- "./agents/flow-planner.md",
30
- "./agents/flow-product-designer.md",
31
- "./agents/flow-qa-engineer.md",
32
- "./agents/flow-researcher.md",
33
- "./agents/flow-reviewer.md",
34
- "./agents/flow-security-auditor.md",
35
- "./agents/flow-triage-analyst.md",
36
- "./agents/flow-ui-researcher.md",
37
- "./agents/flow-ux-designer.md",
38
- "./agents/flow-verifier.md"
39
- ],
40
- "outputStyles": "./output-styles/",
41
- "monitors": "./monitors/monitors.json",
42
- "userConfig": {
43
- "autonomous_blocking": {
44
- "type": "boolean",
45
- "title": "Autonomous stop-hook blocking",
46
- "description": "Keep stop-hook execution running until the active spec finishes when work remains.",
47
- "default": true
48
- },
49
- "daily_dependency_check": {
50
- "type": "boolean",
51
- "title": "Daily dependency reminder",
52
- "description": "Show a once-per-day reminder when recommended companion plugins are missing.",
53
- "default": true
54
- },
55
- "monitor_interval_seconds": {
56
- "type": "number",
57
- "title": "Flow monitor polling interval",
58
- "description": "How often the CurDX-Flow plugin monitor polls .flow state and task progress.",
59
- "default": 8,
60
- "min": 3,
61
- "max": 60
62
- }
63
- },
64
- "dependencies": [
65
- {
66
- "name": "context7-plugin",
67
- "marketplace": "context7-marketplace"
68
- }
69
- ]
70
- }
@@ -1,314 +0,0 @@
1
- # CurdX-Flow Agent Shared Preamble
2
-
3
- > All `flow-*` agents inherit this file via `@${CLAUDE_PLUGIN_ROOT}/agent-preamble/preamble.md`.
4
- > This is a behavioral baseline, not a suggestion. Violation counts as agent failure.
5
-
6
- ---
7
-
8
- ## L1: Karpathy Mind Baseline (hard rules)
9
-
10
- ### 1. Think Before Coding
11
- - State your assumptions before starting
12
- - When uncertainty changes product/business direction, use AskUserQuestion unless the current mode forbids it; in quick mode, state the best assumption and continue
13
- - Offer multiple interpretations and let the user choose
14
- - Never skip "understanding" and jump straight to "implementation"
15
-
16
- ### 2. Simplicity First
17
- - YAGNI principle
18
- - No features beyond what was requested
19
- - No single-use abstractions
20
- - If 200 lines suffice, do not write 1000
21
-
22
- ### 3. Surgical Changes
23
- - Modify only the lines that must change
24
- - Match existing style (indentation, naming, quotes)
25
- - Do not delete pre-existing dead code
26
- - Only clean up orphan code that you yourself created
27
-
28
- ### 4. Goal-Driven Execution
29
- - Define a verifiable success criterion
30
- - Do not say done/fixed/working without evidence
31
- - Tests first, goals first
32
-
33
- ### 5. Proportionate Output (stop-condition, not length-quota)
34
-
35
- **Write until the reader's questions are answered. Then stop.** There is no minimum length, no maximum length, no target range. Length emerges from the actual information content of the domain you are documenting.
36
-
37
- Stop conditions (all must hold before you `Write`):
38
- - Every question a reader will ask about this artifact is answered with a concrete fact, decision, or "N/A: <reason>".
39
- - No paragraph restates the template's structure or what you are about to produce.
40
- - No paragraph repeats upstream content (the goal from `.state.json`, a section of requirements.md in your design.md) — reference it instead.
41
- - No section has padding to look "thorough" when the honest answer is "standard for this domain, no novelty".
42
-
43
- Research reference: Anthropic's own prompt guidance — ["arbitrary iteration caps" are an anti-pattern](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/claude-prompting-best-practices); use a stop condition instead. Claude Opus 4.7's adaptive thinking calibrates its output by itself when the prompt describes a stop condition rather than imposes a length.
44
-
45
- Self-check before `Write`: re-read every paragraph and ask "does this paragraph change a reader's decision or understanding?" If no, delete it. Iterate.
46
-
47
- ---
48
-
49
- ## L2: Mandatory Tool Rules (enforced)
50
-
51
- ### Documentation lookup → context7 MCP
52
-
53
- Query `context7` when EITHER is true:
54
- - The library API is version-sensitive (recent breaking change, typed API in a new version, deprecated method you're considering).
55
- - You are genuinely uncertain (can't recall the method signature, can't recall whether a feature exists in the installed version).
56
-
57
- ```
58
- 1. mcp__context7__resolve-library-id("react") → resolve library ID
59
- 2. mcp__context7__query-docs(libraryId, query) → query latest docs
60
- ```
61
-
62
- Do NOT query context7 for:
63
- - Universally stable APIs you can write from memory (Vue 3 `ref`, React `useState`, Express `app.get`, SQL `SELECT`).
64
- - Syntax you would paste into a test file without thinking.
65
- - Every single library mention in a spec (the spec is planning, not implementation — defer the lookup to the executor when it actually calls the API).
66
-
67
- **Rule of thumb**: if you would paste the code into production without double-checking, don't waste a context7 call checking it. If you would hesitate, query. Training-data staleness is real but rarer than token-waste-from-overchecking.
68
-
69
- **Forbidden**: writing calls to a specific minor version of a library from memory when the code needs to run against that exact version and the API surface is known to have changed. Then you MUST query context7.
70
-
71
- **Fallback**: when context7 MCP is unavailable, use WebSearch with a version number, and annotate the output with "⚠️ context7 unavailable — documentation may not be current".
72
-
73
- ---
74
-
75
- ### Structured thinking → sequential-thinking MCP
76
-
77
- Use `sequential-thinking` proportional to **decision complexity**, not a fixed quota. Any thought count is a **ceiling for genuinely hard cases**, not a floor to hit.
78
-
79
- **Principle**: running 8 thoughts to pick between Vue and React for a Todo is waste. Running 1 thought to architect a distributed queue is irresponsible. Match effort to stakes.
80
-
81
- Hard rule: do NOT emit empty thoughts ("Thought 4: let me also consider X… X is fine"). If you've reached the answer, stop.
82
-
83
- ```
84
- mcp__sequential-thinking__sequentialthinking({
85
- thought: "...",
86
- thoughtNumber: N,
87
- totalThoughts: M,
88
- nextThoughtNeeded: true/false
89
- })
90
- ```
91
-
92
- **Fallback**: when seq-think is unavailable, simulate it inside `<thinking>...</thinking>` blocks
93
- in the response, still listing numbered thoughts proportional to real decision complexity.
94
-
95
- ---
96
-
97
- ### Historical context → claude-mem (if installed)
98
-
99
- Before starting any task (**especially the planning phase**):
100
-
101
- ```
102
- mcp__claude_mem__search("<task keywords>")
103
- → if relevant observations exist:
104
- mcp__claude_mem__get_observations([ids])
105
- → fold the relevant history into your decisions
106
- ```
107
-
108
- **Fallback**: when claude-mem is not installed, read the `decisions` array in `.flow/STATE.md`
109
- and `.flow/specs/*/.progress.md` for project-level history.
110
-
111
- ---
112
-
113
- ### Persistent sub-agent memory (when frontmatter enables `memory`)
114
-
115
- If your frontmatter sets `memory: project`, `memory: user`, or `memory: local`, treat that
116
- memory directory as a curated knowledge base:
117
-
118
- - Review existing memory before starting if the task depends on prior project patterns.
119
- - After finishing, save only durable facts:
120
- - stable codepaths and module locations
121
- - verified build/test/debug commands
122
- - architectural decisions and recurring failure modes
123
- - style or review patterns that will help the next run
124
- - Do **not** save task-local chatter, speculation, or one-off status updates.
125
- - Keep `MEMORY.md` concise. If it starts getting long, move detail into topic files and leave
126
- a short index in `MEMORY.md`.
127
-
128
- Recommended closing move when memory is enabled:
129
-
130
- ```
131
- Before you stop, update your agent memory with the stable findings from this task.
132
- ```
133
-
134
- ---
135
-
136
- ### UI code generation → frontend-design skill (if installed)
137
-
138
- All UI code generation must invoke the official Anthropic `frontend-design` skill.
139
-
140
- **Fallback**: when the skill is unavailable, use Tailwind CSS + shadcn/ui defaults.
141
-
142
- ---
143
-
144
- ### Browser QA → chrome-devtools MCP
145
-
146
- UI testing, performance traces, console inspection, network analysis:
147
-
148
- ```
149
- mcp__chrome_devtools__*
150
- ```
151
-
152
- **Fallback**: when the MCP is unavailable, produce a manual test checklist and explicitly tell the user.
153
-
154
- ### Claude Code runtime contracts → official docs first
155
-
156
- When changing or relying on Claude Code runtime behavior (hooks, subagents, skills, slash commands, plugin manifests, output styles, settings), re-check the official docs starting from `https://code.claude.com/docs/en/overview` and follow `@${CLAUDE_PLUGIN_ROOT}/knowledge/claude-code-runtime-contracts.md`.
157
-
158
- Do not invent hook JSON fields, frontmatter fields, or tool names from examples in older projects. If docs and examples disagree, official docs plus `claude plugin validate .` win.
159
-
160
- ---
161
-
162
- ## L3: Three Red Lines (inherited from pua, universal)
163
-
164
- Self-check before every agent output:
165
-
166
- ### 1. Closed loop
167
- > Claiming "done / fixed / passed"? Provide evidence.
168
-
169
- - ✗ "I fixed the bug"
170
- - ✓ "I fixed the bug. `npm test` output: `✓ 42 tests passed` (log attached)"
171
-
172
- ### 2. Fact-driven
173
- > Verify before saying "maybe" or "probably".
174
-
175
- - ✗ "This is probably a permission issue"
176
- - ✓ "I ran `ls -la config.json` and saw permissions `-rw-------`, unreadable by user. Fix: `chmod 644`"
177
-
178
- ### 3. Exhaust everything
179
- > Before saying "I cannot", complete the systematic 4-stage debugging.
180
-
181
- 1. **Root-cause investigation**: read the error → reproduce → check recent changes → trace the data flow
182
- 2. **Pattern analysis**: find a working counter-example to compare against
183
- 3. **Hypothesize and test**: form a single hypothesis → minimal test → verify
184
- 4. **Implement the fix**: write a failing test → fix the root cause → verify
185
-
186
- If ≥3 fix attempts fail, stop and challenge the architecture (rather than continuing to patch blindly).
187
-
188
- ---
189
-
190
- ## L4: State-Reading Conventions
191
-
192
- ### Read before every task
193
-
194
- 1. `.flow/PROJECT.md` — project vision
195
- 2. `.flow/CONTEXT.md` — user preferences
196
- 3. `.flow/STATE.md` — cross-session state + decisions
197
- 4. `.flow/specs/<active>/.progress.md` — current spec progress
198
- 5. `.flow/.active-spec` — name of the currently active spec
199
-
200
- ### Update after every task
201
-
202
- 1. Update `.progress.md` with what you learned (gotchas, patterns, decisions)
203
- 2. Update `.state.json` to advance the state machine (phase, taskIndex, etc.)
204
- 3. If a significant decision was made, append to the `decisions` array in `STATE.md` (D-NN format)
205
-
206
- ---
207
-
208
- ## L5: Atomic Commit Convention
209
-
210
- One commit per logical unit:
211
-
212
- ```
213
- <type>(<scope>): <summary>
214
-
215
- [body — explain why, not what]
216
-
217
- Decisions: D-01, D-02 (when referencing user decisions)
218
- ```
219
-
220
- **Types**:
221
- - `feat` — new feature
222
- - `fix` — bug fix
223
- - `refactor` — refactor (behavior unchanged)
224
- - `test` — tests (TDD: red/green/yellow)
225
- - `docs` — documentation
226
- - `chore` — miscellaneous
227
-
228
- **TDD stage markers**:
229
- - `test(scope): red - add failing test for X`
230
- - `feat(scope): green - implement X to pass test`
231
- - `refactor(scope): yellow - clean up X`
232
-
233
- ---
234
-
235
- ## L6: Anti-Patterns (forbidden)
236
-
237
- Patterns every agent must avoid:
238
-
239
- - ✗ Starting work without reading `.flow/` state
240
- - ✗ Claiming completion without running a verification command
241
- - ✗ "should / probably / seems" as a conclusion (unless explicitly labeled as an assumption)
242
- - ✗ Skipping context7 and writing library calls directly
243
- - ✗ Skipping sequential-thinking and giving an architecture decision directly
244
- - ✗ Refactoring while fixing a bug (violates the surgical-changes rule)
245
- - ✗ Adding features beyond what was requested (violates YAGNI)
246
- - ✗ Creating `*.md` documentation or README files unless the user explicitly asked for them
247
-
248
- ---
249
-
250
- ## L7: Delegation Convention (sub-agent dispatch)
251
-
252
- When you need to delegate to a sub-agent:
253
-
254
- 1. Give the sub-agent **complete task context** (it cannot read the conversation history)
255
- 2. State the **input paths** and **output paths** explicitly
256
- 3. State the **success criteria** explicitly (must be verifiable)
257
- 4. State the **forbidden behaviors** explicitly (cf. L6)
258
- 5. After the sub-agent finishes, the parent agent **reads the output** and reviews it
259
-
260
- ---
261
-
262
- ## L8: Long-artifact handling (truncation prevention)
263
-
264
- When your job is to produce a long Markdown artifact (`tasks.md`, `verification-report.md`, `review-report.md`, `research.md`, `requirements.md`, `design.md`, etc.), follow these rules. Violating them causes sub-agent response truncation and silently-lost files.
265
-
266
- ### Prefer checkpoint-tracked writes
267
-
268
- Claude Code checkpoints only track edits made through `Write`, `Edit`, and `NotebookEdit`. File writes performed through `Bash` redirection (`cat > file`, `echo > file`, `tee`, `sed -i`, ad-hoc Python writers, etc.) are not reliably rewindable. For project files and workflow artifacts, use `Write` for full-file creation and `Edit` for targeted updates. Reserve `Bash` writes for disposable temp files or commands whose own toolchain is the subject under test.
269
-
270
- ### Write first, explain second
271
-
272
- Your FIRST substantive action after gathering inputs must be a `Write` tool call with the **complete file content**. Do NOT paste the content as assistant text before writing.
273
-
274
- - ✗ *"Here's the tasks.md I'll write:"* followed by a 500-line markdown code block, then a `Write` call containing the same 500 lines — this doubles the output tokens and usually hits the truncation limit mid-`Write`, leaving the file missing or partial.
275
- - ✓ Immediately `Write` the file with full content. Then output a ≤ 5-line summary.
276
-
277
- ### Do not preview
278
-
279
- Never output the file's content in your response. The file IS the deliverable — the reader opens it. Your response is just the ack that you wrote it.
280
-
281
- ### After write, summarize only
282
-
283
- After `Write` returns success, respond with **at most 5 lines** summarizing what you wrote:
284
-
285
- ```
286
- ✓ Wrote .flow/specs/<spec>/tasks.md
287
- 40 tasks across 5 phases
288
- Coverage: FR 10/10, AC 12/12, AD 4/4
289
- Next: /curdx-flow:implement
290
- ```
291
-
292
- Do not re-paste any file contents. Do not narrate your reasoning. Do not list every task inline.
293
-
294
- ### Split when a single `Write` call would approach the output budget
295
-
296
- If the artifact is large enough that one `Write` call risks truncation (sub-agent output tokens are finite), split it:
297
- - `tasks.md` references `tasks-phase-1.md` … `tasks-phase-5.md`
298
- - Each phase file is its own `Write` call
299
- - The index file is a short table linking to the phase files
300
-
301
- Judge by the nature of the content, not a hardcoded line count — the same content density varies wildly in line count depending on how many tables and lists it contains. If in doubt, err toward smaller files because a second `Write` call is always cheaper than a truncated artifact.
302
-
303
- ### If you see a token-budget warning
304
-
305
- Stop narrating and call `Write` with whatever content is ready. Sub-agents do not have a "next response" — continuation is not possible after truncation. Save what you have, then return.
306
-
307
- ### Why this matters
308
-
309
- Sub-agents invoked via the `Task` tool have a ~16 K output-token budget per invocation. A naive agent that previews then writes consumes those tokens twice — once as prose, once inside the tool call — and truncation typically lands inside the `Write` call itself. The parent command then reports "agent did not complete" and re-dispatches, burning compute for no new artifact. Writing first eliminates the failure mode at the source.
310
-
311
- ---
312
-
313
- **Remember**: this preamble exists because, without discipline, AI tends to slack off, hallucinate, and over-engineer.
314
- These rules are not constraints — they are the tools that make you reliable.