agentic-qe 1.0.5 → 1.2.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 (383) hide show
  1. package/.claude/agents/qe-coverage-analyzer.md +8 -0
  2. package/.claude/agents/qe-flaky-test-hunter.md +9 -1
  3. package/.claude/agents/qe-quality-analyzer.md +405 -0
  4. package/.claude/agents/qe-test-generator.md +7 -0
  5. package/.claude/agents/reasoning/agent.md +816 -0
  6. package/.claude/agents/reasoning/goal-planner.md +73 -0
  7. package/.claude/settings.json +21 -20
  8. package/.claude/skills/README.md +124 -0
  9. package/.claude/skills/agentdb-advanced/SKILL.md +550 -0
  10. package/.claude/skills/agentdb-learning/SKILL.md +545 -0
  11. package/.claude/skills/agentdb-memory-patterns/SKILL.md +339 -0
  12. package/.claude/skills/agentdb-optimization/SKILL.md +509 -0
  13. package/.claude/skills/agentdb-vector-search/SKILL.md +339 -0
  14. package/.claude/skills/agentic-quality-engineering/SKILL.md +604 -0
  15. package/.claude/skills/api-testing-patterns/SKILL.md +686 -0
  16. package/.claude/skills/bug-reporting-excellence/SKILL.md +632 -0
  17. package/.claude/skills/code-review-quality/SKILL.md +683 -0
  18. package/.claude/skills/consultancy-practices/SKILL.md +540 -0
  19. package/.claude/skills/context-driven-testing/SKILL.md +466 -0
  20. package/.claude/skills/exploratory-testing-advanced/SKILL.md +676 -0
  21. package/.claude/skills/flow-nexus-neural/SKILL.md +738 -0
  22. package/.claude/skills/flow-nexus-platform/SKILL.md +1157 -0
  23. package/.claude/skills/flow-nexus-swarm/SKILL.md +610 -0
  24. package/.claude/skills/github-code-review/SKILL.md +1140 -0
  25. package/.claude/skills/github-multi-repo/SKILL.md +874 -0
  26. package/.claude/skills/github-project-management/SKILL.md +1277 -0
  27. package/.claude/skills/github-release-management/SKILL.md +1081 -0
  28. package/.claude/skills/github-workflow-automation/SKILL.md +1065 -0
  29. package/.claude/skills/hive-mind-advanced/SKILL.md +712 -0
  30. package/.claude/skills/holistic-testing-pact/SKILL.md +225 -0
  31. package/.claude/skills/hooks-automation/SKILL.md +1201 -0
  32. package/.claude/skills/pair-programming/SKILL.md +1202 -0
  33. package/.claude/skills/performance-analysis/SKILL.md +563 -0
  34. package/.claude/skills/performance-testing/SKILL.md +662 -0
  35. package/.claude/skills/quality-metrics/SKILL.md +592 -0
  36. package/.claude/skills/reasoningbank-agentdb/SKILL.md +446 -0
  37. package/.claude/skills/reasoningbank-intelligence/SKILL.md +201 -0
  38. package/.claude/skills/refactoring-patterns/SKILL.md +778 -0
  39. package/.claude/skills/risk-based-testing/SKILL.md +721 -0
  40. package/.claude/skills/security-testing/SKILL.md +651 -0
  41. package/.claude/skills/skill-builder/SKILL.md +910 -0
  42. package/.claude/skills/sparc-methodology/SKILL.md +1115 -0
  43. package/.claude/skills/stream-chain/SKILL.md +563 -0
  44. package/.claude/skills/swarm-advanced/SKILL.md +973 -0
  45. package/.claude/skills/swarm-orchestration/SKILL.md +179 -0
  46. package/.claude/skills/tdd-london-chicago/SKILL.md +567 -0
  47. package/.claude/skills/technical-writing/SKILL.md +235 -0
  48. package/.claude/skills/test-automation-strategy/SKILL.md +842 -0
  49. package/.claude/skills/verification-quality/SKILL.md +649 -0
  50. package/.claude/skills/xp-practices/SKILL.md +671 -0
  51. package/.claude/statusline-command.sh +176 -0
  52. package/CHANGELOG.md +645 -1
  53. package/CONTRIBUTING.md +51 -0
  54. package/README.md +758 -162
  55. package/bin/aqe +90 -938
  56. package/config/improvement-loop.config.ts +323 -0
  57. package/config/neural-agent.config.ts +197 -0
  58. package/dist/adapters/MemoryStoreAdapter.d.ts +16 -16
  59. package/dist/adapters/MemoryStoreAdapter.d.ts.map +1 -1
  60. package/dist/adapters/MemoryStoreAdapter.js +22 -16
  61. package/dist/adapters/MemoryStoreAdapter.js.map +1 -1
  62. package/dist/agents/BaseAgent.d.ts +69 -0
  63. package/dist/agents/BaseAgent.d.ts.map +1 -1
  64. package/dist/agents/BaseAgent.js +382 -1
  65. package/dist/agents/BaseAgent.js.map +1 -1
  66. package/dist/agents/CoverageAnalyzerAgent.d.ts +69 -3
  67. package/dist/agents/CoverageAnalyzerAgent.d.ts.map +1 -1
  68. package/dist/agents/CoverageAnalyzerAgent.js +418 -51
  69. package/dist/agents/CoverageAnalyzerAgent.js.map +1 -1
  70. package/dist/agents/DeploymentReadinessAgent.d.ts.map +1 -1
  71. package/dist/agents/DeploymentReadinessAgent.js +13 -13
  72. package/dist/agents/DeploymentReadinessAgent.js.map +1 -1
  73. package/dist/agents/FlakyTestHunterAgent.d.ts +76 -4
  74. package/dist/agents/FlakyTestHunterAgent.d.ts.map +1 -1
  75. package/dist/agents/FlakyTestHunterAgent.js +375 -13
  76. package/dist/agents/FlakyTestHunterAgent.js.map +1 -1
  77. package/dist/agents/FleetCommanderAgent.d.ts.map +1 -1
  78. package/dist/agents/FleetCommanderAgent.js +2 -2
  79. package/dist/agents/FleetCommanderAgent.js.map +1 -1
  80. package/dist/agents/LearningAgent.d.ts +84 -0
  81. package/dist/agents/LearningAgent.d.ts.map +1 -0
  82. package/dist/agents/LearningAgent.js +197 -0
  83. package/dist/agents/LearningAgent.js.map +1 -0
  84. package/dist/agents/NeuralAgentExtension.d.ts +117 -0
  85. package/dist/agents/NeuralAgentExtension.d.ts.map +1 -0
  86. package/dist/agents/NeuralAgentExtension.js +288 -0
  87. package/dist/agents/NeuralAgentExtension.js.map +1 -0
  88. package/dist/agents/PerformanceTesterAgent.d.ts.map +1 -1
  89. package/dist/agents/PerformanceTesterAgent.js +4 -3
  90. package/dist/agents/PerformanceTesterAgent.js.map +1 -1
  91. package/dist/agents/ProductionIntelligenceAgent.js +7 -7
  92. package/dist/agents/ProductionIntelligenceAgent.js.map +1 -1
  93. package/dist/agents/QualityAnalyzerAgent.d.ts.map +1 -1
  94. package/dist/agents/QualityAnalyzerAgent.js +2 -2
  95. package/dist/agents/QualityAnalyzerAgent.js.map +1 -1
  96. package/dist/agents/QualityGateAgent.js +5 -5
  97. package/dist/agents/QualityGateAgent.js.map +1 -1
  98. package/dist/agents/RegressionRiskAnalyzerAgent.js +7 -7
  99. package/dist/agents/RegressionRiskAnalyzerAgent.js.map +1 -1
  100. package/dist/agents/RequirementsValidatorAgent.d.ts.map +1 -1
  101. package/dist/agents/RequirementsValidatorAgent.js +1 -1
  102. package/dist/agents/RequirementsValidatorAgent.js.map +1 -1
  103. package/dist/agents/SecurityScannerAgent.js +6 -6
  104. package/dist/agents/SecurityScannerAgent.js.map +1 -1
  105. package/dist/agents/TestExecutorAgent.d.ts.map +1 -1
  106. package/dist/agents/TestExecutorAgent.js +1 -3
  107. package/dist/agents/TestExecutorAgent.js.map +1 -1
  108. package/dist/agents/TestGeneratorAgent.d.ts +53 -2
  109. package/dist/agents/TestGeneratorAgent.d.ts.map +1 -1
  110. package/dist/agents/TestGeneratorAgent.js +372 -31
  111. package/dist/agents/TestGeneratorAgent.js.map +1 -1
  112. package/dist/agents/mixins/NeuralCapableMixin.d.ts +130 -0
  113. package/dist/agents/mixins/NeuralCapableMixin.d.ts.map +1 -0
  114. package/dist/agents/mixins/NeuralCapableMixin.js +358 -0
  115. package/dist/agents/mixins/NeuralCapableMixin.js.map +1 -0
  116. package/dist/agents/mixins/QUICCapableMixin.d.ts +34 -0
  117. package/dist/agents/mixins/QUICCapableMixin.d.ts.map +1 -0
  118. package/dist/agents/mixins/QUICCapableMixin.js +346 -0
  119. package/dist/agents/mixins/QUICCapableMixin.js.map +1 -0
  120. package/dist/cli/commands/agent/index.d.ts +5 -0
  121. package/dist/cli/commands/agent/index.d.ts.map +1 -1
  122. package/dist/cli/commands/agent/index.js +11 -6
  123. package/dist/cli/commands/agent/index.js.map +1 -1
  124. package/dist/cli/commands/agent/kill.d.ts +13 -0
  125. package/dist/cli/commands/agent/kill.d.ts.map +1 -0
  126. package/dist/cli/commands/agent/kill.js +65 -0
  127. package/dist/cli/commands/agent/kill.js.map +1 -0
  128. package/dist/cli/commands/agent/list.d.ts +19 -0
  129. package/dist/cli/commands/agent/list.d.ts.map +1 -0
  130. package/dist/cli/commands/agent/list.js +92 -0
  131. package/dist/cli/commands/agent/list.js.map +1 -0
  132. package/dist/cli/commands/agent/logs.d.ts +14 -0
  133. package/dist/cli/commands/agent/logs.d.ts.map +1 -0
  134. package/dist/cli/commands/agent/logs.js +77 -0
  135. package/dist/cli/commands/agent/logs.js.map +1 -0
  136. package/dist/cli/commands/agent/metrics.d.ts +21 -0
  137. package/dist/cli/commands/agent/metrics.d.ts.map +1 -0
  138. package/dist/cli/commands/agent/metrics.js +87 -0
  139. package/dist/cli/commands/agent/metrics.js.map +1 -0
  140. package/dist/cli/commands/agent/spawn.d.ts +28 -0
  141. package/dist/cli/commands/agent/spawn.d.ts.map +1 -0
  142. package/dist/cli/commands/agent/spawn.js +83 -0
  143. package/dist/cli/commands/agent/spawn.js.map +1 -0
  144. package/dist/cli/commands/improve/index.d.ts +70 -0
  145. package/dist/cli/commands/improve/index.d.ts.map +1 -0
  146. package/dist/cli/commands/improve/index.js +530 -0
  147. package/dist/cli/commands/improve/index.js.map +1 -0
  148. package/dist/cli/commands/init.d.ts +57 -0
  149. package/dist/cli/commands/init.d.ts.map +1 -1
  150. package/dist/cli/commands/init.js +1127 -42
  151. package/dist/cli/commands/init.js.map +1 -1
  152. package/dist/cli/commands/learn/index.d.ts +68 -0
  153. package/dist/cli/commands/learn/index.d.ts.map +1 -0
  154. package/dist/cli/commands/learn/index.js +431 -0
  155. package/dist/cli/commands/learn/index.js.map +1 -0
  156. package/dist/cli/commands/patterns/index.d.ts +75 -0
  157. package/dist/cli/commands/patterns/index.d.ts.map +1 -0
  158. package/dist/cli/commands/patterns/index.js +502 -0
  159. package/dist/cli/commands/patterns/index.js.map +1 -0
  160. package/dist/cli/commands/skills/index.d.ts +51 -0
  161. package/dist/cli/commands/skills/index.d.ts.map +1 -0
  162. package/dist/cli/commands/skills/index.js +364 -0
  163. package/dist/cli/commands/skills/index.js.map +1 -0
  164. package/dist/cli/index.js +458 -8
  165. package/dist/cli/index.js.map +1 -1
  166. package/dist/core/EventBus.d.ts +38 -0
  167. package/dist/core/EventBus.d.ts.map +1 -1
  168. package/dist/core/EventBus.js +176 -31
  169. package/dist/core/EventBus.js.map +1 -1
  170. package/dist/core/FleetManager.d.ts +35 -1
  171. package/dist/core/FleetManager.d.ts.map +1 -1
  172. package/dist/core/FleetManager.js +121 -45
  173. package/dist/core/FleetManager.js.map +1 -1
  174. package/dist/core/MemoryManager.d.ts +19 -1
  175. package/dist/core/MemoryManager.d.ts.map +1 -1
  176. package/dist/core/MemoryManager.js +25 -1
  177. package/dist/core/MemoryManager.js.map +1 -1
  178. package/dist/core/embeddings/EmbeddingCache.d.ts +134 -0
  179. package/dist/core/embeddings/EmbeddingCache.d.ts.map +1 -0
  180. package/dist/core/embeddings/EmbeddingCache.js +239 -0
  181. package/dist/core/embeddings/EmbeddingCache.js.map +1 -0
  182. package/dist/core/embeddings/EmbeddingGenerator.d.ts +224 -0
  183. package/dist/core/embeddings/EmbeddingGenerator.d.ts.map +1 -0
  184. package/dist/core/embeddings/EmbeddingGenerator.js +459 -0
  185. package/dist/core/embeddings/EmbeddingGenerator.js.map +1 -0
  186. package/dist/core/embeddings/index.d.ts +15 -0
  187. package/dist/core/embeddings/index.d.ts.map +1 -0
  188. package/dist/core/embeddings/index.js +22 -0
  189. package/dist/core/embeddings/index.js.map +1 -0
  190. package/dist/core/memory/AgentDBIntegration.d.ts +35 -0
  191. package/dist/core/memory/AgentDBIntegration.d.ts.map +1 -0
  192. package/dist/core/memory/AgentDBIntegration.js +75 -0
  193. package/dist/core/memory/AgentDBIntegration.js.map +1 -0
  194. package/dist/core/memory/AgentDBManager.d.ts +200 -0
  195. package/dist/core/memory/AgentDBManager.d.ts.map +1 -0
  196. package/dist/core/memory/AgentDBManager.js +263 -0
  197. package/dist/core/memory/AgentDBManager.js.map +1 -0
  198. package/dist/core/memory/AgentDBService.d.ts +160 -0
  199. package/dist/core/memory/AgentDBService.d.ts.map +1 -0
  200. package/dist/core/memory/AgentDBService.js +450 -0
  201. package/dist/core/memory/AgentDBService.js.map +1 -0
  202. package/dist/core/memory/RealAgentDBAdapter.d.ts +51 -0
  203. package/dist/core/memory/RealAgentDBAdapter.d.ts.map +1 -0
  204. package/dist/core/memory/RealAgentDBAdapter.js +230 -0
  205. package/dist/core/memory/RealAgentDBAdapter.js.map +1 -0
  206. package/dist/core/memory/ReasoningBankAdapter.d.ts +58 -0
  207. package/dist/core/memory/ReasoningBankAdapter.d.ts.map +1 -0
  208. package/dist/core/memory/ReasoningBankAdapter.js +80 -0
  209. package/dist/core/memory/ReasoningBankAdapter.js.map +1 -0
  210. package/dist/core/memory/SwarmMemoryManager.d.ts +79 -2
  211. package/dist/core/memory/SwarmMemoryManager.d.ts.map +1 -1
  212. package/dist/core/memory/SwarmMemoryManager.js +243 -52
  213. package/dist/core/memory/SwarmMemoryManager.js.map +1 -1
  214. package/dist/core/memory/index.d.ts +4 -0
  215. package/dist/core/memory/index.d.ts.map +1 -1
  216. package/dist/core/memory/index.js +9 -1
  217. package/dist/core/memory/index.js.map +1 -1
  218. package/dist/core/neural/NeuralTrainer.d.ts +137 -0
  219. package/dist/core/neural/NeuralTrainer.d.ts.map +1 -0
  220. package/dist/core/neural/NeuralTrainer.js +543 -0
  221. package/dist/core/neural/NeuralTrainer.js.map +1 -0
  222. package/dist/core/neural/index.d.ts +8 -0
  223. package/dist/core/neural/index.d.ts.map +1 -0
  224. package/dist/core/neural/index.js +24 -0
  225. package/dist/core/neural/index.js.map +1 -0
  226. package/dist/core/neural/types.d.ts +216 -0
  227. package/dist/core/neural/types.d.ts.map +1 -0
  228. package/dist/core/neural/types.js +8 -0
  229. package/dist/core/neural/types.js.map +1 -0
  230. package/dist/core/security/CertificateValidator.d.ts +130 -0
  231. package/dist/core/security/CertificateValidator.d.ts.map +1 -0
  232. package/dist/core/security/CertificateValidator.js +376 -0
  233. package/dist/core/security/CertificateValidator.js.map +1 -0
  234. package/dist/core/transport/QUICTransport.d.ts +62 -0
  235. package/dist/core/transport/QUICTransport.d.ts.map +1 -0
  236. package/dist/core/transport/QUICTransport.js +381 -0
  237. package/dist/core/transport/QUICTransport.js.map +1 -0
  238. package/dist/core/transport/SecureQUICTransport.d.ts +71 -0
  239. package/dist/core/transport/SecureQUICTransport.d.ts.map +1 -0
  240. package/dist/core/transport/SecureQUICTransport.js +253 -0
  241. package/dist/core/transport/SecureQUICTransport.js.map +1 -0
  242. package/dist/index.d.ts +10 -0
  243. package/dist/index.d.ts.map +1 -1
  244. package/dist/index.js +10 -0
  245. package/dist/index.js.map +1 -1
  246. package/dist/learning/AdvancedFeatureExtractor.d.ts +123 -0
  247. package/dist/learning/AdvancedFeatureExtractor.d.ts.map +1 -0
  248. package/dist/learning/AdvancedFeatureExtractor.js +423 -0
  249. package/dist/learning/AdvancedFeatureExtractor.js.map +1 -0
  250. package/dist/learning/FlakyFixRecommendations.d.ts +40 -0
  251. package/dist/learning/FlakyFixRecommendations.d.ts.map +1 -0
  252. package/dist/learning/FlakyFixRecommendations.js +247 -0
  253. package/dist/learning/FlakyFixRecommendations.js.map +1 -0
  254. package/dist/learning/FlakyPredictionModel.d.ts +67 -0
  255. package/dist/learning/FlakyPredictionModel.d.ts.map +1 -0
  256. package/dist/learning/FlakyPredictionModel.js +336 -0
  257. package/dist/learning/FlakyPredictionModel.js.map +1 -0
  258. package/dist/learning/FlakyTestDetector.d.ts +55 -0
  259. package/dist/learning/FlakyTestDetector.d.ts.map +1 -0
  260. package/dist/learning/FlakyTestDetector.js +237 -0
  261. package/dist/learning/FlakyTestDetector.js.map +1 -0
  262. package/dist/learning/ImprovementLoop.d.ts +133 -0
  263. package/dist/learning/ImprovementLoop.d.ts.map +1 -0
  264. package/dist/learning/ImprovementLoop.js +412 -0
  265. package/dist/learning/ImprovementLoop.js.map +1 -0
  266. package/dist/learning/ImprovementWorker.d.ts +83 -0
  267. package/dist/learning/ImprovementWorker.d.ts.map +1 -0
  268. package/dist/learning/ImprovementWorker.js +164 -0
  269. package/dist/learning/ImprovementWorker.js.map +1 -0
  270. package/dist/learning/LearningEngine.d.ts +144 -0
  271. package/dist/learning/LearningEngine.d.ts.map +1 -0
  272. package/dist/learning/LearningEngine.js +531 -0
  273. package/dist/learning/LearningEngine.js.map +1 -0
  274. package/dist/learning/NeuralPatternMatcher.d.ts +184 -0
  275. package/dist/learning/NeuralPatternMatcher.d.ts.map +1 -0
  276. package/dist/learning/NeuralPatternMatcher.js +702 -0
  277. package/dist/learning/NeuralPatternMatcher.js.map +1 -0
  278. package/dist/learning/NeuralTrainer.d.ts +209 -0
  279. package/dist/learning/NeuralTrainer.d.ts.map +1 -0
  280. package/dist/learning/NeuralTrainer.js +478 -0
  281. package/dist/learning/NeuralTrainer.js.map +1 -0
  282. package/dist/learning/PerformanceTracker.d.ts +118 -0
  283. package/dist/learning/PerformanceTracker.d.ts.map +1 -0
  284. package/dist/learning/PerformanceTracker.js +376 -0
  285. package/dist/learning/PerformanceTracker.js.map +1 -0
  286. package/dist/learning/StatisticalAnalysis.d.ts +47 -0
  287. package/dist/learning/StatisticalAnalysis.d.ts.map +1 -0
  288. package/dist/learning/StatisticalAnalysis.js +170 -0
  289. package/dist/learning/StatisticalAnalysis.js.map +1 -0
  290. package/dist/learning/SwarmIntegration.d.ts +107 -0
  291. package/dist/learning/SwarmIntegration.d.ts.map +1 -0
  292. package/dist/learning/SwarmIntegration.js +191 -0
  293. package/dist/learning/SwarmIntegration.js.map +1 -0
  294. package/dist/learning/index.d.ts +16 -0
  295. package/dist/learning/index.d.ts.map +1 -0
  296. package/dist/learning/index.js +32 -0
  297. package/dist/learning/index.js.map +1 -0
  298. package/dist/learning/types.d.ts +289 -0
  299. package/dist/learning/types.d.ts.map +1 -0
  300. package/dist/learning/types.js +25 -0
  301. package/dist/learning/types.js.map +1 -0
  302. package/dist/mcp/MCPToolRegistry.d.ts +34 -0
  303. package/dist/mcp/MCPToolRegistry.d.ts.map +1 -0
  304. package/dist/mcp/MCPToolRegistry.js +48 -0
  305. package/dist/mcp/MCPToolRegistry.js.map +1 -0
  306. package/dist/mcp/handlers/phase2/Phase2Tools.d.ts +175 -0
  307. package/dist/mcp/handlers/phase2/Phase2Tools.d.ts.map +1 -0
  308. package/dist/mcp/handlers/phase2/Phase2Tools.js +693 -0
  309. package/dist/mcp/handlers/phase2/Phase2Tools.js.map +1 -0
  310. package/dist/mcp/server.d.ts +4 -4
  311. package/dist/mcp/server.d.ts.map +1 -1
  312. package/dist/mcp/server.js +94 -0
  313. package/dist/mcp/server.js.map +1 -1
  314. package/dist/mcp/services/AgentRegistry.d.ts.map +1 -1
  315. package/dist/mcp/services/AgentRegistry.js +7 -1
  316. package/dist/mcp/services/AgentRegistry.js.map +1 -1
  317. package/dist/mcp/tools.d.ts +15 -0
  318. package/dist/mcp/tools.d.ts.map +1 -1
  319. package/dist/mcp/tools.js +17 -1
  320. package/dist/mcp/tools.js.map +1 -1
  321. package/dist/reasoning/CodeSignatureGenerator.d.ts +98 -0
  322. package/dist/reasoning/CodeSignatureGenerator.d.ts.map +1 -0
  323. package/dist/reasoning/CodeSignatureGenerator.js +427 -0
  324. package/dist/reasoning/CodeSignatureGenerator.js.map +1 -0
  325. package/dist/reasoning/PatternClassifier.d.ts +98 -0
  326. package/dist/reasoning/PatternClassifier.d.ts.map +1 -0
  327. package/dist/reasoning/PatternClassifier.js +345 -0
  328. package/dist/reasoning/PatternClassifier.js.map +1 -0
  329. package/dist/reasoning/PatternExtractor.d.ts +131 -0
  330. package/dist/reasoning/PatternExtractor.d.ts.map +1 -0
  331. package/dist/reasoning/PatternExtractor.js +539 -0
  332. package/dist/reasoning/PatternExtractor.js.map +1 -0
  333. package/dist/reasoning/PatternMemoryIntegration.d.ts +102 -0
  334. package/dist/reasoning/PatternMemoryIntegration.d.ts.map +1 -0
  335. package/dist/reasoning/PatternMemoryIntegration.js +336 -0
  336. package/dist/reasoning/PatternMemoryIntegration.js.map +1 -0
  337. package/dist/reasoning/QEReasoningBank.d.ts +121 -0
  338. package/dist/reasoning/QEReasoningBank.d.ts.map +1 -0
  339. package/dist/reasoning/QEReasoningBank.js +235 -0
  340. package/dist/reasoning/QEReasoningBank.js.map +1 -0
  341. package/dist/reasoning/TestTemplateCreator.d.ts +95 -0
  342. package/dist/reasoning/TestTemplateCreator.d.ts.map +1 -0
  343. package/dist/reasoning/TestTemplateCreator.js +535 -0
  344. package/dist/reasoning/TestTemplateCreator.js.map +1 -0
  345. package/dist/reasoning/index.d.ts +10 -0
  346. package/dist/reasoning/index.d.ts.map +1 -0
  347. package/dist/reasoning/index.js +31 -0
  348. package/dist/reasoning/index.js.map +1 -0
  349. package/dist/reasoning/types.d.ts +717 -0
  350. package/dist/reasoning/types.d.ts.map +1 -0
  351. package/dist/reasoning/types.js +57 -0
  352. package/dist/reasoning/types.js.map +1 -0
  353. package/dist/transport/QUICTransport.d.ts +340 -0
  354. package/dist/transport/QUICTransport.d.ts.map +1 -0
  355. package/dist/transport/QUICTransport.js +814 -0
  356. package/dist/transport/QUICTransport.js.map +1 -0
  357. package/dist/transport/UDPTransport.d.ts +348 -0
  358. package/dist/transport/UDPTransport.d.ts.map +1 -0
  359. package/dist/transport/UDPTransport.js +820 -0
  360. package/dist/transport/UDPTransport.js.map +1 -0
  361. package/dist/types/errors.d.ts +1 -1
  362. package/dist/types/index.d.ts +41 -0
  363. package/dist/types/index.d.ts.map +1 -1
  364. package/dist/types/index.js +2 -0
  365. package/dist/types/index.js.map +1 -1
  366. package/dist/types/pattern.types.d.ts +364 -0
  367. package/dist/types/pattern.types.d.ts.map +1 -0
  368. package/dist/types/pattern.types.js +60 -0
  369. package/dist/types/pattern.types.js.map +1 -0
  370. package/dist/types/quic.d.ts +339 -0
  371. package/dist/types/quic.d.ts.map +1 -0
  372. package/dist/types/quic.js +48 -0
  373. package/dist/types/quic.js.map +1 -0
  374. package/dist/utils/Config.js +1 -1
  375. package/dist/utils/Config.js.map +1 -1
  376. package/dist/utils/Database.d.ts +14 -0
  377. package/dist/utils/Database.d.ts.map +1 -1
  378. package/dist/utils/Database.js +51 -4
  379. package/dist/utils/Database.js.map +1 -1
  380. package/dist/utils/Logger.d.ts.map +1 -1
  381. package/dist/utils/Logger.js +111 -26
  382. package/dist/utils/Logger.js.map +1 -1
  383. package/package.json +54 -9
@@ -0,0 +1,1201 @@
1
+ ---
2
+ name: Hooks Automation
3
+ description: Automated coordination, formatting, and learning from Claude Code operations using intelligent hooks with MCP integration. Includes pre/post task hooks, session management, Git integration, memory coordination, and neural pattern training for enhanced development workflows.
4
+ ---
5
+
6
+ # Hooks Automation
7
+
8
+ Intelligent automation system that coordinates, validates, and learns from Claude Code operations through hooks integrated with MCP tools and neural pattern training.
9
+
10
+ ## What This Skill Does
11
+
12
+ This skill provides a comprehensive hook system that automatically manages development operations, coordinates swarm agents, maintains session state, and continuously learns from coding patterns. It enables automated agent assignment, code formatting, performance tracking, and cross-session memory persistence.
13
+
14
+ **Key Capabilities:**
15
+ - **Pre-Operation Hooks**: Validate, prepare, and auto-assign agents before operations
16
+ - **Post-Operation Hooks**: Format, analyze, and train patterns after operations
17
+ - **Session Management**: Persist state, restore context, generate summaries
18
+ - **Memory Coordination**: Synchronize knowledge across swarm agents
19
+ - **Git Integration**: Automated commit hooks with quality verification
20
+ - **Neural Training**: Continuous learning from successful patterns
21
+ - **MCP Integration**: Seamless coordination with swarm tools
22
+
23
+ ## Prerequisites
24
+
25
+ **Required:**
26
+ - Claude Flow CLI installed (`npm install -g claude-flow@alpha`)
27
+ - Claude Code with hooks enabled
28
+ - `.claude/settings.json` with hook configurations
29
+
30
+ **Optional:**
31
+ - MCP servers configured (claude-flow, ruv-swarm, flow-nexus)
32
+ - Git repository for version control
33
+ - Testing framework for quality verification
34
+
35
+ ## Quick Start
36
+
37
+ ### Initialize Hooks System
38
+
39
+ ```bash
40
+ # Initialize with default hooks configuration
41
+ npx claude-flow init --hooks
42
+ ```
43
+
44
+ This creates:
45
+ - `.claude/settings.json` with pre-configured hooks
46
+ - Hook command documentation in `.claude/commands/hooks/`
47
+ - Default hook handlers for common operations
48
+
49
+ ### Basic Hook Usage
50
+
51
+ ```bash
52
+ # Pre-task hook (auto-spawns agents)
53
+ npx claude-flow hook pre-task --description "Implement authentication"
54
+
55
+ # Post-edit hook (auto-formats and stores in memory)
56
+ npx claude-flow hook post-edit --file "src/auth.js" --memory-key "auth/login"
57
+
58
+ # Session end hook (saves state and metrics)
59
+ npx claude-flow hook session-end --session-id "dev-session" --export-metrics
60
+ ```
61
+
62
+ ---
63
+
64
+ ## Complete Guide
65
+
66
+ ### Available Hooks
67
+
68
+ #### Pre-Operation Hooks
69
+
70
+ Hooks that execute BEFORE operations to prepare and validate:
71
+
72
+ **pre-edit** - Validate and assign agents before file modifications
73
+ ```bash
74
+ npx claude-flow hook pre-edit [options]
75
+
76
+ Options:
77
+ --file, -f <path> File path to be edited
78
+ --auto-assign-agent Automatically assign best agent (default: true)
79
+ --validate-syntax Pre-validate syntax before edit
80
+ --check-conflicts Check for merge conflicts
81
+ --backup-file Create backup before editing
82
+
83
+ Examples:
84
+ npx claude-flow hook pre-edit --file "src/auth/login.js"
85
+ npx claude-flow hook pre-edit -f "config/db.js" --validate-syntax
86
+ npx claude-flow hook pre-edit -f "production.env" --backup-file --check-conflicts
87
+ ```
88
+
89
+ **Features:**
90
+ - Auto agent assignment based on file type
91
+ - Syntax validation to prevent broken code
92
+ - Conflict detection for concurrent edits
93
+ - Automatic file backups for safety
94
+
95
+ **pre-bash** - Check command safety and resource requirements
96
+ ```bash
97
+ npx claude-flow hook pre-bash --command <cmd>
98
+
99
+ Options:
100
+ --command, -c <cmd> Command to validate
101
+ --check-safety Verify command safety (default: true)
102
+ --estimate-resources Estimate resource usage
103
+ --require-confirmation Request user confirmation for risky commands
104
+
105
+ Examples:
106
+ npx claude-flow hook pre-bash -c "rm -rf /tmp/cache"
107
+ npx claude-flow hook pre-bash --command "docker build ." --estimate-resources
108
+ ```
109
+
110
+ **Features:**
111
+ - Command safety validation
112
+ - Resource requirement estimation
113
+ - Destructive command confirmation
114
+ - Permission checks
115
+
116
+ **pre-task** - Auto-spawn agents and prepare for complex tasks
117
+ ```bash
118
+ npx claude-flow hook pre-task [options]
119
+
120
+ Options:
121
+ --description, -d <text> Task description for context
122
+ --auto-spawn-agents Automatically spawn required agents (default: true)
123
+ --load-memory Load relevant memory from previous sessions
124
+ --optimize-topology Select optimal swarm topology
125
+ --estimate-complexity Analyze task complexity
126
+
127
+ Examples:
128
+ npx claude-flow hook pre-task --description "Implement user authentication"
129
+ npx claude-flow hook pre-task -d "Continue API dev" --load-memory
130
+ npx claude-flow hook pre-task -d "Refactor codebase" --optimize-topology
131
+ ```
132
+
133
+ **Features:**
134
+ - Automatic agent spawning based on task analysis
135
+ - Memory loading for context continuity
136
+ - Topology optimization for task structure
137
+ - Complexity estimation and time prediction
138
+
139
+ **pre-search** - Prepare and optimize search operations
140
+ ```bash
141
+ npx claude-flow hook pre-search --query <query>
142
+
143
+ Options:
144
+ --query, -q <text> Search query
145
+ --check-cache Check cache first (default: true)
146
+ --optimize-query Optimize search pattern
147
+
148
+ Examples:
149
+ npx claude-flow hook pre-search -q "authentication middleware"
150
+ ```
151
+
152
+ **Features:**
153
+ - Cache checking for faster results
154
+ - Query optimization
155
+ - Search pattern improvement
156
+
157
+ #### Post-Operation Hooks
158
+
159
+ Hooks that execute AFTER operations to process and learn:
160
+
161
+ **post-edit** - Auto-format, validate, and update memory
162
+ ```bash
163
+ npx claude-flow hook post-edit [options]
164
+
165
+ Options:
166
+ --file, -f <path> File path that was edited
167
+ --auto-format Automatically format code (default: true)
168
+ --memory-key, -m <key> Store edit context in memory
169
+ --train-patterns Train neural patterns from edit
170
+ --validate-output Validate edited file
171
+
172
+ Examples:
173
+ npx claude-flow hook post-edit --file "src/components/Button.jsx"
174
+ npx claude-flow hook post-edit -f "api/auth.js" --memory-key "auth/login"
175
+ npx claude-flow hook post-edit -f "utils/helpers.ts" --train-patterns
176
+ ```
177
+
178
+ **Features:**
179
+ - Language-specific auto-formatting (Prettier, Black, gofmt)
180
+ - Memory storage for edit context and decisions
181
+ - Neural pattern training for continuous improvement
182
+ - Output validation with linting
183
+
184
+ **post-bash** - Log execution and update metrics
185
+ ```bash
186
+ npx claude-flow hook post-bash --command <cmd>
187
+
188
+ Options:
189
+ --command, -c <cmd> Command that was executed
190
+ --log-output Log command output (default: true)
191
+ --update-metrics Update performance metrics
192
+ --store-result Store result in memory
193
+
194
+ Examples:
195
+ npx claude-flow hook post-bash -c "npm test" --update-metrics
196
+ ```
197
+
198
+ **Features:**
199
+ - Command execution logging
200
+ - Performance metric tracking
201
+ - Result storage for analysis
202
+ - Error pattern detection
203
+
204
+ **post-task** - Performance analysis and decision storage
205
+ ```bash
206
+ npx claude-flow hook post-task [options]
207
+
208
+ Options:
209
+ --task-id, -t <id> Task identifier for tracking
210
+ --analyze-performance Generate performance metrics (default: true)
211
+ --store-decisions Save task decisions to memory
212
+ --export-learnings Export neural pattern learnings
213
+ --generate-report Create task completion report
214
+
215
+ Examples:
216
+ npx claude-flow hook post-task --task-id "auth-implementation"
217
+ npx claude-flow hook post-task -t "api-refactor" --analyze-performance
218
+ npx claude-flow hook post-task -t "bug-fix-123" --store-decisions
219
+ ```
220
+
221
+ **Features:**
222
+ - Execution time and token usage measurement
223
+ - Decision and implementation choice recording
224
+ - Neural learning pattern export
225
+ - Completion report generation
226
+
227
+ **post-search** - Cache results and improve patterns
228
+ ```bash
229
+ npx claude-flow hook post-search --query <query> --results <path>
230
+
231
+ Options:
232
+ --query, -q <text> Original search query
233
+ --results, -r <path> Results file path
234
+ --cache-results Cache for future use (default: true)
235
+ --train-patterns Improve search patterns
236
+
237
+ Examples:
238
+ npx claude-flow hook post-search -q "auth" -r "results.json" --train-patterns
239
+ ```
240
+
241
+ **Features:**
242
+ - Result caching for faster subsequent searches
243
+ - Search pattern improvement
244
+ - Relevance scoring
245
+
246
+ #### MCP Integration Hooks
247
+
248
+ Hooks that coordinate with MCP swarm tools:
249
+
250
+ **mcp-initialized** - Persist swarm configuration
251
+ ```bash
252
+ npx claude-flow hook mcp-initialized --swarm-id <id>
253
+
254
+ Features:
255
+ - Save swarm topology and configuration
256
+ - Store agent roster in memory
257
+ - Initialize coordination namespace
258
+ ```
259
+
260
+ **agent-spawned** - Update agent roster and memory
261
+ ```bash
262
+ npx claude-flow hook agent-spawned --agent-id <id> --type <type>
263
+
264
+ Features:
265
+ - Register agent in coordination memory
266
+ - Update agent roster
267
+ - Initialize agent-specific memory namespace
268
+ ```
269
+
270
+ **task-orchestrated** - Monitor task progress
271
+ ```bash
272
+ npx claude-flow hook task-orchestrated --task-id <id>
273
+
274
+ Features:
275
+ - Track task progress through memory
276
+ - Monitor agent assignments
277
+ - Update coordination state
278
+ ```
279
+
280
+ **neural-trained** - Save pattern improvements
281
+ ```bash
282
+ npx claude-flow hook neural-trained --pattern <name>
283
+
284
+ Features:
285
+ - Export trained neural patterns
286
+ - Update coordination models
287
+ - Share learning across agents
288
+ ```
289
+
290
+ #### Memory Coordination Hooks
291
+
292
+ **memory-write** - Triggered when agents write to coordination memory
293
+ ```bash
294
+ Features:
295
+ - Validate memory key format
296
+ - Update cross-agent indexes
297
+ - Trigger dependent hooks
298
+ - Notify subscribed agents
299
+ ```
300
+
301
+ **memory-read** - Triggered when agents read from coordination memory
302
+ ```bash
303
+ Features:
304
+ - Log access patterns
305
+ - Update popularity metrics
306
+ - Preload related data
307
+ - Track usage statistics
308
+ ```
309
+
310
+ **memory-sync** - Synchronize memory across swarm agents
311
+ ```bash
312
+ npx claude-flow hook memory-sync --namespace <ns>
313
+
314
+ Features:
315
+ - Sync memory state across agents
316
+ - Resolve conflicts
317
+ - Propagate updates
318
+ - Maintain consistency
319
+ ```
320
+
321
+ #### Session Hooks
322
+
323
+ **session-start** - Initialize new session
324
+ ```bash
325
+ npx claude-flow hook session-start --session-id <id>
326
+
327
+ Options:
328
+ --session-id, -s <id> Session identifier
329
+ --load-context Load context from previous session
330
+ --init-agents Initialize required agents
331
+
332
+ Features:
333
+ - Create session directory
334
+ - Initialize metrics tracking
335
+ - Load previous context
336
+ - Set up coordination namespace
337
+ ```
338
+
339
+ **session-restore** - Load previous session state
340
+ ```bash
341
+ npx claude-flow hook session-restore --session-id <id>
342
+
343
+ Options:
344
+ --session-id, -s <id> Session to restore
345
+ --restore-memory Restore memory state (default: true)
346
+ --restore-agents Restore agent configurations
347
+
348
+ Examples:
349
+ npx claude-flow hook session-restore --session-id "swarm-20241019"
350
+ npx claude-flow hook session-restore -s "feature-auth" --restore-memory
351
+ ```
352
+
353
+ **Features:**
354
+ - Load previous session context
355
+ - Restore memory state and decisions
356
+ - Reconfigure agents to previous state
357
+ - Resume in-progress tasks
358
+
359
+ **session-end** - Cleanup and persist session state
360
+ ```bash
361
+ npx claude-flow hook session-end [options]
362
+
363
+ Options:
364
+ --session-id, -s <id> Session identifier to end
365
+ --save-state Save current session state (default: true)
366
+ --export-metrics Export session metrics
367
+ --generate-summary Create session summary
368
+ --cleanup-temp Remove temporary files
369
+
370
+ Examples:
371
+ npx claude-flow hook session-end --session-id "dev-session-2024"
372
+ npx claude-flow hook session-end -s "feature-auth" --export-metrics --generate-summary
373
+ npx claude-flow hook session-end -s "quick-fix" --cleanup-temp
374
+ ```
375
+
376
+ **Features:**
377
+ - Save current context and progress
378
+ - Export session metrics (duration, commands, tokens, files)
379
+ - Generate work summary with decisions and next steps
380
+ - Cleanup temporary files and optimize storage
381
+
382
+ **notify** - Custom notifications with swarm status
383
+ ```bash
384
+ npx claude-flow hook notify --message <msg>
385
+
386
+ Options:
387
+ --message, -m <text> Notification message
388
+ --level <level> Notification level (info|warning|error)
389
+ --swarm-status Include swarm status (default: true)
390
+ --broadcast Send to all agents
391
+
392
+ Examples:
393
+ npx claude-flow hook notify -m "Task completed" --level info
394
+ npx claude-flow hook notify -m "Critical error" --level error --broadcast
395
+ ```
396
+
397
+ **Features:**
398
+ - Send notifications to coordination system
399
+ - Include swarm status and metrics
400
+ - Broadcast to all agents
401
+ - Log important events
402
+
403
+ ### Configuration
404
+
405
+ #### Basic Configuration
406
+
407
+ Edit `.claude/settings.json` to configure hooks:
408
+
409
+ ```json
410
+ {
411
+ "hooks": {
412
+ "PreToolUse": [
413
+ {
414
+ "matcher": "^(Write|Edit|MultiEdit)$",
415
+ "hooks": [{
416
+ "type": "command",
417
+ "command": "npx claude-flow hook pre-edit --file '${tool.params.file_path}' --memory-key 'swarm/editor/current'"
418
+ }]
419
+ },
420
+ {
421
+ "matcher": "^Bash$",
422
+ "hooks": [{
423
+ "type": "command",
424
+ "command": "npx claude-flow hook pre-bash --command '${tool.params.command}'"
425
+ }]
426
+ }
427
+ ],
428
+ "PostToolUse": [
429
+ {
430
+ "matcher": "^(Write|Edit|MultiEdit)$",
431
+ "hooks": [{
432
+ "type": "command",
433
+ "command": "npx claude-flow hook post-edit --file '${tool.params.file_path}' --memory-key 'swarm/editor/complete' --auto-format --train-patterns"
434
+ }]
435
+ },
436
+ {
437
+ "matcher": "^Bash$",
438
+ "hooks": [{
439
+ "type": "command",
440
+ "command": "npx claude-flow hook post-bash --command '${tool.params.command}' --update-metrics"
441
+ }]
442
+ }
443
+ ]
444
+ }
445
+ }
446
+ ```
447
+
448
+ #### Advanced Configuration
449
+
450
+ Complete hook configuration with all features:
451
+
452
+ ```json
453
+ {
454
+ "hooks": {
455
+ "enabled": true,
456
+ "debug": false,
457
+ "timeout": 5000,
458
+
459
+ "PreToolUse": [
460
+ {
461
+ "matcher": "^(Write|Edit|MultiEdit)$",
462
+ "hooks": [
463
+ {
464
+ "type": "command",
465
+ "command": "npx claude-flow hook pre-edit --file '${tool.params.file_path}' --auto-assign-agent --validate-syntax",
466
+ "timeout": 3000,
467
+ "continueOnError": true
468
+ }
469
+ ]
470
+ },
471
+ {
472
+ "matcher": "^Task$",
473
+ "hooks": [
474
+ {
475
+ "type": "command",
476
+ "command": "npx claude-flow hook pre-task --description '${tool.params.task}' --auto-spawn-agents --load-memory",
477
+ "async": true
478
+ }
479
+ ]
480
+ },
481
+ {
482
+ "matcher": "^Grep$",
483
+ "hooks": [
484
+ {
485
+ "type": "command",
486
+ "command": "npx claude-flow hook pre-search --query '${tool.params.pattern}' --check-cache"
487
+ }
488
+ ]
489
+ }
490
+ ],
491
+
492
+ "PostToolUse": [
493
+ {
494
+ "matcher": "^(Write|Edit|MultiEdit)$",
495
+ "hooks": [
496
+ {
497
+ "type": "command",
498
+ "command": "npx claude-flow hook post-edit --file '${tool.params.file_path}' --memory-key 'edits/${tool.params.file_path}' --auto-format --train-patterns",
499
+ "async": true
500
+ }
501
+ ]
502
+ },
503
+ {
504
+ "matcher": "^Task$",
505
+ "hooks": [
506
+ {
507
+ "type": "command",
508
+ "command": "npx claude-flow hook post-task --task-id '${result.task_id}' --analyze-performance --store-decisions --export-learnings",
509
+ "async": true
510
+ }
511
+ ]
512
+ },
513
+ {
514
+ "matcher": "^Grep$",
515
+ "hooks": [
516
+ {
517
+ "type": "command",
518
+ "command": "npx claude-flow hook post-search --query '${tool.params.pattern}' --cache-results --train-patterns"
519
+ }
520
+ ]
521
+ }
522
+ ],
523
+
524
+ "SessionStart": [
525
+ {
526
+ "hooks": [
527
+ {
528
+ "type": "command",
529
+ "command": "npx claude-flow hook session-start --session-id '${session.id}' --load-context"
530
+ }
531
+ ]
532
+ }
533
+ ],
534
+
535
+ "SessionEnd": [
536
+ {
537
+ "hooks": [
538
+ {
539
+ "type": "command",
540
+ "command": "npx claude-flow hook session-end --session-id '${session.id}' --export-metrics --generate-summary --cleanup-temp"
541
+ }
542
+ ]
543
+ }
544
+ ]
545
+ }
546
+ }
547
+ ```
548
+
549
+ #### Protected File Patterns
550
+
551
+ Add protection for sensitive files:
552
+
553
+ ```json
554
+ {
555
+ "hooks": {
556
+ "PreToolUse": [
557
+ {
558
+ "matcher": "^(Write|Edit|MultiEdit)$",
559
+ "hooks": [
560
+ {
561
+ "type": "command",
562
+ "command": "npx claude-flow hook check-protected --file '${tool.params.file_path}'"
563
+ }
564
+ ]
565
+ }
566
+ ]
567
+ }
568
+ }
569
+ ```
570
+
571
+ #### Automatic Testing
572
+
573
+ Run tests after file modifications:
574
+
575
+ ```json
576
+ {
577
+ "hooks": {
578
+ "PostToolUse": [
579
+ {
580
+ "matcher": "^Write$",
581
+ "hooks": [
582
+ {
583
+ "type": "command",
584
+ "command": "test -f '${tool.params.file_path%.js}.test.js' && npm test '${tool.params.file_path%.js}.test.js'",
585
+ "continueOnError": true
586
+ }
587
+ ]
588
+ }
589
+ ]
590
+ }
591
+ }
592
+ ```
593
+
594
+ ### MCP Tool Integration
595
+
596
+ Hooks automatically integrate with MCP tools for coordination:
597
+
598
+ #### Pre-Task Hook with Agent Spawning
599
+
600
+ ```javascript
601
+ // Hook command
602
+ npx claude-flow hook pre-task --description "Build REST API"
603
+
604
+ // Internally calls MCP tools:
605
+ mcp__claude-flow__agent_spawn {
606
+ type: "backend-dev",
607
+ capabilities: ["api", "database", "testing"]
608
+ }
609
+
610
+ mcp__claude-flow__memory_usage {
611
+ action: "store",
612
+ key: "swarm/task/api-build/context",
613
+ namespace: "coordination",
614
+ value: JSON.stringify({
615
+ description: "Build REST API",
616
+ agents: ["backend-dev"],
617
+ started: Date.now()
618
+ })
619
+ }
620
+ ```
621
+
622
+ #### Post-Edit Hook with Memory Storage
623
+
624
+ ```javascript
625
+ // Hook command
626
+ npx claude-flow hook post-edit --file "api/auth.js"
627
+
628
+ // Internally calls MCP tools:
629
+ mcp__claude-flow__memory_usage {
630
+ action: "store",
631
+ key: "swarm/edits/api/auth.js",
632
+ namespace: "coordination",
633
+ value: JSON.stringify({
634
+ file: "api/auth.js",
635
+ timestamp: Date.now(),
636
+ changes: { added: 45, removed: 12 },
637
+ formatted: true,
638
+ linted: true
639
+ })
640
+ }
641
+
642
+ mcp__claude-flow__neural_train {
643
+ pattern_type: "coordination",
644
+ training_data: { /* edit patterns */ }
645
+ }
646
+ ```
647
+
648
+ #### Session End Hook with State Persistence
649
+
650
+ ```javascript
651
+ // Hook command
652
+ npx claude-flow hook session-end --session-id "dev-2024"
653
+
654
+ // Internally calls MCP tools:
655
+ mcp__claude-flow__memory_persist {
656
+ sessionId: "dev-2024"
657
+ }
658
+
659
+ mcp__claude-flow__swarm_status {
660
+ swarmId: "current"
661
+ }
662
+
663
+ // Generates metrics and summary
664
+ ```
665
+
666
+ ### Memory Coordination Protocol
667
+
668
+ All hooks follow a standardized memory coordination pattern:
669
+
670
+ #### Three-Phase Memory Protocol
671
+
672
+ **Phase 1: STATUS** - Hook starts
673
+ ```javascript
674
+ mcp__claude-flow__memory_usage {
675
+ action: "store",
676
+ key: "swarm/hooks/pre-edit/status",
677
+ namespace: "coordination",
678
+ value: JSON.stringify({
679
+ status: "running",
680
+ hook: "pre-edit",
681
+ file: "src/auth.js",
682
+ timestamp: Date.now()
683
+ })
684
+ }
685
+ ```
686
+
687
+ **Phase 2: PROGRESS** - Hook processes
688
+ ```javascript
689
+ mcp__claude-flow__memory_usage {
690
+ action: "store",
691
+ key: "swarm/hooks/pre-edit/progress",
692
+ namespace: "coordination",
693
+ value: JSON.stringify({
694
+ progress: 50,
695
+ action: "validating syntax",
696
+ file: "src/auth.js"
697
+ })
698
+ }
699
+ ```
700
+
701
+ **Phase 3: COMPLETE** - Hook finishes
702
+ ```javascript
703
+ mcp__claude-flow__memory_usage {
704
+ action: "store",
705
+ key: "swarm/hooks/pre-edit/complete",
706
+ namespace: "coordination",
707
+ value: JSON.stringify({
708
+ status: "complete",
709
+ result: "success",
710
+ agent_assigned: "backend-dev",
711
+ syntax_valid: true,
712
+ backup_created: true
713
+ })
714
+ }
715
+ ```
716
+
717
+ ### Hook Response Format
718
+
719
+ Hooks return JSON responses to control operation flow:
720
+
721
+ #### Continue Response
722
+ ```json
723
+ {
724
+ "continue": true,
725
+ "reason": "All validations passed",
726
+ "metadata": {
727
+ "agent_assigned": "backend-dev",
728
+ "syntax_valid": true,
729
+ "file": "src/auth.js"
730
+ }
731
+ }
732
+ ```
733
+
734
+ #### Block Response
735
+ ```json
736
+ {
737
+ "continue": false,
738
+ "reason": "Protected file - manual review required",
739
+ "metadata": {
740
+ "file": ".env.production",
741
+ "protection_level": "high",
742
+ "requires": "manual_approval"
743
+ }
744
+ }
745
+ ```
746
+
747
+ #### Warning Response
748
+ ```json
749
+ {
750
+ "continue": true,
751
+ "reason": "Syntax valid but complexity high",
752
+ "warnings": [
753
+ "Cyclomatic complexity: 15 (threshold: 10)",
754
+ "Consider refactoring for better maintainability"
755
+ ],
756
+ "metadata": {
757
+ "complexity": 15,
758
+ "threshold": 10
759
+ }
760
+ }
761
+ ```
762
+
763
+ ### Git Integration
764
+
765
+ Hooks can integrate with Git operations for quality control:
766
+
767
+ #### Pre-Commit Hook
768
+ ```bash
769
+ # Add to .git/hooks/pre-commit or use husky
770
+
771
+ #!/bin/bash
772
+ # Run quality checks before commit
773
+
774
+ # Get staged files
775
+ FILES=$(git diff --cached --name-only --diff-filter=ACM)
776
+
777
+ for FILE in $FILES; do
778
+ # Run pre-edit hook for validation
779
+ npx claude-flow hook pre-edit --file "$FILE" --validate-syntax
780
+
781
+ if [ $? -ne 0 ]; then
782
+ echo "Validation failed for $FILE"
783
+ exit 1
784
+ fi
785
+
786
+ # Run post-edit hook for formatting
787
+ npx claude-flow hook post-edit --file "$FILE" --auto-format
788
+ done
789
+
790
+ # Run tests
791
+ npm test
792
+
793
+ exit $?
794
+ ```
795
+
796
+ #### Post-Commit Hook
797
+ ```bash
798
+ # Add to .git/hooks/post-commit
799
+
800
+ #!/bin/bash
801
+ # Track commit metrics
802
+
803
+ COMMIT_HASH=$(git rev-parse HEAD)
804
+ COMMIT_MSG=$(git log -1 --pretty=%B)
805
+
806
+ npx claude-flow hook notify \
807
+ --message "Commit completed: $COMMIT_MSG" \
808
+ --level info \
809
+ --swarm-status
810
+ ```
811
+
812
+ #### Pre-Push Hook
813
+ ```bash
814
+ # Add to .git/hooks/pre-push
815
+
816
+ #!/bin/bash
817
+ # Quality gate before push
818
+
819
+ # Run full test suite
820
+ npm run test:all
821
+
822
+ # Run quality checks
823
+ npx claude-flow hook session-end \
824
+ --generate-report \
825
+ --export-metrics
826
+
827
+ # Verify quality thresholds
828
+ TRUTH_SCORE=$(npx claude-flow metrics score --format json | jq -r '.truth_score')
829
+
830
+ if (( $(echo "$TRUTH_SCORE < 0.95" | bc -l) )); then
831
+ echo "Truth score below threshold: $TRUTH_SCORE < 0.95"
832
+ exit 1
833
+ fi
834
+
835
+ exit 0
836
+ ```
837
+
838
+ ### Agent Coordination Workflow
839
+
840
+ How agents use hooks for coordination:
841
+
842
+ #### Agent Workflow Example
843
+
844
+ ```bash
845
+ # Agent 1: Backend Developer
846
+ # STEP 1: Pre-task preparation
847
+ npx claude-flow hook pre-task \
848
+ --description "Implement user authentication API" \
849
+ --auto-spawn-agents \
850
+ --load-memory
851
+
852
+ # STEP 2: Work begins - pre-edit validation
853
+ npx claude-flow hook pre-edit \
854
+ --file "api/auth.js" \
855
+ --auto-assign-agent \
856
+ --validate-syntax
857
+
858
+ # STEP 3: Edit file (via Claude Code Edit tool)
859
+ # ... code changes ...
860
+
861
+ # STEP 4: Post-edit processing
862
+ npx claude-flow hook post-edit \
863
+ --file "api/auth.js" \
864
+ --memory-key "swarm/backend/auth-api" \
865
+ --auto-format \
866
+ --train-patterns
867
+
868
+ # STEP 5: Notify coordination system
869
+ npx claude-flow hook notify \
870
+ --message "Auth API implementation complete" \
871
+ --swarm-status \
872
+ --broadcast
873
+
874
+ # STEP 6: Task completion
875
+ npx claude-flow hook post-task \
876
+ --task-id "auth-api" \
877
+ --analyze-performance \
878
+ --store-decisions \
879
+ --export-learnings
880
+ ```
881
+
882
+ ```bash
883
+ # Agent 2: Test Engineer (receives notification)
884
+ # STEP 1: Check memory for API details
885
+ npx claude-flow hook session-restore \
886
+ --session-id "swarm-current" \
887
+ --restore-memory
888
+
889
+ # Memory contains: swarm/backend/auth-api with implementation details
890
+
891
+ # STEP 2: Generate tests
892
+ npx claude-flow hook pre-task \
893
+ --description "Write tests for auth API" \
894
+ --load-memory
895
+
896
+ # STEP 3: Create test file
897
+ npx claude-flow hook post-edit \
898
+ --file "api/auth.test.js" \
899
+ --memory-key "swarm/testing/auth-api-tests" \
900
+ --train-patterns
901
+
902
+ # STEP 4: Share test results
903
+ npx claude-flow hook notify \
904
+ --message "Auth API tests complete - 100% coverage" \
905
+ --broadcast
906
+ ```
907
+
908
+ ### Custom Hook Creation
909
+
910
+ Create custom hooks for specific workflows:
911
+
912
+ #### Custom Hook Template
913
+
914
+ ```javascript
915
+ // .claude/hooks/custom-quality-check.js
916
+
917
+ module.exports = {
918
+ name: 'custom-quality-check',
919
+ type: 'pre',
920
+ matcher: /\.(ts|js)$/,
921
+
922
+ async execute(context) {
923
+ const { file, content } = context;
924
+
925
+ // Custom validation logic
926
+ const complexity = await analyzeComplexity(content);
927
+ const securityIssues = await scanSecurity(content);
928
+
929
+ // Store in memory
930
+ await storeInMemory({
931
+ key: `quality/${file}`,
932
+ value: { complexity, securityIssues }
933
+ });
934
+
935
+ // Return decision
936
+ if (complexity > 15 || securityIssues.length > 0) {
937
+ return {
938
+ continue: false,
939
+ reason: 'Quality checks failed',
940
+ warnings: [
941
+ `Complexity: ${complexity} (max: 15)`,
942
+ `Security issues: ${securityIssues.length}`
943
+ ]
944
+ };
945
+ }
946
+
947
+ return {
948
+ continue: true,
949
+ reason: 'Quality checks passed',
950
+ metadata: { complexity, securityIssues: 0 }
951
+ };
952
+ }
953
+ };
954
+ ```
955
+
956
+ #### Register Custom Hook
957
+
958
+ ```json
959
+ {
960
+ "hooks": {
961
+ "PreToolUse": [
962
+ {
963
+ "matcher": "^(Write|Edit)$",
964
+ "hooks": [
965
+ {
966
+ "type": "script",
967
+ "script": ".claude/hooks/custom-quality-check.js"
968
+ }
969
+ ]
970
+ }
971
+ ]
972
+ }
973
+ }
974
+ ```
975
+
976
+ ### Real-World Examples
977
+
978
+ #### Example 1: Full-Stack Development Workflow
979
+
980
+ ```bash
981
+ # Session start - initialize coordination
982
+ npx claude-flow hook session-start --session-id "fullstack-feature"
983
+
984
+ # Pre-task planning
985
+ npx claude-flow hook pre-task \
986
+ --description "Build user profile feature - frontend + backend + tests" \
987
+ --auto-spawn-agents \
988
+ --optimize-topology
989
+
990
+ # Backend work
991
+ npx claude-flow hook pre-edit --file "api/profile.js"
992
+ # ... implement backend ...
993
+ npx claude-flow hook post-edit \
994
+ --file "api/profile.js" \
995
+ --memory-key "profile/backend" \
996
+ --train-patterns
997
+
998
+ # Frontend work (reads backend details from memory)
999
+ npx claude-flow hook pre-edit --file "components/Profile.jsx"
1000
+ # ... implement frontend ...
1001
+ npx claude-flow hook post-edit \
1002
+ --file "components/Profile.jsx" \
1003
+ --memory-key "profile/frontend" \
1004
+ --train-patterns
1005
+
1006
+ # Testing (reads both backend and frontend from memory)
1007
+ npx claude-flow hook pre-task \
1008
+ --description "Test profile feature" \
1009
+ --load-memory
1010
+
1011
+ # Session end - export everything
1012
+ npx claude-flow hook session-end \
1013
+ --session-id "fullstack-feature" \
1014
+ --export-metrics \
1015
+ --generate-summary
1016
+ ```
1017
+
1018
+ #### Example 2: Debugging with Hooks
1019
+
1020
+ ```bash
1021
+ # Start debugging session
1022
+ npx claude-flow hook session-start --session-id "debug-memory-leak"
1023
+
1024
+ # Pre-task: analyze issue
1025
+ npx claude-flow hook pre-task \
1026
+ --description "Debug memory leak in event handlers" \
1027
+ --load-memory \
1028
+ --estimate-complexity
1029
+
1030
+ # Search for event emitters
1031
+ npx claude-flow hook pre-search --query "EventEmitter"
1032
+ # ... search executes ...
1033
+ npx claude-flow hook post-search \
1034
+ --query "EventEmitter" \
1035
+ --cache-results
1036
+
1037
+ # Fix the issue
1038
+ npx claude-flow hook pre-edit \
1039
+ --file "services/events.js" \
1040
+ --backup-file
1041
+ # ... fix code ...
1042
+ npx claude-flow hook post-edit \
1043
+ --file "services/events.js" \
1044
+ --memory-key "debug/memory-leak-fix" \
1045
+ --validate-output
1046
+
1047
+ # Verify fix
1048
+ npx claude-flow hook post-task \
1049
+ --task-id "memory-leak-fix" \
1050
+ --analyze-performance \
1051
+ --generate-report
1052
+
1053
+ # End session
1054
+ npx claude-flow hook session-end \
1055
+ --session-id "debug-memory-leak" \
1056
+ --export-metrics
1057
+ ```
1058
+
1059
+ #### Example 3: Multi-Agent Refactoring
1060
+
1061
+ ```bash
1062
+ # Initialize swarm for refactoring
1063
+ npx claude-flow hook pre-task \
1064
+ --description "Refactor legacy codebase to modern patterns" \
1065
+ --auto-spawn-agents \
1066
+ --optimize-topology
1067
+
1068
+ # Agent 1: Code Analyzer
1069
+ npx claude-flow hook pre-task --description "Analyze code complexity"
1070
+ # ... analysis ...
1071
+ npx claude-flow hook post-task \
1072
+ --task-id "analysis" \
1073
+ --store-decisions
1074
+
1075
+ # Agent 2: Refactoring (reads analysis from memory)
1076
+ npx claude-flow hook session-restore \
1077
+ --session-id "swarm-refactor" \
1078
+ --restore-memory
1079
+
1080
+ for file in src/**/*.js; do
1081
+ npx claude-flow hook pre-edit --file "$file" --backup-file
1082
+ # ... refactor ...
1083
+ npx claude-flow hook post-edit \
1084
+ --file "$file" \
1085
+ --memory-key "refactor/$file" \
1086
+ --auto-format \
1087
+ --train-patterns
1088
+ done
1089
+
1090
+ # Agent 3: Testing (reads refactored code from memory)
1091
+ npx claude-flow hook pre-task \
1092
+ --description "Generate tests for refactored code" \
1093
+ --load-memory
1094
+
1095
+ # Broadcast completion
1096
+ npx claude-flow hook notify \
1097
+ --message "Refactoring complete - all tests passing" \
1098
+ --broadcast
1099
+ ```
1100
+
1101
+ ### Performance Tips
1102
+
1103
+ 1. **Keep Hooks Lightweight** - Target < 100ms execution time
1104
+ 2. **Use Async for Heavy Operations** - Don't block the main flow
1105
+ 3. **Cache Aggressively** - Store frequently accessed data
1106
+ 4. **Batch Related Operations** - Combine multiple actions
1107
+ 5. **Use Memory Wisely** - Set appropriate TTLs
1108
+ 6. **Monitor Hook Performance** - Track execution times
1109
+ 7. **Parallelize When Possible** - Run independent hooks concurrently
1110
+
1111
+ ### Debugging Hooks
1112
+
1113
+ Enable debug mode for troubleshooting:
1114
+
1115
+ ```bash
1116
+ # Enable debug output
1117
+ export CLAUDE_FLOW_DEBUG=true
1118
+
1119
+ # Test specific hook with verbose output
1120
+ npx claude-flow hook pre-edit --file "test.js" --debug
1121
+
1122
+ # Check hook execution logs
1123
+ cat .claude-flow/logs/hooks-$(date +%Y-%m-%d).log
1124
+
1125
+ # Validate configuration
1126
+ npx claude-flow hook validate-config
1127
+ ```
1128
+
1129
+ ### Benefits
1130
+
1131
+ - **Automatic Agent Assignment**: Right agent for every file type
1132
+ - **Consistent Code Formatting**: Language-specific formatters
1133
+ - **Continuous Learning**: Neural patterns improve over time
1134
+ - **Cross-Session Memory**: Context persists between sessions
1135
+ - **Performance Tracking**: Comprehensive metrics and analytics
1136
+ - **Automatic Coordination**: Agents sync via memory
1137
+ - **Smart Agent Spawning**: Task-based agent selection
1138
+ - **Quality Gates**: Pre-commit validation and verification
1139
+ - **Error Prevention**: Syntax validation before edits
1140
+ - **Knowledge Sharing**: Decisions stored and shared
1141
+ - **Reduced Manual Work**: Automation of repetitive tasks
1142
+ - **Better Collaboration**: Seamless multi-agent coordination
1143
+
1144
+ ### Best Practices
1145
+
1146
+ 1. **Configure Hooks Early** - Set up during project initialization
1147
+ 2. **Use Memory Keys Strategically** - Organize with clear namespaces
1148
+ 3. **Enable Auto-Formatting** - Maintain code consistency
1149
+ 4. **Train Patterns Continuously** - Learn from successful operations
1150
+ 5. **Monitor Performance** - Track hook execution times
1151
+ 6. **Validate Configuration** - Test hooks before production use
1152
+ 7. **Document Custom Hooks** - Maintain hook documentation
1153
+ 8. **Set Appropriate Timeouts** - Prevent hanging operations
1154
+ 9. **Handle Errors Gracefully** - Use continueOnError when appropriate
1155
+ 10. **Review Metrics Regularly** - Optimize based on usage patterns
1156
+
1157
+ ### Troubleshooting
1158
+
1159
+ #### Hooks Not Executing
1160
+ - Verify `.claude/settings.json` syntax
1161
+ - Check hook matcher patterns
1162
+ - Enable debug mode
1163
+ - Review permission settings
1164
+ - Ensure claude-flow CLI is in PATH
1165
+
1166
+ #### Hook Timeouts
1167
+ - Increase timeout values in configuration
1168
+ - Make hooks asynchronous for heavy operations
1169
+ - Optimize hook logic
1170
+ - Check network connectivity for MCP tools
1171
+
1172
+ #### Memory Issues
1173
+ - Set appropriate TTLs for memory keys
1174
+ - Clean up old memory entries
1175
+ - Use memory namespaces effectively
1176
+ - Monitor memory usage
1177
+
1178
+ #### Performance Problems
1179
+ - Profile hook execution times
1180
+ - Use caching for repeated operations
1181
+ - Batch operations when possible
1182
+ - Reduce hook complexity
1183
+
1184
+ ### Related Commands
1185
+
1186
+ - `npx claude-flow init --hooks` - Initialize hooks system
1187
+ - `npx claude-flow hook --list` - List available hooks
1188
+ - `npx claude-flow hook --test <hook>` - Test specific hook
1189
+ - `npx claude-flow memory usage` - Manage memory
1190
+ - `npx claude-flow agent spawn` - Spawn agents
1191
+ - `npx claude-flow swarm init` - Initialize swarm
1192
+
1193
+ ### Integration with Other Skills
1194
+
1195
+ This skill works seamlessly with:
1196
+ - **SPARC Methodology** - Hooks enhance SPARC workflows
1197
+ - **Pair Programming** - Automated quality in pairing sessions
1198
+ - **Verification Quality** - Truth-score validation in hooks
1199
+ - **GitHub Workflows** - Git integration for commits/PRs
1200
+ - **Performance Analysis** - Metrics collection in hooks
1201
+ - **Swarm Advanced** - Multi-agent coordination via hooks