@polymorphism-tech/morph-spec 4.22.0 → 6.0.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 (211) hide show
  1. package/CLAUDE.md +57 -71
  2. package/README.md +2 -2
  3. package/bin/morph-spec.js +224 -491
  4. package/claude-plugin.json +1 -1
  5. package/docs/CHEATSHEET.md +1 -1
  6. package/docs/QUICKSTART.md +1 -1
  7. package/framework/CLAUDE.md +55 -38
  8. package/framework/MORPH.md +244 -0
  9. package/framework/agents.json +127 -1198
  10. package/framework/commands/morph-apply.md +56 -240
  11. package/framework/commands/morph-archive.md +48 -85
  12. package/framework/commands/morph-preflight.md +7 -7
  13. package/framework/commands/morph-proposal.md +35 -191
  14. package/framework/commands/morph-status.md +19 -50
  15. package/framework/commands/morph-troubleshoot.md +2 -2
  16. package/framework/evals/rubrics/README.md +44 -0
  17. package/framework/evals/rubrics/architecture.md +46 -0
  18. package/framework/evals/rubrics/code-quality.md +50 -0
  19. package/framework/evals/rubrics/contracts.md +47 -0
  20. package/framework/evals/rubrics/test-coverage.md +50 -0
  21. package/framework/evals/scenarios/dotnet-crud.yaml +42 -0
  22. package/framework/evals/scenarios/nextjs-auth.yaml +38 -0
  23. package/framework/evals/suites/standard.yaml +5 -0
  24. package/framework/evals/trace-schema.md +67 -0
  25. package/framework/hooks/claude-code/core/README.md +3 -0
  26. package/framework/hooks/claude-code/core/denylist.json +14 -0
  27. package/framework/hooks/claude-code/{pre-tool-use → core}/enforce-phase-writes.js +5 -5
  28. package/framework/hooks/claude-code/core/post-edit-typecheck.js +69 -0
  29. package/framework/hooks/claude-code/core/pre-bash-denylist.js +29 -0
  30. package/framework/hooks/claude-code/{pre-tool-use → core}/protect-spec-files.js +4 -6
  31. package/framework/hooks/claude-code/{stop → core}/validate-completion.js +13 -82
  32. package/framework/hooks/shared/phase-utils.js +20 -31
  33. package/framework/hooks/shared/state-reader.js +4 -5
  34. package/framework/{skills/level-0-meta/mcp-registry.json → mcp/registry.json} +254 -243
  35. package/framework/phases.json +41 -115
  36. package/framework/rubrics/eval-rubric.json +66 -0
  37. package/framework/skills/README.md +39 -64
  38. package/framework/skills/core/README.md +3 -0
  39. package/framework/skills/core/morph-brainstorming/SKILL.md +102 -0
  40. package/framework/skills/core/morph-eval/SKILL.md +57 -0
  41. package/framework/skills/core/morph-implement/SKILL.md +83 -0
  42. package/framework/skills/core/morph-plan/SKILL.md +64 -0
  43. package/framework/skills/core/morph-review/SKILL.md +62 -0
  44. package/framework/skills/core/morph-stack-scan/SKILL.md +109 -0
  45. package/framework/skills/core/morph-standards/SKILL.md +49 -0
  46. package/framework/templates/CLAUDE.md.core.guide.md +29 -0
  47. package/framework/templates/CLAUDE.md.core.template +22 -0
  48. package/framework/templates/REGISTRY.json +4 -4
  49. package/framework/workflows/configs/fast-track.json +5 -10
  50. package/framework/workflows/configs/full.json +4 -8
  51. package/framework/workflows/configs/quick.json +32 -0
  52. package/framework/workflows/configs/standard.json +57 -64
  53. package/package.json +7 -6
  54. package/src/commands/mcp/mcp-setup.js +58 -31
  55. package/src/commands/project/doctor.js +69 -70
  56. package/src/commands/project/init.js +26 -5
  57. package/src/commands/project/status.js +18 -19
  58. package/src/commands/state/approve.js +1 -1
  59. package/src/commands/validation/validate-feature.js +18 -112
  60. package/src/core/paths/output-schema.js +133 -152
  61. package/src/core/state/phase-state-machine.js +10 -24
  62. package/src/core/state/state-manager.js +17 -17
  63. package/src/core/workflows/workflow-detector.js +214 -31
  64. package/src/core/workflows/workflow-router.js +204 -0
  65. package/src/dashboard/app/pages/AgentMap.jsx +32 -33
  66. package/src/dashboard/app/pages/LiveState.jsx +1 -1
  67. package/src/dashboard/app/pages/PhasePipeline.jsx +2 -4
  68. package/src/dashboard/app/pages/SkillsLibrary.jsx +2 -3
  69. package/src/dashboard/app/pages/Workflows.jsx +2 -2
  70. package/src/dashboard/scanner/agents-scanner.js +30 -35
  71. package/src/lib/agents/metrics-aggregator.js +1 -1
  72. package/src/lib/agents/output-collector.js +7 -9
  73. package/src/lib/context/context-builder.js +289 -0
  74. package/src/lib/detectors/claude-config-detector.js +19 -3
  75. package/src/lib/generators/context-generator.js +20 -42
  76. package/src/lib/generators/index.js +1 -0
  77. package/src/lib/generators/mandate-generator.js +512 -0
  78. package/src/lib/generators/metadata-extractor.js +1 -1
  79. package/src/lib/generators/recap-generator.js +3 -4
  80. package/src/lib/installers/mcp-installer.js +300 -92
  81. package/src/lib/phase-chain/phase-validator.js +36 -40
  82. package/src/lib/stack/stack-profile.js +74 -91
  83. package/src/lib/tasks/task-parser.js +1 -1
  84. package/src/lib/tasks/wave-resolver.js +353 -0
  85. package/src/lib/validators/checkpoint-persistence.js +2 -2
  86. package/src/lib/validators/content/cross-phase-validator.js +281 -0
  87. package/src/lib/validators/content/index.js +1 -0
  88. package/src/lib/validators/shared/emit-validator-dispatch.js +6 -56
  89. package/src/scripts/global-install.js +2 -27
  90. package/src/utils/agents-installer.js +224 -447
  91. package/src/utils/claude-settings-manager.js +57 -15
  92. package/src/utils/file-copier.js +1 -0
  93. package/src/utils/hooks-installer.js +15 -117
  94. package/src/utils/skills-installer.js +12 -18
  95. package/bin/detect-agents.js +0 -226
  96. package/bin/task-manager.js +0 -1036
  97. package/framework/agents/README.md +0 -13
  98. package/framework/agents/ai-agents/ai-system-architect.md +0 -194
  99. package/framework/agents/ai-agents/vector-search-expert.md +0 -247
  100. package/framework/agents/architecture/architecture-expert.md +0 -98
  101. package/framework/agents/architecture/morph-spec-architect.md +0 -66
  102. package/framework/agents/architecture/packages-validator.md +0 -89
  103. package/framework/agents/architecture/security-expert.md +0 -79
  104. package/framework/agents/architecture/seo-growth-hacker.md +0 -168
  105. package/framework/agents/architecture/standards-architect.md +0 -153
  106. package/framework/agents/backend/dotnet-senior.md +0 -163
  107. package/framework/agents/backend/ef-modeler.md +0 -119
  108. package/framework/agents/backend/hangfire-orchestrator.md +0 -133
  109. package/framework/agents/backend/ms-agent-expert.md +0 -55
  110. package/framework/agents/backend/neon-expert.md +0 -379
  111. package/framework/agents/frontend/css-specialist.md +0 -89
  112. package/framework/agents/frontend/design-system-validator.md +0 -100
  113. package/framework/agents/frontend/gsap-animator.md +0 -131
  114. package/framework/agents/frontend/nextjs-component-validator.md +0 -97
  115. package/framework/agents/frontend/nextjs-expert.md +0 -201
  116. package/framework/agents/frontend/ui-designer.md +0 -259
  117. package/framework/agents/infrastructure/infra-architect.md +0 -215
  118. package/framework/agents/integrations/asaas-financial.md +0 -138
  119. package/framework/agents/integrations/neon-auth.md +0 -151
  120. package/framework/agents/integrations/resend-email.md +0 -127
  121. package/framework/hooks/claude-code/post-tool-use/agent-complete.js +0 -122
  122. package/framework/hooks/claude-code/post-tool-use/dispatch.js +0 -363
  123. package/framework/hooks/claude-code/post-tool-use/handle-tool-failure.js +0 -78
  124. package/framework/hooks/claude-code/post-tool-use/validator-feedback.js +0 -194
  125. package/framework/hooks/claude-code/pre-compact/save-morph-context.js +0 -199
  126. package/framework/hooks/claude-code/pre-tool-use/task-tracking-guard.js +0 -55
  127. package/framework/hooks/claude-code/session-start/inject-morph-context.js +0 -323
  128. package/framework/hooks/claude-code/session-start/post-compact-restore.js +0 -41
  129. package/framework/hooks/claude-code/session-start/resume-context.js +0 -77
  130. package/framework/hooks/claude-code/teammate-idle/teammate-idle.js +0 -90
  131. package/framework/hooks/claude-code/user-prompt/enrich-prompt.js +0 -114
  132. package/framework/hooks/shared/compact-restore.js +0 -123
  133. package/framework/hooks/shared/dispatch-helpers.js +0 -147
  134. package/framework/hooks/shared/skill-reminder-helpers.js +0 -79
  135. package/framework/hooks/shared/stale-task-reset.js +0 -57
  136. package/framework/hooks/shared/worktree-helpers.js +0 -75
  137. package/framework/skills/level-0-meta/README.md +0 -7
  138. package/framework/skills/level-0-meta/morph-agent-teams/SKILL.md +0 -472
  139. package/framework/skills/level-0-meta/morph-brainstorming/SKILL.md +0 -174
  140. package/framework/skills/level-0-meta/morph-brainstorming/references/proposal-example.md +0 -138
  141. package/framework/skills/level-0-meta/morph-checklist/SKILL.md +0 -145
  142. package/framework/skills/level-0-meta/morph-code-review/SKILL.md +0 -250
  143. package/framework/skills/level-0-meta/morph-code-review/references/review-example.md +0 -164
  144. package/framework/skills/level-0-meta/morph-code-review/references/review-guidelines.md +0 -100
  145. package/framework/skills/level-0-meta/morph-code-review/scripts/scan-csharp.mjs +0 -151
  146. package/framework/skills/level-0-meta/morph-code-review-nextjs/SKILL.md +0 -165
  147. package/framework/skills/level-0-meta/morph-code-review-nextjs/references/review-example-nextjs.md +0 -254
  148. package/framework/skills/level-0-meta/morph-code-review-nextjs/scripts/scan-nextjs.mjs +0 -189
  149. package/framework/skills/level-0-meta/morph-frontend-review/SKILL.md +0 -344
  150. package/framework/skills/level-0-meta/morph-frontend-review/scripts/scan-accessibility.mjs +0 -376
  151. package/framework/skills/level-0-meta/morph-gemini-image/SKILL.md +0 -290
  152. package/framework/skills/level-0-meta/morph-init/SKILL.md +0 -537
  153. package/framework/skills/level-0-meta/morph-parallel-dispatch/SKILL.md +0 -225
  154. package/framework/skills/level-0-meta/morph-post-implementation/SKILL.md +0 -401
  155. package/framework/skills/level-0-meta/morph-post-implementation/scripts/detect-dev-server.mjs +0 -153
  156. package/framework/skills/level-0-meta/morph-post-implementation/scripts/detect-stack.mjs +0 -234
  157. package/framework/skills/level-0-meta/morph-simulation-checklist/SKILL.md +0 -106
  158. package/framework/skills/level-0-meta/morph-tool-usage-guide/SKILL.md +0 -243
  159. package/framework/skills/level-0-meta/morph-tool-usage-guide/references/tools-per-phase.md +0 -169
  160. package/framework/skills/level-0-meta/morph-verification-before-completion/SKILL.md +0 -148
  161. package/framework/skills/level-0-meta/morph-verification-before-completion/scripts/check-phase-outputs.mjs +0 -110
  162. package/framework/skills/level-1-workflows/README.md +0 -7
  163. package/framework/skills/level-1-workflows/morph-phase-codebase-analysis/SKILL.md +0 -269
  164. package/framework/skills/level-1-workflows/morph-phase-design/SKILL.md +0 -453
  165. package/framework/skills/level-1-workflows/morph-phase-design/references/architecture-analysis-guide.md +0 -44
  166. package/framework/skills/level-1-workflows/morph-phase-design/references/spec-authoring-guide.md +0 -55
  167. package/framework/skills/level-1-workflows/morph-phase-design/references/spec-example.md +0 -253
  168. package/framework/skills/level-1-workflows/morph-phase-implement/.morph/logs/activity.json +0 -38
  169. package/framework/skills/level-1-workflows/morph-phase-implement/SKILL.md +0 -634
  170. package/framework/skills/level-1-workflows/morph-phase-implement/prompts/code-quality-reviewer-prompt.md +0 -50
  171. package/framework/skills/level-1-workflows/morph-phase-implement/prompts/implementer-prompt.md +0 -54
  172. package/framework/skills/level-1-workflows/morph-phase-implement/prompts/spec-reviewer-prompt.md +0 -47
  173. package/framework/skills/level-1-workflows/morph-phase-implement/references/recap-example.md +0 -132
  174. package/framework/skills/level-1-workflows/morph-phase-implement/references/vsa-implementation-guide.md +0 -92
  175. package/framework/skills/level-1-workflows/morph-phase-plan/SKILL.md +0 -257
  176. package/framework/skills/level-1-workflows/morph-phase-tasks/.morph/logs/activity.json +0 -14
  177. package/framework/skills/level-1-workflows/morph-phase-tasks/SKILL.md +0 -291
  178. package/framework/skills/level-1-workflows/morph-phase-tasks/references/task-planning-patterns.md +0 -143
  179. package/framework/skills/level-1-workflows/morph-phase-tasks/references/tasks-example.md +0 -404
  180. package/framework/skills/level-1-workflows/morph-phase-tasks/scripts/validate-tasks.mjs +0 -112
  181. package/framework/skills/level-1-workflows/morph-phase-uiux/SKILL.md +0 -995
  182. package/framework/skills/level-1-workflows/morph-scope-escalation/SKILL.md +0 -147
  183. package/framework/squad-templates/backend-only.json +0 -47
  184. package/framework/squad-templates/frontend-only.json +0 -56
  185. package/framework/squad-templates/full-stack.json +0 -74
  186. package/src/commands/agents/agent-metrics.js +0 -174
  187. package/src/commands/agents/audit-dispatch.js +0 -82
  188. package/src/commands/agents/detect-agents.js +0 -275
  189. package/src/commands/agents/dispatch-agents.js +0 -461
  190. package/src/commands/agents/index.js +0 -13
  191. package/src/commands/agents/manage-agents.js +0 -352
  192. package/src/commands/agents/project-metrics.js +0 -74
  193. package/src/commands/phase/phase-reset.js +0 -74
  194. package/src/commands/scope/escalate.js +0 -217
  195. package/src/commands/state/advance-phase.js +0 -600
  196. package/src/commands/state/phase-runner.js +0 -215
  197. package/src/commands/state/state.js +0 -444
  198. package/src/commands/task/expand.js +0 -100
  199. package/src/commands/tasks/index.js +0 -4
  200. package/src/commands/tasks/task.js +0 -105
  201. package/src/commands/templates/index.js +0 -5
  202. package/src/commands/templates/template-render.js +0 -93
  203. package/src/commands/trust/trust.js +0 -118
  204. package/src/lib/agents/agents-manager.js +0 -349
  205. package/src/lib/build/build-runner.js +0 -99
  206. package/src/lib/checkpoints/checkpoint-hooks.js +0 -111
  207. package/src/lib/contracts/sprint-contract-generator.js +0 -137
  208. package/src/lib/scope/impact-analyzer.js +0 -106
  209. package/src/lib/trust/trust-manager.js +0 -157
  210. package/src/utils/tier-helpers.js +0 -24
  211. /package/framework/hooks/claude-code/{post-tool-use → core}/loop-detect.js +0 -0
@@ -1,75 +0,0 @@
1
- /**
2
- * Shared helpers for worktree-related hook logic.
3
- * Pure functions — no side effects, easy to test.
4
- */
5
-
6
- /**
7
- * Parse JSON output from `morph-spec worktree setup`.
8
- * Finds the last line starting with '{' to skip chalk-colored output.
9
- * @param {string} stdout - Raw stdout from the command
10
- * @returns {Object|null}
11
- */
12
- export function parseWorktreeResult(stdout) {
13
- if (!stdout || typeof stdout !== 'string') return null;
14
- try {
15
- const trimmed = stdout.trim();
16
- if (!trimmed) return null;
17
- const lines = trimmed.split('\n');
18
- for (let i = lines.length - 1; i >= 0; i--) {
19
- const line = lines[i].trim();
20
- if (line.startsWith('{')) {
21
- return JSON.parse(line);
22
- }
23
- }
24
- return null;
25
- } catch {
26
- return null;
27
- }
28
- }
29
-
30
- /**
31
- * Build context line(s) to inject based on worktree setup result.
32
- * Outputs MANDATORY instructions for Claude to work inside the worktree.
33
- * @param {Object|null} result - Parsed result from parseWorktreeResult
34
- * @returns {string} Context lines to inject, or '' to skip injection
35
- */
36
- export function buildWorktreeContextLine(result) {
37
- if (!result) return '';
38
- if (result.error) return '';
39
-
40
- const path = result.path;
41
- const feature = result.feature || '';
42
-
43
- if (result.created || result.alreadyExists) {
44
- return [
45
- `🪴 WORKTREE ACTIVE — branch: ${result.branch}`,
46
- ` WORKTREE_PATH: ${path}`,
47
- ` MANDATORY: ALL work for feature '${feature}' MUST happen inside the worktree:`,
48
- ` • Bash: run \`cd ${path}\` first (CWD persists for subsequent commands)`,
49
- ` • Read/Write/Edit: use ${path} as base for ALL file paths`,
50
- ` • Glob/Grep: set path parameter to ${path}`,
51
- ` DO NOT write files to the main project directory.`,
52
- ].join('\n');
53
- }
54
-
55
- return '';
56
- }
57
-
58
- /**
59
- * Build worktree context from state metadata (for resume sessions).
60
- * @param {Object} worktreeMeta - { path, branch } from state.features[name].worktree
61
- * @param {string} featureName - Feature name
62
- * @returns {string} Context lines or ''
63
- */
64
- export function buildWorktreeResumeContext(worktreeMeta, featureName) {
65
- if (!worktreeMeta?.path) return '';
66
- return [
67
- `🪴 WORKTREE ACTIVE — branch: ${worktreeMeta.branch}`,
68
- ` WORKTREE_PATH: ${worktreeMeta.path}`,
69
- ` MANDATORY: ALL work for feature '${featureName}' MUST happen inside the worktree:`,
70
- ` • Bash: run \`cd ${worktreeMeta.path}\` first (CWD persists for subsequent commands)`,
71
- ` • Read/Write/Edit: use ${worktreeMeta.path} as base for ALL file paths`,
72
- ` • Glob/Grep: set path parameter to ${worktreeMeta.path}`,
73
- ` DO NOT write files to the main project directory.`,
74
- ].join('\n');
75
- }
@@ -1,7 +0,0 @@
1
- # Level 0: Meta-Skills
2
-
3
- High-level orchestration skills and user-facing commands.
4
-
5
- **Purpose:** Skills that orchestrate multiple workflows or provide top-level guidance.
6
-
7
- **Examples:** morph-checklist, simulation-checklist, code-review
@@ -1,472 +0,0 @@
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 + Neon)
67
- - Testing teammate (unit + integration)
68
-
69
- 4. **Research & Standards Validation (Phases 0-3)**
70
- - Investigate multiple integration options (Neon Auth vs custom JWT vs Passkeys)
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 Neon database branch 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 + Neon)
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-Neon-Auth: Argue for Neon Auth (database-native, no external deps, branch isolation, Better Auth)
199
- - Pro-NextAuth: Argue for NextAuth.js (flexible providers, community ecosystem, self-hosted)
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 + Neon database 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*