claude-flow-novice 1.3.0 → 1.3.2

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 (305) hide show
  1. package/.claude-flow-novice/preferences/generation.json +147 -0
  2. package/.claude-flow-novice/preferences/language-configs/javascript.json +51 -0
  3. package/.claude-flow-novice/preferences/language-configs/python.json +50 -0
  4. package/.claude-flow-novice/preferences/language-configs/rust.json +237 -0
  5. package/.claude-flow-novice/preferences/language-configs/typescript.json +54 -0
  6. package/.claude-flow-novice/preferences/project-local.json +91 -0
  7. package/.claude-flow-novice/preferences/resource-delegation.json +120 -0
  8. package/.claude-flow-novice/preferences/team-shared.json +195 -0
  9. package/.claude-flow-novice/preferences/user-global.json +247 -0
  10. package/.claude-flow-novice/templates/claude-md-templates/CLAUDE-JAVASCRIPT.md +769 -0
  11. package/.claude-flow-novice/templates/claude-md-templates/CLAUDE-PYTHON.md +1214 -0
  12. package/.claude-flow-novice/templates/claude-md-templates/CLAUDE-RUST.md +475 -0
  13. package/.claude-flow-novice/templates/claude-md-templates/CLAUDE-TYPESCRIPT.md +851 -0
  14. package/.claude-flow-novice/templates/claude-md-templates/README.md +263 -0
  15. package/CLAUDE.md +81 -0
  16. package/README-NPM.md +0 -0
  17. package/package.json +11 -7
  18. package/scripts/build/README.md +167 -0
  19. package/scripts/build/build-config.js +27 -0
  20. package/scripts/build/build-prompt-copier.sh +30 -0
  21. package/scripts/build/performance-monitor.js +869 -0
  22. package/scripts/build/prepare-publish.js +150 -0
  23. package/scripts/build/typescript-fixer.js +621 -0
  24. package/scripts/build/unified-builder.sh +428 -0
  25. package/scripts/build/update-bin-version.js +32 -0
  26. package/scripts/dev/README.md +264 -0
  27. package/scripts/dev/claude-flow-wrapper.sh +35 -0
  28. package/scripts/dev/claude-monitor.py +419 -0
  29. package/scripts/dev/claude-sparc.sh +562 -0
  30. package/scripts/dev/claude-wrapper.sh +17 -0
  31. package/scripts/dev/demo-phase3-compliance.js +172 -0
  32. package/scripts/dev/demo-task-system.ts +224 -0
  33. package/scripts/dev/deployment-validator.js +315 -0
  34. package/scripts/dev/spawn-claude-terminal.sh +32 -0
  35. package/scripts/dev/start-portal.sh +506 -0
  36. package/scripts/dev/start-web-ui.js +15 -0
  37. package/scripts/dev/stop-portal.sh +311 -0
  38. package/scripts/dev/validate-examples.ts +288 -0
  39. package/scripts/dev/validate-phase2.cjs +451 -0
  40. package/scripts/dev/validate-phase2.js +785 -0
  41. package/scripts/dev/validate-phase3.cjs +208 -0
  42. package/scripts/dev/validate-security-remediation.js +1 -0
  43. package/scripts/legacy/README.md +272 -0
  44. package/scripts/legacy/batch-fix-ts.sh +54 -0
  45. package/scripts/legacy/build-migration.sh +105 -0
  46. package/scripts/legacy/build-monitor.js +209 -0
  47. package/scripts/legacy/build-with-filter.sh +84 -0
  48. package/scripts/legacy/build-workaround.sh +71 -0
  49. package/scripts/legacy/fix-ts-advanced.js +358 -0
  50. package/scripts/legacy/fix-ts-final.sh +50 -0
  51. package/scripts/legacy/fix-ts-targeted.sh +49 -0
  52. package/scripts/legacy/fix-typescript-errors.js +305 -0
  53. package/scripts/legacy/force-build.sh +63 -0
  54. package/scripts/legacy/optimize-performance.js +400 -0
  55. package/scripts/legacy/performance-monitor.js +263 -0
  56. package/scripts/legacy/performance-monitoring.js +532 -0
  57. package/scripts/legacy/performance-test-runner.js +645 -0
  58. package/scripts/legacy/quick-fix-ts.js +281 -0
  59. package/scripts/legacy/safe-build.sh +63 -0
  60. package/scripts/migration/README.md +434 -0
  61. package/scripts/migration/install-arm64.js +78 -0
  62. package/scripts/migration/install.js +83 -0
  63. package/scripts/migration/migrate-hooks.js +173 -0
  64. package/scripts/migration/migration-examples.ts +318 -0
  65. package/scripts/optimization/build-optimizer.js +438 -0
  66. package/scripts/optimization/config-validator.js +761 -0
  67. package/scripts/optimization/test-optimization.js +432 -0
  68. package/scripts/optimization/unified-activation.js +839 -0
  69. package/scripts/performance/ACTIVATION_COMMANDS.md +292 -0
  70. package/scripts/performance/sqlite-enhanced-activation.sh +583 -0
  71. package/scripts/performance/test-enhanced-backend.sh +504 -0
  72. package/scripts/performance-test-runner.js +698 -0
  73. package/scripts/security/README.md +339 -0
  74. package/scripts/security/install-git-hooks.sh +132 -0
  75. package/scripts/security/ruv-swarm-safe.js +74 -0
  76. package/scripts/test/README.md +236 -0
  77. package/scripts/test/check-links.ts +274 -0
  78. package/scripts/test/check-performance-regression.ts +168 -0
  79. package/scripts/test/coverage-report.ts +692 -0
  80. package/scripts/test/generate-swarm-tests.js +633 -0
  81. package/scripts/test/integration-test-validation.cjs +253 -0
  82. package/scripts/test/load-test-swarm.js +576 -0
  83. package/scripts/test/run-phase3-compliance-tests.js +427 -0
  84. package/scripts/test/test-batch-tasks.ts +29 -0
  85. package/scripts/test/test-byzantine-resolution.js +246 -0
  86. package/scripts/test/test-claude-spawn-options.sh +63 -0
  87. package/scripts/test/test-cli-wizard.js +331 -0
  88. package/scripts/test/test-comprehensive.js +401 -0
  89. package/scripts/test/test-coordination-features.ts +238 -0
  90. package/scripts/test/test-fallback-systems.js +276 -0
  91. package/scripts/test/test-init-command.ts +302 -0
  92. package/scripts/test/test-mcp.ts +251 -0
  93. package/scripts/test/test-runner.ts +568 -0
  94. package/scripts/test/test-swarm-integration.sh +92 -0
  95. package/scripts/test/test-swarm.ts +142 -0
  96. package/scripts/test/validation-summary.ts +408 -0
  97. package/scripts/utils/README.md +261 -0
  98. package/scripts/utils/clean-build-artifacts.sh +94 -0
  99. package/scripts/utils/cleanup-root.sh +69 -0
  100. package/scripts/utils/fix-cliffy-imports.js +307 -0
  101. package/scripts/utils/fix-duplicate-imports.js +114 -0
  102. package/scripts/utils/fix-error-handling.cjs +70 -0
  103. package/scripts/utils/fix-import-paths.js +104 -0
  104. package/scripts/utils/fix-imports.js +116 -0
  105. package/scripts/utils/fix-shebang.js +78 -0
  106. package/scripts/utils/fix-test-modules.js +27 -0
  107. package/scripts/utils/fix-timezone-issue-246.js +200 -0
  108. package/scripts/utils/fix-ts-comprehensive.py +182 -0
  109. package/scripts/utils/fix-ts-targeted-batch.js +250 -0
  110. package/scripts/utils/remove-benchmark-conflicts.sh +140 -0
  111. package/scripts/utils/simple-test-fixer.js +190 -0
  112. package/scripts/utils/validate-metrics-structure.cjs +144 -0
  113. package/scripts/verify-mcp-server.js +86 -0
  114. package/src/cli/simple-commands/__tests__/agent.test.js +291 -0
  115. package/src/cli/simple-commands/__tests__/memory.test.js +8 -0
  116. package/src/cli/simple-commands/__tests__/swarm.test.js +371 -0
  117. package/src/cli/simple-commands/__tests__/task.test.js +8 -0
  118. package/src/cli/simple-commands/agent.js +216 -0
  119. package/src/cli/simple-commands/analysis.js +570 -0
  120. package/src/cli/simple-commands/automation-executor.js +1603 -0
  121. package/src/cli/simple-commands/automation.js +627 -0
  122. package/src/cli/simple-commands/batch-manager.js +338 -0
  123. package/src/cli/simple-commands/claude-telemetry.js +311 -0
  124. package/src/cli/simple-commands/claude-track.js +102 -0
  125. package/src/cli/simple-commands/concurrent-display.js +348 -0
  126. package/src/cli/simple-commands/config.js +319 -0
  127. package/src/cli/simple-commands/coordination.js +307 -0
  128. package/src/cli/simple-commands/enhanced-ui-views.js +654 -0
  129. package/src/cli/simple-commands/enhanced-webui-complete.js +1038 -0
  130. package/src/cli/simple-commands/fix-hook-variables.js +363 -0
  131. package/src/cli/simple-commands/github/gh-coordinator.js +605 -0
  132. package/src/cli/simple-commands/github/github-api.js +624 -0
  133. package/src/cli/simple-commands/github/init.js +543 -0
  134. package/src/cli/simple-commands/github.js +377 -0
  135. package/src/cli/simple-commands/goal.js +145 -0
  136. package/src/cli/simple-commands/hive-mind/auto-save-middleware.js +311 -0
  137. package/src/cli/simple-commands/hive-mind/communication.js +740 -0
  138. package/src/cli/simple-commands/hive-mind/core.js +1031 -0
  139. package/src/cli/simple-commands/hive-mind/db-optimizer.js +872 -0
  140. package/src/cli/simple-commands/hive-mind/mcp-wrapper.js +1364 -0
  141. package/src/cli/simple-commands/hive-mind/memory.js +1292 -0
  142. package/src/cli/simple-commands/hive-mind/performance-optimizer.js +618 -0
  143. package/src/cli/simple-commands/hive-mind/performance-test.js +373 -0
  144. package/src/cli/simple-commands/hive-mind/queen.js +809 -0
  145. package/src/cli/simple-commands/hive-mind/session-manager.js +1223 -0
  146. package/src/cli/simple-commands/hive-mind-optimize.js +361 -0
  147. package/src/cli/simple-commands/hive-mind-wizard.js +281 -0
  148. package/src/cli/simple-commands/hive-mind.js +3112 -0
  149. package/src/cli/simple-commands/hive.js +140 -0
  150. package/src/cli/simple-commands/hook-safety.js +671 -0
  151. package/src/cli/simple-commands/hooks.js +1268 -0
  152. package/src/cli/simple-commands/init/.claude/checkpoints/1756224542.json +7 -0
  153. package/src/cli/simple-commands/init/.claude/checkpoints/1756224544.json +8 -0
  154. package/src/cli/simple-commands/init/README.md +106 -0
  155. package/src/cli/simple-commands/init/VALIDATION_ROLLBACK.md +488 -0
  156. package/src/cli/simple-commands/init/agent-copier.js +347 -0
  157. package/src/cli/simple-commands/init/batch-init.js +663 -0
  158. package/src/cli/simple-commands/init/claude-commands/claude-flow-commands.js +438 -0
  159. package/src/cli/simple-commands/init/claude-commands/optimized-claude-flow-commands.js +876 -0
  160. package/src/cli/simple-commands/init/claude-commands/optimized-slash-commands.js +356 -0
  161. package/src/cli/simple-commands/init/claude-commands/optimized-sparc-commands.js +501 -0
  162. package/src/cli/simple-commands/init/claude-commands/slash-commands.js +57 -0
  163. package/src/cli/simple-commands/init/claude-commands/sparc-commands.js +296 -0
  164. package/src/cli/simple-commands/init/copy-revised-templates.js +175 -0
  165. package/src/cli/simple-commands/init/executable-wrapper.js +122 -0
  166. package/src/cli/simple-commands/init/gitignore-updater.js +137 -0
  167. package/src/cli/simple-commands/init/help.js +110 -0
  168. package/src/cli/simple-commands/init/hive-mind-init.js +749 -0
  169. package/src/cli/simple-commands/init/index.js +1953 -0
  170. package/src/cli/simple-commands/init/performance-monitor.js +344 -0
  171. package/src/cli/simple-commands/init/rollback/backup-manager.js +542 -0
  172. package/src/cli/simple-commands/init/rollback/index.js +399 -0
  173. package/src/cli/simple-commands/init/rollback/recovery-manager.js +778 -0
  174. package/src/cli/simple-commands/init/rollback/rollback-executor.js +521 -0
  175. package/src/cli/simple-commands/init/rollback/state-tracker.js +486 -0
  176. package/src/cli/simple-commands/init/sparc/roo-readme.js +61 -0
  177. package/src/cli/simple-commands/init/sparc/roomodes-config.js +102 -0
  178. package/src/cli/simple-commands/init/sparc/workflows.js +40 -0
  179. package/src/cli/simple-commands/init/sparc-structure.js +68 -0
  180. package/src/cli/simple-commands/init/template-copier.js +640 -0
  181. package/src/cli/simple-commands/init/templates/CLAUDE.md +1185 -0
  182. package/src/cli/simple-commands/init/templates/CLAUDE.md.optimized +265 -0
  183. package/src/cli/simple-commands/init/templates/claude-flow-universal +81 -0
  184. package/src/cli/simple-commands/init/templates/claude-flow.bat +18 -0
  185. package/src/cli/simple-commands/init/templates/claude-flow.ps1 +24 -0
  186. package/src/cli/simple-commands/init/templates/claude-md.js +1101 -0
  187. package/src/cli/simple-commands/init/templates/commands/analysis/bottleneck-detect.md +162 -0
  188. package/src/cli/simple-commands/init/templates/commands/automation/auto-agent.md +122 -0
  189. package/src/cli/simple-commands/init/templates/commands/coordination/swarm-init.md +85 -0
  190. package/src/cli/simple-commands/init/templates/commands/github/github-swarm.md +121 -0
  191. package/src/cli/simple-commands/init/templates/commands/helpers/standard-checkpoint-hooks.sh +179 -0
  192. package/src/cli/simple-commands/init/templates/commands/hooks/notification.md +113 -0
  193. package/src/cli/simple-commands/init/templates/commands/hooks/post-command.md +116 -0
  194. package/src/cli/simple-commands/init/templates/commands/hooks/post-edit.md +117 -0
  195. package/src/cli/simple-commands/init/templates/commands/hooks/post-task.md +112 -0
  196. package/src/cli/simple-commands/init/templates/commands/hooks/pre-command.md +113 -0
  197. package/src/cli/simple-commands/init/templates/commands/hooks/pre-edit.md +113 -0
  198. package/src/cli/simple-commands/init/templates/commands/hooks/pre-search.md +112 -0
  199. package/src/cli/simple-commands/init/templates/commands/hooks/pre-task.md +111 -0
  200. package/src/cli/simple-commands/init/templates/commands/hooks/session-end.md +118 -0
  201. package/src/cli/simple-commands/init/templates/commands/hooks/session-restore.md +118 -0
  202. package/src/cli/simple-commands/init/templates/commands/hooks/session-start.md +117 -0
  203. package/src/cli/simple-commands/init/templates/coordination-md.js +340 -0
  204. package/src/cli/simple-commands/init/templates/coordination.md +16 -0
  205. package/src/cli/simple-commands/init/templates/enhanced-templates.js +2347 -0
  206. package/src/cli/simple-commands/init/templates/github-safe-enhanced.js +331 -0
  207. package/src/cli/simple-commands/init/templates/github-safe.js +106 -0
  208. package/src/cli/simple-commands/init/templates/memory-bank-md.js +259 -0
  209. package/src/cli/simple-commands/init/templates/memory-bank.md +16 -0
  210. package/src/cli/simple-commands/init/templates/readme-files.js +72 -0
  211. package/src/cli/simple-commands/init/templates/safe-hook-patterns.js +430 -0
  212. package/src/cli/simple-commands/init/templates/settings.json +109 -0
  213. package/src/cli/simple-commands/init/templates/settings.json.enhanced +35 -0
  214. package/src/cli/simple-commands/init/templates/sparc-modes.js +1401 -0
  215. package/src/cli/simple-commands/init/templates/verification-claude-md.js +432 -0
  216. package/src/cli/simple-commands/init/validation/config-validator.js +354 -0
  217. package/src/cli/simple-commands/init/validation/health-checker.js +599 -0
  218. package/src/cli/simple-commands/init/validation/index.js +388 -0
  219. package/src/cli/simple-commands/init/validation/mode-validator.js +387 -0
  220. package/src/cli/simple-commands/init/validation/post-init-validator.js +390 -0
  221. package/src/cli/simple-commands/init/validation/pre-init-validator.js +290 -0
  222. package/src/cli/simple-commands/init/validation/test-runner.js +488 -0
  223. package/src/cli/simple-commands/init.js +4 -0
  224. package/src/cli/simple-commands/mcp-health.js +163 -0
  225. package/src/cli/simple-commands/mcp-integration-layer.js +689 -0
  226. package/src/cli/simple-commands/mcp.js +420 -0
  227. package/src/cli/simple-commands/memory-consolidation.js +631 -0
  228. package/src/cli/simple-commands/memory.js +345 -0
  229. package/src/cli/simple-commands/migrate-hooks.js +63 -0
  230. package/src/cli/simple-commands/monitor.js +417 -0
  231. package/src/cli/simple-commands/neural.js +148 -0
  232. package/src/cli/simple-commands/pair-autofix-only.js +755 -0
  233. package/src/cli/simple-commands/pair-basic.js +751 -0
  234. package/src/cli/simple-commands/pair-old.js +623 -0
  235. package/src/cli/simple-commands/pair-working.js +849 -0
  236. package/src/cli/simple-commands/pair.js +849 -0
  237. package/src/cli/simple-commands/performance-hooks.js +149 -0
  238. package/src/cli/simple-commands/performance-metrics.js +601 -0
  239. package/src/cli/simple-commands/process-ui-enhanced.js +821 -0
  240. package/src/cli/simple-commands/process-ui.js +274 -0
  241. package/src/cli/simple-commands/realtime-update-system.js +659 -0
  242. package/src/cli/simple-commands/sparc/architecture.js +1750 -0
  243. package/src/cli/simple-commands/sparc/commands.js +575 -0
  244. package/src/cli/simple-commands/sparc/completion.js +1831 -0
  245. package/src/cli/simple-commands/sparc/coordinator.js +1045 -0
  246. package/src/cli/simple-commands/sparc/index.js +321 -0
  247. package/src/cli/simple-commands/sparc/phase-base.js +430 -0
  248. package/src/cli/simple-commands/sparc/pseudocode.js +984 -0
  249. package/src/cli/simple-commands/sparc/refinement.js +1856 -0
  250. package/src/cli/simple-commands/sparc/specification.js +736 -0
  251. package/src/cli/simple-commands/sparc-modes/architect.js +125 -0
  252. package/src/cli/simple-commands/sparc-modes/ask.js +126 -0
  253. package/src/cli/simple-commands/sparc-modes/code.js +148 -0
  254. package/src/cli/simple-commands/sparc-modes/debug.js +112 -0
  255. package/src/cli/simple-commands/sparc-modes/devops.js +137 -0
  256. package/src/cli/simple-commands/sparc-modes/docs-writer.js +38 -0
  257. package/src/cli/simple-commands/sparc-modes/generic.js +34 -0
  258. package/src/cli/simple-commands/sparc-modes/index.js +201 -0
  259. package/src/cli/simple-commands/sparc-modes/integration.js +55 -0
  260. package/src/cli/simple-commands/sparc-modes/mcp.js +38 -0
  261. package/src/cli/simple-commands/sparc-modes/monitoring.js +38 -0
  262. package/src/cli/simple-commands/sparc-modes/optimization.js +38 -0
  263. package/src/cli/simple-commands/sparc-modes/security-review.js +130 -0
  264. package/src/cli/simple-commands/sparc-modes/sparc-orchestrator.js +167 -0
  265. package/src/cli/simple-commands/sparc-modes/spec-pseudocode.js +38 -0
  266. package/src/cli/simple-commands/sparc-modes/supabase-admin.js +149 -0
  267. package/src/cli/simple-commands/sparc-modes/swarm.js +436 -0
  268. package/src/cli/simple-commands/sparc-modes/tdd.js +112 -0
  269. package/src/cli/simple-commands/sparc-modes/tutorial.js +277 -0
  270. package/src/cli/simple-commands/sparc.js +530 -0
  271. package/src/cli/simple-commands/start-ui.js +147 -0
  272. package/src/cli/simple-commands/start-wrapper.js +285 -0
  273. package/src/cli/simple-commands/start.js +2 -0
  274. package/src/cli/simple-commands/status.js +303 -0
  275. package/src/cli/simple-commands/stream-chain-clean.js +221 -0
  276. package/src/cli/simple-commands/stream-chain-fixed.js +89 -0
  277. package/src/cli/simple-commands/stream-chain-real.js +408 -0
  278. package/src/cli/simple-commands/stream-chain-working.js +323 -0
  279. package/src/cli/simple-commands/stream-chain.js +491 -0
  280. package/src/cli/simple-commands/stream-processor.js +340 -0
  281. package/src/cli/simple-commands/swarm-executor.js +253 -0
  282. package/src/cli/simple-commands/swarm-metrics-integration.js +371 -0
  283. package/src/cli/simple-commands/swarm-ui.js +741 -0
  284. package/src/cli/simple-commands/swarm-webui-integration.js +311 -0
  285. package/src/cli/simple-commands/swarm.js +2277 -0
  286. package/src/cli/simple-commands/task.js +228 -0
  287. package/src/cli/simple-commands/templates/mle-star-workflow.json +294 -0
  288. package/src/cli/simple-commands/timestamp-fix.js +104 -0
  289. package/src/cli/simple-commands/token-tracker.js +372 -0
  290. package/src/cli/simple-commands/tool-execution-framework.js +555 -0
  291. package/src/cli/simple-commands/train-and-stream.js +354 -0
  292. package/src/cli/simple-commands/training-pipeline.js +874 -0
  293. package/src/cli/simple-commands/training.js +288 -0
  294. package/src/cli/simple-commands/verification-hooks.js +336 -0
  295. package/src/cli/simple-commands/verification-integration.js +464 -0
  296. package/src/cli/simple-commands/verification-training-integration.js +646 -0
  297. package/src/cli/simple-commands/verification.js +551 -0
  298. package/src/cli/simple-commands/web-server.js +929 -0
  299. package/src/cli/simple-commands/webui-validator.js +136 -0
  300. package/src/language/README.md +503 -0
  301. package/src/language/claude-md-generator.js +618 -0
  302. package/src/language/cli.js +422 -0
  303. package/src/language/example.js +347 -0
  304. package/src/language/integration-system.js +619 -0
  305. package/src/language/language-detector.js +581 -0
@@ -0,0 +1,851 @@
1
+ # Claude Code Configuration - SPARC Development Environment (TypeScript)
2
+
3
+ ## 🚨 CRITICAL: CONCURRENT EXECUTION & FILE MANAGEMENT
4
+
5
+ **ABSOLUTE RULES**:
6
+ 1. ALL operations MUST be concurrent/parallel in a single message
7
+ 2. **NEVER save working files, text/mds and tests to the root folder**
8
+ 3. ALWAYS organize files in appropriate subdirectories
9
+ 4. **USE CLAUDE CODE'S TASK TOOL** for spawning agents concurrently, not just MCP
10
+
11
+ ### ⚡ GOLDEN RULE: "1 MESSAGE = ALL RELATED OPERATIONS"
12
+
13
+ **MANDATORY PATTERNS:**
14
+ - **TodoWrite**: ALWAYS batch ALL todos in ONE call (5-10+ todos minimum)
15
+ - **Task tool (Claude Code)**: ALWAYS spawn ALL agents in ONE message with full instructions
16
+ - **File operations**: ALWAYS batch ALL reads/writes/edits in ONE message
17
+ - **Bash commands**: ALWAYS batch ALL terminal operations in ONE message
18
+ - **Memory operations**: ALWAYS batch ALL memory store/retrieve in ONE message
19
+
20
+ ### 🎯 CRITICAL: Claude Code Task Tool for Agent Execution
21
+
22
+ **Claude Code's Task tool is the PRIMARY way to spawn agents:**
23
+ ```javascript
24
+ // ✅ CORRECT: Use Claude Code's Task tool for parallel agent execution
25
+ [Single Message]:
26
+ Task("TS researcher", "Analyze TypeScript patterns and ecosystem...", "researcher")
27
+ Task("TS coder", "Implement core TypeScript modules with strong typing...", "coder")
28
+ Task("TS tester", "Create comprehensive tests with Jest/Vitest and type testing...", "tester")
29
+ Task("TS reviewer", "Review code for TypeScript best practices and type safety...", "reviewer")
30
+ Task("TS architect", "Design system architecture with TypeScript patterns...", "system-architect")
31
+ ```
32
+
33
+ ### 📁 TypeScript File Organization Rules
34
+
35
+ **NEVER save to root folder. Use TypeScript project structure:**
36
+ - `/src` - Source TypeScript files (.ts, .tsx)
37
+ - `/dist` or `/build` - Compiled JavaScript output
38
+ - `/types` - Type declaration files (.d.ts)
39
+ - `/test` or `/__tests__` - Test files (.test.ts, .spec.ts)
40
+ - `/docs` - Documentation and markdown files
41
+ - `/config` - Configuration files
42
+ - `/scripts` - Build and utility scripts
43
+ - `/node_modules` - Dependencies (auto-generated, add to .gitignore)
44
+ - `package.json` - Project manifest and dependencies
45
+ - `tsconfig.json` - TypeScript configuration
46
+ - `package-lock.json` - Dependency lock file
47
+
48
+ ## Project Overview
49
+
50
+ This TypeScript project uses SPARC (Specification, Pseudocode, Architecture, Refinement, Completion) methodology with Claude-Flow orchestration for systematic Test-Driven Development with strong typing.
51
+
52
+ ## TypeScript-Specific SPARC Commands
53
+
54
+ ### Core Commands
55
+ - `npx claude-flow sparc modes` - List available modes
56
+ - `npx claude-flow sparc run <mode> "<ts-task>"` - Execute TypeScript-specific mode
57
+ - `npx claude-flow sparc tdd "<ts-feature>"` - Run complete TDD workflow for TypeScript
58
+ - `npx claude-flow sparc info <mode>` - Get mode details
59
+
60
+ ### TypeScript Build Commands
61
+ - `npm install` - Install dependencies
62
+ - `npm run build` - Compile TypeScript to JavaScript
63
+ - `npm run build:watch` - Watch mode compilation
64
+ - `npm run dev` - Development mode with hot reload
65
+ - `npm test` - Run tests with type checking
66
+ - `npm run test:watch` - Run tests in watch mode
67
+ - `npm run test:coverage` - Run tests with coverage
68
+ - `npm run typecheck` - Type checking only (no emit)
69
+ - `npm run lint` - Run ESLint with TypeScript rules
70
+ - `npm run lint:fix` - Fix ESLint issues automatically
71
+ - `npm run format` - Format code with Prettier
72
+
73
+ ### TypeScript Quality Commands
74
+ - `tsc --noEmit` - Type checking without compilation
75
+ - `npm run build -- --strict` - Strict compilation
76
+ - `npm run test:types` - Type-only testing
77
+ - `madge --circular --extensions ts src/` - Check circular dependencies
78
+
79
+ ## TypeScript SPARC Workflow Phases
80
+
81
+ 1. **Specification** - Requirements analysis with type definitions (`sparc run spec-pseudocode`)
82
+ 2. **Pseudocode** - Algorithm design with type annotations (`sparc run spec-pseudocode`)
83
+ 3. **Architecture** - System design with TypeScript interfaces (`sparc run architect`)
84
+ 4. **Refinement** - TDD implementation with type-safe tests (`sparc tdd`)
85
+ 5. **Completion** - Integration with full type checking (`sparc run integration`)
86
+
87
+ ## TypeScript Code Style & Best Practices
88
+
89
+ - **Strong Typing**: Use strict TypeScript configuration
90
+ - **Type Safety**: Avoid `any`, prefer specific types and interfaces
91
+ - **Generics**: Use generic types for reusable components
92
+ - **Utility Types**: Leverage TypeScript utility types (Partial, Pick, etc.)
93
+ - **Type Guards**: Implement runtime type checking
94
+ - **Module Resolution**: Use path mapping and proper imports
95
+ - **Testing**: Type-safe testing with proper mocking
96
+ - **Documentation**: TSDoc comments for type documentation
97
+
98
+ ## 🚀 TypeScript-Specific Agents (78+ Total)
99
+
100
+ ### Core TypeScript Development
101
+ `ts-coder`, `ts-architect`, `ts-tester`, `ts-reviewer`, `type-designer`
102
+
103
+ ### Type System Specialists
104
+ `interface-designer`, `generic-specialist`, `utility-type-expert`, `type-guard-creator`
105
+
106
+ ### Framework Specialists
107
+ `react-ts-dev`, `vue-ts-dev`, `angular-dev`, `node-ts-dev`, `express-ts-dev`
108
+
109
+ ### Testing & Quality
110
+ `jest-ts-expert`, `vitest-specialist`, `type-test-creator`, `ts-lint-expert`
111
+
112
+ ### Build & Tooling
113
+ `tsc-expert`, `webpack-ts-config`, `vite-ts-specialist`, `tsup-expert`
114
+
115
+ ### All Standard Agents Available
116
+ `coder`, `reviewer`, `tester`, `planner`, `researcher`, `system-architect`, `code-analyzer`, `performance-benchmarker`, `cicd-engineer`, `security-manager`
117
+
118
+ ## 🎯 TypeScript Development Patterns
119
+
120
+ ### ✅ CORRECT TYPESCRIPT WORKFLOW
121
+
122
+ ```javascript
123
+ // Step 1: Set up TypeScript project coordination
124
+ [Single Message - Coordination Setup]:
125
+ mcp__claude-flow__swarm_init { topology: "hierarchical", maxAgents: 6 }
126
+ mcp__claude-flow__agent_spawn { type: "ts-architect" }
127
+ mcp__claude-flow__agent_spawn { type: "ts-coder" }
128
+ mcp__claude-flow__agent_spawn { type: "type-designer" }
129
+
130
+ // Step 2: Parallel TypeScript development execution
131
+ [Single Message - Parallel Agent Execution]:
132
+ Task("TS architect", "Design type-safe architecture with interfaces and generics. Store type definitions in memory.", "ts-architect")
133
+ Task("Type designer", "Create comprehensive type definitions and interfaces. Focus on type safety.", "type-designer")
134
+ Task("TS coder", "Implement modules with strict TypeScript. Use proper type annotations.", "ts-coder")
135
+ Task("TS tester", "Create type-safe test suite with Jest. Include type testing.", "ts-tester")
136
+ Task("Build engineer", "Configure TypeScript build pipeline with proper type checking.", "tsc-expert")
137
+
138
+ // Batch ALL TypeScript todos
139
+ TodoWrite { todos: [
140
+ {content: "Set up tsconfig.json with strict settings", status: "in_progress", activeForm: "Setting up tsconfig.json"},
141
+ {content: "Design core type definitions and interfaces", status: "pending", activeForm: "Designing core type definitions"},
142
+ {content: "Implement modules with strong typing", status: "pending", activeForm: "Implementing modules with strong typing"},
143
+ {content: "Add comprehensive type-safe tests", status: "pending", activeForm: "Adding comprehensive type-safe tests"},
144
+ {content: "Configure ESLint for TypeScript", status: "pending", activeForm: "Configuring ESLint for TypeScript"},
145
+ {content: "Set up build pipeline with type checking", status: "pending", activeForm: "Setting up build pipeline"},
146
+ {content: "Add TSDoc documentation", status: "pending", activeForm: "Adding TSDoc documentation"},
147
+ {content: "Configure path mapping and module resolution", status: "pending", activeForm: "Configuring path mapping"}
148
+ ]}
149
+
150
+ // Parallel TypeScript file operations
151
+ Write "package.json"
152
+ Write "tsconfig.json"
153
+ Write "src/index.ts"
154
+ Write "src/types/index.ts"
155
+ Write "test/index.test.ts"
156
+ Write ".eslintrc.js"
157
+ ```
158
+
159
+ ## TypeScript Agent Coordination Protocol
160
+
161
+ ### Every TypeScript Agent MUST:
162
+
163
+ **1️⃣ BEFORE Work:**
164
+ ```bash
165
+ npx claude-flow@alpha hooks pre-task --description "[ts-task]"
166
+ npm run typecheck # Verify type checking
167
+ ```
168
+
169
+ **2️⃣ DURING Work:**
170
+ ```bash
171
+ npm run lint # Check TypeScript linting
172
+ npm run typecheck # Continuous type checking
173
+ npx claude-flow@alpha hooks post-edit --file "[file]" --memory-key "ts/[agent]/[step]"
174
+ ```
175
+
176
+ **3️⃣ AFTER Work:**
177
+ ```bash
178
+ npm run build # Compile TypeScript
179
+ npm test # Run type-safe tests
180
+ npx claude-flow@alpha hooks post-task --task-id "[task]"
181
+ ```
182
+
183
+ ## TypeScript-Specific Configurations
184
+
185
+ ### package.json Template
186
+ ```json
187
+ {
188
+ "name": "typescript-project",
189
+ "version": "1.0.0",
190
+ "description": "TypeScript project with SPARC methodology",
191
+ "main": "dist/index.js",
192
+ "types": "dist/index.d.ts",
193
+ "scripts": {
194
+ "build": "tsc",
195
+ "build:watch": "tsc --watch",
196
+ "dev": "ts-node-dev --respawn --transpile-only src/index.ts",
197
+ "start": "node dist/index.js",
198
+ "test": "jest",
199
+ "test:watch": "jest --watch",
200
+ "test:coverage": "jest --coverage",
201
+ "test:types": "tsc --noEmit",
202
+ "typecheck": "tsc --noEmit",
203
+ "lint": "eslint src/ --ext .ts,.tsx",
204
+ "lint:fix": "eslint src/ --ext .ts,.tsx --fix",
205
+ "format": "prettier --write src/",
206
+ "validate": "npm run typecheck && npm run lint && npm run test",
207
+ "clean": "rimraf dist"
208
+ },
209
+ "keywords": ["typescript", "node", "api"],
210
+ "author": "Your Name <email@example.com>",
211
+ "license": "MIT",
212
+ "dependencies": {
213
+ "express": "^4.18.0",
214
+ "cors": "^2.8.5",
215
+ "helmet": "^6.0.0",
216
+ "dotenv": "^16.0.0"
217
+ },
218
+ "devDependencies": {
219
+ "@types/node": "^18.0.0",
220
+ "@types/express": "^4.17.0",
221
+ "@types/cors": "^2.8.0",
222
+ "@types/jest": "^29.0.0",
223
+ "@typescript-eslint/eslint-plugin": "^5.50.0",
224
+ "@typescript-eslint/parser": "^5.50.0",
225
+ "eslint": "^8.0.0",
226
+ "jest": "^29.0.0",
227
+ "prettier": "^2.7.0",
228
+ "ts-jest": "^29.0.0",
229
+ "ts-node": "^10.9.0",
230
+ "ts-node-dev": "^2.0.0",
231
+ "typescript": "^4.9.0",
232
+ "rimraf": "^4.0.0"
233
+ },
234
+ "engines": {
235
+ "node": ">=16.0.0",
236
+ "npm": ">=8.0.0"
237
+ }
238
+ }
239
+ ```
240
+
241
+ ### tsconfig.json Template
242
+ ```json
243
+ {
244
+ "compilerOptions": {
245
+ "target": "ES2020",
246
+ "lib": ["ES2020"],
247
+ "module": "commonjs",
248
+ "moduleResolution": "node",
249
+ "outDir": "./dist",
250
+ "rootDir": "./src",
251
+ "strict": true,
252
+ "esModuleInterop": true,
253
+ "skipLibCheck": true,
254
+ "forceConsistentCasingInFileNames": true,
255
+ "declaration": true,
256
+ "declarationMap": true,
257
+ "sourceMap": true,
258
+ "removeComments": false,
259
+ "noImplicitAny": true,
260
+ "noImplicitReturns": true,
261
+ "noImplicitThis": true,
262
+ "noUnusedLocals": true,
263
+ "noUnusedParameters": true,
264
+ "exactOptionalPropertyTypes": true,
265
+ "noImplicitOverride": true,
266
+ "noPropertyAccessFromIndexSignature": true,
267
+ "noUncheckedIndexedAccess": true,
268
+ "resolveJsonModule": true,
269
+ "experimentalDecorators": true,
270
+ "emitDecoratorMetadata": true,
271
+ "baseUrl": "./src",
272
+ "paths": {
273
+ "@/*": ["*"],
274
+ "@/types/*": ["types/*"],
275
+ "@/utils/*": ["utils/*"],
276
+ "@/config/*": ["config/*"]
277
+ }
278
+ },
279
+ "include": [
280
+ "src/**/*"
281
+ ],
282
+ "exclude": [
283
+ "node_modules",
284
+ "dist",
285
+ "**/*.test.ts",
286
+ "**/*.spec.ts"
287
+ ],
288
+ "ts-node": {
289
+ "esm": true
290
+ }
291
+ }
292
+ ```
293
+
294
+ ### ESLint Configuration (.eslintrc.js)
295
+ ```javascript
296
+ module.exports = {
297
+ env: {
298
+ browser: true,
299
+ es2021: true,
300
+ node: true,
301
+ jest: true,
302
+ },
303
+ extends: [
304
+ 'eslint:recommended',
305
+ '@typescript-eslint/recommended',
306
+ '@typescript-eslint/recommended-requiring-type-checking',
307
+ ],
308
+ parser: '@typescript-eslint/parser',
309
+ parserOptions: {
310
+ ecmaVersion: 'latest',
311
+ sourceType: 'module',
312
+ project: './tsconfig.json',
313
+ },
314
+ plugins: [
315
+ '@typescript-eslint',
316
+ ],
317
+ rules: {
318
+ '@typescript-eslint/no-unused-vars': 'error',
319
+ '@typescript-eslint/no-explicit-any': 'error',
320
+ '@typescript-eslint/explicit-function-return-type': 'error',
321
+ '@typescript-eslint/explicit-module-boundary-types': 'error',
322
+ '@typescript-eslint/no-unsafe-assignment': 'error',
323
+ '@typescript-eslint/no-unsafe-member-access': 'error',
324
+ '@typescript-eslint/no-unsafe-call': 'error',
325
+ '@typescript-eslint/no-unsafe-return': 'error',
326
+ '@typescript-eslint/prefer-nullish-coalescing': 'error',
327
+ '@typescript-eslint/prefer-optional-chain': 'error',
328
+ '@typescript-eslint/strict-boolean-expressions': 'error',
329
+ },
330
+ };
331
+ ```
332
+
333
+ ### Jest Configuration (jest.config.js)
334
+ ```javascript
335
+ module.exports = {
336
+ preset: 'ts-jest',
337
+ testEnvironment: 'node',
338
+ roots: ['<rootDir>/src', '<rootDir>/test'],
339
+ testMatch: ['**/__tests__/**/*.ts', '**/?(*.)+(spec|test).ts'],
340
+ transform: {
341
+ '^.+\\.ts$': 'ts-jest',
342
+ },
343
+ collectCoverageFrom: [
344
+ 'src/**/*.ts',
345
+ '!src/**/*.test.ts',
346
+ '!src/**/*.spec.ts',
347
+ '!src/**/*.d.ts',
348
+ ],
349
+ coverageDirectory: 'coverage',
350
+ coverageReporters: ['text', 'lcov', 'html'],
351
+ coverageThreshold: {
352
+ global: {
353
+ branches: 80,
354
+ functions: 80,
355
+ lines: 80,
356
+ statements: 80,
357
+ },
358
+ },
359
+ moduleNameMapping: {
360
+ '^@/(.*)$': '<rootDir>/src/$1',
361
+ },
362
+ setupFilesAfterEnv: ['<rootDir>/test/setup.ts'],
363
+ };
364
+ ```
365
+
366
+ ## Type Definition Strategies
367
+
368
+ ### Interface Design
369
+ ```typescript
370
+ // Core interfaces
371
+ interface User {
372
+ readonly id: string;
373
+ name: string;
374
+ email: string;
375
+ createdAt: Date;
376
+ updatedAt: Date;
377
+ }
378
+
379
+ interface CreateUserRequest {
380
+ name: string;
381
+ email: string;
382
+ }
383
+
384
+ interface UpdateUserRequest {
385
+ name?: string;
386
+ email?: string;
387
+ }
388
+
389
+ // Generic interfaces
390
+ interface Repository<T, K = string> {
391
+ findById(id: K): Promise<T | null>;
392
+ findAll(): Promise<T[]>;
393
+ create(entity: Omit<T, 'id' | 'createdAt' | 'updatedAt'>): Promise<T>;
394
+ update(id: K, updates: Partial<T>): Promise<T | null>;
395
+ delete(id: K): Promise<boolean>;
396
+ }
397
+
398
+ // Utility types usage
399
+ type UserRepository = Repository<User>;
400
+ type PartialUser = Partial<User>;
401
+ type UserWithoutDates = Omit<User, 'createdAt' | 'updatedAt'>;
402
+ type UserEmailOnly = Pick<User, 'email'>;
403
+ ```
404
+
405
+ ### Advanced Type Patterns
406
+ ```typescript
407
+ // Discriminated unions
408
+ type ApiResponse<T> =
409
+ | { success: true; data: T }
410
+ | { success: false; error: string };
411
+
412
+ // Conditional types
413
+ type NonNullable<T> = T extends null | undefined ? never : T;
414
+
415
+ // Mapped types
416
+ type Readonly<T> = {
417
+ readonly [P in keyof T]: T[P];
418
+ };
419
+
420
+ // Template literal types
421
+ type EventName<T extends string> = `on${Capitalize<T>}`;
422
+ type UserEvents = EventName<'create' | 'update' | 'delete'>;
423
+ // Result: 'onCreate' | 'onUpdate' | 'onDelete'
424
+
425
+ // Brand types for type safety
426
+ type UserId = string & { readonly __brand: unique symbol };
427
+ type Email = string & { readonly __brand: unique symbol };
428
+
429
+ const createUserId = (id: string): UserId => id as UserId;
430
+ const createEmail = (email: string): Email => {
431
+ if (!email.includes('@')) {
432
+ throw new Error('Invalid email format');
433
+ }
434
+ return email as Email;
435
+ };
436
+ ```
437
+
438
+ ### Type Guards
439
+ ```typescript
440
+ // Type guard functions
441
+ const isString = (value: unknown): value is string => {
442
+ return typeof value === 'string';
443
+ };
444
+
445
+ const isUser = (value: unknown): value is User => {
446
+ return (
447
+ typeof value === 'object' &&
448
+ value !== null &&
449
+ 'id' in value &&
450
+ 'name' in value &&
451
+ 'email' in value &&
452
+ isString((value as User).id) &&
453
+ isString((value as User).name) &&
454
+ isString((value as User).email)
455
+ );
456
+ };
457
+
458
+ // Usage in functions
459
+ const processUser = (data: unknown): User => {
460
+ if (!isUser(data)) {
461
+ throw new Error('Invalid user data');
462
+ }
463
+ return data; // TypeScript knows this is User
464
+ };
465
+ ```
466
+
467
+ ## Testing Strategies
468
+
469
+ ### Type-Safe Unit Tests
470
+ ```typescript
471
+ // test/user.test.ts
472
+ import { User, UserService } from '../src/user';
473
+
474
+ describe('UserService', () => {
475
+ let userService: UserService;
476
+
477
+ beforeEach(() => {
478
+ userService = new UserService();
479
+ });
480
+
481
+ describe('createUser', () => {
482
+ test('should create user with valid data', async () => {
483
+ const userData = {
484
+ name: 'John Doe',
485
+ email: 'john@example.com',
486
+ };
487
+
488
+ const result = await userService.createUser(userData);
489
+
490
+ expect(result).toEqual<User>({
491
+ id: expect.any(String),
492
+ name: userData.name,
493
+ email: userData.email,
494
+ createdAt: expect.any(Date),
495
+ updatedAt: expect.any(Date),
496
+ });
497
+ });
498
+
499
+ test('should throw error for invalid email', async () => {
500
+ const userData = {
501
+ name: 'John Doe',
502
+ email: 'invalid-email',
503
+ };
504
+
505
+ await expect(userService.createUser(userData))
506
+ .rejects
507
+ .toThrow('Invalid email format');
508
+ });
509
+ });
510
+ });
511
+ ```
512
+
513
+ ### Mock Types
514
+ ```typescript
515
+ // test/mocks.ts
516
+ import { Repository } from '../src/types';
517
+
518
+ export const createMockRepository = <T>(): jest.Mocked<Repository<T>> => ({
519
+ findById: jest.fn(),
520
+ findAll: jest.fn(),
521
+ create: jest.fn(),
522
+ update: jest.fn(),
523
+ delete: jest.fn(),
524
+ });
525
+
526
+ // Usage in tests
527
+ describe('UserService with mocks', () => {
528
+ test('should call repository correctly', async () => {
529
+ const mockRepo = createMockRepository<User>();
530
+ const userService = new UserService(mockRepo);
531
+
532
+ mockRepo.findById.mockResolvedValue({
533
+ id: '1',
534
+ name: 'John',
535
+ email: 'john@example.com',
536
+ createdAt: new Date(),
537
+ updatedAt: new Date(),
538
+ });
539
+
540
+ const result = await userService.getUser('1');
541
+
542
+ expect(mockRepo.findById).toHaveBeenCalledWith('1');
543
+ expect(result).toBeDefined();
544
+ });
545
+ });
546
+ ```
547
+
548
+ ### Type Testing
549
+ ```typescript
550
+ // test/types.test.ts
551
+ import { expectType, expectError } from 'tsd';
552
+ import { User, CreateUserRequest } from '../src/types';
553
+
554
+ // Test type assignments
555
+ expectType<User>({
556
+ id: '123',
557
+ name: 'John',
558
+ email: 'john@example.com',
559
+ createdAt: new Date(),
560
+ updatedAt: new Date(),
561
+ });
562
+
563
+ // Test that certain assignments should fail
564
+ expectError<CreateUserRequest>({
565
+ id: '123', // Should not have id
566
+ name: 'John',
567
+ email: 'john@example.com',
568
+ });
569
+
570
+ // Test utility types
571
+ expectType<Partial<User>>({
572
+ name: 'John', // Only name is provided
573
+ });
574
+ ```
575
+
576
+ ## Error Handling with Types
577
+
578
+ ### Typed Error Classes
579
+ ```typescript
580
+ // Base error class
581
+ abstract class AppError extends Error {
582
+ abstract readonly statusCode: number;
583
+ abstract readonly errorCode: string;
584
+
585
+ constructor(message: string, public readonly context?: Record<string, unknown>) {
586
+ super(message);
587
+ this.name = this.constructor.name;
588
+ }
589
+ }
590
+
591
+ // Specific error types
592
+ class ValidationError extends AppError {
593
+ readonly statusCode = 400;
594
+ readonly errorCode = 'VALIDATION_ERROR';
595
+ }
596
+
597
+ class NotFoundError extends AppError {
598
+ readonly statusCode = 404;
599
+ readonly errorCode = 'NOT_FOUND';
600
+ }
601
+
602
+ class DatabaseError extends AppError {
603
+ readonly statusCode = 500;
604
+ readonly errorCode = 'DATABASE_ERROR';
605
+ }
606
+
607
+ // Type-safe error handling
608
+ type ErrorType = ValidationError | NotFoundError | DatabaseError;
609
+
610
+ const handleError = (error: ErrorType): void => {
611
+ switch (error.errorCode) {
612
+ case 'VALIDATION_ERROR':
613
+ console.log('Validation failed:', error.message);
614
+ break;
615
+ case 'NOT_FOUND':
616
+ console.log('Resource not found:', error.message);
617
+ break;
618
+ case 'DATABASE_ERROR':
619
+ console.log('Database error:', error.message);
620
+ break;
621
+ default:
622
+ // TypeScript ensures this is never reached
623
+ const _exhaustive: never = error;
624
+ break;
625
+ }
626
+ };
627
+ ```
628
+
629
+ ### Result Type Pattern
630
+ ```typescript
631
+ // Result type for error handling without exceptions
632
+ type Result<T, E = Error> =
633
+ | { success: true; data: T }
634
+ | { success: false; error: E };
635
+
636
+ const safeParseUser = (data: unknown): Result<User, ValidationError> => {
637
+ if (!isUser(data)) {
638
+ return {
639
+ success: false,
640
+ error: new ValidationError('Invalid user data'),
641
+ };
642
+ }
643
+
644
+ return {
645
+ success: true,
646
+ data: data,
647
+ };
648
+ };
649
+
650
+ // Usage
651
+ const handleUserData = (data: unknown): void => {
652
+ const result = safeParseUser(data);
653
+
654
+ if (result.success) {
655
+ console.log('User:', result.data.name);
656
+ } else {
657
+ console.error('Error:', result.error.message);
658
+ }
659
+ };
660
+ ```
661
+
662
+ ## Performance Optimization
663
+
664
+ ### Type-Level Performance
665
+ ```typescript
666
+ // Use const assertions for better inference
667
+ const config = {
668
+ apiUrl: 'https://api.example.com',
669
+ timeout: 5000,
670
+ retries: 3,
671
+ } as const;
672
+
673
+ type Config = typeof config;
674
+ // Result: { readonly apiUrl: "https://api.example.com"; readonly timeout: 5000; ... }
675
+
676
+ // Avoid deep object types in hot paths
677
+ interface OptimizedUser {
678
+ id: string;
679
+ name: string;
680
+ // Avoid nested objects in frequently used types
681
+ }
682
+
683
+ // Use branded types for compile-time safety with zero runtime cost
684
+ type ProductId = string & { readonly __brand: 'ProductId' };
685
+ type CategoryId = string & { readonly __brand: 'CategoryId' };
686
+
687
+ // These prevent mixing different ID types
688
+ const getProduct = (id: ProductId): Product => { /* ... */ };
689
+ const getCategory = (id: CategoryId): Category => { /* ... */ };
690
+ ```
691
+
692
+ ### Build Optimization
693
+ ```typescript
694
+ // tsconfig.json for production builds
695
+ {
696
+ "compilerOptions": {
697
+ "target": "ES2020",
698
+ "module": "commonjs",
699
+ "declaration": false,
700
+ "sourceMap": false,
701
+ "removeComments": true,
702
+ "importHelpers": true,
703
+ "skipLibCheck": true,
704
+ "incremental": true,
705
+ "tsBuildInfoFile": ".tsbuildinfo"
706
+ },
707
+ "exclude": [
708
+ "**/*.test.ts",
709
+ "**/*.spec.ts"
710
+ ]
711
+ }
712
+ ```
713
+
714
+ ## Documentation with TSDoc
715
+
716
+ ### Comprehensive Documentation
717
+ ```typescript
718
+ /**
719
+ * Service for managing user operations.
720
+ *
721
+ * @example
722
+ * ```typescript
723
+ * const userService = new UserService(userRepository);
724
+ * const user = await userService.createUser({
725
+ * name: 'John Doe',
726
+ * email: 'john@example.com'
727
+ * });
728
+ * ```
729
+ */
730
+ export class UserService {
731
+ constructor(private readonly userRepository: Repository<User>) {}
732
+
733
+ /**
734
+ * Creates a new user with the provided data.
735
+ *
736
+ * @param userData - The user data for creation
737
+ * @returns Promise that resolves to the created user
738
+ *
739
+ * @throws {@link ValidationError}
740
+ * Thrown when the provided user data is invalid
741
+ *
742
+ * @throws {@link DatabaseError}
743
+ * Thrown when database operation fails
744
+ *
745
+ * @example
746
+ * ```typescript
747
+ * const newUser = await userService.createUser({
748
+ * name: 'Alice Smith',
749
+ * email: 'alice@example.com'
750
+ * });
751
+ * console.log(`Created user: ${newUser.name}`);
752
+ * ```
753
+ */
754
+ async createUser(userData: CreateUserRequest): Promise<User> {
755
+ // Implementation
756
+ }
757
+
758
+ /**
759
+ * Finds a user by their unique identifier.
760
+ *
761
+ * @param id - The unique user identifier
762
+ * @returns Promise that resolves to the user or null if not found
763
+ *
764
+ * @example
765
+ * ```typescript
766
+ * const user = await userService.findUser('user-123');
767
+ * if (user) {
768
+ * console.log(`Found user: ${user.name}`);
769
+ * } else {
770
+ * console.log('User not found');
771
+ * }
772
+ * ```
773
+ */
774
+ async findUser(id: string): Promise<User | null> {
775
+ // Implementation
776
+ }
777
+ }
778
+ ```
779
+
780
+ ## CI/CD Configuration
781
+
782
+ ### GitHub Actions (.github/workflows/typescript.yml)
783
+ ```yaml
784
+ name: TypeScript CI
785
+
786
+ on:
787
+ push:
788
+ branches: [ main, develop ]
789
+ pull_request:
790
+ branches: [ main ]
791
+
792
+ jobs:
793
+ test:
794
+ runs-on: ubuntu-latest
795
+
796
+ strategy:
797
+ matrix:
798
+ node-version: [16.x, 18.x, 20.x]
799
+
800
+ steps:
801
+ - uses: actions/checkout@v3
802
+
803
+ - name: Use Node.js ${{ matrix.node-version }}
804
+ uses: actions/setup-node@v3
805
+ with:
806
+ node-version: ${{ matrix.node-version }}
807
+ cache: 'npm'
808
+
809
+ - run: npm ci
810
+
811
+ - name: Type Check
812
+ run: npm run typecheck
813
+
814
+ - name: Lint
815
+ run: npm run lint
816
+
817
+ - name: Test
818
+ run: npm run test:coverage
819
+
820
+ - name: Build
821
+ run: npm run build
822
+
823
+ - name: Upload coverage to Codecov
824
+ uses: codecov/codecov-action@v3
825
+ with:
826
+ file: ./coverage/lcov.info
827
+
828
+ type-check:
829
+ runs-on: ubuntu-latest
830
+ steps:
831
+ - uses: actions/checkout@v3
832
+ - uses: actions/setup-node@v3
833
+ with:
834
+ node-version: '18'
835
+ cache: 'npm'
836
+ - run: npm ci
837
+ - name: Type check
838
+ run: npm run typecheck
839
+ ```
840
+
841
+ ## Support Resources
842
+
843
+ - **TypeScript Handbook**: https://www.typescriptlang.org/docs/
844
+ - **TSDoc**: https://tsdoc.org/
845
+ - **TypeScript ESLint**: https://typescript-eslint.io/
846
+ - **Jest with TypeScript**: https://jestjs.io/docs/getting-started#using-typescript
847
+ - **TypeScript Deep Dive**: https://basarat.gitbook.io/typescript/
848
+
849
+ ---
850
+
851
+ Remember: **Claude Flow coordinates, Claude Code creates TypeScript!**