@polymorphism-tech/morph-spec 4.21.0 → 5.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (213) 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 -1183
  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 -28
  33. package/framework/hooks/shared/state-reader.js +4 -5
  34. package/framework/{skills/level-0-meta/mcp-registry.json → mcp/registry.json} +254 -210
  35. package/framework/phases.json +40 -114
  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/standards/STANDARDS.json +32 -0
  47. package/framework/standards/frontend/design-system/ai-image-generation.md +244 -0
  48. package/framework/standards/integration/mcp/mcp-tools.md +48 -0
  49. package/framework/templates/CLAUDE.md.core.guide.md +29 -0
  50. package/framework/templates/CLAUDE.md.core.template +22 -0
  51. package/framework/templates/REGISTRY.json +4 -4
  52. package/framework/workflows/configs/fast-track.json +5 -10
  53. package/framework/workflows/configs/full.json +4 -8
  54. package/framework/workflows/configs/quick.json +32 -0
  55. package/framework/workflows/configs/standard.json +57 -64
  56. package/package.json +7 -6
  57. package/src/commands/mcp/mcp-setup.js +58 -31
  58. package/src/commands/project/doctor.js +69 -70
  59. package/src/commands/project/init.js +26 -5
  60. package/src/commands/project/status.js +18 -19
  61. package/src/commands/state/approve.js +1 -1
  62. package/src/commands/validation/validate-feature.js +18 -112
  63. package/src/core/paths/output-schema.js +133 -151
  64. package/src/core/state/phase-state-machine.js +10 -24
  65. package/src/core/state/state-manager.js +17 -17
  66. package/src/core/workflows/workflow-detector.js +214 -31
  67. package/src/core/workflows/workflow-router.js +204 -0
  68. package/src/dashboard/app/pages/AgentMap.jsx +32 -33
  69. package/src/dashboard/app/pages/LiveState.jsx +1 -1
  70. package/src/dashboard/app/pages/PhasePipeline.jsx +2 -4
  71. package/src/dashboard/app/pages/SkillsLibrary.jsx +2 -3
  72. package/src/dashboard/app/pages/Workflows.jsx +2 -2
  73. package/src/dashboard/scanner/agents-scanner.js +30 -35
  74. package/src/lib/agents/metrics-aggregator.js +1 -1
  75. package/src/lib/agents/output-collector.js +7 -8
  76. package/src/lib/context/context-builder.js +289 -0
  77. package/src/lib/detectors/claude-config-detector.js +19 -3
  78. package/src/lib/generators/context-generator.js +20 -42
  79. package/src/lib/generators/index.js +1 -0
  80. package/src/lib/generators/mandate-generator.js +512 -0
  81. package/src/lib/generators/metadata-extractor.js +1 -1
  82. package/src/lib/generators/recap-generator.js +3 -4
  83. package/src/lib/installers/mcp-installer.js +300 -92
  84. package/src/lib/phase-chain/phase-validator.js +36 -40
  85. package/src/lib/stack/stack-profile.js +74 -91
  86. package/src/lib/tasks/task-parser.js +1 -1
  87. package/src/lib/tasks/wave-resolver.js +353 -0
  88. package/src/lib/validators/checkpoint-persistence.js +2 -2
  89. package/src/lib/validators/content/cross-phase-validator.js +281 -0
  90. package/src/lib/validators/content/index.js +1 -0
  91. package/src/lib/validators/shared/emit-validator-dispatch.js +6 -56
  92. package/src/scripts/global-install.js +2 -27
  93. package/src/utils/agents-installer.js +224 -447
  94. package/src/utils/claude-settings-manager.js +57 -15
  95. package/src/utils/file-copier.js +1 -0
  96. package/src/utils/hooks-installer.js +15 -117
  97. package/src/utils/skills-installer.js +12 -18
  98. package/bin/detect-agents.js +0 -226
  99. package/bin/task-manager.js +0 -1036
  100. package/framework/agents/README.md +0 -13
  101. package/framework/agents/ai-agents/ai-system-architect.md +0 -194
  102. package/framework/agents/ai-agents/vector-search-expert.md +0 -247
  103. package/framework/agents/architecture/architecture-expert.md +0 -98
  104. package/framework/agents/architecture/morph-spec-architect.md +0 -66
  105. package/framework/agents/architecture/packages-validator.md +0 -89
  106. package/framework/agents/architecture/security-expert.md +0 -79
  107. package/framework/agents/architecture/seo-growth-hacker.md +0 -168
  108. package/framework/agents/architecture/standards-architect.md +0 -153
  109. package/framework/agents/backend/dotnet-senior.md +0 -163
  110. package/framework/agents/backend/ef-modeler.md +0 -119
  111. package/framework/agents/backend/hangfire-orchestrator.md +0 -133
  112. package/framework/agents/backend/ms-agent-expert.md +0 -55
  113. package/framework/agents/backend/neon-expert.md +0 -379
  114. package/framework/agents/frontend/css-specialist.md +0 -89
  115. package/framework/agents/frontend/design-system-validator.md +0 -100
  116. package/framework/agents/frontend/gsap-animator.md +0 -131
  117. package/framework/agents/frontend/nextjs-component-validator.md +0 -97
  118. package/framework/agents/frontend/nextjs-expert.md +0 -201
  119. package/framework/agents/frontend/ui-designer.md +0 -259
  120. package/framework/agents/infrastructure/infra-architect.md +0 -215
  121. package/framework/agents/integrations/asaas-financial.md +0 -138
  122. package/framework/agents/integrations/neon-auth.md +0 -151
  123. package/framework/agents/integrations/resend-email.md +0 -127
  124. package/framework/hooks/claude-code/post-tool-use/agent-complete.js +0 -122
  125. package/framework/hooks/claude-code/post-tool-use/dispatch.js +0 -363
  126. package/framework/hooks/claude-code/post-tool-use/handle-tool-failure.js +0 -78
  127. package/framework/hooks/claude-code/post-tool-use/validator-feedback.js +0 -194
  128. package/framework/hooks/claude-code/pre-compact/save-morph-context.js +0 -199
  129. package/framework/hooks/claude-code/pre-tool-use/task-tracking-guard.js +0 -55
  130. package/framework/hooks/claude-code/session-start/inject-morph-context.js +0 -323
  131. package/framework/hooks/claude-code/session-start/post-compact-restore.js +0 -41
  132. package/framework/hooks/claude-code/session-start/resume-context.js +0 -77
  133. package/framework/hooks/claude-code/teammate-idle/teammate-idle.js +0 -90
  134. package/framework/hooks/claude-code/user-prompt/enrich-prompt.js +0 -114
  135. package/framework/hooks/shared/compact-restore.js +0 -123
  136. package/framework/hooks/shared/dispatch-helpers.js +0 -147
  137. package/framework/hooks/shared/skill-reminder-helpers.js +0 -79
  138. package/framework/hooks/shared/stale-task-reset.js +0 -57
  139. package/framework/hooks/shared/worktree-helpers.js +0 -75
  140. package/framework/skills/level-0-meta/README.md +0 -7
  141. package/framework/skills/level-0-meta/morph-agent-teams/SKILL.md +0 -472
  142. package/framework/skills/level-0-meta/morph-brainstorming/SKILL.md +0 -174
  143. package/framework/skills/level-0-meta/morph-brainstorming/references/proposal-example.md +0 -138
  144. package/framework/skills/level-0-meta/morph-checklist/SKILL.md +0 -145
  145. package/framework/skills/level-0-meta/morph-code-review/SKILL.md +0 -250
  146. package/framework/skills/level-0-meta/morph-code-review/references/review-example.md +0 -164
  147. package/framework/skills/level-0-meta/morph-code-review/references/review-guidelines.md +0 -100
  148. package/framework/skills/level-0-meta/morph-code-review/scripts/scan-csharp.mjs +0 -151
  149. package/framework/skills/level-0-meta/morph-code-review-nextjs/SKILL.md +0 -165
  150. package/framework/skills/level-0-meta/morph-code-review-nextjs/references/review-example-nextjs.md +0 -254
  151. package/framework/skills/level-0-meta/morph-code-review-nextjs/scripts/scan-nextjs.mjs +0 -189
  152. package/framework/skills/level-0-meta/morph-frontend-review/SKILL.md +0 -344
  153. package/framework/skills/level-0-meta/morph-frontend-review/scripts/scan-accessibility.mjs +0 -376
  154. package/framework/skills/level-0-meta/morph-init/SKILL.md +0 -537
  155. package/framework/skills/level-0-meta/morph-parallel-dispatch/SKILL.md +0 -225
  156. package/framework/skills/level-0-meta/morph-post-implementation/SKILL.md +0 -382
  157. package/framework/skills/level-0-meta/morph-post-implementation/scripts/detect-dev-server.mjs +0 -153
  158. package/framework/skills/level-0-meta/morph-post-implementation/scripts/detect-stack.mjs +0 -234
  159. package/framework/skills/level-0-meta/morph-simulation-checklist/SKILL.md +0 -106
  160. package/framework/skills/level-0-meta/morph-tool-usage-guide/SKILL.md +0 -243
  161. package/framework/skills/level-0-meta/morph-tool-usage-guide/references/tools-per-phase.md +0 -169
  162. package/framework/skills/level-0-meta/morph-verification-before-completion/SKILL.md +0 -148
  163. package/framework/skills/level-0-meta/morph-verification-before-completion/scripts/check-phase-outputs.mjs +0 -110
  164. package/framework/skills/level-1-workflows/README.md +0 -7
  165. package/framework/skills/level-1-workflows/morph-phase-codebase-analysis/SKILL.md +0 -269
  166. package/framework/skills/level-1-workflows/morph-phase-design/SKILL.md +0 -453
  167. package/framework/skills/level-1-workflows/morph-phase-design/references/architecture-analysis-guide.md +0 -44
  168. package/framework/skills/level-1-workflows/morph-phase-design/references/spec-authoring-guide.md +0 -55
  169. package/framework/skills/level-1-workflows/morph-phase-design/references/spec-example.md +0 -253
  170. package/framework/skills/level-1-workflows/morph-phase-implement/.morph/logs/activity.json +0 -38
  171. package/framework/skills/level-1-workflows/morph-phase-implement/SKILL.md +0 -493
  172. package/framework/skills/level-1-workflows/morph-phase-implement/prompts/code-quality-reviewer-prompt.md +0 -50
  173. package/framework/skills/level-1-workflows/morph-phase-implement/prompts/implementer-prompt.md +0 -46
  174. package/framework/skills/level-1-workflows/morph-phase-implement/prompts/spec-reviewer-prompt.md +0 -47
  175. package/framework/skills/level-1-workflows/morph-phase-implement/references/recap-example.md +0 -132
  176. package/framework/skills/level-1-workflows/morph-phase-implement/references/vsa-implementation-guide.md +0 -92
  177. package/framework/skills/level-1-workflows/morph-phase-plan/SKILL.md +0 -257
  178. package/framework/skills/level-1-workflows/morph-phase-tasks/.morph/logs/activity.json +0 -14
  179. package/framework/skills/level-1-workflows/morph-phase-tasks/SKILL.md +0 -291
  180. package/framework/skills/level-1-workflows/morph-phase-tasks/references/task-planning-patterns.md +0 -143
  181. package/framework/skills/level-1-workflows/morph-phase-tasks/references/tasks-example.md +0 -404
  182. package/framework/skills/level-1-workflows/morph-phase-tasks/scripts/validate-tasks.mjs +0 -112
  183. package/framework/skills/level-1-workflows/morph-phase-uiux/SKILL.md +0 -788
  184. package/framework/skills/level-1-workflows/morph-scope-escalation/SKILL.md +0 -147
  185. package/framework/squad-templates/backend-only.json +0 -47
  186. package/framework/squad-templates/frontend-only.json +0 -56
  187. package/framework/squad-templates/full-stack.json +0 -74
  188. package/src/commands/agents/agent-metrics.js +0 -174
  189. package/src/commands/agents/audit-dispatch.js +0 -82
  190. package/src/commands/agents/detect-agents.js +0 -275
  191. package/src/commands/agents/dispatch-agents.js +0 -461
  192. package/src/commands/agents/index.js +0 -13
  193. package/src/commands/agents/manage-agents.js +0 -352
  194. package/src/commands/agents/project-metrics.js +0 -74
  195. package/src/commands/phase/phase-reset.js +0 -74
  196. package/src/commands/scope/escalate.js +0 -217
  197. package/src/commands/state/advance-phase.js +0 -600
  198. package/src/commands/state/phase-runner.js +0 -215
  199. package/src/commands/state/state.js +0 -444
  200. package/src/commands/task/expand.js +0 -100
  201. package/src/commands/tasks/index.js +0 -4
  202. package/src/commands/tasks/task.js +0 -105
  203. package/src/commands/templates/index.js +0 -5
  204. package/src/commands/templates/template-render.js +0 -93
  205. package/src/commands/trust/trust.js +0 -118
  206. package/src/lib/agents/agents-manager.js +0 -349
  207. package/src/lib/build/build-runner.js +0 -99
  208. package/src/lib/checkpoints/checkpoint-hooks.js +0 -111
  209. package/src/lib/contracts/sprint-contract-generator.js +0 -137
  210. package/src/lib/scope/impact-analyzer.js +0 -106
  211. package/src/lib/trust/trust-manager.js +0 -157
  212. package/src/utils/tier-helpers.js +0 -24
  213. /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*