@polymorphism-tech/morph-spec 4.12.0 → 4.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (314) hide show
  1. package/README.md +21 -29
  2. package/bin/morph-spec.js +41 -24
  3. package/bin/task-manager.js +962 -1341
  4. package/bin/validate.js +1 -1
  5. package/claude-plugin.json +1 -1
  6. package/docs/CHEATSHEET.md +10 -11
  7. package/docs/QUICKSTART.md +15 -15
  8. package/framework/CLAUDE.md +5 -2
  9. package/framework/agents/README.md +3 -4
  10. package/framework/agents/ai-agents/ai-system-architect.md +6 -10
  11. package/framework/agents/architecture/seo-growth-hacker.md +166 -326
  12. package/framework/agents/architecture/standards-architect.md +21 -31
  13. package/framework/agents/backend/dotnet-senior.md +160 -86
  14. package/framework/agents/backend/ef-modeler.md +2 -6
  15. package/framework/agents/backend/hangfire-orchestrator.md +8 -9
  16. package/framework/agents/backend/ms-agent-expert.md +1 -1
  17. package/framework/agents/frontend/nextjs-expert.md +198 -133
  18. package/framework/agents/frontend/ui-ux-designer.md +226 -267
  19. package/framework/agents/infrastructure/infra-architect.md +191 -27
  20. package/framework/agents/integrations/clerk-auth.md +19 -26
  21. package/framework/agents/integrations/hangfire-integration.md +1 -4
  22. package/framework/agents.json +215 -1453
  23. package/framework/commands/morph-apply.md +4 -4
  24. package/framework/commands/morph-preflight.md +4 -26
  25. package/framework/commands/morph-proposal.md +19 -19
  26. package/framework/commands/morph-status.md +2 -2
  27. package/framework/commands/morph-troubleshoot.md +6 -13
  28. package/framework/hooks/README.md +1 -6
  29. package/framework/hooks/claude-code/post-tool-use/validator-feedback.js +4 -6
  30. package/framework/hooks/claude-code/pre-compact/save-morph-context.js +12 -7
  31. package/framework/hooks/claude-code/pre-tool-use/enforce-phase-writes.js +2 -2
  32. package/framework/hooks/claude-code/pre-tool-use/protect-spec-files.js +2 -2
  33. package/framework/hooks/claude-code/pre-tool-use/task-tracking-guard.js +5 -10
  34. package/framework/hooks/claude-code/session-start/inject-morph-context.js +63 -30
  35. package/framework/hooks/claude-code/session-start/resume-context.js +77 -0
  36. package/framework/hooks/claude-code/statusline.py +4 -5
  37. package/framework/hooks/claude-code/stop/validate-completion.js +4 -4
  38. package/framework/hooks/claude-code/user-prompt/enrich-prompt.js +8 -8
  39. package/framework/hooks/shared/compact-restore.js +28 -5
  40. package/framework/hooks/shared/phase-utils.js +4 -8
  41. package/framework/hooks/shared/state-reader.js +34 -3
  42. package/framework/phases.json +7 -45
  43. package/framework/rules/ai-agents-standards.md +15 -0
  44. package/framework/rules/asaas-standards.md +13 -0
  45. package/framework/rules/clerk-standards.md +13 -0
  46. package/framework/rules/csharp-standards.md +8 -4
  47. package/framework/rules/data-standards.md +18 -0
  48. package/framework/rules/dotnet-templates.md +87 -0
  49. package/framework/rules/frontend-standards.md +13 -13
  50. package/framework/rules/hangfire-standards.md +13 -0
  51. package/framework/rules/infrastructure-standards.md +27 -16
  52. package/framework/rules/morph-workflow.md +73 -13
  53. package/framework/rules/nextjs-standards.md +1 -0
  54. package/framework/rules/nextjs-templates.md +40 -0
  55. package/framework/rules/resend-standards.md +12 -0
  56. package/framework/rules/supabase-standards.md +29 -0
  57. package/framework/skills/README.md +6 -8
  58. package/framework/skills/level-0-meta/mcp-registry.json +21 -99
  59. package/framework/{standards/ai-agents/team-orchestration.md → skills/level-0-meta/morph-agent-teams/SKILL.md} +472 -479
  60. package/framework/skills/level-0-meta/morph-brainstorming/SKILL.md +28 -1
  61. package/framework/skills/level-0-meta/morph-checklist/SKILL.md +2 -2
  62. package/framework/skills/level-0-meta/morph-code-review/SKILL.md +1 -5
  63. package/framework/skills/level-0-meta/morph-code-review/scripts/scan-csharp.mjs +1 -1
  64. package/framework/skills/level-0-meta/morph-frontend-review/SKILL.md +23 -41
  65. package/framework/skills/level-0-meta/morph-init/SKILL.md +18 -14
  66. package/framework/skills/level-0-meta/morph-parallel-dispatch/SKILL.md +225 -0
  67. package/framework/skills/level-0-meta/morph-post-implementation/SKILL.md +20 -0
  68. package/framework/skills/level-0-meta/morph-tool-usage-guide/SKILL.md +4 -8
  69. package/framework/skills/level-0-meta/morph-tool-usage-guide/references/tools-per-phase.md +15 -59
  70. package/framework/skills/level-0-meta/morph-verification-before-completion/SKILL.md +7 -19
  71. package/framework/skills/level-0-meta/morph-verification-before-completion/scripts/check-phase-outputs.mjs +8 -8
  72. package/framework/skills/level-1-workflows/README.md +1 -1
  73. package/framework/skills/level-1-workflows/morph-phase-codebase-analysis/SKILL.md +49 -50
  74. package/framework/skills/level-1-workflows/morph-phase-design/SKILL.md +58 -124
  75. package/framework/skills/level-1-workflows/morph-phase-design/references/architecture-analysis-guide.md +5 -50
  76. package/framework/skills/level-1-workflows/morph-phase-design/references/spec-example.md +1 -1
  77. package/framework/skills/level-1-workflows/morph-phase-implement/SKILL.md +127 -159
  78. package/framework/skills/level-1-workflows/morph-phase-implement/prompts/implementer-prompt.md +4 -3
  79. package/framework/skills/level-1-workflows/morph-phase-implement/prompts/spec-reviewer-prompt.md +2 -2
  80. package/framework/skills/level-1-workflows/morph-phase-implement/references/recap-example.md +1 -1
  81. package/framework/skills/level-1-workflows/morph-phase-plan/SKILL.md +17 -13
  82. package/framework/skills/level-1-workflows/morph-phase-tasks/SKILL.md +22 -40
  83. package/framework/skills/level-1-workflows/morph-phase-tasks/references/task-planning-patterns.md +0 -2
  84. package/framework/skills/level-1-workflows/morph-phase-tasks/references/tasks-example.md +5 -5
  85. package/framework/skills/level-1-workflows/morph-phase-uiux/SKILL.md +57 -77
  86. package/framework/skills/level-1-workflows/morph-scope-escalation/SKILL.md +1 -1
  87. package/framework/squad-templates/backend-only.json +6 -6
  88. package/framework/squad-templates/frontend-only.json +17 -8
  89. package/framework/squad-templates/full-stack.json +29 -24
  90. package/framework/standards/STANDARDS.json +1021 -2369
  91. package/framework/standards/backend/dotnet/fluent-validation-vsa.md +200 -0
  92. package/framework/standards/backend/dotnet/result-pattern.md +213 -0
  93. package/framework/standards/backend/dotnet/scalar-ui.md +172 -0
  94. package/framework/standards/backend/dotnet/scrutor.md +158 -0
  95. package/framework/standards/backend/dotnet/vsa-handler-patterns.md +274 -0
  96. package/framework/standards/frontend/nextjs/motion-patterns.md +1 -1
  97. package/framework/standards/infrastructure/supabase/mcp-setup.md +83 -193
  98. package/framework/standards/integration/mcp/mcp-tools.md +91 -77
  99. package/framework/templates/IDE-SNIPPETS.md +2 -6
  100. package/framework/templates/README.md +709 -814
  101. package/framework/templates/REGISTRY.json +223 -762
  102. package/framework/templates/code/dotnet/abstractions/api-endpoint.cs +7 -0
  103. package/framework/templates/code/dotnet/abstractions/error.cs +60 -0
  104. package/framework/templates/code/dotnet/abstractions/handler.cs +12 -0
  105. package/framework/templates/code/dotnet/abstractions/result.cs +74 -0
  106. package/framework/templates/code/dotnet/backend/repository.cs +148 -141
  107. package/framework/templates/code/dotnet/constants/api-tags.cs +6 -0
  108. package/framework/templates/code/dotnet/exceptions/exception-handler.cs +32 -0
  109. package/framework/templates/code/dotnet/extensions/database-extensions.cs +20 -0
  110. package/framework/templates/code/dotnet/extensions/handler-registration.cs +38 -0
  111. package/framework/templates/code/dotnet/extensions/health-checks.cs +24 -0
  112. package/framework/templates/code/dotnet/extensions/map-endpoints.cs +35 -0
  113. package/framework/templates/code/dotnet/extensions/result-extensions.cs +29 -0
  114. package/framework/templates/code/dotnet/feature/endpoint.cs.hbs +21 -0
  115. package/framework/templates/code/dotnet/feature/entity.cs.hbs +8 -0
  116. package/framework/templates/code/dotnet/feature/errors.cs.hbs +8 -0
  117. package/framework/templates/code/dotnet/feature/handler.cs.hbs +24 -0
  118. package/framework/templates/code/dotnet/feature/request.cs.hbs +4 -0
  119. package/framework/templates/code/dotnet/feature/response.cs.hbs +4 -0
  120. package/framework/templates/code/dotnet/feature/validator.cs.hbs +15 -0
  121. package/framework/templates/code/dotnet/jobs/job.cs +21 -17
  122. package/framework/templates/code/dotnet/pipelines/logging-decorator.cs +31 -0
  123. package/framework/templates/code/dotnet/pipelines/validation-decorator.cs +97 -0
  124. package/framework/templates/code/dotnet/test.cs +192 -106
  125. package/framework/templates/context/ARCHITECTURE.md +89 -0
  126. package/framework/templates/context/CONTEXT-FEATURE.md +2 -2
  127. package/framework/templates/context/CONTEXT.md +180 -181
  128. package/framework/templates/context/design-system.md +1 -5
  129. package/framework/templates/docs/onboarding.md +2 -3
  130. package/framework/templates/docs/proposal.md +171 -182
  131. package/framework/templates/docs/spec.md +1 -3
  132. package/framework/templates/docs/ui-components.md +0 -72
  133. package/framework/templates/examples/design-system-examples.md +4 -4
  134. package/framework/templates/feature/decisions.md +0 -66
  135. package/framework/templates/feature/recap.md +1 -2
  136. package/framework/templates/infrastructure/github/README.md +56 -593
  137. package/framework/templates/integrations/clerk-config.cs +0 -41
  138. package/framework/templates/meta-prompts/parallel-workers/parallel-worker.md +2 -2
  139. package/framework/templates/meta-prompts/squad-leaders/backend-squad.md +1 -2
  140. package/framework/templates/meta-prompts/squad-leaders/frontend-squad.md +83 -126
  141. package/framework/templates/meta-prompts/validators/pre-commit-validator.md +2 -2
  142. package/framework/templates/project/validate.js +2 -4
  143. package/framework/templates/ui/design-system.css +1 -1
  144. package/framework/workflows/README.md +8 -8
  145. package/framework/workflows/configs/fast-track.json +51 -0
  146. package/framework/workflows/configs/full.json +68 -0
  147. package/framework/workflows/configs/standard.json +7 -3
  148. package/framework/workflows/docs/STORY-DRIVEN-DEVELOPMENT.md +1 -1
  149. package/framework/workflows/docs/enforcement-pipeline.md +18 -19
  150. package/framework/workflows/docs/full-morph.md +69 -76
  151. package/framework/workflows/docs/standard.md +49 -44
  152. package/framework/workflows/docs/ui-refresh.md +1 -1
  153. package/package.json +3 -3
  154. package/src/commands/agents/dispatch-agents.js +55 -116
  155. package/src/commands/context/context-refresh.js +79 -0
  156. package/src/commands/phase/phase-reset.js +1 -1
  157. package/src/commands/project/doctor.js +10 -32
  158. package/src/commands/project/init.js +12 -0
  159. package/src/commands/project/status.js +6 -12
  160. package/src/commands/scaffold/scaffold.js +131 -0
  161. package/src/commands/scope/escalate.js +1 -1
  162. package/src/commands/state/advance-phase.js +15 -29
  163. package/src/commands/state/state.js +20 -5
  164. package/src/commands/tasks/task.js +0 -30
  165. package/src/commands/validation/validate-feature.js +3 -10
  166. package/src/core/paths/output-schema.js +12 -13
  167. package/src/core/state/phase-state-machine.js +211 -217
  168. package/src/core/state/state-manager.js +9 -9
  169. package/src/lib/agents/agents-manager.js +2 -2
  170. package/src/lib/agents/output-collector.js +1 -2
  171. package/src/lib/detectors/design-system-detector.js +4 -4
  172. package/src/lib/detectors/index.js +1 -11
  173. package/src/lib/generators/architecture-scanner.js +640 -0
  174. package/src/lib/generators/context-generator.js +3 -3
  175. package/src/lib/generators/design-system-generator.js +508 -587
  176. package/src/lib/generators/index.js +12 -10
  177. package/src/lib/generators/metadata-extractor.js +386 -387
  178. package/src/lib/generators/recap-generator.js +4 -4
  179. package/src/lib/generators/scaffold-generator.js +317 -0
  180. package/src/lib/generators/settings-generator.js +0 -1
  181. package/src/lib/phase-chain/phase-validator.js +64 -42
  182. package/src/lib/stack/stack-profile.js +2 -2
  183. package/src/lib/standards/digest-builder.js +72 -285
  184. package/src/lib/tasks/task-parser.js +11 -5
  185. package/src/lib/validators/architecture/architecture-validator.js +259 -387
  186. package/src/lib/validators/content/content-validator.js +287 -287
  187. package/src/lib/validators/css/css-validator.js +340 -352
  188. package/src/lib/validators/packages/package-validator.js +347 -360
  189. package/src/lib/validators/shared/issue-counter.js +14 -18
  190. package/src/lib/validators/validation-runner.js +3 -19
  191. package/src/scripts/setup-infra.js +1 -1
  192. package/src/utils/agents-installer.js +24 -3
  193. package/src/utils/file-copier.js +1 -0
  194. package/src/utils/hooks-installer.js +11 -19
  195. package/src/utils/skills-installer.js +178 -178
  196. package/framework/agents/architecture/prompt-engineer.md +0 -195
  197. package/framework/agents/backend/api-designer.md +0 -106
  198. package/framework/agents/frontend/blazor-builder.md +0 -229
  199. package/framework/agents/frontend/nextjs-ui-specialist.md +0 -218
  200. package/framework/agents/infrastructure/azure-architect.md +0 -150
  201. package/framework/agents/infrastructure/azure-deploy-specialist.md +0 -707
  202. package/framework/agents/infrastructure/bicep-architect.md +0 -132
  203. package/framework/agents/infrastructure/container-specialist.md +0 -137
  204. package/framework/agents/infrastructure/devops-engineer.md +0 -126
  205. package/framework/agents/integrations/azure-identity.md +0 -148
  206. package/framework/agents/quality/code-analyzer.md +0 -239
  207. package/framework/agents/quality/testing-specialist.md +0 -130
  208. package/framework/hooks/claude-code/notification/approval-reminder.js +0 -57
  209. package/framework/hooks/claude-code/post-tool-use/context-refresh.js +0 -109
  210. package/framework/hooks/claude-code/post-tool-use/skill-reminder.js +0 -78
  211. package/framework/index/troubleshooting-index.json +0 -184
  212. package/framework/rules/testing-standards.md +0 -14
  213. package/framework/skills/level-0-meta/morph-replicate/SKILL.md +0 -230
  214. package/framework/skills/level-0-meta/morph-replicate/references/blazor-html-mapping.md +0 -70
  215. package/framework/skills/level-1-workflows/morph-phase-clarify/SKILL.md +0 -256
  216. package/framework/skills/level-1-workflows/morph-phase-clarify/references/clarifications-example.md +0 -117
  217. package/framework/skills/level-1-workflows/morph-phase-setup/SKILL.md +0 -269
  218. package/framework/standards/ai-agents/blazor-ui.md +0 -364
  219. package/framework/standards/architecture/ddd/aggregates.md +0 -120
  220. package/framework/standards/architecture/ddd/bounded-contexts.md +0 -105
  221. package/framework/standards/architecture/ddd/complexity-levels.md +0 -108
  222. package/framework/standards/architecture/ddd/entities.md +0 -99
  223. package/framework/standards/architecture/ddd/ubiquitous-language.md +0 -58
  224. package/framework/standards/architecture/ddd/value-objects.md +0 -124
  225. package/framework/standards/backend/api/minimal-api.md +0 -494
  226. package/framework/standards/backend/api/rest.md +0 -492
  227. package/framework/standards/backend/authentication/passkeys.md +0 -428
  228. package/framework/standards/backend/database/ef-core.md +0 -199
  229. package/framework/standards/backend/database/migrations.md +0 -393
  230. package/framework/standards/backend/database/repository-patterns.md +0 -528
  231. package/framework/standards/backend/dotnet/async.md +0 -366
  232. package/framework/standards/backend/dotnet/core.md +0 -117
  233. package/framework/standards/backend/dotnet/di.md +0 -439
  234. package/framework/standards/backend/dotnet/program-cs-checklist.md +0 -92
  235. package/framework/standards/context/analytics.md +0 -96
  236. package/framework/standards/context/bundles.md +0 -110
  237. package/framework/standards/context/priming.md +0 -78
  238. package/framework/standards/core/architecture.md +0 -185
  239. package/framework/standards/core/coding.md +0 -214
  240. package/framework/standards/core/git-branching-strategy.md +0 -403
  241. package/framework/standards/core/git.md +0 -185
  242. package/framework/standards/core/testing.md +0 -295
  243. package/framework/standards/data/nosql/blob-storage.md +0 -102
  244. package/framework/standards/data/vector-search/azure-ai-search.md +0 -121
  245. package/framework/standards/frontend/blazor/design-checklist.md +0 -222
  246. package/framework/standards/frontend/blazor/fluent-ui-setup.md +0 -595
  247. package/framework/standards/frontend/blazor/fluent-ui.md +0 -137
  248. package/framework/standards/frontend/blazor/html-conversion.md +0 -184
  249. package/framework/standards/frontend/blazor/lifecycle.md +0 -195
  250. package/framework/standards/frontend/blazor/pitfalls.md +0 -198
  251. package/framework/standards/frontend/blazor/state.md +0 -191
  252. package/framework/standards/frontend/design-system/aesthetic-direction.md +0 -266
  253. package/framework/standards/frontend/design-system/design-trends.md +0 -171
  254. package/framework/standards/infrastructure/azure/azure.md +0 -624
  255. package/framework/standards/infrastructure/azure/bicep/bicep-patterns.md +0 -422
  256. package/framework/standards/infrastructure/azure/devops/azure-devops-setup.md +0 -516
  257. package/framework/standards/infrastructure/azure/devops/local-development.md +0 -520
  258. package/framework/standards/infrastructure/azure/services/functions.md +0 -486
  259. package/framework/standards/infrastructure/azure/services/service-bus.md +0 -459
  260. package/framework/standards/infrastructure/azure/services/storage.md +0 -407
  261. package/framework/standards/infrastructure/vercel/vercel-database.md +0 -106
  262. package/framework/standards/integration/api/graphql.md +0 -91
  263. package/framework/standards/integration/api/grpc.md +0 -114
  264. package/framework/standards/integration/api/rest-design.md +0 -95
  265. package/framework/standards/integration/event-driven/cqrs.md +0 -101
  266. package/framework/standards/integration/event-driven/event-sourcing.md +0 -124
  267. package/framework/standards/integration/event-driven/service-bus.md +0 -95
  268. package/framework/standards/observability/logging.md +0 -131
  269. package/framework/standards/observability/metrics.md +0 -121
  270. package/framework/standards/observability/monitoring.md +0 -114
  271. package/framework/standards/observability/tracing.md +0 -132
  272. package/framework/standards/workflows/parallel-execution.md +0 -112
  273. package/framework/standards/workflows/thread-management.md +0 -113
  274. package/framework/templates/code/dotnet/backend/service.cs +0 -139
  275. package/framework/templates/code/dotnet/contracts/Commands.cs +0 -74
  276. package/framework/templates/code/dotnet/contracts/Entities.cs +0 -25
  277. package/framework/templates/code/dotnet/contracts/Queries.cs +0 -74
  278. package/framework/templates/code/dotnet/contracts/api-contracts.cs +0 -173
  279. package/framework/templates/code/dotnet/contracts/contracts-level1.cs +0 -69
  280. package/framework/templates/code/dotnet/contracts/contracts-level2.cs +0 -86
  281. package/framework/templates/code/dotnet/contracts/contracts-level3.cs +0 -41
  282. package/framework/templates/code/dotnet/frontend/component.razor +0 -239
  283. package/framework/templates/infrastructure/azure/Dockerfile.example +0 -82
  284. package/framework/templates/infrastructure/azure/README.md +0 -286
  285. package/framework/templates/infrastructure/azure/app-insights.bicep +0 -63
  286. package/framework/templates/infrastructure/azure/app-service.bicep +0 -164
  287. package/framework/templates/infrastructure/azure/container-app-env.bicep +0 -49
  288. package/framework/templates/infrastructure/azure/container-app.bicep +0 -156
  289. package/framework/templates/infrastructure/azure/deploy-checklist.md +0 -426
  290. package/framework/templates/infrastructure/azure/deploy.ps1 +0 -229
  291. package/framework/templates/infrastructure/azure/deploy.sh +0 -208
  292. package/framework/templates/infrastructure/azure/key-vault.bicep +0 -91
  293. package/framework/templates/infrastructure/azure/main.bicep +0 -189
  294. package/framework/templates/infrastructure/azure/parameters.dev.json +0 -29
  295. package/framework/templates/infrastructure/azure/parameters.prod.json +0 -29
  296. package/framework/templates/infrastructure/azure/parameters.staging.json +0 -29
  297. package/framework/templates/infrastructure/azure/sql-database.bicep +0 -103
  298. package/framework/templates/infrastructure/azure/storage.bicep +0 -106
  299. package/framework/templates/infrastructure/github/actions/azure-auth/action.yml.hbs +0 -22
  300. package/framework/templates/infrastructure/github/workflows/deploy-azure-app-service.yml.hbs +0 -61
  301. package/framework/templates/integrations/azure-identity-config.cs +0 -288
  302. package/framework/templates/project-structure/dotnet-ddd.md +0 -70
  303. package/framework/templates/saas/subscription.cs +0 -347
  304. package/framework/templates/saas/tenant.cs +0 -338
  305. package/framework/templates/ui/FluentDesignTheme.cs +0 -149
  306. package/framework/templates/ui/MudTheme.cs +0 -281
  307. package/framework/workflows/configs/nodejs-cli.json +0 -40
  308. package/src/commands/standards/context-budget.js +0 -89
  309. package/src/lib/standards/index.js +0 -7
  310. package/src/lib/standards/standards-context-injector.js +0 -302
  311. package/src/lib/validators/blazor/blazor-concurrency-analyzer.js +0 -316
  312. package/src/lib/validators/blazor/blazor-state-validator.js +0 -279
  313. package/src/lib/validators/blazor/blazor-validator.js +0 -369
  314. package/src/lib/validators/blazor/index.js +0 -9
@@ -1,479 +1,472 @@
1
- # Agent Teams Workflow - Claude Code Integration
2
-
3
- > **Scope:** universal
4
- > **Layer:** 0 (always load)
5
- > **Keywords:** agent, team, orchestration, claude code, parallel
6
- > **Load When:** always
7
-
8
- **Status:** EXPERIMENTAL - Enable via `CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1`
9
-
10
- Orchestrate multiple Claude Code instances as a coordinated team for parallel development workflows
11
-
12
- ---
13
-
14
- ## Overview
15
-
16
- **Agent Teams** are a Claude Code feature that coordinates multiple independent Claude instances working together on complex tasks. Unlike subagents (which run within a single context and only report back), Agent Teams members can communicate directly with each other, share findings, challenge each other's approaches, and coordinate through a shared task list.
17
-
18
- ### Core Architecture
19
-
20
- | Component | Role |
21
- |-----------|------|
22
- | **Team Lead** | Main Claude session that creates the team, spawns teammates, coordinates work |
23
- | **Teammates** | Independent Claude Code instances, each with own context window |
24
- | **Shared Task List** | Coordinated work items with dependencies and state (pending/in-progress/completed) |
25
- | **Mailbox** | Direct messaging system between agents |
26
-
27
- **Storage:**
28
- - Team config: `~/.claude/teams/{team-name}/config.json`
29
- - Task list: `~/.claude/tasks/{team-name}/`
30
-
31
- ---
32
-
33
- ## Agent Teams vs Subagents
34
-
35
- | Aspect | Subagents | Agent Teams |
36
- |--------|-----------|-------------|
37
- | **Context** | Own context, results return to caller | Fully independent contexts |
38
- | **Communication** | Report back to main agent only | Direct inter-teammate messaging + broadcast |
39
- | **Coordination** | Main agent manages all work | Shared task list with self-claiming |
40
- | **Best for** | Focused research, verification, isolated tasks | Complex work requiring discussion & collaboration |
41
- | **Token cost** | Lower (results summarized) | Higher (each teammate = separate Claude instance) |
42
- | **Use in MORPH** | Quick analysis, validation, isolated research | Parallel feature implementation, multi-module refactoring |
43
-
44
- ---
45
-
46
- ## When to Use Agent Teams in MORPH-SPEC
47
-
48
- ### ✅ **Strong Use Cases**
49
-
50
- 1. **Parallel Feature Implementation (FASE 5)**
51
- - Multiple independent features in the same release
52
- - Each teammate owns 1-2 modules (e.g., Auth, Payments, Reporting)
53
- - No file conflicts (each module has distinct files)
54
-
55
- 2. **Architecture Review & Debugging**
56
- - Multiple teammates investigate competing hypotheses
57
- - Each applies different lens (security, performance, maintainability)
58
- - Teams debate and converge on best solution
59
-
60
- 3. **Cross-Stack Coordination**
61
- - Frontend teammate (Blazor/Next.js)
62
- - Backend teammate (API + EF Core)
63
- - Infrastructure teammate (Bicep + Azure)
64
- - Testing teammate (unit + integration)
65
-
66
- 4. **Research & Standards Validation (FASE 0-2)**
67
- - Investigate multiple integration options (Clerk vs Azure AD vs custom)
68
- - Compare UI libraries (Fluent UI vs MudBlazor vs Radzen)
69
- - Validate architecture patterns (CQRS vs simple Repository)
70
-
71
- ### ❌ **Not Recommended**
72
-
73
- - Single-file edits or small bug fixes
74
- - Sequential tasks with many dependencies
75
- - Same-file modifications by multiple teammates (causes conflicts)
76
- - Routine tasks where coordination overhead > benefit
77
-
78
- ---
79
-
80
- ## Setup & Configuration
81
-
82
- ### 1. Enable Agent Teams
83
-
84
- Add to `.claude/settings.local.json` (or env variable):
85
-
86
- ```json
87
- {
88
- "env": {
89
- "CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS": "1"
90
- },
91
- "teammateMode": "auto" // or "in-process" / "tmux"
92
- }
93
- ```
94
-
95
- **Display Modes:**
96
- - `"auto"`: Split panes if in tmux, otherwise in-process
97
- - `"in-process"`: All teammates in main terminal (Shift+Up/Down to switch)
98
- - `"tmux"`: Each teammate in separate pane (requires tmux or iTerm2)
99
-
100
- ### 2. Start a Team
101
-
102
- **Natural Language Request:**
103
- ```
104
- Create an agent team to implement the scheduled-reports feature.
105
- Spawn 3 teammates:
106
- - Backend engineer: EF Core models + Hangfire jobs (uses ef-modeler, hangfire-orchestrator skills)
107
- - Frontend engineer: Blazor dashboard + report viewer (uses blazor-builder, ui-ux-designer skills)
108
- - Testing specialist: Unit + integration tests (uses testing-specialist skill)
109
-
110
- Require plan approval for each teammate before implementation.
111
- ```
112
-
113
- **What Claude Does:**
114
- 1. Creates team config in `~/.claude/teams/scheduled-reports/`
115
- 2. Spawns 3 independent Claude instances
116
- 3. Each teammate loads project context (CLAUDE.md, MCP servers, skills)
117
- 4. Lead assigns initial tasks from shared task list
118
- 5. Teammates work in plan mode until lead approves
119
- 6. After approval, teammates implement independently
120
-
121
- ### 3. Control the Team
122
-
123
- **Delegate Mode** (Lead focuses on coordination only):
124
- ```
125
- Press Shift+Tab to cycle into delegate mode
126
- ```
127
- - Lead can't use code tools (Edit/Write/Bash)
128
- - Only coordination tools: spawn, message, task management
129
-
130
- **Direct Teammate Communication:**
131
- - In-process mode: Shift+Up/Down to select, type to message
132
- - Split-pane mode: Click teammate pane to interact directly
133
-
134
- **Task Management:**
135
- ```
136
- # Lead assigns task
137
- Assign task T003 (implement report scheduler) to the backend engineer
138
-
139
- # Teammate self-claims next available task
140
- After completing T001, backend engineer claims T004 (add report repository)
141
- ```
142
-
143
- **Shutdown:**
144
- ```
145
- Ask the backend teammate to shut down gracefully
146
- ```
147
-
148
- ---
149
-
150
- ## MORPH-SPEC Integration Patterns
151
-
152
- ### Pattern 1: Parallel Feature Implementation (FASE 5)
153
-
154
- **Scenario:** Multi-module feature with independent components
155
-
156
- ```bash
157
- # 1. Complete FASES 0-4 normally (proposal → design → tasks)
158
- morph-spec state set scheduled-reports phase implement
159
-
160
- # 2. Claude creates agent team based on tasks.json structure
161
- # Example tasks.json with module grouping:
162
- {
163
- "tasks": [
164
- { "id": "T001", "module": "backend", "title": "Create ReportDefinition entity" },
165
- { "id": "T002", "module": "backend", "title": "Implement Hangfire scheduler" },
166
- { "id": "T003", "module": "frontend", "title": "Create report dashboard UI" },
167
- { "id": "T004", "module": "frontend", "title": "Add report preview component" },
168
- { "id": "T005", "module": "infra", "title": "Provision Blob Storage for reports" },
169
- { "id": "T006", "module": "tests", "title": "Unit tests for scheduler", "dependsOn": ["T002"] }
170
- ]
171
- }
172
- ```
173
-
174
- **Team Structure:**
175
- - **Lead:** Standards Architect (coordinates, validates contracts, syncs decisions.md)
176
- - **Backend Teammate:** .NET Senior + Hangfire Orchestrator + EF Modeler
177
- - **Frontend Teammate:** Blazor Builder + UI/UX Designer
178
- - **Infra Teammate:** Azure Architect + Bicep Architect
179
- - **Testing Teammate:** Testing Specialist
180
-
181
- **Workflow:**
182
- 1. Lead assigns tasks by module
183
- 2. Each teammate implements their tasks independently
184
- 3. Teammates run `morph-spec task done {feature} {task-id}` after each task
185
- 4. Validation pipeline runs automatically (contract compliance, decisions constraints)
186
- 5. Lead synthesizes recap.md after all tasks complete
187
-
188
- ### Pattern 2: Architecture Decision Debate (FASE 2)
189
-
190
- **Scenario:** Multiple valid approaches for complex problem
191
-
192
- ```
193
- Create an agent team to decide on the authentication architecture.
194
- Spawn 3 debate teammates:
195
- - Pro-Clerk: Argue for Clerk.com (ease of use, modern UI, MFA built-in)
196
- - Pro-Azure AD: Argue for Azure AD B2C (enterprise compliance, existing infra)
197
- - Pro-Custom: Argue for custom JWT + Passkeys (full control, no vendor lock-in)
198
-
199
- Have them debate, challenge each other's assumptions, and document pros/cons.
200
- Update decisions.md with consensus.
201
- ```
202
-
203
- **Output:** Structured ADR in `decisions.md` with all perspectives considered
204
-
205
- ### Pattern 3: Code Review by Concern (Post-FASE 5)
206
-
207
- **Scenario:** Thorough review before production deployment
208
-
209
- ```
210
- Create an agent team to review the scheduled-reports implementation.
211
- Spawn 4 reviewers:
212
- - Security reviewer: Auth, SQL injection, XSS, secrets management
213
- - Performance reviewer: Query efficiency, caching, background job overhead
214
- - Standards reviewer: Blazor patterns, EF Core best practices, contract compliance
215
- - UX reviewer: Accessibility, responsive design, error handling
216
-
217
- Each reviewer reports findings to the lead, then synthesize into review.md
218
- ```
219
-
220
- ---
221
-
222
- ## Best Practices for MORPH-SPEC
223
-
224
- ### 1. Size Tasks Appropriately
225
-
226
- **Good task granularity (5-6 tasks per teammate):**
227
- ```json
228
- {
229
- "id": "T003",
230
- "title": "Implement report scheduling service",
231
- "module": "backend",
232
- "files": ["Services/ReportScheduler.cs", "Jobs/GenerateReportJob.cs"],
233
- "estimatedHours": 2
234
- }
235
- ```
236
-
237
- **Too small (coordination overhead > benefit):**
238
- ```json
239
- { "id": "T001", "title": "Add using statement" }
240
- ```
241
-
242
- **Too large (teammate works too long without check-ins):**
243
- ```json
244
- { "id": "T099", "title": "Implement entire authentication system" }
245
- ```
246
-
247
- ### 2. Prevent File Conflicts
248
-
249
- **Design task ownership to avoid overlapping edits:**
250
-
251
- ❌ **Bad (conflict risk):**
252
- - Backend teammate modifies `Program.cs` for DI
253
- - Frontend teammate modifies `Program.cs` for middleware
254
-
255
- ✅ **Good (isolated ownership):**
256
- - Backend teammate: `Services/`, `Data/`, `Jobs/`
257
- - Frontend teammate: `Pages/`, `Components/`, `wwwroot/`
258
- - Lead handles shared files (`Program.cs`, `appsettings.json`) after review
259
-
260
- ### 3. Leverage Shared Context
261
-
262
- **All teammates automatically load:**
263
- - `CLAUDE.md` (MORPH-SPEC instructions)
264
- - `.claude/skills/` (all available skills)
265
- - `.morph/config.json` (project configuration)
266
- - `framework/standards/` + `.morph/framework/standards/`
267
-
268
- **Pass task-specific context in spawn prompt:**
269
- ```
270
- Spawn backend teammate with prompt: "Implement scheduled reports feature.
271
- Active agents: ef-modeler, hangfire-orchestrator, dotnet-senior.
272
- Read .morph/features/scheduled-reports/1-design/spec.md and contracts.cs.
273
- Follow Blazor concurrency patterns from framework/standards/blazor-state.md.
274
- All background jobs MUST use IDbContextFactory (scoped repository pattern)."
275
- ```
276
-
277
- ### 4. Use Hooks for Quality Gates
278
-
279
- **Enforce validation before task completion:**
280
-
281
- ```json
282
- // .claude/hooks.json
283
- {
284
- "TaskCompleted": {
285
- "command": "morph-spec validate-task ${MORPH_FEATURE} ${TASK_ID}",
286
- "exitCode2Feedback": "Task validation failed. Fix violations before marking complete."
287
- },
288
- "TeammateIdle": {
289
- "command": "morph-spec check-teammate-progress ${TEAMMATE_ID}",
290
- "exitCode2Feedback": "Teammate has incomplete work. Continue implementation."
291
- }
292
- }
293
- ```
294
-
295
- ### 5. Monitor Token Usage
296
-
297
- **Agent Teams = High Token Cost:**
298
- - Each teammate = separate Claude instance with full context
299
- - 4 teammates on a 2-hour task ≈ 4x token usage vs single session
300
-
301
- **When worth it:**
302
- - Parallel implementation of 3+ independent modules
303
- - Complex architecture decisions requiring debate
304
- - Time-sensitive features where parallel work reduces calendar time
305
-
306
- **When NOT worth it:**
307
- - Single-module features
308
- - Sequential refactoring
309
- - Simple bug fixes
310
-
311
- ---
312
-
313
- ## Troubleshooting
314
-
315
- ### Issue: Lead Implements Instead of Delegating
316
-
317
- **Symptom:** Lead starts coding tasks instead of waiting for teammates
318
-
319
- **Solution:**
320
- ```
321
- Wait for your teammates to complete their tasks before proceeding.
322
- Use delegate mode to restrict yourself to coordination only.
323
- ```
324
- Then press `Shift+Tab` to cycle into delegate mode.
325
-
326
- ### Issue: Task Not Marked Complete
327
-
328
- **Symptom:** Teammate finished work but task still shows "in_progress"
329
-
330
- **Solution:**
331
- ```
332
- # Check if validation passed
333
- morph-spec state get {feature}
334
-
335
- # If validation failed, teammate must fix violations
336
- Tell the frontend teammate to check validation output and fix contract violations
337
-
338
- # If validation passed but task stuck, manually mark complete
339
- morph-spec task done {feature} {task-id}
340
- ```
341
-
342
- ### Issue: Orphaned tmux Sessions
343
-
344
- **Symptom:** `tmux ls` shows team sessions after cleanup
345
-
346
- **Solution:**
347
- ```bash
348
- tmux kill-session -t scheduled-reports-team
349
- rm -rf ~/.claude/teams/scheduled-reports
350
- ```
351
-
352
- ### Issue: Permission Prompts Spam
353
-
354
- **Symptom:** Too many permission requests for teammates
355
-
356
- **Solution:** Pre-approve common operations in `settings.local.json`:
357
- ```json
358
- {
359
- "dangerouslySkipPermissions": {
360
- "allowedPaths": [".morph/features/**"],
361
- "allowedCommands": ["morph-spec task done", "morph-spec validate-*"]
362
- }
363
- }
364
- ```
365
-
366
- ---
367
-
368
- ## Integration with MORPH Workflows
369
-
370
- ### Full MORPH (9 phases) + Agent Teams
371
-
372
- | Phase | Team Usage |
373
- |-------|------------|
374
- | **0 PROPOSAL** | Single session (detect-agents) |
375
- | **1 SETUP** | Single session |
376
- | **1.5 UI/UX** | Optional: Spawn UI/UX designer teammate for mockup generation |
377
- | **2 DESIGN** | Optional: Spawn debate team for DECISION POINTS |
378
- | **3 CLARIFY** | Single session |
379
- | **4 TASKS** | Single session (generate tasks.json) |
380
- | **5 IMPLEMENT** | **Primary use case:** Spawn implementation team by module |
381
- | **6 SYNC** | Single session (lead synthesizes decisions.md → standards/) |
382
-
383
- ### Fast Track + Agent Teams
384
-
385
- **Not recommended:** Coordination overhead defeats purpose of fast workflow.
386
-
387
- **Exception:** If fast-track task expands during implementation:
388
- ```
389
- morph-spec state set {feature} workflow full-morph
390
- # Then create agent team for expanded scope
391
- ```
392
-
393
- ---
394
-
395
- ## Limitations (as of 2026-02-12)
396
-
397
- - **No session resumption:** `/resume` doesn't restore in-process teammates
398
- - **Task status can lag:** Manual nudge may be needed
399
- - **One team per session:** Clean up before starting new team
400
- - **No nested teams:** Teammates can't spawn their own teams
401
- - **Split panes require tmux/iTerm2:** Not available in VS Code terminal, Windows Terminal, Ghostty
402
-
403
- ---
404
-
405
- ## Example: Full MORPH Workflow with Agent Team
406
-
407
- ```bash
408
- # FASES 0-4: Single Claude session
409
- /morph-proposal scheduled-reports
410
- # ... proposal approved, design approved, tasks generated ...
411
-
412
- # FASE 5: Create agent team
413
- morph-spec state set scheduled-reports phase implement
414
- ```
415
-
416
- ```
417
- Create an agent team to implement scheduled-reports.
418
-
419
- Team structure based on tasks.json modules:
420
- - Backend teammate (T001-T005): EF models, Hangfire jobs, repositories
421
- - Frontend teammate (T006-T010): Blazor pages, components, CSS
422
- - Infra teammate (T011-T012): Bicep modules for Blob Storage + Service Bus
423
-
424
- Require plan approval for each teammate.
425
- Use delegate mode so I only coordinate.
426
- ```
427
-
428
- **Claude creates team, spawns 3 teammates, each works independently:**
429
-
430
- ```bash
431
- # Backend teammate
432
- morph-spec task start scheduled-reports T001
433
- # ... implements ReportDefinition.cs ...
434
- morph-spec task done scheduled-reports T001
435
- # Validation runs: contract-compliance, blazor-concurrency (IDbContextFactory check)
436
- # ✅ Task T001 completed
437
-
438
- # Frontend teammate (parallel)
439
- morph-spec task start scheduled-reports T006
440
- # ... implements ReportDashboard.razor ...
441
- morph-spec task done scheduled-reports T006
442
- # Validation runs: blazor-validator, css-validator, contrast-checker
443
- # ✅ Task T006 completed
444
- ```
445
-
446
- **After all tasks complete, lead synthesizes:**
447
- ```bash
448
- morph-spec generate recap scheduled-reports
449
- # Pulls data from state.json, validation results, contracts.cs
450
- # Generates comprehensive recap.md
451
-
452
- morph-spec phase advance scheduled-reports
453
- # Validates FASE 5 → advances to FASE 6 → shows next steps
454
- ```
455
-
456
- ---
457
-
458
- ## Summary
459
-
460
- **Agent Teams enable MORPH-SPEC to:**
461
- - Implement multi-module features in parallel (reduces calendar time)
462
- - Debate architecture decisions with multiple perspectives
463
- - Conduct thorough reviews across security/performance/standards
464
-
465
- **Use when:**
466
- - 3+ independent modules/components
467
- - Complex architecture decisions
468
- - Cross-stack coordination (backend + frontend + infra)
469
-
470
- **Avoid when:**
471
- - Single-module features
472
- - Sequential workflows
473
- - Same-file modifications needed
474
-
475
- **Key insight:** Agent Teams amplify MORPH-SPEC's strengths (structured workflows, spec-driven development, validation pipeline) by parallelizing implementation while maintaining quality gates and coordination.
476
-
477
- ---
478
-
479
- *MORPH-SPEC by Polymorphism Tech - Integrated with Claude Code Agent Teams*
1
+ ---
2
+ name: morph-agent-teams
3
+ description: Guide for orchestrating Claude Code Agent Teams within MORPH-SPEC workflows. Covers team setup, parallel implementation patterns, architecture debate teams, and integration with MORPH phases and validation gates. Use when a feature has 3+ independent modules that benefit from parallel development.
4
+ user-invocable: true
5
+ argument-hint: "[feature-name]"
6
+ allowed-tools: Read, Bash, Glob, Grep, Edit, Write, AskUserQuestion
7
+ ---
8
+
9
+ # Agent Teams Workflow - Claude Code Integration
10
+
11
+ > Orchestrate multiple Claude Code instances as a coordinated team for parallel development workflows within MORPH-SPEC.
12
+
13
+ **Status:** EXPERIMENTAL - Enable via `CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1`
14
+
15
+ ---
16
+
17
+ ## Overview
18
+
19
+ **Agent Teams** are a Claude Code feature that coordinates multiple independent Claude instances working together on complex tasks. Unlike subagents (which run within a single context and only report back), Agent Teams members can communicate directly with each other, share findings, challenge each other's approaches, and coordinate through a shared task list.
20
+
21
+ ### Core Architecture
22
+
23
+ | Component | Role |
24
+ |-----------|------|
25
+ | **Team Lead** | Main Claude session that creates the team, spawns teammates, coordinates work |
26
+ | **Teammates** | Independent Claude Code instances, each with own context window |
27
+ | **Shared Task List** | Coordinated work items with dependencies and state (pending/in-progress/completed) |
28
+ | **Mailbox** | Direct messaging system between agents |
29
+
30
+ **Storage:**
31
+ - Team config: `~/.claude/teams/{team-name}/config.json`
32
+ - Task list: `~/.claude/tasks/{team-name}/`
33
+
34
+ ---
35
+
36
+ ## Agent Teams vs Subagents
37
+
38
+ | Aspect | Subagents | Agent Teams |
39
+ |--------|-----------|-------------|
40
+ | **Context** | Own context, results return to caller | Fully independent contexts |
41
+ | **Communication** | Report back to main agent only | Direct inter-teammate messaging + broadcast |
42
+ | **Coordination** | Main agent manages all work | Shared task list with self-claiming |
43
+ | **Best for** | Focused research, verification, isolated tasks | Complex work requiring discussion & collaboration |
44
+ | **Token cost** | Lower (results summarized) | Higher (each teammate = separate Claude instance) |
45
+ | **Use in MORPH** | Quick analysis, validation, isolated research | Parallel feature implementation, multi-module refactoring |
46
+
47
+ ---
48
+
49
+ ## When to Use Agent Teams in MORPH-SPEC
50
+
51
+ ### Strong Use Cases
52
+
53
+ 1. **Parallel Feature Implementation (Phase 5 - Implement)**
54
+ - Multiple independent features in the same release
55
+ - Each teammate owns 1-2 modules (e.g., Auth, Payments, Reporting)
56
+ - No file conflicts (each module has distinct files)
57
+
58
+ 2. **Architecture Review & Debugging**
59
+ - Multiple teammates investigate competing hypotheses
60
+ - Each applies different lens (security, performance, maintainability)
61
+ - Teams debate and converge on best solution
62
+
63
+ 3. **Cross-Stack Coordination**
64
+ - Frontend teammate (Next.js + shadcn/ui)
65
+ - Backend teammate (API + .NET VSA)
66
+ - Infrastructure teammate (EasyPanel + Supabase)
67
+ - Testing teammate (unit + integration)
68
+
69
+ 4. **Research & Standards Validation (Phases 0-3)**
70
+ - Investigate multiple integration options (Clerk vs Supabase Auth vs custom)
71
+ - Compare UI patterns (shadcn/ui component composition strategies)
72
+ - Validate architecture patterns (CQRS vs simple Repository)
73
+
74
+ ### Not Recommended
75
+
76
+ - Single-file edits or small bug fixes
77
+ - Sequential tasks with many dependencies
78
+ - Same-file modifications by multiple teammates (causes conflicts)
79
+ - Routine tasks where coordination overhead > benefit
80
+
81
+ ---
82
+
83
+ ## Setup & Configuration
84
+
85
+ ### 1. Enable Agent Teams
86
+
87
+ Add to `.claude/settings.local.json` (or env variable):
88
+
89
+ ```json
90
+ {
91
+ "env": {
92
+ "CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS": "1"
93
+ },
94
+ "teammateMode": "auto"
95
+ }
96
+ ```
97
+
98
+ **Display Modes:**
99
+ - `"auto"`: Split panes if in tmux, otherwise in-process
100
+ - `"in-process"`: All teammates in main terminal (Shift+Up/Down to switch)
101
+ - `"tmux"`: Each teammate in separate pane (requires tmux or iTerm2)
102
+
103
+ ### 2. Start a Team
104
+
105
+ **Natural Language Request:**
106
+ ```
107
+ Create an agent team to implement the scheduled-reports feature.
108
+ Spawn 3 teammates:
109
+ - Backend engineer: .NET VSA endpoints + Hangfire jobs (uses dotnet-senior, hangfire-orchestrator skills)
110
+ - Frontend engineer: Dashboard + report viewer (uses nextjs-expert, ui-designer skills)
111
+ - Testing engineer: Unit + integration tests (uses dotnet-senior skill)
112
+
113
+ Require plan approval for each teammate before implementation.
114
+ ```
115
+
116
+ **What Claude Does:**
117
+ 1. Creates team config in `~/.claude/teams/scheduled-reports/`
118
+ 2. Spawns 3 independent Claude instances
119
+ 3. Each teammate loads project context (CLAUDE.md, MCP servers, skills)
120
+ 4. Lead assigns initial tasks from shared task list
121
+ 5. Teammates work in plan mode until lead approves
122
+ 6. After approval, teammates implement independently
123
+
124
+ ### 3. Control the Team
125
+
126
+ **Delegate Mode** (Lead focuses on coordination only):
127
+ ```
128
+ Press Shift+Tab to cycle into delegate mode
129
+ ```
130
+ - Lead can't use code tools (Edit/Write/Bash)
131
+ - Only coordination tools: spawn, message, task management
132
+
133
+ **Direct Teammate Communication:**
134
+ - In-process mode: Shift+Up/Down to select, type to message
135
+ - Split-pane mode: Click teammate pane to interact directly
136
+
137
+ **Task Management:**
138
+ ```
139
+ # Lead assigns task
140
+ Assign task T003 (implement report scheduler) to the backend engineer
141
+
142
+ # Teammate self-claims next available task
143
+ After completing T001, backend engineer claims T004 (add report repository)
144
+ ```
145
+
146
+ **Shutdown:**
147
+ ```
148
+ Ask the backend teammate to shut down gracefully
149
+ ```
150
+
151
+ ---
152
+
153
+ ## MORPH-SPEC Integration Patterns
154
+
155
+ ### Pattern 1: Parallel Feature Implementation (Implement Phase)
156
+
157
+ **Scenario:** Multi-module feature with independent components
158
+
159
+ ```bash
160
+ # 1. Complete phases 0-4 normally (proposal -> design -> tasks)
161
+ morph-spec state set scheduled-reports phase implement
162
+
163
+ # 2. Claude creates agent team based on tasks.json structure
164
+ # Example tasks.json with module grouping:
165
+ {
166
+ "tasks": [
167
+ { "id": "T001", "module": "backend", "title": "Create ReportDefinition entity" },
168
+ { "id": "T002", "module": "backend", "title": "Implement Hangfire scheduler" },
169
+ { "id": "T003", "module": "frontend", "title": "Create report dashboard page" },
170
+ { "id": "T004", "module": "frontend", "title": "Add report preview component" },
171
+ { "id": "T005", "module": "infra", "title": "Configure Supabase storage bucket for reports" },
172
+ { "id": "T006", "module": "tests", "title": "Unit tests for scheduler", "dependsOn": ["T002"] }
173
+ ]
174
+ }
175
+ ```
176
+
177
+ **Team Structure:**
178
+ - **Lead:** Standards Architect (coordinates, validates contracts, syncs decisions.md)
179
+ - **Backend Teammate:** .NET Senior + Hangfire Orchestrator
180
+ - **Frontend Teammate:** Next.js Expert + UI Designer
181
+ - **Infra Teammate:** Infra Architect (EasyPanel + Supabase)
182
+ - **Testing Teammate:** (Handled by backend or frontend teammate)
183
+
184
+ **Workflow:**
185
+ 1. Lead assigns tasks by module
186
+ 2. Each teammate implements their tasks independently
187
+ 3. Teammates run `morph-spec task done {feature} {task-id}` after each task
188
+ 4. Validation pipeline runs automatically (contract compliance, decisions constraints)
189
+ 5. Lead synthesizes recap.md after all tasks complete
190
+
191
+ ### Pattern 2: Architecture Decision Debate (Design Phase)
192
+
193
+ **Scenario:** Multiple valid approaches for complex problem
194
+
195
+ ```
196
+ Create an agent team to decide on the authentication architecture.
197
+ Spawn 3 debate teammates:
198
+ - Pro-Clerk: Argue for Clerk.com (ease of use, modern UI, MFA built-in)
199
+ - Pro-Supabase-Auth: Argue for Supabase Auth (integrated with existing DB, Row Level Security)
200
+ - Pro-Custom: Argue for custom JWT + Passkeys (full control, no vendor lock-in)
201
+
202
+ Have them debate, challenge each other's assumptions, and document pros/cons.
203
+ Update decisions.md with consensus.
204
+ ```
205
+
206
+ **Output:** Structured ADR in `decisions.md` with all perspectives considered
207
+
208
+ ### Pattern 3: Code Review by Concern (Post-Implementation)
209
+
210
+ **Scenario:** Thorough review before production deployment
211
+
212
+ ```
213
+ Create an agent team to review the scheduled-reports implementation.
214
+ Spawn 4 reviewers:
215
+ - Security reviewer: Auth, SQL injection, XSS, secrets management
216
+ - Performance reviewer: Query efficiency, caching, background job overhead
217
+ - Standards reviewer: Next.js patterns, .NET VSA best practices, contract compliance
218
+ - UX reviewer: Accessibility, responsive design, error handling
219
+
220
+ Each reviewer reports findings to the lead, then synthesize into review.md
221
+ ```
222
+
223
+ ---
224
+
225
+ ## Best Practices for MORPH-SPEC
226
+
227
+ ### 1. Size Tasks Appropriately
228
+
229
+ **Good task granularity (5-6 tasks per teammate):**
230
+ ```json
231
+ {
232
+ "id": "T003",
233
+ "title": "Implement report scheduling service",
234
+ "module": "backend",
235
+ "files": ["Features/Reports/ScheduleReport/Endpoint.cs", "Jobs/GenerateReportJob.cs"],
236
+ "estimatedHours": 2
237
+ }
238
+ ```
239
+
240
+ **Too small (coordination overhead > benefit):**
241
+ ```json
242
+ { "id": "T001", "title": "Add using statement" }
243
+ ```
244
+
245
+ **Too large (teammate works too long without check-ins):**
246
+ ```json
247
+ { "id": "T099", "title": "Implement entire authentication system" }
248
+ ```
249
+
250
+ ### 2. Prevent File Conflicts
251
+
252
+ **Design task ownership to avoid overlapping edits:**
253
+
254
+ **Bad (conflict risk):**
255
+ - Backend teammate modifies `Program.cs` for DI
256
+ - Frontend teammate modifies `next.config.ts` for redirects
257
+
258
+ **Good (isolated ownership):**
259
+ - Backend teammate: `Features/`, `Jobs/`, `Infrastructure/`
260
+ - Frontend teammate: `app/`, `components/`, `lib/`
261
+ - Lead handles shared files (`Program.cs`, `next.config.ts`) after review
262
+
263
+ ### 3. Leverage Shared Context
264
+
265
+ **All teammates automatically load:**
266
+ - `CLAUDE.md` (MORPH-SPEC instructions)
267
+ - `.claude/skills/` (all available skills)
268
+ - `.morph/config.json` (project configuration)
269
+ - `framework/standards/` + `.morph/framework/standards/`
270
+
271
+ **Pass task-specific context in spawn prompt:**
272
+ ```
273
+ Spawn backend teammate with prompt: "Implement scheduled reports feature.
274
+ Active agents: dotnet-senior, hangfire-orchestrator.
275
+ Read .morph/features/scheduled-reports/2-design/spec.md and contracts.
276
+ All background jobs MUST use scoped DI and follow VSA endpoint patterns."
277
+ ```
278
+
279
+ ### 4. Use Hooks for Quality Gates
280
+
281
+ **Enforce validation before task completion:**
282
+
283
+ ```json
284
+ // .claude/hooks.json
285
+ {
286
+ "TaskCompleted": {
287
+ "command": "morph-spec validate-task ${MORPH_FEATURE} ${TASK_ID}",
288
+ "exitCode2Feedback": "Task validation failed. Fix violations before marking complete."
289
+ },
290
+ "TeammateIdle": {
291
+ "command": "morph-spec check-teammate-progress ${TEAMMATE_ID}",
292
+ "exitCode2Feedback": "Teammate has incomplete work. Continue implementation."
293
+ }
294
+ }
295
+ ```
296
+
297
+ ### 5. Monitor Token Usage
298
+
299
+ **Agent Teams = High Token Cost:**
300
+ - Each teammate = separate Claude instance with full context
301
+ - 4 teammates on a 2-hour task = 4x token usage vs single session
302
+
303
+ **When worth it:**
304
+ - Parallel implementation of 3+ independent modules
305
+ - Complex architecture decisions requiring debate
306
+ - Time-sensitive features where parallel work reduces calendar time
307
+
308
+ **When NOT worth it:**
309
+ - Single-module features
310
+ - Sequential refactoring
311
+ - Simple bug fixes
312
+
313
+ ---
314
+
315
+ ## Troubleshooting
316
+
317
+ ### Issue: Lead Implements Instead of Delegating
318
+
319
+ **Symptom:** Lead starts coding tasks instead of waiting for teammates
320
+
321
+ **Solution:**
322
+ ```
323
+ Wait for your teammates to complete their tasks before proceeding.
324
+ Use delegate mode to restrict yourself to coordination only.
325
+ ```
326
+ Then press `Shift+Tab` to cycle into delegate mode.
327
+
328
+ ### Issue: Task Not Marked Complete
329
+
330
+ **Symptom:** Teammate finished work but task still shows "in_progress"
331
+
332
+ **Solution:**
333
+ ```
334
+ # Check if validation passed
335
+ morph-spec state get {feature}
336
+
337
+ # If validation failed, teammate must fix violations
338
+ Tell the frontend teammate to check validation output and fix contract violations
339
+
340
+ # If validation passed but task stuck, manually mark complete
341
+ morph-spec task done {feature} {task-id}
342
+ ```
343
+
344
+ ### Issue: Orphaned tmux Sessions
345
+
346
+ **Symptom:** `tmux ls` shows team sessions after cleanup
347
+
348
+ **Solution:**
349
+ ```bash
350
+ tmux kill-session -t scheduled-reports-team
351
+ rm -rf ~/.claude/teams/scheduled-reports
352
+ ```
353
+
354
+ ### Issue: Permission Prompts Spam
355
+
356
+ **Symptom:** Too many permission requests for teammates
357
+
358
+ **Solution:** Pre-approve common operations in `settings.local.json`:
359
+ ```json
360
+ {
361
+ "dangerouslySkipPermissions": {
362
+ "allowedPaths": [".morph/features/**"],
363
+ "allowedCommands": ["morph-spec task done", "morph-spec validate-*"]
364
+ }
365
+ }
366
+ ```
367
+
368
+ ---
369
+
370
+ ## Integration with MORPH Workflows
371
+
372
+ ### Full MORPH (9 phases) + Agent Teams
373
+
374
+ | Phase | Team Usage |
375
+ |-------|------------|
376
+ | **0 PROPOSAL** | Single session (detect-agents) |
377
+ | **1 SETUP** | Single session |
378
+ | **1.5 UI/UX** | Optional: Spawn UI/UX designer teammate for mockup generation |
379
+ | **2 DESIGN** | Optional: Spawn debate team for DECISION POINTS |
380
+ | **3 CLARIFY** | Single session |
381
+ | **4 PLAN** | Single session |
382
+ | **5 TASKS** | Single session (generate tasks.json) |
383
+ | **6 IMPLEMENT** | **Primary use case:** Spawn implementation team by module |
384
+ | **7 SYNC** | Single session (lead synthesizes decisions.md) |
385
+
386
+ ---
387
+
388
+ ## Limitations
389
+
390
+ - **No session resumption:** `/resume` doesn't restore in-process teammates
391
+ - **Task status can lag:** Manual nudge may be needed
392
+ - **One team per session:** Clean up before starting new team
393
+ - **No nested teams:** Teammates can't spawn their own teams
394
+ - **Split panes require tmux/iTerm2:** Not available in VS Code terminal, Windows Terminal, Ghostty
395
+
396
+ ---
397
+
398
+ ## Example: Full MORPH Workflow with Agent Team
399
+
400
+ ```bash
401
+ # Phases 0-5: Single Claude session
402
+ /morph-proposal scheduled-reports
403
+ # ... proposal approved, design approved, tasks generated ...
404
+
405
+ # Phase 6: Create agent team
406
+ morph-spec state set scheduled-reports phase implement
407
+ ```
408
+
409
+ ```
410
+ Create an agent team to implement scheduled-reports.
411
+
412
+ Team structure based on tasks.json modules:
413
+ - Backend teammate (T001-T005): .NET VSA endpoints, Hangfire jobs, repositories
414
+ - Frontend teammate (T006-T010): Next.js pages, shadcn/ui components, CSS
415
+ - Infra teammate (T011-T012): EasyPanel config + Supabase storage setup
416
+
417
+ Require plan approval for each teammate.
418
+ Use delegate mode so I only coordinate.
419
+ ```
420
+
421
+ **Claude creates team, spawns 3 teammates, each works independently:**
422
+
423
+ ```bash
424
+ # Backend teammate
425
+ morph-spec task start scheduled-reports T001
426
+ # ... implements ReportDefinition entity + VSA endpoint ...
427
+ morph-spec task done scheduled-reports T001
428
+ # Validation runs: contract-compliance
429
+ # Task T001 completed
430
+
431
+ # Frontend teammate (parallel)
432
+ morph-spec task start scheduled-reports T006
433
+ # ... implements report dashboard with shadcn/ui DataTable ...
434
+ morph-spec task done scheduled-reports T006
435
+ # Validation runs: css-validator, contrast-checker
436
+ # Task T006 completed
437
+ ```
438
+
439
+ **After all tasks complete, lead synthesizes:**
440
+ ```bash
441
+ morph-spec generate recap scheduled-reports
442
+ # Pulls data from state.json, validation results, contracts
443
+ # Generates comprehensive recap.md
444
+
445
+ morph-spec phase advance scheduled-reports
446
+ # Validates implement phase -> advances -> shows next steps
447
+ ```
448
+
449
+ ---
450
+
451
+ ## Summary
452
+
453
+ **Agent Teams enable MORPH-SPEC to:**
454
+ - Implement multi-module features in parallel (reduces calendar time)
455
+ - Debate architecture decisions with multiple perspectives
456
+ - Conduct thorough reviews across security/performance/standards
457
+
458
+ **Use when:**
459
+ - 3+ independent modules/components
460
+ - Complex architecture decisions
461
+ - Cross-stack coordination (backend + frontend + infra)
462
+
463
+ **Avoid when:**
464
+ - Single-module features
465
+ - Sequential workflows
466
+ - Same-file modifications needed
467
+
468
+ **Key insight:** Agent Teams amplify MORPH-SPEC's strengths (structured workflows, spec-driven development, validation pipeline) by parallelizing implementation while maintaining quality gates and coordination.
469
+
470
+ ---
471
+
472
+ *MORPH-SPEC by Polymorphism Tech - Integrated with Claude Code Agent Teams*