claude-flow-novice 2.5.2 → 2.8.1

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 (370) hide show
  1. package/.claude/adaptive-context/cfn-v3-reflection.json +21 -0
  2. package/.claude/agents/AGENT_LIFECYCLE.md +495 -0
  3. package/.claude/agents/CLAUDE.md +1002 -1233
  4. package/.claude/agents/accessibility-advocate.md +457 -0
  5. package/.claude/agents/agent-principles/README.md +226 -226
  6. package/.claude/agents/agent-principles/agent-type-guidelines.md +10 -0
  7. package/.claude/agents/agent-principles/format-selection.md +10 -0
  8. package/.claude/agents/agent-principles/phase4-template-optimization.md +502 -494
  9. package/.claude/agents/agent-principles/prompt-engineering.md +8 -0
  10. package/.claude/agents/agent-principles/quality-metrics.md +8 -0
  11. package/.claude/agents/analysis/code-analyzer.md +7 -17
  12. package/.claude/agents/analysis/code-review/analyze-code-quality.md +2 -104
  13. package/.claude/agents/analysis/perf-analyzer.md +2 -196
  14. package/.claude/agents/context/context-curator.md +78 -84
  15. package/.claude/agents/context/context-reflector.md +27 -81
  16. package/.claude/agents/coordinators/README.md +42 -0
  17. package/.claude/agents/coordinators/cfn-v3-coordinator.md +440 -0
  18. package/.claude/agents/{product-owner-team → coordinators}/cto-agent.md +154 -187
  19. package/.claude/agents/coordinators/multi-sprint-coordinator.md +50 -0
  20. package/.claude/agents/{product-owner-team → coordinators}/product-owner-agent.md +6 -39
  21. package/.claude/agents/{cfn-loop → coordinators}/product-owner.md +72 -17
  22. package/.claude/agents/core-agents/reviewer.md +114 -135
  23. package/.claude/agents/custom/agent-builder.md +637 -0
  24. package/.claude/agents/developers/README.md +69 -0
  25. package/.claude/agents/developers/backend-dev.md +77 -0
  26. package/.claude/agents/{core-agents → developers}/coder.md +131 -26
  27. package/.claude/agents/developers/react-frontend-engineer.md +121 -0
  28. package/.claude/agents/{frontend → developers}/state-architect.md +1 -0
  29. package/.claude/agents/{frontend → developers}/ui-designer.md +1 -0
  30. package/.claude/agents/development/backend/dev-backend-api.md +0 -29
  31. package/.claude/agents/development/npm-package-specialist.md +355 -347
  32. package/.claude/agents/documentation/api-docs/docs-api-openapi.md +8 -0
  33. package/.claude/agents/documentation/api-docs.md +8 -0
  34. package/.claude/agents/github/github-commit-agent.md +125 -117
  35. package/.claude/agents/goal/goal-planner.md +8 -0
  36. package/.claude/agents/infrastructure/README.md +100 -0
  37. package/.claude/agents/{specialized → infrastructure}/devops-engineer.md +131 -150
  38. package/.claude/agents/planners/README.md +94 -0
  39. package/.claude/agents/{core-agents → planners}/analyst.md +1 -22
  40. package/.claude/agents/{planning-team → planners}/api-designer-persona.md +8 -0
  41. package/.claude/agents/{core-agents → planners}/architect.md +7 -20
  42. package/.claude/agents/{core-agents → planners}/planner.md +0 -21
  43. package/.claude/agents/{planning-team → planners}/security-architect-persona.md +8 -28
  44. package/.claude/agents/{planning-team → planners}/system-architect-persona.md +6 -38
  45. package/.claude/agents/{architecture → planners}/system-architect.md +12 -17
  46. package/.claude/agents/product-owner-team/accessibility-advocate-persona.md +132 -161
  47. package/.claude/agents/product-owner-team/power-user-persona.md +149 -182
  48. package/.claude/agents/retrospective-analyst.md +84 -0
  49. package/.claude/agents/reviewers/README.md +58 -0
  50. package/.claude/agents/{analysis → reviewers}/code-quality-validator.md +8 -17
  51. package/.claude/agents/reviewers/reviewer.md +181 -0
  52. package/.claude/agents/sparc/architecture.md +6 -25
  53. package/.claude/agents/sparc/pseudocode.md +6 -0
  54. package/.claude/agents/sparc/refinement.md +6 -0
  55. package/.claude/agents/sparc/specification.md +1 -0
  56. package/.claude/agents/specialists/README.md +60 -0
  57. package/.claude/agents/{core-agents → specialists}/base-template-generator.md +8 -21
  58. package/.claude/agents/{specialized → specialists}/cli-agent-optimizer.md +1 -1
  59. package/.claude/agents/{specialized → specialists}/code-booster.md +1 -0
  60. package/.claude/agents/{consensus → specialists}/consensus-builder.md +1 -17
  61. package/.claude/agents/{specialized/mobile → specialists}/mobile-dev.md +0 -20
  62. package/.claude/agents/{core-agents → specialists}/performance-benchmarker.md +134 -148
  63. package/.claude/agents/{specialized → specialists}/rust-developer.md +1 -20
  64. package/.claude/agents/{specialized → specialists}/rust-enterprise-developer.md +1 -20
  65. package/.claude/agents/{specialized → specialists}/rust-mvp-developer.md +1 -20
  66. package/.claude/agents/{core-agents → specialists}/security-manager.md +68 -88
  67. package/.claude/agents/{security → specialists}/security-specialist-existing.md +6 -57
  68. package/.claude/agents/{security → specialists}/security-specialist.md +6 -30
  69. package/.claude/agents/{specialized/mobile → specialists}/spec-mobile-react-native.md +2 -21
  70. package/.claude/agents/testers/README.md +94 -0
  71. package/.claude/agents/{testing → testers}/e2e/playwright-agent.md +1 -20
  72. package/.claude/agents/{testing → testers}/interaction-tester.md +1 -20
  73. package/.claude/agents/{testing → testers}/playwright-tester.md +1 -1
  74. package/.claude/agents/testers/tester.md +139 -0
  75. package/.claude/agents/testers/unit/tdd-london-swarm.md +49 -0
  76. package/.claude/agents/testers/validation/production-validator.md +33 -0
  77. package/.claude/agents-ignore/cfn-loop-coordinator.md +157 -0
  78. package/.claude/agents-ignore/cfn-loop-coordinator.md.backup +156 -0
  79. package/.claude/agents-ignore/coordinator.md.backup +182 -0
  80. package/.claude/agents-ignore/cost-savings-cfn-loop-coordinator.md +760 -0
  81. package/.claude/agents-ignore/cost-savings-coordinator.md +173 -0
  82. package/.claude/artifacts/ace-reflections/REFLECT-001-summary.json +39 -0
  83. package/.claude/artifacts/ace-reflections/sprint-7_$(date -u +/"%Y%m%d_%H%M%S/").json" +47 -0
  84. package/.claude/artifacts/reflection-merge-logs/cli-agent-spawning-v2.5.2-merge-report.md +61 -0
  85. package/.claude/commands/CFN_COORDINATOR_PARAMETERS.md +10 -10
  86. package/.claude/commands/cfn-loop-epic.md +43 -19
  87. package/.claude/commands/cfn-loop-single.md +3 -3
  88. package/.claude/commands/cfn-loop-sprints.md +1 -1
  89. package/.claude/commands/cfn-loop.md +45 -32
  90. package/.claude/commands/cfn-mode.md +20 -0
  91. package/.claude/commands/custom-routing-activate.md +37 -123
  92. package/.claude/commands/custom-routing-deactivate.md +27 -124
  93. package/.claude/commands/switch-api.md +41 -16
  94. package/.claude/commands/write-plan.md +104 -0
  95. package/.claude/data/cfn-loop.db +0 -0
  96. package/.claude/data/cfn_loop_logs.db +0 -0
  97. package/.claude/hooks/BACKUP_USAGE.md +243 -0
  98. package/.claude/hooks/post-edit-cfn-retrospective.sh +79 -0
  99. package/.claude/hooks/post-edit.sh +21 -0
  100. package/.claude/hooks/pre-edit-backup.sh +71 -0
  101. package/.claude/hooks/restore-from-backup.sh +37 -0
  102. package/.claude/prompts/cfn-loop-context.md +115 -0
  103. package/.claude/prompts/loop-specific/loop2.md +50 -0
  104. package/.claude/prompts/loop-specific/loop3.md +43 -0
  105. package/.claude/prompts/loop-specific/loop4.md +54 -0
  106. package/.claude/root-claude-distribute/CLAUDE.md +76 -2
  107. package/.claude/skills/ace-system/sprint-7-lessons.json +46 -0
  108. package/.claude/skills/ace-system/store-reflection.sh +33 -136
  109. package/.claude/skills/agent-discovery/SKILL.md +40 -0
  110. package/.claude/skills/agent-discovery/agents-registry-clean.json +0 -0
  111. package/.claude/skills/agent-discovery/agents-registry-fixed.json +19 -0
  112. package/.claude/skills/agent-discovery/agents-registry.json +718 -0
  113. package/.claude/skills/agent-discovery/discover-agents.py +175 -0
  114. package/.claude/skills/agent-discovery/discover-agents.sh +87 -0
  115. package/.claude/skills/agent-discovery/invoke-registry.sh +11 -0
  116. package/.claude/skills/agent-discovery/temp_script.py +0 -0
  117. package/.claude/skills/agent-execution/execute-agent.sh +126 -0
  118. package/.claude/skills/agent-output-processing/SKILL.md +359 -0
  119. package/.claude/skills/agent-selector/SKILL.md +90 -0
  120. package/.claude/skills/agent-selector/select-agents.sh +96 -0
  121. package/.claude/skills/agent-spawning/agent-selection-guide.md +1 -1
  122. package/.claude/skills/agent-swap/SKILL.md +36 -0
  123. package/.claude/skills/agent-swap/recommend-swap.sh +60 -0
  124. package/.claude/skills/api-validation/test-endpoints.sh +54 -0
  125. package/.claude/skills/automatic-memory-persistence/SKILL.md +73 -0
  126. package/.claude/skills/automatic-memory-persistence/persist-agent-output.sh +49 -0
  127. package/.claude/skills/automatic-memory-persistence/query-agent-history.sh +35 -0
  128. package/.claude/skills/automatic-memory-persistence/test-memory-persistence.sh +235 -0
  129. package/.claude/skills/cfn-loop-orchestration/README.md +41 -0
  130. package/.claude/skills/cfn-loop-orchestration/SKILL.md +299 -0
  131. package/.claude/skills/cfn-loop-orchestration/helpers/auto-tune-timeouts.sh +228 -0
  132. package/.claude/skills/cfn-loop-orchestration/helpers/consensus.sh +84 -0
  133. package/.claude/skills/cfn-loop-orchestration/helpers/deliverable-verifier.sh +71 -0
  134. package/.claude/skills/cfn-loop-orchestration/helpers/gate-check.sh +90 -0
  135. package/.claude/skills/cfn-loop-orchestration/helpers/iteration-manager.sh +87 -0
  136. package/.claude/skills/cfn-loop-orchestration/helpers/timeout-calculator.sh +51 -0
  137. package/.claude/skills/cfn-loop-orchestration/inject-loop-context.sh +41 -0
  138. package/.claude/skills/cfn-loop-orchestration/monitor-execution.sh +156 -0
  139. package/.claude/skills/cfn-loop-orchestration/orchestrate.sh +840 -0
  140. package/.claude/skills/cfn-loop-orchestration/security_utils.sh +99 -0
  141. package/.claude/skills/cfn-loop-orchestration/test-cfn-orchestration.sh +281 -0
  142. package/.claude/skills/cfn-loop-orchestration/test-edge-cases.sh +188 -0
  143. package/.claude/skills/cfn-loop-validation/SKILL.md +307 -217
  144. package/.claude/skills/complexity-estimator/SKILL.md +96 -0
  145. package/.claude/skills/complexity-estimator/estimate-complexity.sh +144 -0
  146. package/.claude/skills/context-pruner/SKILL.md +75 -0
  147. package/.claude/skills/context-pruner/prune-context.sh +73 -0
  148. package/.claude/skills/defense-in-depth/SKILL.md +133 -0
  149. package/.claude/skills/dependency-extractor/SKILL.md +35 -0
  150. package/.claude/skills/dependency-extractor/extract-dependencies.sh +66 -0
  151. package/.claude/skills/epic-decomposer/SKILL.md +44 -0
  152. package/.claude/skills/epic-decomposer/decompose-epic.sh +104 -0
  153. package/.claude/skills/improvement-recommender/SKILL.md +33 -0
  154. package/.claude/skills/improvement-recommender/recommend-improvements.sh +92 -0
  155. package/.claude/skills/intervention-detector/SKILL.md +39 -0
  156. package/.claude/skills/intervention-detector/detect-intervention.sh +111 -0
  157. package/.claude/skills/intervention-orchestrator/SKILL.md +43 -0
  158. package/.claude/skills/intervention-orchestrator/execute-intervention.sh +59 -0
  159. package/.claude/skills/loop2-output-processing/SKILL.md +163 -0
  160. package/.claude/skills/loop2-output-processing/execute-and-extract.sh +77 -0
  161. package/.claude/skills/loop2-output-processing/execute-and-extract.sh.backup +36 -0
  162. package/.claude/skills/loop2-output-processing/parse-feedback.sh +147 -0
  163. package/.claude/skills/loop2-output-processing/process-validator-output.sh +275 -0
  164. package/.claude/skills/loop2-output-processing/test-bug27-fix.sh +200 -0
  165. package/.claude/skills/loop2-output-processing/test-loop2-processing.sh +113 -0
  166. package/.claude/skills/loop3-output-processing/AGENT_COMPLETION_PROTOCOL.md +206 -0
  167. package/.claude/skills/loop3-output-processing/SKILL.md +421 -0
  168. package/.claude/skills/loop3-output-processing/calculate-confidence.sh +28 -0
  169. package/.claude/skills/loop3-output-processing/execute-and-extract.sh +85 -0
  170. package/.claude/skills/loop3-output-processing/parse-confidence.sh +31 -0
  171. package/.claude/skills/loop3-output-processing/test-agent-timeout.sh +327 -0
  172. package/.claude/skills/loop3-output-processing/test-loop3-processing.sh +155 -0
  173. package/.claude/skills/loop3-output-processing/verify-deliverables.sh +42 -0
  174. package/.claude/skills/pattern-extraction/SKILL.md +30 -0
  175. package/.claude/skills/pattern-extraction/extract-patterns.sh +80 -0
  176. package/.claude/skills/playbook/SKILL.md +113 -0
  177. package/.claude/skills/playbook/init-playbook.sh +54 -0
  178. package/.claude/skills/playbook/playbook.db +0 -0
  179. package/.claude/skills/playbook/query-playbook.sh +79 -0
  180. package/.claude/skills/playbook/update-playbook.sh +69 -0
  181. package/.claude/skills/playbook-auto-update/SKILL.md +29 -0
  182. package/.claude/skills/playbook-auto-update/auto-update-playbook.sh +86 -0
  183. package/.claude/skills/product-owner-decision/SKILL.md +332 -0
  184. package/.claude/skills/product-owner-decision/execute-decision.sh +176 -0
  185. package/.claude/skills/product-owner-decision/parse-decision.sh +66 -0
  186. package/.claude/skills/product-owner-decision/validate-deliverables.sh +82 -0
  187. package/.claude/skills/redis-coordination/AGENT_LOGGING.md +280 -0
  188. package/.claude/skills/redis-coordination/LOGGING.md +260 -0
  189. package/.claude/skills/redis-coordination/README.md +30 -29
  190. package/.claude/skills/redis-coordination/SKILL.md +685 -83
  191. package/.claude/skills/redis-coordination/agent-log.sh +124 -0
  192. package/.claude/skills/redis-coordination/analyze-task-complexity.sh +277 -0
  193. package/.claude/skills/redis-coordination/cfn-loop-exec.sh +468 -0
  194. package/.claude/skills/redis-coordination/collect-confidence-scores.sh +179 -0
  195. package/.claude/skills/redis-coordination/collect-results.sh +75 -0
  196. package/.claude/skills/redis-coordination/data/cfn-loop.db +0 -0
  197. package/.claude/skills/redis-coordination/demos/test-iteration-feedback.sh +320 -0
  198. package/.claude/skills/redis-coordination/{test-orchestrator.sh → demos/test-orchestrator.sh} +25 -0
  199. package/.claude/skills/redis-coordination/execute-product-owner-decision.sh +258 -0
  200. package/.claude/skills/redis-coordination/get-agent-timeout.sh +176 -176
  201. package/.claude/skills/redis-coordination/init-swarm.sh +6 -1
  202. package/.claude/skills/redis-coordination/invoke-waiting-mode.sh +106 -183
  203. package/.claude/skills/redis-coordination/invoke-waiting-mode.sh.backup-p7 +423 -0
  204. package/.claude/skills/redis-coordination/log-event.sh +109 -0
  205. package/.claude/skills/redis-coordination/monitor-cfn-violations.sh +391 -0
  206. package/.claude/skills/redis-coordination/orchestrate-cfn-loop-v3.sh +141 -0
  207. package/.claude/skills/redis-coordination/orchestrate-cfn-loop.sh +31 -933
  208. package/.claude/skills/redis-coordination/orchestrate-cfn-loop.sh.backup +38 -0
  209. package/.claude/skills/redis-coordination/orchestrate-cfn-loop.sh.backup-1761167675 +1672 -0
  210. package/.claude/skills/redis-coordination/orchestrate-cfn-loop.sh.backup-p5 +1604 -0
  211. package/.claude/skills/redis-coordination/orchestrate-cfn-loop.sh.backup-phase1 +1550 -0
  212. package/.claude/skills/redis-coordination/orchestrate-cfn-loop.sh.backup-phase2 +1621 -0
  213. package/.claude/skills/redis-coordination/orchestrate-cfn-loop.sh.backup-phase3 +1621 -0
  214. package/.claude/skills/redis-coordination/orchestrate-cfn-loop.sh.bak +0 -0
  215. package/.claude/skills/redis-coordination/orchestrate-cfn-loop.sh.broken +1627 -0
  216. package/.claude/skills/redis-coordination/orchestrate-cfn-loop.sh.corrupted +80 -0
  217. package/.claude/skills/redis-coordination/orchestrate-cfn-loop.sh.deprecated +1864 -0
  218. package/.claude/skills/redis-coordination/query-logs.sh +103 -0
  219. package/.claude/skills/redis-coordination/retrieve-context.sh +58 -0
  220. package/.claude/skills/redis-coordination/select-specialist-agent.sh +371 -0
  221. package/.claude/skills/redis-coordination/semantic-match-tfidf.py +252 -0
  222. package/.claude/skills/redis-coordination/send-heartbeat.sh +164 -72
  223. package/.claude/skills/redis-coordination/signal.sh +38 -0
  224. package/.claude/skills/redis-coordination/store-context.sh +86 -0
  225. package/.claude/skills/redis-coordination/store-epic-context.sh +123 -0
  226. package/.claude/skills/redis-coordination/test-context-injection.sh +354 -0
  227. package/.claude/skills/redis-coordination/test-timeout-enforcement.sh +513 -0
  228. package/.claude/skills/redis-coordination/tests/convert-line-endings.sh +15 -0
  229. package/.claude/skills/redis-coordination/tests/dlq-functionality-test.sh +101 -101
  230. package/.claude/skills/redis-coordination/tests/edge-cases-test.sh +98 -98
  231. package/.claude/skills/redis-coordination/tests/integration-test.sh +169 -169
  232. package/.claude/skills/redis-coordination/tests/retry-mechanism-test.sh +81 -81
  233. package/.claude/skills/redis-coordination/tests/run-test-suite.sh +91 -91
  234. package/.claude/skills/redis-coordination/tests/run-tests.sh +4 -0
  235. package/.claude/skills/redis-coordination/tests/test-primitives.sh +166 -0
  236. package/.claude/skills/redis-coordination/tests/test-utils.sh +53 -121
  237. package/.claude/skills/redis-coordination/tests/test_coordination_primitives.sh.deprecated +20 -0
  238. package/.claude/skills/redis-coordination/tests/test_utils.sh +49 -0
  239. package/.claude/skills/redis-coordination/v2_modularization/core_orchestration.sh +76 -0
  240. package/.claude/skills/redis-coordination/validate-parameters.sh +492 -0
  241. package/.claude/skills/retrospective-report/SKILL.md +31 -0
  242. package/.claude/skills/retrospective-report/generate-report.sh +101 -0
  243. package/.claude/skills/run-all-skill-tests.sh +124 -0
  244. package/.claude/skills/scope-simplifier/SKILL.md +37 -0
  245. package/.claude/skills/scope-simplifier/simplify-scope.sh +68 -0
  246. package/.claude/skills/simplified-agent-lifecycle/COST_ANALYSIS.md +49 -0
  247. package/.claude/skills/simplified-agent-lifecycle/DESIGN.md +98 -0
  248. package/.claude/skills/simplified-agent-lifecycle/MIGRATION_PLAN.md +74 -0
  249. package/.claude/skills/skill-builder/SKILL.md +910 -0
  250. package/.claude/skills/specialist-injection/SKILL.md +41 -0
  251. package/.claude/skills/specialist-injection/recommend-specialist.sh +57 -0
  252. package/.claude/skills/sprint-execution/SKILL.md +27 -0
  253. package/.claude/skills/sprint-execution/execute-sprint-task.sh +59 -0
  254. package/.claude/skills/sprint-execution/execute-sprint.sh +65 -0
  255. package/.claude/skills/sprint-planner/SKILL.md +37 -0
  256. package/.claude/skills/sprint-planner/plan-sprint.sh +85 -0
  257. package/.claude/skills/standardized-error-handling/SKILL.md +56 -0
  258. package/.claude/skills/standardized-error-handling/capture-agent-error.sh +87 -0
  259. package/.claude/skills/standardized-error-handling/test-error-handling.sh +166 -0
  260. package/.claude/skills/task-classifier/SKILL.md +94 -0
  261. package/.claude/skills/task-classifier/classify-task.sh +115 -0
  262. package/.claude/skills/validation-templates/SKILL.md +47 -0
  263. package/.claude/skills/validation-templates/content.json +38 -0
  264. package/.claude/skills/validation-templates/data.json +38 -0
  265. package/.claude/skills/validation-templates/design.json +38 -0
  266. package/.claude/skills/validation-templates/infrastructure.json +38 -0
  267. package/.claude/skills/validation-templates/research.json +38 -0
  268. package/.claude/skills/validation-templates/software.json +38 -0
  269. package/.claude/skills/webapp-testing/README.md +142 -0
  270. package/.claude/skills/webapp-testing/SCREENSHOT_NAMING_CONVENTION.md +547 -0
  271. package/.claude/skills/webapp-testing/SKILL.md +877 -0
  272. package/.claude/skills/webapp-testing/capture-screenshot.sh +238 -0
  273. package/.claude/skills/webapp-testing/cfn-loop-integration.sh +265 -0
  274. package/.claude/skills/webapp-testing/compare-screenshots.sh +199 -0
  275. package/.claude/skills/webapp-testing/init-storage.sh +150 -0
  276. package/.claude/skills/webapp-testing/set-baseline.sh +196 -0
  277. package/.claude/skills/webapp-testing/test-webapp-testing.sh +233 -0
  278. package/.claude/spawn-pattern-examples.md +3 -3
  279. package/CLAUDE.md +364 -16
  280. package/README.md +598 -251
  281. package/dist/agents/agent-loader.js +146 -165
  282. package/dist/agents/agent-loader.js.map +1 -1
  283. package/dist/cli/agent-command.js +153 -0
  284. package/dist/cli/agent-command.js.map +1 -0
  285. package/dist/cli/agent-definition-parser.js +183 -0
  286. package/dist/cli/agent-definition-parser.js.map +1 -0
  287. package/dist/cli/agent-executor.js +310 -0
  288. package/dist/cli/agent-executor.js.map +1 -0
  289. package/dist/cli/agent-prompt-builder.js +268 -0
  290. package/dist/cli/agent-prompt-builder.js.map +1 -0
  291. package/dist/cli/agent-spawn.js +56 -2
  292. package/dist/cli/agent-spawn.js.map +1 -1
  293. package/dist/cli/anthropic-client.js +421 -0
  294. package/dist/cli/anthropic-client.js.map +1 -0
  295. package/dist/cli/cfn-context.js +150 -0
  296. package/dist/cli/cfn-context.js.map +1 -1
  297. package/dist/cli/cfn-fork.js +159 -0
  298. package/dist/cli/cfn-fork.js.map +1 -0
  299. package/dist/cli/cli-agent-context.js +358 -0
  300. package/dist/cli/cli-agent-context.js.map +1 -0
  301. package/dist/cli/config-manager.js +109 -91
  302. package/dist/cli/config-manager.js.map +1 -1
  303. package/dist/cli/conversation-fork.js +201 -0
  304. package/dist/cli/conversation-fork.js.map +1 -0
  305. package/dist/cli/index.js +119 -2
  306. package/dist/cli/index.js.map +1 -1
  307. package/dist/cli/iteration-history.js +188 -0
  308. package/dist/cli/iteration-history.js.map +1 -0
  309. package/dist/cli/tool-definitions.js +263 -0
  310. package/dist/cli/tool-definitions.js.map +1 -0
  311. package/dist/cli/tool-executor.js +247 -0
  312. package/dist/cli/tool-executor.js.map +1 -0
  313. package/dist/hello.js +8 -0
  314. package/dist/hello.js.map +1 -0
  315. package/package.json +16 -6
  316. package/scripts/README.md +68 -0
  317. package/scripts/cfn-intervention-example.sh +21 -0
  318. package/scripts/migrate-test-infrastructure.sh +40 -0
  319. package/scripts/switch-api.sh +233 -0
  320. package/scripts/validate-test-migration.sh +49 -0
  321. package/scripts/verify-no-secrets.sh +55 -0
  322. package/.claude/agents/architecture/system-architect.md.backup +0 -603
  323. package/.claude/agents/code-booster.md +0 -131
  324. package/.claude/agents/consensus/performance-benchmarker.md +0 -101
  325. package/.claude/agents/consensus/security-manager.md +0 -107
  326. package/.claude/agents/context-curator.md +0 -167
  327. package/.claude/agents/context-reflector.md +0 -65
  328. package/.claude/agents/core-agents/cfn-loop-coordinator.md +0 -134
  329. package/.claude/agents/core-agents/code-quality-validator.md +0 -149
  330. package/.claude/agents/core-agents/context-curator.md +0 -452
  331. package/.claude/agents/core-agents/context-reflector.md +0 -273
  332. package/.claude/agents/core-agents/cost-savings-cfn-loop-coordinator.md +0 -190
  333. package/.claude/agents/core-agents/tester.md +0 -170
  334. package/.claude/agents/development/backend-dev.md +0 -165
  335. package/.claude/agents/devops/devops-engineer.md +0 -148
  336. package/.claude/agents/frontend/interaction-tester.md +0 -139
  337. package/.claude/agents/frontend/react-frontend-engineer.md +0 -9
  338. package/.claude/agents/personas/accessibility-advocate-persona.md +0 -107
  339. package/.claude/agents/testing/production-validator.md +0 -179
  340. package/.claude/agents/testing/tdd-london-swarm.md +0 -209
  341. package/.claude/agents/testing/unit/tdd-london-swarm.md +0 -43
  342. package/.claude/agents/testing/validation/production-validator.md +0 -43
  343. package/dist/coordination/fleet-manager.test.js +0 -141
  344. package/dist/coordination/fleet-manager.test.js.map +0 -1
  345. package/dist/middleware/transparency-middleware.test.js +0 -184
  346. package/dist/middleware/transparency-middleware.test.js.map +0 -1
  347. /package/.claude/agents/{core-agents → developers}/researcher.md +0 -0
  348. /package/.claude/agents/{consensus → specialists}/crdt-synchronizer.md +0 -0
  349. /package/.claude/agents/{consensus → specialists}/quorum-manager.md +0 -0
  350. /package/.claude/agents/{consensus → specialists}/raft-manager.md +0 -0
  351. /package/.claude/{agents/core-agents → agents-ignore}/coordinator.md +0 -0
  352. /package/.claude/{agents/core-agents/cost-savings-coordinator.md → agents-ignore/cost-savings-coordinator.md.backup} +0 -0
  353. /package/.claude/skills/redis-coordination/{phase4-wake-queue-test-report.md → demos/phase4-wake-queue-test-report.md} +0 -0
  354. /package/.claude/skills/redis-coordination/{test-bzpopmin-fix.sh → demos/test-bzpopmin-fix.sh} +0 -0
  355. /package/.claude/skills/redis-coordination/{test-cancel-swarm.sh → demos/test-cancel-swarm.sh} +0 -0
  356. /package/.claude/skills/redis-coordination/{test-dlq.sh → demos/test-dlq.sh} +0 -0
  357. /package/.claude/skills/redis-coordination/{test-priority-wake-phase4-unix.sh → demos/test-priority-wake-phase4-unix.sh} +0 -0
  358. /package/.claude/skills/redis-coordination/{test-priority-wake-phase4.sh → demos/test-priority-wake-phase4.sh} +0 -0
  359. /package/.claude/skills/redis-coordination/{test-priority-wake.sh → demos/test-priority-wake.sh} +0 -0
  360. /package/.claude/skills/redis-coordination/{test-quick-fix.sh → demos/test-quick-fix.sh} +0 -0
  361. /package/.claude/skills/redis-coordination/{test-quorum-absolute.sh → demos/test-quorum-absolute.sh} +0 -0
  362. /package/.claude/skills/redis-coordination/{test-quorum-fallback.sh → demos/test-quorum-fallback.sh} +0 -0
  363. /package/.claude/skills/redis-coordination/{test-quorum-percentage.sh → demos/test-quorum-percentage.sh} +0 -0
  364. /package/.claude/skills/redis-coordination/{test-quorum-with-retry.sh → demos/test-quorum-with-retry.sh} +0 -0
  365. /package/.claude/skills/redis-coordination/{test-quorum.sh → demos/test-quorum.sh} +0 -0
  366. /package/.claude/skills/redis-coordination/{test-shutdown-handling.sh → demos/test-shutdown-handling.sh} +0 -0
  367. /package/.claude/skills/redis-coordination/{test-shutdown.sh → demos/test-shutdown.sh} +0 -0
  368. /package/.claude/skills/redis-coordination/{test-utils-unix.sh → demos/test-utils-unix.sh} +0 -0
  369. /package/.claude/skills/redis-coordination/{test-utils.sh → demos/test-utils.sh} +0 -0
  370. /package/.claude/skills/redis-coordination/{test-waiting-mode.sh → demos/test-waiting-mode.sh} +0 -0
@@ -1,1233 +1,1002 @@
1
- # The Definitive Guide to Agent Profile Design
2
-
3
- **Version:** 3.0.0
4
- **Last Updated:** 2025-10-17
5
- **Status:** Production-Ready with Phase 4 Template Optimization
6
-
7
- This document is the single source of truth for creating, editing, and validating agent profiles in the Claude Flow ecosystem. It incorporates empirical findings from our comprehensive Rust benchmarking system, Phase 4 bulk optimization results (75 agents, 73% reduction), and establishes evidence-based best practices with reusable template patterns.
8
-
9
- ---
10
-
11
- ## Table of Contents
12
-
13
- 1. [Quick Start](#quick-start)
14
- 2. [Phase 4 Template System](#phase-4-template-system)
15
- 3. [Core Universal Principles](#core-universal-principles)
16
- 4. [Agent Profile Structure](#agent-profile-structure)
17
- 5. [Examples & Templates](#examples--templates)
18
- 6. [Specialized Guidance](#specialized-guidance)
19
-
20
- ---
21
-
22
- ## Quick Start
23
-
24
- ### The Three Golden Rules
25
-
26
- 1. **Complexity-Verbosity Inverse Law**: As task complexity increases, prompt verbosity should DECREASE
27
- 2. **Priming Paradox**: Verbose prompts excel at basic tasks, minimal prompts excel at complex reasoning
28
- 3. **Rust Validation**: These findings are validated for Rust; hypotheses for other languages
29
-
30
- ### Format Selection in 30 Seconds
31
-
32
- ```yaml
33
- Is the task BASIC (parsing, simple logic, CRUD)?
34
- Use CODE-HEAVY format (+43% quality improvement)
35
-
36
- Is the task COMPLEX with clear requirements (architecture, review)?
37
- Use MINIMAL format (avoid over-constraining)
38
-
39
- Is the task MEDIUM complexity with structured steps?
40
- Use METADATA format (structured guidance)
41
- ```
42
-
43
- **For detailed format guidance:** See [Format Selection Principles](./agent-principles/format-selection.md)
44
-
45
- ### Agent Size Guidelines (Phase 4 Validated)
46
-
47
- **Target:** 100-200 lines per agent (average: 137 lines)
48
-
49
- ```yaml
50
- All Agents:
51
- Use 5 reusable templates for common patterns
52
- → Preserve only unique domain logic
53
- → Target: 100-200 lines (validated across 75 agents)
54
-
55
- Templates Available:
56
- - redis-coordination.md (90 lines)
57
- - memory-operations.md (78 lines)
58
- - post-edit-validation.md (121 lines)
59
- - cfn-loop-mechanics.md (70 lines)
60
- - team-dynamics.md (80 lines)
61
- ```
62
-
63
- **Phase 4 Results:** 75 agents optimized, 73% codebase reduction, 50-66% faster loading
64
-
65
- ---
66
-
67
- ## Phase 4 Template System
68
-
69
- ### Overview
70
-
71
- **Phase 4 (October 2025)** successfully optimized 75 of 81 agents using template extraction:
72
- - **23,615 lines removed** (71% average reduction per agent)
73
- - **Average agent size:** 137 lines (down from 470 lines)
74
- - **5 reusable templates** created
75
- - **100% functionality preserved**
76
-
77
- ### The 5 Core Templates
78
-
79
- #### 1. Redis Coordination (`.claude/templates/redis-coordination.md`)
80
- **What:** Redis pub/sub patterns, LPUSH/BLPOP, hierarchical broadcast, mesh hybrid
81
- **When:** All agents need Redis coordination
82
- **Size:** 90 lines
83
- **Usage:**
84
- ```markdown
85
- ## Redis Coordination
86
-
87
- → See: `.claude/templates/redis-coordination.md`
88
-
89
- - Event publishing patterns
90
- - Signal ACK protocol
91
- - Error handling strategies
92
- ```
93
-
94
- #### 2. Memory Operations (`.claude/templates/memory-operations.md`)
95
- **What:** SQLite + Redis integration, 5-level ACL, retention policies
96
- **When:** All agents need memory persistence
97
- **Size:** 78 lines
98
- **Usage:**
99
- ```markdown
100
- ## Memory Operations
101
-
102
- See: `.claude/templates/memory-operations.md`
103
-
104
- - SQLite lifecycle hooks
105
- - ACL-based access control
106
- - Retry logic for persistence
107
- ```
108
-
109
- #### 3. Post-Edit Validation (`.claude/templates/post-edit-validation.md`)
110
- **What:** Hook integration, 5 feedback types, validation patterns
111
- **When:** All agents perform file edits
112
- **Size:** 121 lines
113
- **Usage:**
114
- ```markdown
115
- ## 🚨 MANDATORY POST-EDIT VALIDATION
116
-
117
- ```bash
118
- npx claude-flow@alpha hooks post-edit [FILE_PATH] --memory-key "agent/step" --structured
119
- ```
120
-
121
- → See: `.claude/templates/post-edit-validation.md` for feedback types
122
- ```
123
-
124
- #### 4. CFN Loop Mechanics (`.claude/templates/cfn-loop-mechanics.md`)
125
- **What:** Loop structure, decision framework (PROCEED/LOOP/DEFER/ESCALATE), mode thresholds
126
- **When:** Agents participate in CFN Loop
127
- **Size:** 70 lines
128
- **Usage:**
129
- ```markdown
130
- ## CFN Loop Mechanics
131
-
132
- See: `.claude/templates/cfn-loop-mechanics.md`
133
-
134
- - Loop progression logic
135
- - Mode-specific thresholds (MVP/Standard/Enterprise)
136
- - Decision framework
137
- ```
138
-
139
- #### 5. Team Dynamics (`.claude/templates/team-dynamics.md`)
140
- **What:** Dynamic role adaptation, collaboration patterns, confidence calibration
141
- **When:** All agents work in teams
142
- **Size:** 80 lines
143
- **Usage:**
144
- ```markdown
145
- ## Team Role Awareness
146
-
147
- See: `.claude/templates/team-dynamics.md`
148
-
149
- **Specialty:** [Agent domain]
150
- **Solo Confidence:** ≥0.80
151
- **Team Confidence:** ≥0.75
152
-
153
- ## Collaboration Patterns
154
- - **With Implementers:** Provide specifications
155
- - **With Validators:** Share results via Redis
156
- - **Solo:** Full implementation cycle
157
- ```
158
-
159
- ### Template-Based Agent Structure (Validated)
160
-
161
- **New Standard (100-200 lines):**
162
-
163
- ```markdown
164
- ---
165
- # Frontmatter (30 lines)
166
- name: agent-name
167
- description: |
168
- MUST BE USED when [use case]
169
- Keywords - [keywords]
170
- tools: [Read, Write, Edit, Bash, TodoWrite]
171
- model: haiku
172
- type: specialist
173
- acl_level: 1
174
- validation_hooks:
175
- - agent-template-validator
176
- - cfn-loop-memory-validator
177
- lifecycle:
178
- pre_task: "sqlite-cli exec 'INSERT INTO agents...'"
179
- post_task: "sqlite-cli exec 'UPDATE agents...'"
180
- ---
181
-
182
- # Agent Name (1 line)
183
-
184
- Brief intro (2-3 lines)
185
-
186
- ## 🚨 MANDATORY POST-EDIT VALIDATION (8 lines)
187
-
188
- → See: `.claude/templates/post-edit-validation.md`
189
-
190
- ## Template References (20 lines)
191
-
192
- See: `.claude/templates/redis-coordination.md`
193
- → See: `.claude/templates/memory-operations.md`
194
- See: `.claude/templates/team-dynamics.md`
195
- → See: `.claude/templates/cfn-loop-mechanics.md`
196
-
197
- ## Core Unique Logic (50-120 lines)
198
-
199
- [ONLY agent-specific domain expertise]
200
-
201
- ## Success Metrics (10 lines)
202
- ```
203
-
204
- ### Benefits of Template System
205
-
206
- **Developer Productivity:**
207
- - easier maintenance (single template update propagates)
208
- - Faster agent creation (templates provide scaffolding)
209
- - Consistent structure across 75 agents
210
-
211
- **System Performance:**
212
- - 50-66% faster agent loading
213
- - 73% reduction in token usage
214
- - 70% more efficient rule processing
215
-
216
- **Quality:**
217
- - 100% functionality preserved
218
- - All validation hooks maintained
219
- - Standardized patterns reduce bugs
220
-
221
- **Cost Savings:**
222
- - 73% fewer tokens per agent
223
- - ~32,925 equivalent lines reused via templates
224
- - reduction in maintenance effort
225
-
226
- ### Creating New Agents (Template-First Approach)
227
-
228
- **Step 1:** Choose appropriate templates (typically all 5)
229
-
230
- **Step 2:** Define unique domain logic only (50-120 lines)
231
-
232
- **Step 3:** Reference templates, don't duplicate
233
- ```markdown
234
- ## Redis Coordination
235
-
236
- → See: `.claude/templates/redis-coordination.md`
237
-
238
- [Only agent-specific Redis patterns here]
239
- ```
240
-
241
- **Step 4:** Validate agent size <200 lines
242
-
243
- **Example:** See optimized agents in `.claude/agents/` (all <200 lines)
244
-
245
- ---
246
-
247
- ## Core Universal Principles
248
-
249
- ### 1. Agent Profile Structure **REQUIRED FORMAT**
250
-
251
- Every agent MUST include:
252
-
253
- #### Frontmatter (YAML)
254
-
255
- ```yaml
256
- ---
257
- name: agent-name # REQUIRED: Lowercase with hyphens
258
- description: | # REQUIRED: Clear, keyword-rich description
259
- MUST BE USED when [primary use case].
260
- Use PROACTIVELY for [specific scenarios].
261
- ALWAYS delegate when user asks [trigger phrases].
262
- Keywords - [comma-separated keywords for search]
263
- tools: [Read, Write, Edit, Bash, TodoWrite, mcp__claude-flow__swarm_init, mcp__claude-flow__agent_spawn] # REQUIRED: Comma-separated list, can include MCP commands
264
- model: sonnet # REQUIRED: sonnet | opus | haiku
265
- provider: zai # OPTIONAL: zai | anthropic | custom (defaults to zai if not specified)
266
- color: seagreen # REQUIRED: Visual identifier
267
- type: specialist # OPTIONAL: specialist | coordinator | swarm
268
- capabilities: # OPTIONAL: Array of capability tags
269
- - rust
270
- - error-handling
271
- lifecycle: # OPTIONAL: Hooks for agent lifecycle
272
- pre_task: "npx claude-flow@alpha hooks pre-task"
273
- post_task: "npx claude-flow@alpha hooks post-task"
274
- hooks: # OPTIONAL: Integration points
275
- memory_key: "agent-name/context"
276
- validation: "post-edit"
277
- validation_hooks: # OPTIONAL: Auto-triggered validators
278
- - agent-template-validator # Auto-validates on .md save
279
- - cfn-loop-memory-validator # Auto-validates memory.set() calls
280
- - test-coverage-validator # Auto-validates after tests
281
- - blocking-coordination-validator # For coordinators only
282
- triggers: # OPTIONAL: Automatic activation patterns
283
- - "build rust"
284
- - "implement concurrent"
285
- constraints: # OPTIONAL: Limitations and boundaries
286
- - "Do not modify production database"
287
- ---
288
- ```
289
-
290
- #### Body Structure
291
-
292
- ```markdown
293
- # Agent Name
294
-
295
- [Opening paragraph: WHO you are, WHAT you do]
296
-
297
- ## 🚨 MANDATORY POST-EDIT VALIDATION
298
-
299
- **CRITICAL**: After **EVERY** file edit operation, you **MUST** run the enhanced post-edit hook:
300
-
301
- ```bash
302
- npx claude-flow@alpha hooks post-edit [FILE_PATH] --memory-key "agent/step" --structured
303
- ```
304
-
305
- **This provides:**
306
- - 🧪 **TDD Compliance**: Validates test-first development practices
307
- - 🔒 **Security Analysis**: Detects eval(), hardcoded credentials, XSS vulnerabilities
308
- - 🎨 **Formatting**: Prettier/rustfmt analysis with diff preview
309
- - 📊 **Coverage Analysis**: Test coverage validation with configurable thresholds (≥80%)
310
- - 🤖 **Actionable Recommendations**: Specific steps to improve code quality
311
- - 💾 **Memory Coordination**: Stores results for cross-agent collaboration
312
-
313
- **Additional Validators:**
314
- - **Agent Template Validator**: Auto-validates SQLite lifecycle hooks, ACL declarations, error handling patterns (triggers on `.claude/agents/**/*.md` edits)
315
- - **CFN Loop Memory Validator**: Auto-validates ACL levels for Loop 3/2/4 memory operations (triggers on `memory.set()` calls)
316
- - **Test Coverage Validator**: Auto-validates 80% line coverage, 75% branch coverage thresholds (triggers after test execution)
317
- - **Blocking Coordination Validator**: Auto-validates HMAC secrets, signal ACK patterns (coordinators only)
318
-
319
- ## Core Responsibilities
320
-
321
- [Primary duties in clear, actionable bullet points]
322
-
323
- ## Approach & Methodology
324
-
325
- [HOW the agent accomplishes tasks - frameworks, patterns, decision-making]
326
-
327
- ## Integration & Collaboration
328
-
329
- [How this agent works with other agents and the broader system]
330
-
331
- ## Success Metrics
332
-
333
- [How to measure agent effectiveness]
334
- ```
335
-
336
- ---
337
-
338
- ### 2. The Complexity-Verbosity Inverse Law
339
-
340
- **Empirical Finding:** Task complexity and prompt verbosity have an inverse relationship.
341
-
342
- ```
343
- Basic Tasks (parsing, CRUD):
344
- - Code-Heavy: 85.3% quality (+43% vs Minimal)
345
- - Best approach: Detailed examples with step-by-step guidance
346
-
347
- Complex Tasks (architecture, lock-free algorithms):
348
- - Minimal: 87.2% quality (+31% vs Code-Heavy)
349
- - Best approach: High-level principles with reasoning freedom
350
- ```
351
-
352
- **Why This Matters:**
353
- - Basic tasks benefit from concrete patterns (priming effect)
354
- - Complex tasks need creative freedom (over-specification creates tunnel vision)
355
- - Medium tasks need structured scaffolding without over-constraining
356
-
357
- **For detailed analysis:** See [Format Selection Principles](./agent-principles/format-selection.md)
358
-
359
- ---
360
-
361
- ### 3. Mandatory Post-Edit Validation System
362
-
363
- **UNIVERSAL REQUIREMENT:** Every agent MUST run post-edit hooks after file modifications.
364
-
365
- ```bash
366
- npx claude-flow@alpha hooks post-edit [FILE_PATH] \
367
- --memory-key "agent-name/context" \
368
- --structured
369
- ```
370
-
371
- **Core Benefits:**
372
- - TDD compliance verification
373
- - Security analysis (XSS, eval(), hardcoded credentials)
374
- - Formatting validation (Prettier, rustfmt)
375
- - Test coverage analysis (≥80% line, ≥75% branch)
376
- - Cross-agent memory coordination
377
- - Actionable recommendations
378
-
379
- **Four Production-Ready Validators:**
380
-
381
- 1. **Agent Template Validator** (Priority 1 - CRITICAL)
382
- - Validates SQLite lifecycle hooks (spawn, update, terminate)
383
- - Validates ACL level declarations (1-5)
384
- - Validates error handling patterns (SQLite failures, Redis connection loss)
385
- - Validates blocking coordination imports (coordinators only)
386
- - Triggers: On edit to `.claude/agents/**/*.md` files
387
- - Automation: 95% (WASM-accelerated pattern matching)
388
-
389
- 2. **CFN Loop Memory Pattern Validator** (Priority 2 - HIGH)
390
- - Validates ACL level correctness (Loop 3: Private=1, Loop 2: Swarm=3, Loop 4: Project=4)
391
- - Validates memory key format (`cfn/phase-{id}/loop{N}/...`)
392
- - Validates TTL values match retention policies (Loop 4: 365 days)
393
- - Validates encryption for sensitive data (Loop 3 private data)
394
- - Triggers: On `memory.set()` calls in code
395
- - Automation: 90% (deterministic rule matching)
396
-
397
- 3. **Test Coverage Validator** (Priority 3 - MEDIUM)
398
- - Validates line coverage 80%
399
- - Validates branch coverage ≥ 75%
400
- - Validates function coverage ≥ 80%
401
- - Validates agent lifecycle tests present
402
- - Validates signal ACK protocol tests present
403
- - Triggers: After test execution
404
- - Automation: 100% (quantitative metrics)
405
-
406
- 4. **Blocking Coordination Validator** (DEPRECATED - Use Redis BLPOP instead)
407
- - ⚠️ **Status**: Deprecated in favor of Redis BLPOP primitives
408
- - See: `.claude/skills/redis-coordination/SKILL.md` for modern patterns
409
- - Migration guide: `legacy/v1/deprecated/BLOCKING_COORDINATION_MIGRATION.md`
410
-
411
- **Hook Composition Pattern:**
412
-
413
- Hooks compose for comprehensive validation:
414
-
415
- ```javascript
416
- // CompositeHook pattern enables layered validation
417
- const agentValidation = new CompositeHook(
418
- new AgentTemplateValidator(),
419
- new CFNLoopMemoryValidator(),
420
- new TestCoverageValidator()
421
- );
422
-
423
- // Results merge for actionable recommendations
424
- const result = await agentValidation.validate(file, content);
425
- // → { valid: boolean, results: [], combinedRecommendations: [] }
426
- ```
427
-
428
- **Performance Expectations:**
429
- - Individual validator: <2s (WASM-accelerated)
430
- - Composite validation: <5s total (parallel execution)
431
- - False positive rate: <2%
432
-
433
- **For integration details:** See [Prompt Engineering Best Practices](./agent-principles/prompt-engineering.md)
434
-
435
- ---
436
-
437
- ### 4. Agent Template Validator Specification
438
-
439
- **Purpose:** Ensures all agent templates follow SQLite lifecycle, ACL, and error handling best practices.
440
-
441
- **Validation Criteria:**
442
-
443
- **SQLite Lifecycle Hooks** (All agents MUST persist to SQLite for audit trail)
444
- ```typescript
445
- // Agent spawn registration
446
- await sqlite.execute(`
447
- INSERT INTO agents (id, type, status, spawned_at)
448
- VALUES (?, ?, 'active', CURRENT_TIMESTAMP)
449
- `, [agentId, agentType]);
450
-
451
- // Confidence score updates during execution
452
- await sqlite.execute(`
453
- UPDATE agents SET status = ?, confidence = ?, updated_at = CURRENT_TIMESTAMP
454
- WHERE id = ?
455
- `, [status, confidenceScore, agentId]);
456
-
457
- // Agent termination and cleanup
458
- await sqlite.execute(`
459
- UPDATE agents SET status = 'completed', completed_at = CURRENT_TIMESTAMP
460
- WHERE id = ?
461
- `, [agentId]);
462
- ```
463
-
464
- **ACL Level Declaration** (Data access control by agent type)
465
- ```yaml
466
- # ACL Level Guidelines by Agent Type:
467
- implementers:
468
- acl_level: 1 # Private (agent-scoped data)
469
- example: "coder, backend-dev, frontend-dev"
470
-
471
- validators:
472
- acl_level: 3 # Swarm (shared across validation team)
473
- example: "reviewer, security-specialist, tester"
474
-
475
- coordinators:
476
- acl_level: 3 # Swarm (coordinate multiple agents)
477
- example: "architect, planner, devops-engineer"
478
-
479
- product_owner:
480
- acl_level: 4 # Project (strategic decisions, audit trail)
481
- example: "product-owner (CFN Loop 4 only)"
482
- ```
483
-
484
- **Error Handling for SQLite Failures**
485
- ```javascript
486
- try {
487
- await sqlite.memoryAdapter.set(key, value, { aclLevel: 1 });
488
- } catch (error) {
489
- if (error.code === 'SQLITE_BUSY') {
490
- // Retry with exponential backoff
491
- await retryWithBackoff(() => sqlite.memoryAdapter.set(key, value));
492
- } else if (error.code === 'SQLITE_LOCKED') {
493
- // Wait for lock release
494
- await waitForLockRelease(key);
495
- } else {
496
- // Log and gracefully degrade
497
- console.error('SQLite failure:', error);
498
- // Fallback to Redis for non-critical data
499
- await redis.set(key, value);
500
- }
501
- }
502
- ```
503
-
504
- **Redis BLPOP Coordination** (Coordinators - Modern Pattern)
505
- ```bash
506
- # Zero-token blocking coordination using Redis primitives
507
- # See: .claude/skills/redis-coordination/SKILL.md
508
-
509
- # Agent signals completion
510
- redis-cli lpush "swarm:${TASK_ID}:${AGENT_ID}:done" "complete"
511
-
512
- # Coordinator blocks until agent completes (zero tokens consumed)
513
- redis-cli blpop "swarm:${TASK_ID}:${AGENT_ID}:done" 30
514
-
515
- # Wake agent for next iteration
516
- ./.claude/skills/redis-coordination/invoke-waiting-mode.sh wake \
517
- --task-id "$TASK_ID" --agent-id "$AGENT_ID" --reason "cfn_loop_iteration"
518
- ```
519
-
520
- **Memory Key Patterns:**
521
-
522
- ```yaml
523
- # Standard agent memory patterns
524
- agent_memory:
525
- format: "agent/{agentId}/confidence/{taskId}"
526
- example: "agent/coder-1/confidence/auth-implementation"
527
- acl_level: 1 # Private to agent
528
-
529
- # CFN Loop memory patterns
530
- cfn_loop_memory:
531
- loop_3: "cfn/phase-{id}/loop3/agent-{id}/{metric}"
532
- loop_2: "cfn/phase-{id}/loop2/validation/{validator-id}"
533
- loop_4: "cfn/phase-{id}/loop4/decision/{decision-type}"
534
-
535
- # ACL levels by loop
536
- loop_3_acl: 1 # Private (implementation details)
537
- loop_2_acl: 3 # Swarm (validation team access)
538
- loop_4_acl: 4 # Project (strategic decisions)
539
- ```
540
-
541
- **Validation Trigger:**
542
- - File path: `.claude/agents/**/*.md`
543
- - Trigger event: File save/edit
544
- - Execution time: <2s (WASM-accelerated)
545
- - Integration: Automatic via post-edit hook
546
-
547
- **Validation Output Example:**
548
-
549
- ```json
550
- {
551
- "validator": "agent-template-validator",
552
- "file": ".claude/agents/backend/coder.md",
553
- "valid": false,
554
- "violations": [
555
- {
556
- "type": "missing_sqlite_lifecycle",
557
- "severity": "error",
558
- "message": "Missing agent spawn registration (INSERT INTO agents)",
559
- "line": null,
560
- "recommendation": "Add SQLite lifecycle hooks in agent initialization"
561
- },
562
- {
563
- "type": "missing_acl_declaration",
564
- "severity": "error",
565
- "message": "No ACL level declared for memory operations",
566
- "line": 45,
567
- "recommendation": "Add aclLevel: 1 for implementer agents"
568
- }
569
- ],
570
- "warnings": [
571
- {
572
- "type": "error_handling_basic",
573
- "message": "Basic error handling present, consider retry logic",
574
- "recommendation": "Implement exponential backoff for SQLite BUSY errors"
575
- }
576
- ]
577
- }
578
- ```
579
-
580
- **For CFN Loop integration:** See section on SQLite Integration Requirements below.
581
-
582
- ---
583
-
584
- ### 5. SQLite Integration Requirements
585
-
586
- **All agents MUST persist to SQLite for audit trail and cross-session recovery.**
587
-
588
- **ACL Level Guidelines:**
589
-
590
- | Agent Type | ACL Level | Scope | Example Use Cases |
591
- |-----------|-----------|-------|-------------------|
592
- | **Implementers** | 1 (Private) | Agent-scoped data | Code snippets, temporary state, confidence scores |
593
- | **Validators** | 3 (Swarm) | Validation team shared | Review feedback, security findings, test results |
594
- | **Coordinators** | 3 (Swarm) | Multi-agent coordination | Task assignments, progress tracking, blocking signals |
595
- | **Product Owner** | 4 (Project) | Strategic decisions | GOAP decisions, backlog items, phase approvals |
596
-
597
- **Memory Key Patterns:**
598
-
599
- ```javascript
600
- // Standard agent memory
601
- const agentKey = `agent/${agentId}/confidence/${taskId}`;
602
- await sqlite.memoryAdapter.set(agentKey, confidenceScore, {
603
- aclLevel: 1, // Private to agent
604
- ttl: 2592000 // 30 days
605
- });
606
-
607
- // CFN Loop patterns
608
- const loop3Key = `cfn/phase-auth/loop3/agent-coder-1/implementation`;
609
- await sqlite.memoryAdapter.set(loop3Key, implementationDetails, {
610
- aclLevel: 1, // Private (Loop 3 implementation)
611
- ttl: 2592000 // 30 days
612
- });
613
-
614
- const loop2Key = `cfn/phase-auth/loop2/validation/reviewer-1`;
615
- await sqlite.memoryAdapter.set(loop2Key, validationResults, {
616
- aclLevel: 3, // Swarm (Loop 2 validation team)
617
- ttl: 7776000 // 90 days
618
- });
619
-
620
- const loop4Key = `cfn/phase-auth/loop4/decision/proceed`;
621
- await sqlite.memoryAdapter.set(loop4Key, goapDecision, {
622
- aclLevel: 4, // Project (Loop 4 strategic decision)
623
- ttl: 31536000 // 365 days (compliance requirement)
624
- });
625
- ```
626
-
627
- **Error Handling Patterns:**
628
-
629
- ```javascript
630
- // Retry with exponential backoff for transient errors
631
- async function retryWithBackoff(operation, maxRetries = 3) {
632
- for (let i = 0; i < maxRetries; i++) {
633
- try {
634
- return await operation();
635
- } catch (error) {
636
- if (error.code === 'SQLITE_BUSY' && i < maxRetries - 1) {
637
- const delay = Math.pow(2, i) * 100; // 100ms, 200ms, 400ms
638
- await new Promise(resolve => setTimeout(resolve, delay));
639
- } else {
640
- throw error;
641
- }
642
- }
643
- }
644
- }
645
-
646
- // Graceful degradation for non-critical data
647
- async function writeWithFallback(key, value, options) {
648
- try {
649
- await sqlite.memoryAdapter.set(key, value, options);
650
- } catch (error) {
651
- console.warn('SQLite write failed, falling back to Redis:', error);
652
- // Fallback to Redis for non-audit data only
653
- if (options.aclLevel < 4) {
654
- await redis.set(key, JSON.stringify(value));
655
- } else {
656
- // Critical data MUST persist to SQLite
657
- throw new Error('Cannot write critical data to fallback store');
658
- }
659
- }
660
- }
661
- ```
662
-
663
- **Agent Lifecycle Hooks Integration:**
664
-
665
- ```yaml
666
- # In agent frontmatter
667
- lifecycle:
668
- pre_task: |
669
- # Register agent in SQLite on spawn
670
- sqlite-cli exec "INSERT INTO agents (id, type, status, spawned_at)
671
- VALUES ('${AGENT_ID}', '${AGENT_TYPE}', 'active', CURRENT_TIMESTAMP)"
672
-
673
- post_task: |
674
- # Update agent status and confidence on completion
675
- sqlite-cli exec "UPDATE agents
676
- SET status = 'completed',
677
- confidence = ${CONFIDENCE_SCORE},
678
- completed_at = CURRENT_TIMESTAMP
679
- WHERE id = '${AGENT_ID}'"
680
- ```
681
-
682
- **For CFN Loop memory patterns:** See CFN Loop Memory Pattern Validator above.
683
-
684
- ---
685
-
686
- ### 6. Integration with Claude Flow
687
-
688
- #### Hook System
689
-
690
- Every agent integrates with:
691
- - **Pre-task hooks**: Initialize context, set up memory namespace, register in SQLite
692
- - **Post-edit hooks**: Validate quality, coordinate with other agents, run validators
693
- - **Post-task hooks**: Finalize task, export metrics, update SQLite status
694
- - **Session management**: Persist state across sessions via SQLite
695
-
696
- #### Memory Coordination (SQLite + ACL)
697
-
698
- ```javascript
699
- // Standard memory key pattern: {agent-type}/{domain}/{aspect}
700
- await sqlite.memoryAdapter.set("architect/auth/design", designDoc, { aclLevel: 3 });
701
- await sqlite.memoryAdapter.set("coder/auth/implementation", code, { aclLevel: 1 });
702
- await sqlite.memoryAdapter.set("reviewer/auth/feedback", feedback, { aclLevel: 3 });
703
- await sqlite.memoryAdapter.set("tester/auth/coverage", coverage, { aclLevel: 3 });
704
-
705
- // CFN Loop memory pattern: cfn/phase-{id}/loop{N}/{agent-id}/{metric}
706
- await sqlite.memoryAdapter.set("cfn/phase-auth/loop3/coder-1/confidence", 0.85, {
707
- aclLevel: 1, // Loop 3: Private implementation data
708
- ttl: 2592000 // 30 days
709
- });
710
-
711
- await sqlite.memoryAdapter.set("cfn/phase-auth/loop2/reviewer-1/consensus", 0.92, {
712
- aclLevel: 3, // Loop 2: Swarm validation data
713
- ttl: 7776000 // 90 days
714
- });
715
-
716
- await sqlite.memoryAdapter.set("cfn/phase-auth/loop4/decision", "DEFER", {
717
- aclLevel: 4, // Loop 4: Project strategic decision
718
- ttl: 31536000 // 365 days (compliance)
719
- });
720
- ```
721
-
722
- **ACL Enforcement:**
723
- - ACL Level 1 (Private): Only creating agent can read
724
- - ACL Level 3 (Swarm): All agents in same swarm can read
725
- - ACL Level 4 (Project): All agents in project can read
726
- - ACL Level 5 (Team/System): Reserved for infrastructure
727
-
728
- #### Swarm Coordination with SQLite Lifecycle
729
-
730
- When spawning multiple agents:
731
- 1. **Pre-task hook**: Register agent in SQLite, initialize memory namespace
732
- 2. **Execute work**: Implement task with progress updates to SQLite
733
- 3. **Post-edit hook**: Validate each file with all 4 validators (agent-template, cfn-loop-memory, test-coverage, blocking-coordination)
734
- 4. **Store results**: Persist to SQLite with appropriate ACL level
735
- 5. **Post-task hook**: Finalize task, update agent status to 'completed', export metrics
736
-
737
- **Hook Execution Sequence:**
738
-
739
- ```bash
740
- # 1. Pre-task: Agent registration
741
- sqlite-cli exec "INSERT INTO agents (id, type, status, spawned_at) VALUES ('coder-1', 'coder', 'active', CURRENT_TIMESTAMP)"
742
-
743
- # 2. Work execution with progress updates
744
- sqlite-cli exec "UPDATE agents SET status = 'in_progress', updated_at = CURRENT_TIMESTAMP WHERE id = 'coder-1'"
745
-
746
- # 3. Post-edit: Run all applicable validators
747
- npx claude-flow@alpha hooks post-edit src/auth.js --memory-key "agent/coder-1/auth" --structured
748
- # → Triggers: agent-template-validator, cfn-loop-memory-validator, test-coverage-validator
749
-
750
- # 4. Store results with ACL
751
- sqlite-cli exec "INSERT INTO memory (key, value, acl_level, ttl) VALUES ('agent/coder-1/confidence/auth', '0.85', 1, 2592000)"
752
-
753
- # 5. Post-task: Finalization
754
- sqlite-cli exec "UPDATE agents SET status = 'completed', confidence = 0.85, completed_at = CURRENT_TIMESTAMP WHERE id = 'coder-1'"
755
- ```
756
-
757
- **Hook Composition for Coordinators:**
758
-
759
- Coordinator agents run standard validation:
760
-
761
- ```bash
762
- # Coordinators trigger standard validators
763
- npx claude-flow@alpha hooks post-edit src/coordinator.js --memory-key "agent/coordinator-1/phase" --structured
764
- # Triggers: agent-template-validator, cfn-loop-memory-validator
765
-
766
- # For Redis coordination validation, see:
767
- # .claude/skills/redis-coordination/test-orchestrator.sh (8/8 passing tests)
768
- ```
769
-
770
- **Performance:**
771
- - Sequential validators: ~5-8s total
772
- - Parallel validators (independent): ~2-3s total (recommended)
773
- - WASM acceleration: 52x speedup for pattern matching
774
-
775
- **For detailed integration:** See [Prompt Engineering Best Practices](./agent-principles/prompt-engineering.md)
776
-
777
- ---
778
-
779
- ## Agent Profile Structure
780
-
781
- ### The Three Formats
782
-
783
- 1. **MINIMAL (200-400 lines)**: For complex, strategic tasks requiring reasoning freedom
784
- 2. **METADATA (400-700 lines)**: For medium complexity with structured workflows
785
- 3. **CODE-HEAVY (700-1200 lines)**: For basic tasks benefiting from concrete examples
786
-
787
- **Detailed format specifications:** [Format Selection Principles](./agent-principles/format-selection.md)
788
-
789
- ### Format Selection Decision Tree
790
-
791
- ```
792
- Task Complexity Assessment
793
-
794
- ┌───┴────┐
795
- │ │
796
- BASIC COMPLEX
797
- │ │
798
- CODE-HEAVY MINIMAL
799
- ```
800
-
801
- **Full decision tree and factors:** [Format Selection Principles](./agent-principles/format-selection.md)
802
-
803
- ---
804
-
805
- ## Examples & Templates
806
-
807
- ### Example 1: Minimal Format (Complex Tasks)
808
-
809
- **File:** `.claude/agents/architecture/system-architect.md`
810
-
811
- ```markdown
812
- ---
813
- name: system-architect
814
- description: |
815
- MUST BE USED when designing enterprise-grade system architecture.
816
- Use PROACTIVELY for distributed systems, event-driven architecture.
817
- Keywords - architecture, system design, microservices, scalability
818
- tools: [Read, Write, Edit, Bash, Grep, Glob, TodoWrite]
819
- model: sonnet
820
- color: seagreen
821
- type: coordinator
822
- validation_hooks:
823
- - agent-template-validator
824
- - cfn-loop-memory-validator
825
- lifecycle:
826
- pre_task: |
827
- sqlite-cli exec "INSERT INTO agents (id, type, status, spawned_at)
828
- VALUES ('${AGENT_ID}', 'system-architect', 'active', CURRENT_TIMESTAMP)"
829
- post_task: |
830
- sqlite-cli exec "UPDATE agents
831
- SET status = 'completed', confidence = ${CONFIDENCE_SCORE},
832
- completed_at = CURRENT_TIMESTAMP
833
- WHERE id = '${AGENT_ID}'"
834
- ---
835
-
836
- # System Architect Agent
837
-
838
- You are a senior system architect with deep expertise in designing
839
- scalable, maintainable, and robust software systems.
840
-
841
- ## 🚨 MANDATORY POST-EDIT VALIDATION
842
-
843
- After EVERY file edit:
844
- ```bash
845
- npx claude-flow@alpha hooks post-edit [FILE] --memory-key "architect/${AGENT_ID}/step" --structured
846
- ```
847
-
848
- This triggers: agent-template-validator, cfn-loop-memory-validator
849
-
850
- ## SQLite Integration
851
-
852
- All architectural decisions MUST persist to SQLite with ACL Level 3 (Swarm):
853
-
854
- ```javascript
855
- // Store ADR in SQLite
856
- await sqlite.memoryAdapter.set(
857
- `architect/${agentId}/adr/${componentName}`,
858
- architectureDecisionRecord,
859
- { aclLevel: 3, ttl: 31536000 } // 1 year retention
860
- );
861
-
862
- // Error handling with retry
863
- try {
864
- await sqlite.memoryAdapter.set(key, value, options);
865
- } catch (error) {
866
- if (error.code === 'SQLITE_BUSY') {
867
- await retryWithBackoff(() => sqlite.memoryAdapter.set(key, value, options));
868
- } else {
869
- throw error;
870
- }
871
- }
872
- ```
873
-
874
- ## Core Responsibilities
875
-
876
- - Design system architectures from business requirements
877
- - Make strategic technical decisions with clear rationale
878
- - Define component boundaries and interactions
879
- - Ensure scalability, security, and maintainability
880
- - Create Architecture Decision Records (ADRs)
881
- - Persist all decisions to SQLite for audit trail
882
-
883
- ## Architectural Approach
884
-
885
- ### Requirements Analysis
886
- Extract functional and non-functional requirements, identify constraints
887
- and quality attributes, understand stakeholder needs.
888
-
889
- ### Design Process
890
- Apply appropriate patterns (microservices, event-driven, CQRS), consider
891
- trade-offs, document decisions with ADRs.
892
-
893
- ### Quality Attributes
894
- - Performance: Response times, throughput
895
- - Scalability: Horizontal and vertical scaling
896
- - Security: Zero-trust, defense-in-depth
897
- - Maintainability: Modular design, clear interfaces
898
- - Reliability: Fault tolerance, disaster recovery
899
-
900
- ## Collaboration
901
-
902
- - Work with Coder agents for implementation guidance (ACL 1)
903
- - Coordinate with Reviewer agents for design validation (ACL 3)
904
- - Provide specifications to DevOps for infrastructure (ACL 3)
905
- - Share ADRs via SQLite memory system (ACL 3)
906
-
907
- ## Success Metrics
908
-
909
- - Architecture meets quality attributes
910
- - Team can implement the design
911
- - Documentation is clear and comprehensive
912
- - Trade-offs are explicitly documented
913
- - All decisions persisted to SQLite with appropriate ACL
914
- ```
915
-
916
- **For more examples:** [Format Selection Principles](./agent-principles/format-selection.md)
917
-
918
- ---
919
-
920
- ### Example 2: Metadata Format (Medium Tasks with CFN Loop Integration)
921
-
922
- **File:** `.claude/agents/development/api-developer.md`
923
-
924
- **Key additions for CFN Loop:**
925
- ```yaml
926
- validation_hooks:
927
- - agent-template-validator
928
- - cfn-loop-memory-validator
929
- - test-coverage-validator
930
- lifecycle:
931
- pre_task: "sqlite-cli exec 'INSERT INTO agents ...'"
932
- post_task: "sqlite-cli exec 'UPDATE agents SET status=completed ...'"
933
- ```
934
-
935
- **CFN Loop Memory Persistence:**
936
- ```javascript
937
- // Loop 3: Implementation confidence (Private)
938
- await sqlite.memoryAdapter.set(
939
- `cfn/phase-api/loop3/api-developer-1/confidence`,
940
- 0.85,
941
- { aclLevel: 1, ttl: 2592000 } // Private, 30 days
942
- );
943
-
944
- // Loop 2: Validation feedback (Swarm)
945
- await sqlite.memoryAdapter.set(
946
- `cfn/phase-api/loop2/reviewer-1/feedback`,
947
- reviewFeedback,
948
- { aclLevel: 3, ttl: 7776000 } // Swarm, 90 days
949
- );
950
- ```
951
-
952
- **For complete example:** See API Developer template in [Format Selection Principles](./agent-principles/format-selection.md)
953
-
954
- ---
955
-
956
- ### Example 3: Code-Heavy Format (Basic Tasks with Blocking Coordination)
957
-
958
- **File:** `.claude/agents/coordination/coordinator.md`
959
-
960
- **Key additions for coordinators:**
961
- ```yaml
962
- type: coordinator
963
- validation_hooks:
964
- - agent-template-validator
965
- - cfn-loop-memory-validator
966
- - blocking-coordination-validator # Coordinator-specific
967
- ```
968
-
969
- **Redis BLPOP Coordination Pattern:**
970
- ```bash
971
- # Modern zero-token coordination using Redis BLPOP primitives
972
- # See: .claude/skills/redis-coordination/SKILL.md
973
-
974
- # 1. Agent enters waiting mode (zero-token blocking)
975
- ./.claude/skills/redis-coordination/invoke-waiting-mode.sh enter \
976
- --task-id "task-123" \
977
- --agent-id "coder-1" \
978
- --context "iteration-1"
979
-
980
- # 2. Coordinator blocks until agent reports (BLPOP - no API calls)
981
- redis-cli blpop "swarm:task-123:coder-1:done" 30
982
-
983
- # 3. Wake agent for next iteration
984
- ./.claude/skills/redis-coordination/invoke-waiting-mode.sh wake \
985
- --task-id "task-123" \
986
- --agent-id "coder-1" \
987
- --reason "cfn_loop_iteration" \
988
- --iteration 2
989
-
990
- # Benefits:
991
- # - Zero tokens consumed while waiting (BLPOP blocks without API calls)
992
- # - Instant wake-up (<100ms latency)
993
- # - Auto-cleanup (keys deleted on read)
994
- # - Validated by 8/8 passing tests
995
- ```
996
-
997
- **For complete example:** See Rust Coder template in [Format Selection Principles](./agent-principles/format-selection.md)
998
-
999
- ---
1000
-
1001
- ## Specialized Guidance
1002
-
1003
- ### By Agent Type
1004
-
1005
- Different agent types have different format requirements and validation hooks:
1006
-
1007
- - **Coder Agents (Implementers)**:
1008
- - Format: Code-Heavy for basic tasks, Minimal for complex algorithms
1009
- - ACL Level: 1 (Private)
1010
- - Validators: agent-template-validator, cfn-loop-memory-validator, test-coverage-validator
1011
- - SQLite: Persist confidence scores, implementation notes
1012
-
1013
- - **Reviewer Agents (Validators)**:
1014
- - Format: Minimal (requires contextual reasoning)
1015
- - ACL Level: 3 (Swarm)
1016
- - Validators: agent-template-validator, cfn-loop-memory-validator
1017
- - SQLite: Persist review feedback, validation consensus
1018
-
1019
- - **Architect Agents (Coordinators)**:
1020
- - Format: Minimal (strategic thinking)
1021
- - ACL Level: 3 (Swarm)
1022
- - Validators: agent-template-validator, cfn-loop-memory-validator
1023
- - SQLite: Persist ADRs, design decisions (1 year retention)
1024
-
1025
- - **Coordinator Agents**:
1026
- - Format: Metadata (structured workflows)
1027
- - ACL Level: 3 (Swarm)
1028
- - Validators: agent-template-validator, cfn-loop-memory-validator
1029
- - SQLite: Persist coordination state, agent assignments
1030
- - Special: Redis BLPOP coordination (see `.claude/skills/redis-coordination/SKILL.md`)
1031
-
1032
- - **Tester Agents (Validators)**:
1033
- - Format: Code-Heavy for unit tests, Metadata for test strategy
1034
- - ACL Level: 3 (Swarm)
1035
- - Validators: agent-template-validator, test-coverage-validator
1036
- - SQLite: Persist test results, coverage metrics
1037
-
1038
- - **Researcher Agents**:
1039
- - Format: Minimal (open-ended exploration)
1040
- - ACL Level: 1 (Private) or 3 (Swarm) depending on context
1041
- - Validators: agent-template-validator
1042
- - SQLite: Persist research findings, competitive analysis
1043
-
1044
- - **DevOps Agents**:
1045
- - Format: Metadata (structured workflows)
1046
- - ACL Level: 3 (Swarm)
1047
- - Validators: agent-template-validator, cfn-loop-memory-validator
1048
- - SQLite: Persist deployment logs, infrastructure state
1049
-
1050
- - **Product Owner (CFN Loop 4 only)**:
1051
- - Format: Minimal (strategic GOAP decisions)
1052
- - ACL Level: 4 (Project)
1053
- - Validators: agent-template-validator, cfn-loop-memory-validator
1054
- - SQLite: Persist GOAP decisions, backlog items (365 day retention for compliance)
1055
-
1056
- **Full type-specific guidance:** [Agent Type Guidelines](./agent-principles/agent-type-guidelines.md)
1057
-
1058
- ---
1059
-
1060
- ### Prompt Engineering
1061
-
1062
- Key principles for effective agent prompts:
1063
-
1064
- 1. **Clear Role Definition**: Establish expertise domain
1065
- 2. **Specific Responsibilities**: Concrete, actionable duties
1066
- 3. **Appropriate Tool Selection**: Only essential tools
1067
- 4. **Integration Points**: Explicit collaboration contracts
1068
- 5. **Validation Hooks**: Mandatory quality gates (4 production-ready validators)
1069
- 6. **SQLite Lifecycle**: Agent spawn, update, completion hooks
1070
- 7. **ACL Declaration**: Appropriate access control level by agent type
1071
- 8. **Error Handling**: SQLite retry logic, graceful degradation
1072
-
1073
- **Hook-Agent Collaboration Interface:**
1074
-
1075
- For complex validation requiring semantic understanding:
1076
-
1077
- ```javascript
1078
- class HybridValidator {
1079
- async validate(file, content) {
1080
- // Hook performs pattern detection (95% automation)
1081
- const patterns = await this.detectPatterns(content);
1082
-
1083
- if (patterns.hasComplexLogic) {
1084
- // Delegate semantic analysis to reviewer agent (5% requiring human-level understanding)
1085
- const agentReview = await this.requestAgentReview({
1086
- file,
1087
- content,
1088
- concern: 'State machine correctness',
1089
- context: patterns.extracted
1090
- });
1091
-
1092
- return { ...patterns, agentReview };
1093
- }
1094
-
1095
- return patterns;
1096
- }
1097
- }
1098
- ```
1099
-
1100
- **Incremental Validation with Caching:**
1101
-
1102
- Avoid re-validating unchanged files (10-100x speedup):
1103
-
1104
- ```javascript
1105
- const hash = computeHash(content);
1106
- if (cache.has(hash)) {
1107
- return cache.get(hash); // Instant validation for unchanged files
1108
- }
1109
- ```
1110
-
1111
- **Anti-patterns to avoid:**
1112
- - Over-specification (tunnel vision)
1113
- - Under-specification (too vague)
1114
- - Example overload (cognitive burden)
1115
- - Rigid checklists (context-insensitive)
1116
- - Missing SQLite lifecycle hooks (no audit trail)
1117
- - Wrong ACL level (data exposure or access denial)
1118
- - Missing error handling (cascading failures)
1119
- - Using deprecated BlockingCoordinationSignals (use Redis BLPOP instead)
1120
-
1121
- **Detailed best practices:** [Prompt Engineering Best Practices](./agent-principles/prompt-engineering.md)
1122
-
1123
- ---
1124
-
1125
- ### Quality Metrics & Validation
1126
-
1127
- **Pre-Deployment Checklist:**
1128
- - [ ] Valid YAML frontmatter (including validation_hooks, lifecycle)
1129
- - [ ] Format matches task complexity (Minimal/Metadata/Code-Heavy)
1130
- - [ ] Clear responsibilities defined
1131
- - [ ] Integration points specified (memory keys, ACL levels)
1132
- - [ ] Post-edit hook included (mandatory)
1133
- - [ ] SQLite lifecycle hooks present (pre_task, post_task)
1134
- - [ ] ACL level declared (1-5 based on agent type)
1135
- - [ ] Error handling patterns implemented (retry, fallback)
1136
- - [ ] Redis BLPOP coordination patterns (coordinators - see redis-coordination skill)
1137
-
1138
- **Hook Validation Metrics:**
1139
- - Agent template validation pass rate (target: 100%)
1140
- - CFN Loop ACL compliance rate (target: 100%, zero violations in production)
1141
- - Test coverage above thresholds (≥80% line, ≥75% branch)
1142
- - Blocking coordination pattern correctness (coordinators: 100%)
1143
- - Hook execution time (<5s total for composite validation)
1144
- - False positive rate (<2%)
1145
-
1146
- **Ongoing Monitoring:**
1147
- - First-time success rate (>80%)
1148
- - Iteration count (<3)
1149
- - Quality score (>85%)
1150
- - User satisfaction (>4.5/5)
1151
- - SQLite persistence success rate (>99.9%)
1152
- - ACL violation rate (0% in production)
1153
- - Agent lifecycle completion rate (>95%)
1154
-
1155
- **Hook Performance Targets:**
1156
- - Individual validator: <2s (WASM-accelerated)
1157
- - Composite validation: <5s (parallel execution)
1158
- - Cache hit rate: >70% during development (incremental validation)
1159
- - Manual validation required: <2% (only semantic edge cases)
1160
-
1161
- **Comprehensive validation guide:** [Quality Metrics & Validation](./agent-principles/quality-metrics.md)
1162
-
1163
- ---
1164
-
1165
- ## Benchmark System
1166
-
1167
- ### Running Benchmarks
1168
-
1169
- ```bash
1170
- cd benchmark/agent-benchmarking
1171
-
1172
- # Run Rust benchmarks (VALIDATED)
1173
- node index.js run 5 --rust --verbose
1174
-
1175
- # Run JavaScript benchmarks (HYPOTHESIS)
1176
- node index.js run 5 --verbose
1177
-
1178
- # Analyze results
1179
- node index.js analyze
1180
- ```
1181
-
1182
- **Detailed benchmarking guide:** [Quality Metrics & Validation](./agent-principles/quality-metrics.md)
1183
-
1184
- ---
1185
-
1186
- ## Conclusion
1187
-
1188
- ### Key Takeaways
1189
-
1190
- 1. **Format matters**: Choose based on task complexity (inverse relationship)
1191
- 2. **Validation is critical**: 4 production-ready hooks ensure quality and coordination
1192
- 3. **SQLite integration**: All agents MUST persist lifecycle and data for audit trail
1193
- 4. **ACL enforcement**: Appropriate access control prevents data exposure
1194
- 5. **Hook composition**: CompositeHook pattern enables layered validation (<5s total)
1195
- 6. **Hybrid validation**: Hooks automate 85%, agents handle semantic understanding (15%)
1196
- 7. **Integration is essential**: Memory, swarm, and event bus enable collaboration
1197
- 8. **Continuous improvement**: Use metrics to refine agents
1198
-
1199
- ### Four Production-Ready Validators
1200
-
1201
- 1. **Agent Template Validator**: SQLite lifecycle, ACL, error handling (95% automation)
1202
- 2. **CFN Loop Memory Pattern Validator**: ACL correctness, key format, TTL (90% automation)
1203
- 3. **Test Coverage Validator**: Line/branch/function coverage thresholds (100% automation)
1204
- 4. **Blocking Coordination Validator**: HMAC, signals, state machines (60% automation + agent review)
1205
-
1206
- ### Next Steps
1207
-
1208
- 1. Choose appropriate format for your agent (Minimal/Metadata/Code-Heavy)
1209
- 2. Use templates as starting points (includes SQLite lifecycle hooks)
1210
- 3. Add validation_hooks to frontmatter (agent-template, cfn-loop-memory, test-coverage, blocking-coordination)
1211
- 4. Implement SQLite lifecycle hooks (pre_task, post_task)
1212
- 5. Declare ACL level (1=Private, 3=Swarm, 4=Project)
1213
- 6. Add error handling patterns (retry, fallback)
1214
- 7. Test with benchmark system
1215
- 8. Deploy with validation hooks (automatic on save)
1216
- 9. Monitor hook metrics (<5s validation, <2% false positives)
1217
- 10. Iterate based on metrics and agent feedback
1218
-
1219
- ---
1220
-
1221
- ## Reference Documents
1222
-
1223
- - **[Format Selection Principles](./agent-principles/format-selection.md)**: Detailed format guidance, benchmarking findings, decision tree
1224
- - **[Agent Type Guidelines](./agent-principles/agent-type-guidelines.md)**: Type-specific recommendations for coders, reviewers, architects, testers, researchers, DevOps
1225
- - **[Prompt Engineering Best Practices](./agent-principles/prompt-engineering.md)**: Effective prompt patterns, anti-patterns, integration with Claude Flow
1226
- - **[Quality Metrics & Validation](./agent-principles/quality-metrics.md)**: Validation checklists, benchmark system, continuous improvement
1227
-
1228
- ---
1229
-
1230
- **Document Version:** 2.0.0
1231
- **Last Updated:** 2025-09-30
1232
- **Maintained By:** Claude Flow Core Team
1233
- **Feedback:** Document improvements and findings for future versions
1
+ ---
2
+ name: agent-creation-guide
3
+ description: Practical guide to creating, customizing, and maintaining AI agents in the Claude Flow Novice system
4
+ model: claude-sonnet-4
5
+ tools: [Read, Write, Edit, Bash, Grep, Glob, TodoWrite]
6
+ ---
7
+
8
+ # Agent Creation & Customization Guide
9
+
10
+ **Version:** 4.0.0
11
+ **Last Updated:** 2025-10-20
12
+ **Audience:** NPM Users & Developers
13
+
14
+ This is your practical guide to creating, customizing, and maintaining AI agents in the Claude Flow Novice system. Whether you're using our npm package or building custom workflows, this guide will help you create powerful, specialized agents tailored to your needs.
15
+
16
+ ---
17
+
18
+ ## Table of Contents
19
+
20
+ 1. [Quick Start - Create Your First Agent](#quick-start-create-your-first-agent)
21
+ 2. [Understanding the Agent Directory](#understanding-the-agent-directory)
22
+ 3. [Agent Anatomy](#agent-anatomy)
23
+ 4. [Step-by-Step Agent Creation](#step-by-step-agent-creation)
24
+ 5. [Ready-to-Use Templates](#ready-to-use-templates)
25
+ 6. [Customization Guide](#customization-guide)
26
+ 7. [Testing Your Agent](#testing-your-agent)
27
+ 8. [Advanced Concepts](#advanced-concepts)
28
+ 9. [Troubleshooting](#troubleshooting)
29
+
30
+ ---
31
+
32
+ ## Quick Start - Create Your First Agent
33
+
34
+ ### What You'll Learn
35
+ In 5 minutes, you'll create a custom agent that can perform specialized tasks in your workflow.
36
+
37
+ ### Prerequisites
38
+ ```bash
39
+ # Install claude-flow-novice
40
+ npm install claude-flow-novice
41
+
42
+ # Verify installation
43
+ npx claude-flow-novice --version
44
+ ```
45
+
46
+ ### Your First Agent (3 Steps)
47
+
48
+ **Step 1: Create the agent file**
49
+ ```bash
50
+ mkdir -p .claude/agents/custom
51
+ touch .claude/agents/custom/my-first-agent.md
52
+ ```
53
+
54
+ **Step 2: Add basic configuration**
55
+ ```markdown
56
+ ---
57
+ name: my-first-agent
58
+ description: |
59
+ MUST BE USED when performing [your specific task].
60
+ Keywords - [relevant, keywords, for, your, task]
61
+ tools: [Read, Write, Edit, Bash, TodoWrite]
62
+ model: haiku
63
+ type: specialist
64
+ ---
65
+
66
+ # My First Agent
67
+
68
+ You are a specialized agent that helps with [describe what your agent does].
69
+
70
+ ## Core Responsibilities
71
+ - [Responsibility 1]
72
+ - [Responsibility 2]
73
+ - [Responsibility 3]
74
+
75
+ ## Approach
76
+ [Describe how your agent should approach tasks]
77
+ ```
78
+
79
+ **Step 3: Test your agent**
80
+ ```bash
81
+ # Spawn your agent
82
+ npx claude-flow-novice agent-spawn my-first-agent --task-id test-1
83
+ ```
84
+
85
+ **That's it!** You've created a working agent.
86
+
87
+ ---
88
+
89
+ ## Understanding the Agent Directory
90
+
91
+ ### Directory Structure
92
+
93
+ ```
94
+ .claude/agents/
95
+ ├── CLAUDE.md # This guide
96
+ ├── core-agents/ # Production-ready core agents
97
+ │ ├── coder.md # Code implementation
98
+ │ ├── reviewer.md # Code review & quality
99
+ │ ├── tester.md # Testing & validation
100
+ │ └── coordinator.md # Multi-agent coordination
101
+ ├── development/ # Development-focused agents
102
+ │ ├── backend-dev.md
103
+ │ ├── react-frontend-engineer.md
104
+ │ └── devops-engineer.md
105
+ ├── security/ # Security-focused agents
106
+ │ └── security-specialist.md
107
+ ├── custom/ # YOUR CUSTOM AGENTS GO HERE
108
+ │ └── your-agent.md
109
+ └── templates/ # Reusable templates
110
+ ├── redis-coordination.md
111
+ ├── memory-operations.md
112
+ └── team-dynamics.md
113
+ ```
114
+
115
+ ### Where to Put Your Agents
116
+
117
+ **Option 1: Project-Specific** (Recommended for teams)
118
+ ```bash
119
+ # Lives in your project repo
120
+ <project-root>/.claude/agents/custom/
121
+ ```
122
+ - ✅ Version controlled with your code
123
+ - ✅ Shared across team
124
+ - Project-specific workflows
125
+
126
+ **Option 2: Personal Agents**
127
+ ```bash
128
+ # Lives in your home directory
129
+ ~/.claude/agents/
130
+ ```
131
+ - ✅ Available across all projects
132
+ - Personal productivity tools
133
+ - ⚠️ Not shared with team
134
+
135
+ ---
136
+
137
+ ## Agent Anatomy
138
+
139
+ Every agent has three main parts:
140
+
141
+ ### 1. Frontmatter (YAML Configuration)
142
+
143
+ ```yaml
144
+ ---
145
+ name: agent-name # Unique identifier (lowercase, hyphens)
146
+ description: | # What the agent does & when to use it
147
+ MUST BE USED when [use case].
148
+ Keywords - [searchable, terms]
149
+ tools: [Read, Write, Edit, Bash] # Available tools (Bash includes Redis CLI)
150
+ model: haiku # haiku | sonnet | opus
151
+ type: specialist # specialist | coordinator | swarm
152
+ capabilities: # Optional tags
153
+ - api-development
154
+ - database-design
155
+ acl_level: 1 # Data access level (1-5)
156
+ ---
157
+ ```
158
+
159
+ ### 2. Agent Body (Instructions)
160
+
161
+ ```markdown
162
+ # Agent Name
163
+
164
+ Brief description of what this agent does.
165
+
166
+ ## Core Responsibilities
167
+ - Primary duty 1
168
+ - Primary duty 2
169
+
170
+ ## Approach & Methodology
171
+ How the agent thinks about and solves problems.
172
+
173
+ ## Collaboration
174
+ How this agent works with other agents.
175
+
176
+ ## Success Metrics
177
+ How to measure if the agent succeeded.
178
+ ```
179
+
180
+ ### 3. Template References (Optional)
181
+
182
+ ```markdown
183
+ ## Redis Coordination
184
+ See: `.claude/templates/redis-coordination.md`
185
+
186
+ ## Memory Operations
187
+ → See: `.claude/templates/memory-operations.md`
188
+ ```
189
+
190
+ ---
191
+
192
+ ## Step-by-Step Agent Creation
193
+
194
+ ### Step 1: Define Your Agent's Purpose
195
+
196
+ **Ask yourself:**
197
+ - What specific task will this agent perform?
198
+ - When should it be automatically triggered?
199
+ - What expertise does it need?
200
+ - How will it collaborate with other agents?
201
+
202
+ **Example:**
203
+ > "I need an agent that reviews database schema migrations for security issues and performance problems."
204
+
205
+ ### Step 2: Choose Your Template
206
+
207
+ We provide 3 templates based on task complexity:
208
+
209
+ | Template | Best For | Size | Example Use |
210
+ |----------|----------|------|-------------|
211
+ | **Simple** | Single, focused tasks | 100-200 lines | File formatter, linter |
212
+ | **Standard** | Multi-step workflows | 200-400 lines | API developer, reviewer |
213
+ | **Advanced** | Complex coordination | 400-700 lines | Architect, coordinator |
214
+
215
+ ### Step 3: Create Your Agent File
216
+
217
+ ```bash
218
+ # For a database migration reviewer
219
+ touch .claude/agents/custom/migration-reviewer.md
220
+ ```
221
+
222
+ ### Step 4: Fill in the Template
223
+
224
+ **Simple Template Example:**
225
+
226
+ ```markdown
227
+ ---
228
+ name: migration-reviewer
229
+ description: |
230
+ MUST BE USED when reviewing database migrations for security and performance.
231
+ Use PROACTIVELY for SQL schema changes, migrations, database updates.
232
+ Keywords - database, migration, schema, SQL, security, performance
233
+ tools: [Read, Grep, TodoWrite]
234
+ model: haiku
235
+ type: specialist
236
+ capabilities:
237
+ - database-security
238
+ - sql-review
239
+ - performance-analysis
240
+ acl_level: 3
241
+ ---
242
+
243
+ # Database Migration Reviewer
244
+
245
+ You are a specialized database expert focused on reviewing migration files for
246
+ security vulnerabilities and performance issues.
247
+
248
+ ## Core Responsibilities
249
+
250
+ 1. **Security Review**
251
+ - Check for SQL injection vulnerabilities
252
+ - Validate access control patterns
253
+ - Review encryption of sensitive data
254
+ - Ensure proper sanitization
255
+
256
+ 2. **Performance Analysis**
257
+ - Identify missing indexes
258
+ - Flag inefficient queries
259
+ - Check for N+1 query patterns
260
+ - Validate transaction boundaries
261
+
262
+ 3. **Best Practices**
263
+ - Ensure migrations are reversible
264
+ - Check for breaking changes
265
+ - Validate naming conventions
266
+ - Verify proper error handling
267
+
268
+ ## Review Process
269
+
270
+ 1. Read migration file
271
+ 2. Analyze SQL patterns
272
+ 3. Check against security checklist
273
+ 4. Evaluate performance implications
274
+ 5. Provide actionable feedback
275
+
276
+ ## Output Format
277
+
278
+ Provide a confidence score (0.0-1.0) and structured feedback:
279
+ - Critical issues (must fix)
280
+ - Warnings (should address)
281
+ - Suggestions (nice to have)
282
+ - Approved changes
283
+
284
+ ## Success Metrics
285
+ - Zero critical security issues
286
+ - No obvious performance bottlenecks
287
+ - Migrations are reversible
288
+ - Confidence score ≥ 0.85
289
+ ```
290
+
291
+ ### Step 5: Test Your Agent
292
+
293
+ ```bash
294
+ # Test with a sample task
295
+ npx claude-flow-novice agent-spawn migration-reviewer \
296
+ --task-id test-migration \
297
+ --prompt "Review the migration in db/migrations/001_add_users_table.sql"
298
+ ```
299
+
300
+ ---
301
+
302
+ ## Ready-to-Use Templates
303
+
304
+ ### Template 1: Code Implementer
305
+
306
+ ```markdown
307
+ ---
308
+ name: my-implementer
309
+ description: |
310
+ MUST BE USED when implementing [specific type of code].
311
+ Keywords - implement, build, create, develop
312
+ tools: [Read, Write, Edit, Bash, TodoWrite]
313
+ model: haiku
314
+ type: specialist
315
+ acl_level: 1
316
+ ---
317
+
318
+ # [Type] Implementer
319
+
320
+ You implement [specific type of code] following best practices.
321
+
322
+ ## Core Responsibilities
323
+ - Write clean, maintainable code
324
+ - Follow TDD approach
325
+ - Implement features from specifications
326
+ - Optimize for readability
327
+
328
+ ## Implementation Workflow
329
+ 1. Understand requirements
330
+ 2. Write tests first
331
+ 3. Implement solution
332
+ 4. Refactor for quality
333
+ 5. Validate coverage
334
+
335
+ ## Success Criteria
336
+ - All tests pass
337
+ - Code coverage ≥ 80%
338
+ - Follows coding standards
339
+ - Confidence score ≥ 0.80
340
+ ```
341
+
342
+ ### Template 2: Code Reviewer
343
+
344
+ ```markdown
345
+ ---
346
+ name: my-reviewer
347
+ description: |
348
+ MUST BE USED for reviewing [specific type of code].
349
+ Keywords - review, validate, quality, security
350
+ tools: [Read, Grep, TodoWrite]
351
+ model: haiku
352
+ type: validator
353
+ acl_level: 3
354
+ ---
355
+
356
+ # [Type] Code Reviewer
357
+
358
+ You review [specific type of code] for quality, security, and best practices.
359
+
360
+ ## Review Criteria
361
+
362
+ ### Code Quality
363
+ - [ ] Clear variable names
364
+ - [ ] Proper error handling
365
+ - [ ] Minimal complexity
366
+ - [ ] Good documentation
367
+
368
+ ### Security
369
+ - [ ] No hardcoded secrets
370
+ - [ ] Proper input validation
371
+ - [ ] Safe API usage
372
+ - [ ] No XSS/injection risks
373
+
374
+ ### Performance
375
+ - [ ] Efficient algorithms
376
+ - [ ] No memory leaks
377
+ - [ ] Proper caching
378
+ - [ ] Optimized queries
379
+
380
+ ## Output Format
381
+ Provide confidence score and categorized feedback:
382
+ - 🔴 Critical (blocking issues)
383
+ - 🟡 Warnings (should fix)
384
+ - 🟢 Suggestions (improvements)
385
+
386
+ ## Success Metrics
387
+ - Confidence score 0.90
388
+ - Zero critical issues
389
+ - Actionable feedback provided
390
+ ```
391
+
392
+ ### Template 3: Specialist Agent
393
+
394
+ ```markdown
395
+ ---
396
+ name: my-specialist
397
+ description: |
398
+ MUST BE USED when [specialized task].
399
+ Use PROACTIVELY for [scenarios].
400
+ Keywords - [domain, specific, keywords]
401
+ tools: [Read, Write, Edit, Bash, Grep, Glob, TodoWrite]
402
+ model: sonnet
403
+ type: specialist
404
+ capabilities:
405
+ - [capability-1]
406
+ - [capability-2]
407
+ acl_level: 1
408
+ ---
409
+
410
+ # [Domain] Specialist
411
+
412
+ You are an expert in [domain] with deep knowledge of [specific expertise].
413
+
414
+ ## Expertise Areas
415
+ - [Area 1]: [Description]
416
+ - [Area 2]: [Description]
417
+ - [Area 3]: [Description]
418
+
419
+ ## Approach
420
+ [How you analyze and solve problems in this domain]
421
+
422
+ ## Tools & Techniques
423
+ - [Tool/Technique 1]
424
+ - [Tool/Technique 2]
425
+ - [Tool/Technique 3]
426
+
427
+ ## Collaboration
428
+ - **With Implementers**: Provide specifications and guidance
429
+ - **With Reviewers**: Share domain expertise
430
+ - **Solo**: Full end-to-end implementation
431
+
432
+ ## Success Metrics
433
+ - Domain-specific quality criteria
434
+ - Stakeholder satisfaction
435
+ - Technical accuracy
436
+ - Confidence score ≥ 0.85
437
+ ```
438
+
439
+ ---
440
+
441
+ ## Customization Guide
442
+
443
+ ### 1. Choosing the Right Model
444
+
445
+ | Model | Speed | Cost | Best For |
446
+ |-------|-------|------|----------|
447
+ | **haiku** | ⚡⚡⚡ | $ | Simple tasks, quick iterations |
448
+ | **sonnet** | ⚡⚡ | $$ | Balanced performance, most tasks |
449
+ | **opus** | ⚡ | $$$ | Complex reasoning, critical tasks |
450
+
451
+ **Recommendation:** Start with `haiku`, upgrade to `sonnet` if needed.
452
+
453
+ ### 2. Selecting Tools
454
+
455
+ Available tools:
456
+ ```yaml
457
+ # File Operations
458
+ tools: [Read, Write, Edit, MultiEdit]
459
+
460
+ # Search & Navigation
461
+ tools: [Grep, Glob]
462
+
463
+ # Execution
464
+ tools: [Bash]
465
+
466
+ # Coordination & Task Management
467
+ tools: [TodoWrite]
468
+
469
+ # Agent Spawning (Coordinators)
470
+ tools: [Bash] # For CLI spawning: npx claude-flow-novice agent-spawn
471
+ ```
472
+
473
+ **Note:** Agent coordination uses Redis pub/sub + CLI spawning, not MCP tools.
474
+
475
+ **Rule of Thumb:** Only include tools your agent will actually use. More tools = more complexity.
476
+
477
+ ### 3. Setting ACL Levels
478
+
479
+ | Level | Scope | Use When |
480
+ |-------|-------|----------|
481
+ | **1** | Private | Agent's own data only |
482
+ | **3** | Swarm | Shared across team of agents |
483
+ | **4** | Project | Strategic decisions, audit logs |
484
+ | **5** | System | Infrastructure only |
485
+
486
+ **Most agents use level 1 or 3.**
487
+
488
+ ### 4. Adding Capabilities (Tags)
489
+
490
+ ```yaml
491
+ capabilities:
492
+ - rust # Language expertise
493
+ - api-design # Domain knowledge
494
+ - security-review # Specialized skill
495
+ - performance-opt # Focus area
496
+ ```
497
+
498
+ These help with agent discovery and routing.
499
+
500
+ ### 5. Customizing Behavior
501
+
502
+ **Tone & Style:**
503
+ ```markdown
504
+ You are a [friendly/professional/technical] agent that [approach].
505
+
506
+ ## Communication Style
507
+ - Use [formal/casual] language
508
+ - Provide [detailed/concise] explanations
509
+ - Focus on [theory/practice]
510
+ ```
511
+
512
+ **Decision-Making:**
513
+ ```markdown
514
+ ## Decision Framework
515
+ When [situation], prioritize:
516
+ 1. [Criterion 1]
517
+ 2. [Criterion 2]
518
+ 3. [Criterion 3]
519
+ ```
520
+
521
+ **Error Handling:**
522
+ ```markdown
523
+ ## Error Handling Strategy
524
+ - For [error type]: [action]
525
+ - If [condition]: [fallback]
526
+ - Always: [safety measure]
527
+ ```
528
+
529
+ ---
530
+
531
+ ## Testing Your Agent
532
+
533
+ ### Manual Testing
534
+
535
+ ```bash
536
+ # Basic spawn test
537
+ npx claude-flow-novice agent-spawn my-agent --task-id test-1
538
+
539
+ # With specific prompt
540
+ npx claude-flow-novice agent-spawn my-agent \
541
+ --task-id test-2 \
542
+ --prompt "Specific task instructions"
543
+ ```
544
+
545
+ ### Integration Testing
546
+
547
+ Create a test task:
548
+ ```bash
549
+ # Create test directory
550
+ mkdir -p tests/agents
551
+
552
+ # Create test file
553
+ cat > tests/agents/test-my-agent.sh << 'EOF'
554
+ #!/bin/bash
555
+ set -e
556
+
557
+ echo "Testing my-agent..."
558
+
559
+ # Spawn agent
560
+ npx claude-flow-novice agent-spawn my-agent \
561
+ --task-id test-integration
562
+
563
+ # Verify output
564
+ # [Add your verification logic]
565
+
566
+ echo "✅ Test passed"
567
+ EOF
568
+
569
+ chmod +x tests/agents/test-my-agent.sh
570
+
571
+ # Run test
572
+ ./tests/agents/test-my-agent.sh
573
+ ```
574
+
575
+ ### Validation Checklist
576
+
577
+ Before deploying your agent:
578
+
579
+ - [ ] YAML frontmatter is valid
580
+ - [ ] Name is unique and descriptive
581
+ - [ ] Description includes use cases and keywords
582
+ - [ ] Tools list includes only needed tools
583
+ - [ ] Core responsibilities are clear
584
+ - [ ] Success metrics are defined
585
+ - [ ] Agent tested with sample tasks
586
+ - [ ] Documentation is complete
587
+
588
+ ---
589
+
590
+ ## Advanced Concepts
591
+
592
+ ### Multi-Agent Coordination
593
+
594
+ Agents can work together using Redis pub/sub and CLI spawning:
595
+
596
+ ```markdown
597
+ ## Redis Coordination
598
+ → See: `.claude/templates/redis-coordination.md`
599
+
600
+ ### Agent Spawning Pattern
601
+ ```bash
602
+ # Spawn agents via CLI (coordinators only)
603
+ npx claude-flow-novice agent-spawn backend-dev --task-id "${TASK_ID}"
604
+ npx claude-flow-novice agent-spawn reviewer --task-id "${TASK_ID}"
605
+ ```
606
+
607
+ ### Signaling Pattern
608
+ ```bash
609
+ # Signal completion
610
+ redis-cli lpush "swarm:${TASK_ID}:${AGENT_ID}:done" "complete"
611
+
612
+ # Wait for other agent (zero-token blocking)
613
+ redis-cli blpop "swarm:${TASK_ID}:other-agent:done" 30
614
+ ```
615
+ ```
616
+
617
+ ### Memory Operations
618
+
619
+ Agents can persist and share data:
620
+
621
+ ```markdown
622
+ ## Memory Operations
623
+ → See: `.claude/templates/memory-operations.md`
624
+
625
+ ### SQLite Integration
626
+ ```typescript
627
+ await sqlite.memoryAdapter.set(
628
+ `agent/${agentId}/data/${taskId}`,
629
+ { confidence: 0.85, status: 'complete' },
630
+ { aclLevel: 1, ttl: 2592000 }
631
+ );
632
+ ```
633
+ ```
634
+
635
+ ### CFN Loop Integration
636
+
637
+ For self-correcting workflows:
638
+
639
+ ```markdown
640
+ ## CFN Loop Mechanics
641
+ → See: `.claude/templates/cfn-loop-mechanics.md`
642
+
643
+ Agents participate in 3-loop validation:
644
+ - Loop 3: Implementation
645
+ - Loop 2: Validation
646
+ - Loop 4: Strategic decisions
647
+ ```
648
+
649
+ ### Lifecycle Hooks
650
+
651
+ ```yaml
652
+ lifecycle:
653
+ pre_task: |
654
+ # Runs before agent starts
655
+ echo "Initializing agent..."
656
+
657
+ post_task: |
658
+ # Runs after agent completes
659
+ echo "Agent completed with confidence: ${CONFIDENCE_SCORE}"
660
+ ```
661
+
662
+ ### Validation Hooks
663
+
664
+ ```yaml
665
+ validation_hooks:
666
+ - agent-template-validator # Validates agent structure
667
+ - cfn-loop-memory-validator # Validates memory operations
668
+ - test-coverage-validator # Validates test coverage
669
+ ```
670
+
671
+ ---
672
+
673
+ ## Troubleshooting
674
+
675
+ ### Agent Not Found
676
+
677
+ **Problem:** `Error: Agent 'my-agent' not found`
678
+
679
+ **Solutions:**
680
+ 1. Check file is in `.claude/agents/` directory
681
+ 2. Verify filename matches agent name: `my-agent.md`
682
+ 3. Ensure YAML frontmatter has `name: my-agent`
683
+
684
+ ### Invalid YAML
685
+
686
+ **Problem:** `Error: Invalid YAML frontmatter`
687
+
688
+ **Solutions:**
689
+ 1. Check YAML syntax with `---` delimiters
690
+ 2. Ensure proper indentation (2 spaces)
691
+ 3. Quote special characters in strings
692
+ 4. Validate at https://www.yamllint.com/
693
+
694
+ ### Agent Behavior Issues
695
+
696
+ **Problem:** Agent doesn't perform as expected
697
+
698
+ **Solutions:**
699
+ 1. Review and clarify core responsibilities
700
+ 2. Simplify instructions (less is often more)
701
+ 3. Add specific examples of desired behavior
702
+ 4. Test with varied prompts
703
+ 5. Check model choice (try upgrading haiku sonnet)
704
+
705
+ ### Tools Not Working
706
+
707
+ **Problem:** `Error: Tool [X] not available`
708
+
709
+ **Solutions:**
710
+ 1. Verify tool is in frontmatter `tools` list
711
+ 2. Check spelling matches exactly
712
+ 3. For agent spawning, use Bash tool with CLI commands
713
+ 4. Review tool permissions
714
+
715
+ ### Memory/Coordination Issues
716
+
717
+ **Problem:** Agents can't share data
718
+
719
+ **Solutions:**
720
+ 1. Check Redis is running: `redis-cli ping`
721
+ 2. Verify ACL levels are compatible
722
+ 3. Ensure memory keys follow patterns
723
+ 4. Check SQLite database exists
724
+
725
+ ---
726
+
727
+ ## Example: Complete Custom Agent
728
+
729
+ Here's a real-world example - a Terraform reviewer agent:
730
+
731
+ ```markdown
732
+ ---
733
+ name: terraform-reviewer
734
+ description: |
735
+ MUST BE USED when reviewing Terraform infrastructure code.
736
+ Use PROACTIVELY for IaC review, security validation, cost optimization.
737
+ Keywords - terraform, infrastructure, IaC, cloud, AWS, security
738
+ tools: [Read, Grep, Glob, TodoWrite]
739
+ model: sonnet
740
+ type: specialist
741
+ capabilities:
742
+ - terraform
743
+ - infrastructure-as-code
744
+ - cloud-security
745
+ - cost-optimization
746
+ acl_level: 3
747
+ ---
748
+
749
+ # Terraform Infrastructure Reviewer
750
+
751
+ You are an infrastructure expert specializing in Terraform code review with
752
+ focus on security, best practices, and cost optimization.
753
+
754
+ ## Core Responsibilities
755
+
756
+ ### 1. Security Review
757
+ - Check for exposed secrets or credentials
758
+ - Validate IAM policies (principle of least privilege)
759
+ - Review security group rules
760
+ - Ensure encryption at rest and in transit
761
+ - Verify logging and monitoring
762
+
763
+ ### 2. Best Practices
764
+ - Validate resource naming conventions
765
+ - Check for proper tagging strategy
766
+ - Ensure state management best practices
767
+ - Review module structure and reusability
768
+ - Validate provider versioning
769
+
770
+ ### 3. Cost Optimization
771
+ - Identify over-provisioned resources
772
+ - Flag expensive resource types
773
+ - Suggest reserved instances where applicable
774
+ - Review data transfer patterns
775
+ - Validate auto-scaling configurations
776
+
777
+ ### 4. Compliance
778
+ - Check against company standards
779
+ - Validate regulatory requirements
780
+ - Ensure disaster recovery provisions
781
+ - Review backup strategies
782
+
783
+ ## Review Process
784
+
785
+ 1. **Parse Terraform Files**
786
+ - Read all `.tf` files in directory
787
+ - Identify resource types and configurations
788
+ - Map dependencies
789
+
790
+ 2. **Security Analysis**
791
+ - Run security checklist
792
+ - Flag critical issues
793
+ - Identify vulnerabilities
794
+
795
+ 3. **Cost Analysis**
796
+ - Estimate monthly costs
797
+ - Identify optimization opportunities
798
+ - Calculate potential savings
799
+
800
+ 4. **Compliance Check**
801
+ - Verify against standards
802
+ - Document exceptions
803
+ - Recommend remediation
804
+
805
+ 5. **Generate Report**
806
+ - Categorize findings by severity
807
+ - Provide specific recommendations
808
+ - Include confidence score
809
+
810
+ ## Output Format
811
+
812
+ ### Summary
813
+ - Overall confidence score (0.0-1.0)
814
+ - Total issues found by severity
815
+ - Estimated monthly cost
816
+ - Compliance status
817
+
818
+ ### Detailed Findings
819
+
820
+ **🔴 Critical Issues** (must fix before deployment)
821
+ - [Issue description]
822
+ - File: `path/to/file.tf:line`
823
+ - Recommendation: [specific fix]
824
+
825
+ **🟡 Warnings** (should address)
826
+ - [Issue description]
827
+ - Impact: [description]
828
+ - Suggestion: [improvement]
829
+
830
+ **🟢 Optimizations** (nice to have)
831
+ - [Opportunity description]
832
+ - Potential savings: [amount]
833
+ - Effort: [low/medium/high]
834
+
835
+ ## Success Metrics
836
+ - Security score ≥ 0.90
837
+ - Zero critical vulnerabilities
838
+ - Cost optimization opportunities identified
839
+ - Compliance requirements met
840
+ - Clear, actionable feedback
841
+
842
+ ## Collaboration
843
+ - **With DevOps**: Review infrastructure changes
844
+ - **With Security Team**: Validate security posture
845
+ - **With Finance**: Optimize cloud spend
846
+ - **Solo**: Complete IaC review and reporting
847
+ ```
848
+
849
+ **Usage:**
850
+ ```bash
851
+ npx claude-flow-novice agent-spawn terraform-reviewer \
852
+ --prompt "Review Terraform files in ./infrastructure"
853
+ ```
854
+
855
+ ---
856
+
857
+ ## Quick Reference
858
+
859
+ ### Common Agent Patterns
860
+
861
+ **Code Writer:**
862
+ ```yaml
863
+ tools: [Read, Write, Edit, Bash, TodoWrite]
864
+ model: haiku
865
+ type: specialist
866
+ acl_level: 1
867
+ ```
868
+
869
+ **Code Reviewer:**
870
+ ```yaml
871
+ tools: [Read, Grep, TodoWrite]
872
+ model: sonnet
873
+ type: validator
874
+ acl_level: 3
875
+ ```
876
+
877
+ **Coordinator:**
878
+ ```yaml
879
+ tools: [Read, Bash, TodoWrite] # Bash for Redis CLI + agent spawning
880
+ model: sonnet
881
+ type: coordinator
882
+ acl_level: 3
883
+ ```
884
+
885
+ ### File Naming Convention
886
+
887
+ ```
888
+ .claude/agents/
889
+ ├── [category]/
890
+ │ └── [agent-name].md # lowercase, hyphens, descriptive
891
+ ```
892
+
893
+ **Good:** `terraform-reviewer.md`, `api-security-validator.md`
894
+ **Bad:** `TerraformReviewer.md`, `agent1.md`, `myAgent.md`
895
+
896
+ ### Essential YAML Fields
897
+
898
+ **Minimum required:**
899
+ ```yaml
900
+ ---
901
+ name: agent-name
902
+ description: |
903
+ What the agent does and when to use it
904
+ tools: [Read, Write]
905
+ model: haiku
906
+ ---
907
+ ```
908
+
909
+ **Recommended:**
910
+ ```yaml
911
+ ---
912
+ name: agent-name
913
+ description: |
914
+ MUST BE USED when [use case]
915
+ Keywords - [keywords]
916
+ tools: [Read, Write, Edit, TodoWrite]
917
+ model: haiku
918
+ type: specialist
919
+ capabilities: [capability-tags]
920
+ acl_level: 1
921
+ ---
922
+ ```
923
+
924
+ ---
925
+
926
+ ## Resources
927
+
928
+ ### Template Files
929
+ - `.claude/templates/redis-coordination.md` - Multi-agent coordination
930
+ - `.claude/templates/memory-operations.md` - Data persistence
931
+ - `.claude/templates/team-dynamics.md` - Agent collaboration
932
+ - `.claude/templates/cfn-loop-mechanics.md` - Self-correcting workflows
933
+
934
+ ### Example Agents
935
+ - `.claude/agents/core-agents/coder.md` - Code implementation
936
+ - `.claude/agents/core-agents/reviewer.md` - Code review
937
+ - `.claude/agents/core-agents/tester.md` - Testing & validation
938
+ - `.claude/agents/development/backend-dev.md` - Backend development
939
+ - `.claude/agents/security/security-specialist.md` - Security analysis
940
+
941
+ ### Documentation
942
+ - `README.md` - Project overview
943
+ - `.claude/skills/` - Reusable skill modules
944
+ - `.claude/commands/` - Slash command definitions
945
+
946
+ ### Technical Deep-Dive
947
+
948
+ For advanced users who want to understand the theoretical foundations:
949
+ - [Format Selection Principles](./agent-principles/format-selection.md)
950
+ - [Agent Type Guidelines](./agent-principles/agent-type-guidelines.md)
951
+ - [Prompt Engineering Best Practices](./agent-principles/prompt-engineering.md)
952
+ - [Quality Metrics & Validation](./agent-principles/quality-metrics.md)
953
+
954
+ ---
955
+
956
+ ## Need Help?
957
+
958
+ ### Common Questions
959
+
960
+ **Q: How many agents should I create?**
961
+ A: Start with 1-3 focused agents. Add more as needed. Quality > quantity.
962
+
963
+ **Q: Should I modify core agents?**
964
+ A: No, create custom agents instead. Core agents may be updated in new releases.
965
+
966
+ **Q: Can agents call other agents?**
967
+ A: Yes! Coordinators spawn agents via CLI: `npx claude-flow-novice agent-spawn [agent-name]`
968
+
969
+ **Q: How do I share agents with my team?**
970
+ A: Put them in `.claude/agents/` and commit to git.
971
+
972
+ **Q: What's the difference between skills and agents?**
973
+ A: Skills are reusable behaviors (like templates). Agents are executable workers that use skills.
974
+
975
+ ### Getting Help
976
+
977
+ 1. Check existing agents for examples
978
+ 2. Review template files for patterns
979
+ 3. Test incrementally with simple tasks
980
+ 4. Start simple, add complexity gradually
981
+ 5. Open issues on GitHub for bugs
982
+
983
+ ---
984
+
985
+ ## What's Next?
986
+
987
+ Now that you understand agent creation, explore:
988
+
989
+ 1. **Multi-Agent Workflows** - Coordinate multiple agents for complex tasks
990
+ 2. **CFN Loop Integration** - Build self-correcting pipelines
991
+ 3. **Custom Skills** - Create reusable behavior modules
992
+ 4. **Web Portal** - Monitor agent execution in real-time
993
+ 5. **Advanced Coordination** - Redis pub/sub, memory operations
994
+
995
+ **Ready to build something amazing? Start creating your first agent!**
996
+
997
+ ---
998
+
999
+ **Document Version:** 4.0.0 (User-Friendly Edition)
1000
+ **Last Updated:** 2025-10-20
1001
+ **Maintained By:** Claude Flow Novice Team
1002
+ **Feedback:** We'd love to hear how you're using agents! Share your creations.