@polymorphism-tech/morph-spec 4.9.0 → 4.10.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 (164) hide show
  1. package/README.md +2 -2
  2. package/bin/morph-spec.js +30 -0
  3. package/bin/task-manager.js +34 -22
  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 +35 -98
  8. package/framework/agents/backend/api-designer.md +3 -0
  9. package/framework/agents/backend/dotnet-senior.md +3 -0
  10. package/framework/agents/backend/ef-modeler.md +2 -0
  11. package/framework/agents/backend/hangfire-orchestrator.md +2 -0
  12. package/framework/agents/backend/ms-agent-expert.md +2 -0
  13. package/framework/agents/frontend/blazor-builder.md +2 -0
  14. package/framework/agents/frontend/nextjs-expert.md +2 -0
  15. package/framework/agents/infrastructure/azure-architect.md +2 -0
  16. package/framework/agents/infrastructure/azure-deploy-specialist.md +2 -0
  17. package/framework/agents/infrastructure/bicep-architect.md +2 -0
  18. package/framework/agents/infrastructure/container-specialist.md +2 -0
  19. package/framework/agents/infrastructure/devops-engineer.md +3 -0
  20. package/framework/agents/infrastructure/infra-architect.md +3 -0
  21. package/framework/agents/integrations/asaas-financial.md +2 -0
  22. package/framework/agents/integrations/azure-identity.md +2 -0
  23. package/framework/agents/integrations/clerk-auth.md +3 -0
  24. package/framework/agents/integrations/hangfire-integration.md +2 -0
  25. package/framework/agents/integrations/resend-email.md +2 -0
  26. package/framework/agents.json +37 -7
  27. package/framework/commands/commit.md +166 -0
  28. package/framework/commands/morph-apply.md +156 -155
  29. package/framework/commands/morph-archive.md +33 -27
  30. package/framework/commands/morph-infra.md +83 -77
  31. package/framework/commands/morph-preflight.md +97 -55
  32. package/framework/commands/morph-proposal.md +131 -58
  33. package/framework/commands/morph-status.md +36 -30
  34. package/framework/commands/morph-troubleshoot.md +68 -59
  35. package/framework/hooks/claude-code/notification/approval-reminder.js +3 -2
  36. package/framework/hooks/claude-code/post-tool-use/dispatch.js +154 -31
  37. package/framework/hooks/claude-code/post-tool-use/skill-reminder.js +7 -84
  38. package/framework/hooks/claude-code/post-tool-use/validator-feedback.js +8 -17
  39. package/framework/hooks/claude-code/pre-compact/save-morph-context.js +16 -3
  40. package/framework/hooks/claude-code/pre-tool-use/enforce-phase-writes.js +4 -3
  41. package/framework/hooks/claude-code/pre-tool-use/protect-spec-files.js +3 -2
  42. package/framework/hooks/claude-code/pre-tool-use/task-tracking-guard.js +60 -0
  43. package/framework/hooks/claude-code/session-start/inject-morph-context.js +55 -2
  44. package/framework/hooks/claude-code/session-start/post-compact-restore.js +41 -0
  45. package/framework/hooks/claude-code/stop/validate-completion.js +2 -15
  46. package/framework/hooks/claude-code/user-prompt/enrich-prompt.js +23 -5
  47. package/framework/hooks/shared/compact-restore.js +100 -0
  48. package/framework/hooks/shared/dispatch-helpers.js +116 -0
  49. package/framework/hooks/shared/phase-utils.js +9 -5
  50. package/framework/hooks/shared/state-reader.js +27 -3
  51. package/framework/phases.json +30 -7
  52. package/framework/rules/csharp-standards.md +3 -0
  53. package/framework/rules/frontend-standards.md +2 -0
  54. package/framework/rules/infrastructure-standards.md +3 -0
  55. package/framework/rules/morph-workflow.md +143 -86
  56. package/framework/rules/nextjs-standards.md +2 -0
  57. package/framework/rules/testing-standards.md +3 -0
  58. package/framework/skills/level-0-meta/mcp-registry.json +86 -51
  59. package/framework/skills/level-0-meta/morph-brainstorming/SKILL.md +139 -0
  60. package/framework/skills/level-0-meta/morph-checklist/SKILL.md +42 -19
  61. package/framework/skills/level-0-meta/{code-review → morph-code-review}/SKILL.md +8 -5
  62. package/framework/skills/level-0-meta/{code-review-nextjs → morph-code-review-nextjs}/SKILL.md +8 -6
  63. package/framework/skills/level-0-meta/morph-frontend-review/SKILL.md +362 -0
  64. package/framework/skills/level-0-meta/morph-init/SKILL.md +114 -20
  65. package/framework/skills/level-0-meta/morph-post-implementation/SKILL.md +362 -0
  66. package/framework/skills/level-0-meta/morph-replicate/SKILL.md +95 -87
  67. package/framework/skills/level-0-meta/{simulation-checklist → morph-simulation-checklist}/SKILL.md +24 -0
  68. package/framework/skills/level-0-meta/{tool-usage-guide → morph-tool-usage-guide}/SKILL.md +43 -43
  69. package/framework/skills/level-0-meta/{tool-usage-guide → morph-tool-usage-guide}/references/tools-per-phase.md +1 -2
  70. package/framework/skills/level-0-meta/{verification-before-completion → morph-verification-before-completion}/SKILL.md +23 -12
  71. package/framework/skills/level-0-meta/{verification-before-completion → morph-verification-before-completion}/scripts/check-phase-outputs.mjs +2 -2
  72. package/framework/skills/level-1-workflows/morph-phase-clarify/SKILL.md +247 -0
  73. package/framework/skills/level-1-workflows/morph-phase-codebase-analysis/SKILL.md +270 -0
  74. package/framework/skills/level-1-workflows/morph-phase-design/SKILL.md +499 -0
  75. package/framework/skills/level-1-workflows/morph-phase-implement/.morph/logs/activity.json +38 -0
  76. package/framework/skills/level-1-workflows/morph-phase-implement/SKILL.md +472 -0
  77. package/framework/skills/level-1-workflows/morph-phase-implement/prompts/code-quality-reviewer-prompt.md +50 -0
  78. package/framework/skills/level-1-workflows/morph-phase-implement/prompts/implementer-prompt.md +45 -0
  79. package/framework/skills/level-1-workflows/morph-phase-implement/prompts/spec-reviewer-prompt.md +47 -0
  80. package/framework/skills/level-1-workflows/morph-phase-plan/SKILL.md +246 -0
  81. package/framework/skills/level-1-workflows/morph-phase-setup/SKILL.md +238 -0
  82. package/framework/skills/level-1-workflows/morph-phase-tasks/.morph/logs/activity.json +14 -0
  83. package/framework/skills/level-1-workflows/morph-phase-tasks/SKILL.md +312 -0
  84. package/framework/skills/level-1-workflows/{phase-tasks → morph-phase-tasks}/scripts/validate-tasks.mjs +3 -3
  85. package/framework/skills/level-1-workflows/morph-phase-uiux/SKILL.md +324 -0
  86. package/framework/skills/level-1-workflows/morph-scope-escalation/SKILL.md +146 -0
  87. package/framework/standards/integration/mcp/mcp-tools.md +25 -7
  88. package/framework/templates/docs/onboarding.md +2 -2
  89. package/package.json +3 -4
  90. package/src/commands/agents/dispatch-agents.js +50 -3
  91. package/src/commands/mcp/mcp-setup.js +39 -2
  92. package/src/commands/phase/phase-reset.js +74 -0
  93. package/src/commands/project/doctor.js +26 -7
  94. package/src/commands/project/update.js +4 -4
  95. package/src/commands/scope/escalate.js +215 -0
  96. package/src/commands/state/advance-phase.js +27 -53
  97. package/src/commands/state/state.js +1 -1
  98. package/src/commands/task/expand.js +100 -0
  99. package/src/core/paths/output-schema.js +4 -3
  100. package/src/core/state/phase-state-machine.js +7 -4
  101. package/src/core/state/state-manager.js +4 -3
  102. package/src/lib/detectors/claude-config-detector.js +93 -347
  103. package/src/lib/detectors/design-system-detector.js +189 -189
  104. package/src/lib/detectors/index.js +155 -57
  105. package/src/lib/generators/context-generator.js +2 -2
  106. package/src/lib/installers/mcp-installer.js +37 -5
  107. package/src/lib/phase-chain/phase-validator.js +22 -16
  108. package/src/lib/scope/impact-analyzer.js +106 -0
  109. package/src/lib/stack-filter.js +58 -0
  110. package/src/lib/tasks/task-parser.js +1 -1
  111. package/src/lib/validators/shared/emit-validator-dispatch.js +64 -0
  112. package/src/scripts/setup-infra.js +68 -18
  113. package/src/utils/agents-installer.js +51 -17
  114. package/src/utils/claude-md-injector.js +90 -0
  115. package/src/utils/file-copier.js +0 -1
  116. package/src/utils/hooks-installer.js +16 -5
  117. package/src/utils/skills-installer.js +67 -7
  118. package/CLAUDE.md +0 -98
  119. package/framework/memory/patterns-learned.md +0 -766
  120. package/framework/skills/level-0-meta/brainstorming/SKILL.md +0 -137
  121. package/framework/skills/level-0-meta/frontend-review/SKILL.md +0 -359
  122. package/framework/skills/level-0-meta/post-implementation/SKILL.md +0 -362
  123. package/framework/skills/level-0-meta/terminal-title/SKILL.md +0 -61
  124. package/framework/skills/level-0-meta/terminal-title/scripts/set_title.sh +0 -65
  125. package/framework/skills/level-1-workflows/phase-clarify/SKILL.md +0 -216
  126. package/framework/skills/level-1-workflows/phase-codebase-analysis/SKILL.md +0 -252
  127. package/framework/skills/level-1-workflows/phase-design/SKILL.md +0 -383
  128. package/framework/skills/level-1-workflows/phase-implement/SKILL.md +0 -492
  129. package/framework/skills/level-1-workflows/phase-setup/SKILL.md +0 -195
  130. package/framework/skills/level-1-workflows/phase-tasks/SKILL.md +0 -271
  131. package/framework/skills/level-1-workflows/phase-uiux/SKILL.md +0 -286
  132. package/src/commands/project/index.js +0 -8
  133. package/src/core/index.js +0 -10
  134. package/src/core/state/index.js +0 -8
  135. package/src/core/templates/index.js +0 -9
  136. package/src/core/templates/template-data-sources.js +0 -325
  137. package/src/core/workflows/index.js +0 -7
  138. package/src/lib/detectors/config-detector.js +0 -223
  139. package/src/lib/detectors/standards-generator.js +0 -335
  140. package/src/lib/detectors/structure-detector.js +0 -275
  141. package/src/lib/monitor/agent-resolver.js +0 -144
  142. package/src/lib/monitor/renderer.js +0 -230
  143. package/src/lib/orchestration/index.js +0 -7
  144. package/src/lib/orchestration/team-orchestrator.js +0 -404
  145. package/src/sanitizer/context-sanitizer.js +0 -221
  146. package/src/sanitizer/patterns.js +0 -163
  147. package/src/writer/file-writer.js +0 -86
  148. /package/framework/skills/level-0-meta/{brainstorming → morph-brainstorming}/references/proposal-example.md +0 -0
  149. /package/framework/skills/level-0-meta/{code-review → morph-code-review}/references/review-example.md +0 -0
  150. /package/framework/skills/level-0-meta/{code-review → morph-code-review}/references/review-guidelines.md +0 -0
  151. /package/framework/skills/level-0-meta/{code-review → morph-code-review}/scripts/scan-csharp.mjs +0 -0
  152. /package/framework/skills/level-0-meta/{code-review-nextjs → morph-code-review-nextjs}/references/review-example-nextjs.md +0 -0
  153. /package/framework/skills/level-0-meta/{code-review-nextjs → morph-code-review-nextjs}/scripts/scan-nextjs.mjs +0 -0
  154. /package/framework/skills/level-0-meta/{frontend-review → morph-frontend-review}/scripts/scan-accessibility.mjs +0 -0
  155. /package/framework/skills/level-0-meta/{post-implementation → morph-post-implementation}/scripts/detect-dev-server.mjs +0 -0
  156. /package/framework/skills/level-0-meta/{post-implementation → morph-post-implementation}/scripts/detect-stack.mjs +0 -0
  157. /package/framework/skills/level-1-workflows/{phase-clarify → morph-phase-clarify}/references/clarifications-example.md +0 -0
  158. /package/framework/skills/level-1-workflows/{phase-design → morph-phase-design}/references/architecture-analysis-guide.md +0 -0
  159. /package/framework/skills/level-1-workflows/{phase-design → morph-phase-design}/references/spec-authoring-guide.md +0 -0
  160. /package/framework/skills/level-1-workflows/{phase-design → morph-phase-design}/references/spec-example.md +0 -0
  161. /package/framework/skills/level-1-workflows/{phase-implement → morph-phase-implement}/references/recap-example.md +0 -0
  162. /package/framework/skills/level-1-workflows/{phase-implement → morph-phase-implement}/references/vsa-implementation-guide.md +0 -0
  163. /package/framework/skills/level-1-workflows/{phase-tasks → morph-phase-tasks}/references/task-planning-patterns.md +0 -0
  164. /package/framework/skills/level-1-workflows/{phase-tasks → morph-phase-tasks}/references/tasks-example.md +0 -0
@@ -0,0 +1,472 @@
1
+ ---
2
+ name: morph:phase-implement
3
+ description: MORPH-SPEC Phase 5 (Implement). Executes feature tasks using TDD with checkpoint validation every 3 tasks, smoke tests via Playwright, and generates code + recap.md. Use after task list approval when starting feature implementation.
4
+ argument-hint: "[feature-name]"
5
+ disable-model-invocation: true
6
+ context: fork
7
+ agent: general-purpose
8
+ user-invocable: false
9
+ cliVersion: "4.10.1"
10
+ allowed-tools: Read, Write, Edit, Bash, Glob, Grep, AskUserQuestion, Agent
11
+ ---
12
+
13
+ # MORPH Implement — Phase 5
14
+
15
+ > INTERNAL: Workflow skill used by /morph-apply during automated phase orchestration. Not a user command.
16
+
17
+ Implement the tasks defined in Phase 4, with checkpoints every 3 tasks and a final recap.
18
+
19
+ ## Prerequisites
20
+
21
+ - [ ] Phase 4 (Tasks) completed
22
+ - [ ] `tasks.md` approved by user
23
+ - [ ] Tasks gate approved (`morph-spec approve $ARGUMENTS tasks`)
24
+ - [ ] All design outputs exist (spec.md, contracts.cs/.ts, decisions.md)
25
+
26
+ ## Step 0: Ensure Implement Phase
27
+
28
+ **Before any reads or writes — verify the current phase:**
29
+
30
+ ```bash
31
+ npx morph-spec state get $ARGUMENTS
32
+ ```
33
+
34
+ Check the `"phase"` field:
35
+
36
+ **If `"phase": "implement"`** → correct phase, proceed.
37
+
38
+ **If `"phase": "tasks"`** → run in sequence:
39
+ 1. `npx morph-spec state mark-output $ARGUMENTS tasks`
40
+ 2. `npx morph-spec approve $ARGUMENTS tasks`
41
+ 3. `npx morph-spec phase advance $ARGUMENTS` (→ implement)
42
+
43
+ **Any other value** → STOP — inconsistent state, report to user.
44
+
45
+ > **Rule:** Never write to `5-implement/` until the phase is `implement`. The hook will block writes.
46
+
47
+ ---
48
+
49
+ ## Pre-flight Validation (MANDATORY)
50
+
51
+ Before any task work, validate that prior phases are truly complete. `state.json` may have been set manually — these commands verify actual filesystem artifacts.
52
+
53
+ ```bash
54
+ # 1. Verify mandatory outputs from all prior phases
55
+ npx morph-spec validate-feature $ARGUMENTS
56
+
57
+ # 2. Confirm all approval gates passed
58
+ npx morph-spec approval-status $ARGUMENTS
59
+
60
+ # 3. Verify activeAgents are populated
61
+ npx morph-spec state get $ARGUMENTS | grep -A5 activeAgents
62
+ ```
63
+
64
+ If any check fails → **STOP**. Do not start any task. Report what's missing:
65
+
66
+ | Problem | Resolution |
67
+ |---------|-----------|
68
+ | Missing output (spec.md, contracts, etc.) | Return to corresponding phase and generate it |
69
+ | Gate not approved (design, plan, tasks) | `npx morph-spec approve $ARGUMENTS <gate>` |
70
+ | Invalid phase | `npx morph-spec phase advance $ARGUMENTS` |
71
+ | Empty activeAgents | Run `/phase-setup $ARGUMENTS` first |
72
+
73
+ **This step is not optional.** Only proceed when all commands return without errors.
74
+
75
+ ---
76
+
77
+ ## Pre-flight MCP — Connection Validation
78
+
79
+ Before starting tasks, verify that MCPs needed for the implement phase are working.
80
+
81
+ **1. Collect MCPs for the implement phase:**
82
+ - Read `framework/skills/level-0-meta/mcp-registry.json` → `phaseMatrix.implement`
83
+ - Read `.claude/settings.local.json` → identify configured MCPs
84
+
85
+ **2. For each CONFIGURED MCP in `phaseMatrix.implement`:**
86
+ 1. Look for a tool matching `healthCheck.toolPattern`
87
+ 2. If found → run `healthCheck.testCall` with `healthCheck.testParams`
88
+ 3. Evaluate:
89
+
90
+ | Result | Action |
91
+ |--------|--------|
92
+ | **Success** | `✓ {MCP} — ready` |
93
+ | **Tool not found** | `○ {MCP} — needs restart` |
94
+ | **Error** | → **AskUserQuestion** (below) |
95
+
96
+ **On error — ask the user:**
97
+
98
+ Use `AskUserQuestion` with header `"{MCP}"` and options:
99
+ - **Continue without {MCP}** — Show `fallback` from registry. Implementation will use the fallback automatically.
100
+ - **Reconfigure credentials** — Collect credentials and update `.claude/settings.local.json`. Re-test after reconfiguring.
101
+ - **Stop implementation** — Abort. User must fix the MCP and re-run `/morph-apply`.
102
+
103
+ > **Design:** This check is fail-open — consistent with morph-spec philosophy. The user gets explicit choice instead of tasks failing silently.
104
+
105
+ ---
106
+
107
+ ## Recommended Tools
108
+
109
+ > **Ref:** `framework/skills/level-0-meta/morph-tool-usage-guide/SKILL.md` for complete guide.
110
+ > **Ref:** `framework/standards/integration/mcp/mcp-tools.md` for MCP reference.
111
+ > **Example:** `references/recap-example.md` — filled-in recap.md showing expected output quality.
112
+
113
+ | Action | Tool | Alternative |
114
+ |--------|------|-------------|
115
+ | Check execution mode (single/subagents/agent-teams) | **Bash** `npx morph-spec dispatch-agents $ARGUMENTS implement` | Task groups + subagent prompts |
116
+ | **Dispatch implementers by domain** (subagents) | **Agent** `subagent_type=<taskGroups[group].agentId>` + `prompt=taskPrompt` from dispatch config | Backend + frontend + infra in parallel |
117
+ | **Create Agent Team** (critical multi-domain features) | Natural language — see Step 0.5b | — |
118
+ | Read task details | **Read** tasks.md, spec.md, contracts.cs/.ts | — |
119
+ | Create new files | **Write** source files | — |
120
+ | Modify existing files | **Edit** source files | — |
121
+ | Look up library API | **Context7 MCP** `query_docs()` | **WebSearch** + **WebFetch** |
122
+ | Run migrations | **Supabase MCP** `query()` | **Bash** `npx supabase migration ...` |
123
+ | Build project | **Bash** `dotnet build` or `npm run build` | — |
124
+ | Run tests | **Bash** `dotnet test` or `npm test` | — |
125
+ | Checkpoint validation | **Bash** `npx morph-spec validate-feature ...` | — |
126
+ | Mark task complete | **Bash** `npx morph-spec task done $ARGUMENTS T001` | — |
127
+ | Smoke test in browser | **Playwright MCP** `browser_navigate()` + `browser_snapshot()` | Manual |
128
+ | Check console errors | **Playwright MCP** `browser_console_messages()` | — |
129
+ | Screenshot for recap | **Playwright MCP** `browser_take_screenshot()` | — |
130
+ | Deploy and logs Vercel | **Vercel MCP** `list_projects()`, `get_deployments()`, `manage_env_vars()` | **Bash** `vercel deploy` |
131
+ | Create PR | **Bash** `gh pr create ...` | **GitHub MCP** `create_pull_request()` |
132
+ | Update state | **Bash** `npx morph-spec state set ...` | — |
133
+
134
+ **Phase MCPs:** Supabase (migrations, RLS), Context7 (API lookup), Playwright (smoke test), GitHub (PRs), Vercel (deploy, logs, env vars).
135
+
136
+ **Anti-patterns:**
137
+ - Task agent for editing a single file (use Edit directly)
138
+ - Agent Teams for single-domain features (subagents suffice)
139
+ - Agent Teams without plan approval (creates risk of divergent implementations)
140
+ - `Bash cat` to create files (use Write tool)
141
+ - `Bash sed` to modify code (use Edit tool)
142
+ - Implementing without reading contracts.cs/.ts first (contracts are the source of truth!)
143
+ - Running backend and frontend tasks sequentially when they are independent
144
+ - **(VSA)** Creating Application Service layer — handler accesses IRepository directly
145
+ - **(VSA)** Manually registering handlers/endpoints in Program.cs — use auto-discovery via reflection
146
+ - **(VSA)** Placing Request/Response in separate files from Handler
147
+ - **(VSA)** Using `Guid.NewGuid()` — use `Guid.CreateVersion7()`
148
+ - Trying to fix a bug without invoking `systematic-debugging` first
149
+
150
+ ---
151
+
152
+ ## Context Loading
153
+
154
+ ### 1. Read full context in PARALLEL
155
+
156
+ ```
157
+ # Single parallel call, not sequential:
158
+ Read: .morph/features/{feature}/4-tasks/tasks.md
159
+ + Read: .morph/features/{feature}/1-design/spec.md
160
+ + Read: .morph/features/{feature}/1-design/contracts.cs (or contracts.ts for TypeScript projects)
161
+ + Read: .morph/config/config.json (→ architecture.style)
162
+ + Read: .morph/features/{feature}/3-plan/plan.md
163
+ ```
164
+
165
+ ### 2. Create native tasks for each T001-T00N
166
+
167
+ After reading `tasks.md`, create **one native task per task found**:
168
+
169
+ ```
170
+ # For each task in tasks.md (T001, T002, ..., T00N):
171
+ TaskCreate: "{T001}: {task title}" → description: full description → activeForm: "Implementing T001"
172
+ TaskCreate: "{T002}: {task title}" → description: full description → activeForm: "Implementing T002"
173
+ ... (one TaskCreate per task)
174
+
175
+ # Orchestral tasks always at the end:
176
+ TaskCreate: "Checkpoints and validation" → activeForm: "Validating checkpoint"
177
+ TaskCreate: "Generate recap.md" → activeForm: "Generating recap"
178
+ ```
179
+
180
+ **After creating all tasks, configure dependencies mirroring `tasks.md`:**
181
+ ```
182
+ # For each task with `dependencies: [T00X, T00Y]` in tasks.md:
183
+ TaskUpdate(taskId="<id of T003>", addBlockedBy=["<id of T001>", "<id of T002>"])
184
+ ```
185
+
186
+ ### 3. Detect architecture style
187
+
188
+ ```bash
189
+ cat .morph/config/config.json | grep architecture
190
+ ```
191
+
192
+ If `config.architecture.style === "vertical-slice"` → follow **Step 1.5** before implementing.
193
+ Otherwise → go directly to the task loop.
194
+
195
+ ### Step 1.5: VSA Implementation Guide (only if `style: "vertical-slice"`)
196
+
197
+ > For the complete slice structure and VSA rules, see `references/vsa-implementation-guide.md`
198
+
199
+ Structure: `Features/{Entity}Feature/{Op}/` with Handler (+ Request/Response records) + Validator + Endpoint per slice. Everything `sealed`. `Guid.CreateVersion7()`. `result.Match()` in endpoints. No Application Service layer — handler accesses IRepository directly. Auto-discovery via reflection: do not manually register in Program.cs.
200
+
201
+ ---
202
+
203
+ ## Workflow
204
+
205
+ ### Step 0.5: Plan Execution Mode
206
+
207
+ **Read the plan's execution strategy:**
208
+ ```
209
+ Read: .morph/features/{feature}/3-plan/plan.md → extract "Execution Strategy" field
210
+ ```
211
+
212
+ The strategy was defined and approved in the Plan phase. Use it directly:
213
+
214
+ | Strategy | Action |
215
+ |----------|--------|
216
+ | `"single"` | → Continue to the sequential task loop (Step 2) |
217
+ | `"subagents"` | → Dispatch Task subagents in parallel (below) |
218
+ | `"agent-teams"` | → Create Agent Team with plan approval (Step 0.5b) |
219
+
220
+ If `plan.md` doesn't exist or the field is missing, run as fallback:
221
+
222
+ ```bash
223
+ npx morph-spec dispatch-agents $ARGUMENTS implement
224
+ ```
225
+
226
+ ---
227
+
228
+ #### Subagents Mode (if strategy is `"subagents"`):
229
+
230
+ 1. Read `taskGroups` from dispatch config (e.g., `backend`, `frontend`, `infra`)
231
+ 2. For each group with >= 3 tasks and no cross-group dependencies, use **Agent tool** with `subagent_type=<agentId>` and `taskPrompt` from dispatch config:
232
+
233
+ > **Mapping:** `taskGroups[group].agentId` = `subagent_type` in Agent tool.
234
+ > Example: `agentId: "dotnet-senior"` → `Agent(subagent_type=dotnet-senior, prompt=taskPrompt)`.
235
+
236
+ Each subagent receives a prompt with:
237
+ - Full spec.md and contracts.cs/.ts content
238
+ - The group's task list
239
+ - Instructions to create native tasks, follow the task loop (start → implement → verify → done), checkpoint every 3 tasks
240
+ - Domain isolation: modify ONLY files in their domain
241
+ - **MANDATORY verification before every `task done`** (see Step 2, item 6b)
242
+
243
+ 3. Dispatch subagents for groups in **parallel** (when no cross-group dependencies)
244
+ 4. After all complete, validate integration: `npx morph-spec validate-feature $ARGUMENTS --phase implement`
245
+
246
+ **If strategy is `"single"`** → continue to sequential task loop below.
247
+
248
+ ---
249
+
250
+ #### Step 0.5b: Agent Teams (critical multi-domain features)
251
+
252
+ **When:** strategy is `"agent-teams"`
253
+ **Requirement:** `CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1` in `.claude/settings.local.json`
254
+
255
+ **Why Agent Teams over subagents:**
256
+ Agent Teams have a shared TaskList, direct teammate messaging, and `TeammateIdle` hooks. Subagents are fire-and-forget. For features where backend and frontend need to coordinate API contracts, Agent Teams ensure frontend doesn't implement calls before backend stabilizes DTOs.
257
+
258
+ Create the team with natural language specifying:
259
+ - Backend teammate (dotnet-senior): backend/domain/application files only
260
+ - Frontend teammate (blazor-builder or nextjs-expert): UI/components/pages files only
261
+ - Quality teammate (standards-architect): review + validate-feature after each implementation
262
+ - Enable **plan approval**: teammates must get plans approved before implementing
263
+ - Gate: only approve plans matching contracts.cs/.ts and spec.md
264
+
265
+ After all teammates complete: `npx morph-spec validate-feature $ARGUMENTS --phase implement`
266
+
267
+ ---
268
+
269
+ ### Step 2: Task Loop
270
+
271
+ ```bash
272
+ npx morph-spec task next $ARGUMENTS
273
+ ```
274
+
275
+ For each task (T001 → T00N):
276
+
277
+ 1. **Mark as in-progress (native task):**
278
+ ```
279
+ TaskUpdate(taskId="<native id>", status="in_progress")
280
+ ```
281
+ 2. **Start via CLI:**
282
+ ```bash
283
+ npx morph-spec task start $ARGUMENTS T001
284
+ ```
285
+ 3. **Read the task description** + contracts.cs/.ts for relevant DTOs/interfaces
286
+ 4. **Implement** using Write (new) or Edit (existing)
287
+ 5. **Verify** — build, lint, tests
288
+ 6. **MANDATORY — Verification before `task done`:**
289
+ Run `validate-feature` before marking ANY task as done. This is non-negotiable — it catches broken code, missing files, and spec violations before they compound across tasks.
290
+ ```bash
291
+ npx morph-spec validate-feature $ARGUMENTS --phase implement
292
+ ```
293
+ Only proceed to step 7 if verification passes. If it fails → fix before marking `task done`.
294
+ 7. **Mark as done via CLI:**
295
+ ```bash
296
+ npx morph-spec task done $ARGUMENTS T001
297
+ ```
298
+ 8. **If `task done` returns without error, mark native task as completed:**
299
+ ```
300
+ TaskUpdate(taskId="<native id>", status="completed")
301
+ ```
302
+ > `TaskUpdate(completed)` only happens if `task done` returns without error (validation passed).
303
+
304
+ ### Step 3: Checkpoint Every 3 Tasks
305
+
306
+ **After every 3 completed tasks:**
307
+
308
+ ```bash
309
+ # Save checkpoint
310
+ npx morph-spec checkpoint-save $ARGUMENTS
311
+
312
+ # Run validation
313
+ npx morph-spec validate-feature $ARGUMENTS --phase implement
314
+ ```
315
+
316
+ **If validation fails:**
317
+ 1. Do NOT advance to the next task
318
+ 2. Fix reported issues
319
+ 3. Re-run validation
320
+ 4. Only then proceed
321
+
322
+ ### Step 4: Test-Driven Development (Recommended)
323
+
324
+ For each implementation task:
325
+
326
+ 1. **Write test first** (unit test for service/domain)
327
+ 2. **Run test** — should fail (RED)
328
+ 3. **Implement** the minimum to pass
329
+ 4. **Run test** — should pass (GREEN)
330
+ 5. **Refactor** if needed (REFACTOR)
331
+
332
+ ```bash
333
+ # .NET
334
+ dotnet test --filter "FullyQualifiedName~{TestClass}"
335
+
336
+ # Node.js
337
+ npm test -- test/path/to/test.js
338
+ ```
339
+
340
+ ### Step 5: Smoke Test with Playwright (if UI)
341
+
342
+ After implementing visual components:
343
+
344
+ ```javascript
345
+ // Navigate to the page
346
+ await mcp__playwright__browser_navigate({ url: 'http://localhost:5000/feature-page' });
347
+
348
+ // Capture page state
349
+ await mcp__playwright__browser_snapshot();
350
+
351
+ // Check console errors
352
+ await mcp__playwright__browser_console_messages({ level: 'error' });
353
+
354
+ // Screenshot for recap
355
+ await mcp__playwright__browser_take_screenshot({ type: 'png' });
356
+ ```
357
+
358
+ ### Step 6: Generate `recap.md`
359
+
360
+ After ALL tasks completed:
361
+
362
+ ```bash
363
+ npx morph-spec generate recap $ARGUMENTS
364
+ ```
365
+
366
+ > For the full recap format, see `references/recap-example.md`
367
+
368
+ ### Step 7: Update State
369
+
370
+ ```bash
371
+ npx morph-spec state set $ARGUMENTS status done
372
+ npx morph-spec state mark-output $ARGUMENTS recap
373
+ ```
374
+
375
+ ### Step 8: Post-Implementation Review (mandatory before PR)
376
+
377
+ ```bash
378
+ /post-implementation $ARGUMENTS
379
+ ```
380
+
381
+ Run the `post-implementation` skill before creating the PR. It orchestrates:
382
+ - Automated scans (CRITICAL findings block PR)
383
+ - Full test suite
384
+ - Final `validate-feature`
385
+ - Smoke test via Playwright (mandatory if dev server active)
386
+ - Code review checklist (CRITICAL + HIGH)
387
+ - **`morph-checklist`** — compliance (security, SEO, performance, accessibility, LGPD)
388
+ - Checkpoint + final recap
389
+
390
+ ### Step 9: Frontend Review (NEXTJS/FULLSTACK)
391
+
392
+ If stack is NEXTJS or FULLSTACK:
393
+
394
+ ```bash
395
+ /frontend-review $ARGUMENTS
396
+ ```
397
+
398
+ Complements `post-implementation` with: accessibility scan (static + axe-core runtime),
399
+ responsive screenshots (mobile/tablet/desktop), and SEO metadata verification.
400
+
401
+ ---
402
+
403
+ ## Morph-Native Dispatch
404
+
405
+ morph-spec uses its own agents and validators for implementation, dispatch, and review.
406
+
407
+ ### Implementation
408
+
409
+ Implementers are dispatched via `dispatch-agents`:
410
+ ```bash
411
+ npx morph-spec dispatch-agents $ARGUMENTS implement
412
+ ```
413
+
414
+ Use the `agentId` from each group as `subagent_type` in the Agent tool:
415
+ ```
416
+ Agent(subagent_type=<agentId>, prompt=<filled prompts/implementer-prompt.md>)
417
+ ```
418
+
419
+ ### Review (Two-Stage)
420
+
421
+ **Stage 1 — Spec Compliance (mandatory):**
422
+ ```
423
+ Agent(subagent_type=<tier-4 validator>, prompt=<filled prompts/spec-reviewer-prompt.md>)
424
+ ```
425
+ Use validators from `dispatch-agents --mode validate`. Spec compliance MUST pass before proceeding.
426
+
427
+ **Stage 2 — Code Quality (mandatory):**
428
+ ```
429
+ Agent(subagent_type=standards-architect, prompt=<filled prompts/code-quality-reviewer-prompt.md>)
430
+ ```
431
+ `critical` issues block. `important` issues must be fixed. `suggestion` is optional.
432
+
433
+ ### Prompt Templates
434
+
435
+ | Template | Usage |
436
+ |----------|-------|
437
+ | `prompts/implementer-prompt.md` | Dispatch to implementer agents |
438
+ | `prompts/spec-reviewer-prompt.md` | Spec compliance review |
439
+ | `prompts/code-quality-reviewer-prompt.md` | Code quality review |
440
+
441
+ ---
442
+
443
+ ## Outputs
444
+
445
+ - Implemented source code (various files)
446
+ - Unit and integration tests
447
+ - `.morph/features/$ARGUMENTS/5-implement/recap.md` — Implementation summary
448
+
449
+ ## Completion Criteria
450
+
451
+ - [x] All tasks completed
452
+ - [x] Build compiles without errors
453
+ - [x] Tests passing
454
+ - [x] Validation pipeline passes
455
+ - [x] `recap.md` generated
456
+ - [x] State updated to `status: done`
457
+ - [x] Checkpoints saved every 3 tasks
458
+ - [x] `/post-implementation` executed without BLOCKs
459
+
460
+ ---
461
+
462
+ ## Phase Outputs
463
+
464
+ <!-- morph:outputs:implement -->
465
+ | Output | Path |
466
+ |--------|------|
467
+ | `recap` | `.morph/features/{feature}/5-implement/recap.md` |
468
+ <!-- /morph:outputs -->
469
+
470
+ ---
471
+
472
+ Feature complete! Consider creating a PR and running `morph-spec generate recap $ARGUMENTS`.
@@ -0,0 +1,50 @@
1
+ # Morph-Spec Code Quality Review
2
+
3
+ You are the standards-architect reviewer for feature '{{FEATURE_NAME}}'.
4
+
5
+ ## Review Scope
6
+
7
+ Review the implementation for code quality, architecture compliance, and adherence to project standards.
8
+
9
+ ## Reference Documents
10
+
11
+ Read these before reviewing:
12
+ - `.morph/context/standards.md` — Project coding standards
13
+ - `.morph/context/README.md` — Project architecture overview
14
+ - `framework/standards/` — Framework-level standards (reference as needed)
15
+
16
+ ## Review Checklist
17
+
18
+ 1. **Naming Conventions** — PascalCase for types, camelCase for variables, kebab-case for files (or as defined in standards)
19
+ 2. **Architecture Compliance** — Code follows the project's architecture pattern (VSA slices, DDD layers, etc.)
20
+ 3. **Async Patterns** — CancellationToken propagated, no fire-and-forget, proper await
21
+ 4. **Error Handling** — Appropriate exceptions, no swallowed errors, consistent patterns
22
+ 5. **Security** — No hardcoded secrets, SQL injection, XSS vectors, or OWASP top 10 issues
23
+ 6. **DI Lifetimes** — Correct service registration (Scoped for DB, Singleton for config, etc.)
24
+ 7. **Test Quality** — Tests follow Arrange-Act-Assert, meaningful assertions, no test duplication
25
+
26
+ ## Output Format
27
+
28
+ ```json
29
+ {
30
+ "passed": true/false,
31
+ "issues": [
32
+ {
33
+ "severity": "critical|important|suggestion",
34
+ "file": "path/to/file",
35
+ "line": 42,
36
+ "description": "What the issue is",
37
+ "fix": "How to fix it"
38
+ }
39
+ ]
40
+ }
41
+ ```
42
+
43
+ ## Rules
44
+
45
+ - `critical` issues MUST be fixed before merge
46
+ - `important` issues SHOULD be fixed
47
+ - `suggestion` issues are optional improvements
48
+ - Only `critical` issues cause `passed: false`
49
+ - Be specific — always include file path and line number
50
+ - Prefer minimal fixes over refactoring
@@ -0,0 +1,45 @@
1
+ # Morph-Spec Implementer Dispatch
2
+
3
+ You are implementing tasks for the feature '{{FEATURE_NAME}}' as agent '{{AGENT_ID}}'.
4
+
5
+ ## Context
6
+
7
+ **Spec:** Read `.morph/features/{{FEATURE_NAME}}/1-design/spec.md`
8
+ **Contracts:** Read `.morph/features/{{FEATURE_NAME}}/1-design/contracts.cs`
9
+ **Plan:** Read `.morph/features/{{FEATURE_NAME}}/3-plan/plan.md`
10
+ **Standards:** Read `.morph/context/standards.md` and relevant files in `framework/standards/`
11
+
12
+ ## Agent Briefing
13
+
14
+ {{AGENT_BRIEFING}}
15
+
16
+ ## Tasks Assigned
17
+
18
+ {{TASK_LIST}}
19
+
20
+ ## Execution Rules
21
+
22
+ 1. Before starting each task:
23
+ - Execute: `npx morph-spec task start {{FEATURE_NAME}} {{TASK_ID}}`
24
+
25
+ 2. For each task, follow TDD:
26
+ - Write the failing test first
27
+ - Run it to verify it fails
28
+ - Write minimal implementation to pass
29
+ - Run tests to verify they pass
30
+ - Commit
31
+
32
+ 3. Before marking any task done:
33
+ - Verify build compiles: `dotnet build` or `npm run build`
34
+ - Run relevant tests
35
+ - Execute: `npx morph-spec task done {{FEATURE_NAME}} {{TASK_ID}}`
36
+
37
+ 4. Every 3 tasks:
38
+ - Execute: `npx morph-spec checkpoint-save {{FEATURE_NAME}}`
39
+ - Execute: `npx morph-spec validate-feature {{FEATURE_NAME}} --phase implement`
40
+
41
+ 5. Contracts are the source of truth — all DTOs, interfaces, and types MUST match `contracts.cs` exactly
42
+
43
+ 6. Modify ONLY files listed in your assigned tasks. Do NOT touch files outside your domain.
44
+
45
+ 7. If you encounter a dependency on another agent's work, STOP and report it.
@@ -0,0 +1,47 @@
1
+ # Morph-Spec Spec Compliance Review
2
+
3
+ You are a Tier-4 spec reviewer for feature '{{FEATURE_NAME}}'.
4
+
5
+ ## Review Scope
6
+
7
+ Review the implementation against the specification. Your job is to ensure the code matches the spec EXACTLY — no more, no less.
8
+
9
+ ## Reference Documents
10
+
11
+ Read these before reviewing:
12
+ - `.morph/features/{{FEATURE_NAME}}/1-design/spec.md` — The specification
13
+ - `.morph/features/{{FEATURE_NAME}}/1-design/contracts.cs` — The contracts (source of truth)
14
+ - `.morph/features/{{FEATURE_NAME}}/3-plan/plan.md` — The implementation plan
15
+
16
+ ## Review Checklist
17
+
18
+ For each task implemented, verify:
19
+
20
+ 1. **Completeness** — All acceptance criteria from spec.md are implemented
21
+ 2. **Correctness** — DTOs, interfaces, and types match contracts.cs exactly
22
+ 3. **No over-building** — No features, flags, or abstractions not in the spec
23
+ 4. **No under-building** — No missing error handling, validations, or edge cases from the spec
24
+ 5. **Naming** — All names match the contracts (exact casing and spelling)
25
+
26
+ ## Output Format
27
+
28
+ ```json
29
+ {
30
+ "passed": true/false,
31
+ "issues": [
32
+ {
33
+ "severity": "error|warning",
34
+ "file": "path/to/file",
35
+ "description": "What doesn't match the spec",
36
+ "specReference": "Which section of spec.md"
37
+ }
38
+ ]
39
+ }
40
+ ```
41
+
42
+ ## Rules
43
+
44
+ - Only flag issues that represent spec non-compliance
45
+ - Do NOT flag style preferences or minor improvements
46
+ - Every issue MUST reference a specific section of spec.md or contracts.cs
47
+ - If the implementation matches the spec, output `{ "passed": true, "issues": [] }`