@polymorphism-tech/morph-spec 4.10.7 → 4.10.9

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 (123) hide show
  1. package/CLAUDE.md +3 -3
  2. package/LICENSE +71 -71
  3. package/README.md +379 -379
  4. package/bin/morph-spec.js +1 -1
  5. package/claude-plugin.json +14 -14
  6. package/docs/CHEATSHEET.md +1 -1
  7. package/docs/QUICKSTART.md +206 -206
  8. package/framework/agents/README.md +14 -14
  9. package/framework/agents/architecture/standards-architect.md +159 -159
  10. package/framework/agents/frontend/blazor-builder.md +13 -0
  11. package/framework/agents/frontend/css-specialist.md +87 -0
  12. package/framework/agents/frontend/nextjs-expert.md +13 -0
  13. package/framework/agents/frontend/nextjs-ui-specialist.md +218 -0
  14. package/framework/agents/frontend/ui-ux-designer.md +80 -10
  15. package/framework/agents/infrastructure/azure-architect.md +149 -149
  16. package/framework/agents/infrastructure/infra-architect.md +48 -48
  17. package/framework/agents.json +2268 -2204
  18. package/framework/hooks/README.md +204 -204
  19. package/framework/hooks/claude-code/session-start/inject-morph-context.js +10 -24
  20. package/framework/hooks/shared/phase-utils.js +139 -139
  21. package/framework/hooks/shared/worktree-helpers.js +30 -8
  22. package/framework/rules/csharp-standards.md +13 -13
  23. package/framework/rules/frontend-standards.md +13 -13
  24. package/framework/rules/infrastructure-standards.md +16 -16
  25. package/framework/rules/testing-standards.md +14 -14
  26. package/framework/skills/level-0-meta/morph-brainstorming/SKILL.md +12 -0
  27. package/framework/skills/level-0-meta/morph-code-review-nextjs/references/review-example-nextjs.md +254 -254
  28. package/framework/skills/level-0-meta/morph-init/SKILL.md +136 -3
  29. package/framework/skills/level-1-workflows/morph-phase-clarify/SKILL.md +247 -247
  30. package/framework/skills/level-1-workflows/morph-phase-codebase-analysis/SKILL.md +270 -270
  31. package/framework/skills/level-1-workflows/morph-phase-design/SKILL.md +515 -499
  32. package/framework/skills/level-1-workflows/morph-phase-implement/SKILL.md +508 -500
  33. package/framework/skills/level-1-workflows/morph-phase-plan/SKILL.md +12 -1
  34. package/framework/skills/level-1-workflows/morph-phase-setup/SKILL.md +272 -262
  35. package/framework/skills/level-1-workflows/morph-phase-tasks/SKILL.md +317 -311
  36. package/framework/skills/level-1-workflows/morph-phase-uiux/SKILL.md +457 -323
  37. package/framework/skills/level-1-workflows/morph-scope-escalation/SKILL.md +1 -1
  38. package/framework/standards/STANDARDS.json +2040 -2040
  39. package/framework/standards/frontend/nextjs/motion-patterns.md +321 -0
  40. package/framework/standards/frontend/nextjs/nextjs-patterns.md +17 -17
  41. package/framework/templates/README.md +814 -814
  42. package/framework/templates/code/dotnet/contracts/Commands.cs +74 -74
  43. package/framework/templates/code/dotnet/contracts/Entities.cs +25 -25
  44. package/framework/templates/code/dotnet/contracts/Queries.cs +74 -74
  45. package/framework/templates/code/dotnet/contracts/README.md +74 -74
  46. package/framework/templates/code/dotnet/contracts/api-contracts.cs +173 -173
  47. package/framework/templates/code/dotnet/frontend/component.razor +239 -239
  48. package/framework/templates/code/dotnet/jobs/agent.cs +163 -163
  49. package/framework/templates/code/dotnet/jobs/job.cs +171 -171
  50. package/framework/templates/code/dotnet/test.cs +239 -239
  51. package/framework/templates/code/sql/rls-policy.sql +57 -57
  52. package/framework/templates/code/sql/supabase-migration.sql +100 -100
  53. package/framework/templates/code/sql/supabase-migration.template.sql +113 -113
  54. package/framework/templates/code/typescript/contracts.ts +168 -168
  55. package/framework/templates/context/CONTEXT.md +181 -181
  56. package/framework/templates/context/design-system.md +211 -0
  57. package/framework/templates/docs/proposal.md +182 -182
  58. package/framework/templates/docs/user-stories.md +34 -34
  59. package/framework/templates/examples/design-system-examples.md +357 -357
  60. package/framework/templates/examples/spec-examples.md +90 -90
  61. package/framework/templates/feature/decisions.md +187 -187
  62. package/framework/templates/feature/recap.md +146 -146
  63. package/framework/templates/feature/tasks.md +199 -199
  64. package/framework/templates/infrastructure/azure/README.md +286 -286
  65. package/framework/templates/infrastructure/azure/deploy-checklist.md +426 -426
  66. package/framework/templates/infrastructure/azure/parameters.dev.json +29 -29
  67. package/framework/templates/infrastructure/azure/parameters.prod.json +29 -29
  68. package/framework/templates/infrastructure/azure/parameters.staging.json +29 -29
  69. package/framework/templates/infrastructure/docker/docker-compose.template.yml +67 -67
  70. package/framework/templates/infrastructure/docker/dockerfile-api.dockerfile +38 -38
  71. package/framework/templates/infrastructure/docker/dockerfile-web.dockerfile +48 -48
  72. package/framework/templates/infrastructure/docker/easypanel.template.json +54 -54
  73. package/package.json +82 -82
  74. package/src/commands/agents/index.js +13 -13
  75. package/src/commands/project/install-plugin-cmd.js +28 -28
  76. package/src/commands/project/setup-infra-cmd.js +12 -12
  77. package/src/commands/project/worktree.js +58 -2
  78. package/src/commands/tasks/index.js +4 -4
  79. package/src/commands/templates/index.js +5 -5
  80. package/src/commands/utils/index.js +3 -3
  81. package/src/commands/validation/index.js +4 -4
  82. package/src/core/state/phase-state-machine.js +217 -217
  83. package/src/lib/detectors/design-system-detector.js +73 -31
  84. package/src/lib/generators/design-system-generator.js +298 -298
  85. package/src/lib/generators/index.js +10 -10
  86. package/src/lib/generators/metadata-extractor.js +387 -387
  87. package/src/lib/stack-filter.js +65 -65
  88. package/src/lib/standards/index.js +7 -7
  89. package/src/lib/standards/standards-context-injector.js +302 -302
  90. package/src/lib/validators/architecture/architecture-validator.js +387 -387
  91. package/src/lib/validators/architecture/index.js +7 -7
  92. package/src/lib/validators/blazor/blazor-concurrency-analyzer.js +316 -316
  93. package/src/lib/validators/blazor/blazor-state-validator.js +279 -279
  94. package/src/lib/validators/blazor/blazor-validator.js +369 -369
  95. package/src/lib/validators/blazor/index.js +9 -9
  96. package/src/lib/validators/content/content-validator.js +287 -287
  97. package/src/lib/validators/content/index.js +7 -7
  98. package/src/lib/validators/contracts/index.js +7 -7
  99. package/src/lib/validators/css/css-validator.js +352 -352
  100. package/src/lib/validators/css/index.js +7 -7
  101. package/src/lib/validators/design-system/design-system-validator.js +231 -231
  102. package/src/lib/validators/design-system/index.js +7 -7
  103. package/src/lib/validators/nextjs/index.js +6 -6
  104. package/src/lib/validators/nextjs/next-component-validator.js +183 -183
  105. package/src/lib/validators/packages/index.js +7 -7
  106. package/src/lib/validators/packages/package-validator.js +360 -360
  107. package/src/lib/validators/shared/index.js +12 -12
  108. package/src/lib/validators/shared/issue-counter.js +18 -18
  109. package/src/lib/validators/shared/result-formatter.js +124 -124
  110. package/src/lib/validators/ui/index.js +7 -7
  111. package/src/lib/validators/ui/ui-contrast-validator.js +422 -422
  112. package/src/scripts/global-install.js +58 -58
  113. package/src/scripts/install-plugin.js +126 -126
  114. package/src/utils/claude-md-injector.js +90 -90
  115. package/src/utils/file-copier.js +200 -196
  116. package/src/utils/hooks-installer.js +556 -494
  117. package/src/utils/logger.js +32 -32
  118. package/src/utils/skills-installer.js +178 -178
  119. package/src/utils/version-checker.js +175 -175
  120. package/framework/skills/level-1-workflows/morph-phase-implement/.morph/logs/activity.json +0 -38
  121. package/framework/skills/level-1-workflows/morph-phase-tasks/.morph/logs/activity.json +0 -14
  122. package/framework/templates/.idea/morph-templates.xml +0 -92
  123. package/framework/templates/.vscode/morph-templates.code-snippets +0 -186
@@ -1,500 +1,508 @@
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
- context: fork
6
- agent: general-purpose
7
- user-invocable: false
8
- cliVersion: "4.10.7"
9
- allowed-tools: Read, Write, Edit, Bash, Glob, Grep, AskUserQuestion, Agent
10
- ---
11
-
12
- # MORPH Implement — Phase 5
13
-
14
- > INTERNAL: Workflow skill used by /morph-apply during automated phase orchestration. Not a user command.
15
-
16
- Implement the tasks defined in Phase 4, with checkpoints every 3 tasks and a final recap.
17
-
18
- ## Prerequisites
19
-
20
- - [ ] Phase 4 (Tasks) completed
21
- - [ ] `tasks.md` approved by user
22
- - [ ] Tasks gate approved (`morph-spec approve $ARGUMENTS tasks`)
23
- - [ ] All design outputs exist (spec.md, contracts.cs/.ts, decisions.md)
24
-
25
- ## Step 0: Ensure Implement Phase
26
-
27
- **Before any reads or writes — verify the current phase:**
28
-
29
- ```bash
30
- npx morph-spec state get $ARGUMENTS
31
- ```
32
-
33
- Check the `"phase"` field:
34
-
35
- **If `"phase": "implement"`** → correct phase, proceed.
36
-
37
- **If `"phase": "tasks"`** → run in sequence:
38
- 1. `npx morph-spec state mark-output $ARGUMENTS tasks`
39
- 2. `npx morph-spec approve $ARGUMENTS tasks`
40
- 3. `npx morph-spec phase advance $ARGUMENTS` (→ implement)
41
-
42
- **Any other value** → STOP — inconsistent state, report to user.
43
-
44
- > **Rule:** Never write to `5-implement/` until the phase is `implement`. The hook will block writes.
45
-
46
- ---
47
-
48
- ## Pre-flight Validation (MANDATORY)
49
-
50
- Before any task work, validate that prior phases are truly complete. `state.json` may have been set manually — these commands verify actual filesystem artifacts.
51
-
52
- ```bash
53
- # 1. Verify mandatory outputs from all prior phases
54
- npx morph-spec validate-feature $ARGUMENTS
55
-
56
- # 2. Confirm all approval gates passed
57
- npx morph-spec approval-status $ARGUMENTS
58
-
59
- # 3. Verify activeAgents are populated
60
- npx morph-spec state get $ARGUMENTS | grep -A5 activeAgents
61
- ```
62
-
63
- If any check fails → **STOP**. Do not start any task. Report what's missing:
64
-
65
- | Problem | Resolution |
66
- |---------|-----------|
67
- | Missing output (spec.md, contracts, etc.) | Return to corresponding phase and generate it |
68
- | Gate not approved (design, plan, tasks) | `npx morph-spec approve $ARGUMENTS <gate>` |
69
- | Invalid phase | `npx morph-spec phase advance $ARGUMENTS` |
70
- | Empty activeAgents | Run `/phase-setup $ARGUMENTS` first |
71
-
72
- **This step is not optional.** Only proceed when all commands return without errors.
73
-
74
- ---
75
-
76
- ## Pre-flight MCP — Connection Validation
77
-
78
- Before starting tasks, verify that MCPs needed for the implement phase are working.
79
-
80
- **1. Collect MCPs for the implement phase:**
81
- - Read `framework/skills/level-0-meta/mcp-registry.json` → `phaseMatrix.implement`
82
- - Read `.claude/settings.local.json` → identify configured MCPs
83
-
84
- **2. For each CONFIGURED MCP in `phaseMatrix.implement`:**
85
- 1. Look for a tool matching `healthCheck.toolPattern`
86
- 2. If found → run `healthCheck.testCall` with `healthCheck.testParams`
87
- 3. Evaluate:
88
-
89
- | Result | Action |
90
- |--------|--------|
91
- | **Success** | `✓ {MCP} — ready` |
92
- | **Tool not found** | `○ {MCP} — needs restart` |
93
- | **Error** | → **AskUserQuestion** (below) |
94
-
95
- **On error — ask the user:**
96
-
97
- Use `AskUserQuestion` with header `"{MCP}"` and options:
98
- - **Continue without {MCP}** — Show `fallback` from registry. Implementation will use the fallback automatically.
99
- - **Reconfigure credentials** — Collect credentials and update `.claude/settings.local.json`. Re-test after reconfiguring.
100
- - **Stop implementation** — Abort. User must fix the MCP and re-run `/morph-apply`.
101
-
102
- > **Design:** This check is fail-open — consistent with morph-spec philosophy. The user gets explicit choice instead of tasks failing silently.
103
-
104
- ---
105
-
106
- ## Recommended Tools
107
-
108
- > **Ref:** `framework/skills/level-0-meta/morph-tool-usage-guide/SKILL.md` for complete guide.
109
- > **Ref:** `framework/standards/integration/mcp/mcp-tools.md` for MCP reference.
110
- > **Example:** `references/recap-example.md` — filled-in recap.md showing expected output quality.
111
-
112
- | Action | Tool | Alternative |
113
- |--------|------|-------------|
114
- | Check execution mode (single/subagents/agent-teams) | **Bash** `npx morph-spec dispatch-agents $ARGUMENTS implement` | Task groups + subagent prompts |
115
- | **Dispatch implementers by domain** (subagents) | **Agent** `subagent_type=<taskGroups[group].subagentType>` + `prompt=taskPrompt` from dispatch config | Backend + frontend + infra in parallel |
116
- | **Create Agent Team** (critical multi-domain features) | Natural language — see Step 0.5b | — |
117
- | Read task details | **Read** tasks.md, spec.md, contracts.cs/.ts | — |
118
- | Create new files | **Write** source files | — |
119
- | Modify existing files | **Edit** source files | — |
120
- | Look up library API | **Context7 MCP** `query_docs()` | **WebSearch** + **WebFetch** |
121
- | Run migrations | **Supabase MCP** `query()` | **Bash** `npx supabase migration ...` |
122
- | Build project | **Bash** `dotnet build` or `npm run build` | — |
123
- | Run tests | **Bash** `dotnet test` or `npm test` | — |
124
- | Checkpoint validation | **Bash** `npx morph-spec validate-feature ...` | — |
125
- | Mark task complete | **Bash** `npx morph-spec task done $ARGUMENTS T001` | — |
126
- | Smoke test in browser | **Playwright MCP** `browser_navigate()` + `browser_snapshot()` | Manual |
127
- | Check console errors | **Playwright MCP** `browser_console_messages()` | — |
128
- | Screenshot for recap | **Playwright MCP** `browser_take_screenshot()` | — |
129
- | Deploy and logs Vercel | **Vercel MCP** `list_projects()`, `get_deployments()`, `manage_env_vars()` | **Bash** `vercel deploy` |
130
- | Create PR | **Bash** `gh pr create ...` | **GitHub MCP** `create_pull_request()` |
131
- | Update state | **Bash** `npx morph-spec state set ...` | — |
132
-
133
- **Phase MCPs:** Supabase (migrations, RLS), Context7 (API lookup), Playwright (smoke test), GitHub (PRs), Vercel (deploy, logs, env vars).
134
-
135
- **Anti-patterns:**
136
- - Task agent for editing a single file (use Edit directly)
137
- - Agent Teams for single-domain features (subagents suffice)
138
- - Agent Teams without plan approval (creates risk of divergent implementations)
139
- - `Bash cat` to create files (use Write tool)
140
- - `Bash sed` to modify code (use Edit tool)
141
- - Implementing without reading contracts.cs/.ts first (contracts are the source of truth!)
142
- - Running backend and frontend tasks sequentially when they are independent
143
- - **(VSA)** Creating Application Service layer — handler accesses IRepository directly
144
- - **(VSA)** Manually registering handlers/endpoints in Program.cs — use auto-discovery via reflection
145
- - **(VSA)** Placing Request/Response in separate files from Handler
146
- - **(VSA)** Using `Guid.NewGuid()` — use `Guid.CreateVersion7()`
147
- - Trying to fix a bug without invoking `systematic-debugging` first
148
-
149
- ---
150
-
151
- ## Context Loading
152
-
153
- ### 1. Read full context in PARALLEL
154
-
155
- ```
156
- # Single parallel call, not sequential:
157
- Read: .morph/features/{feature}/4-tasks/tasks.md
158
- + Read: .morph/features/{feature}/1-design/spec.md
159
- + Read: .morph/features/{feature}/1-design/contracts.cs (or contracts.ts for TypeScript projects)
160
- + Read: .morph/config/config.json (→ architecture.style)
161
- + Read: .morph/features/{feature}/3-plan/plan.md
162
- ```
163
-
164
- ### 2. Create native tasks for each T001-T00N
165
-
166
- After reading `tasks.md`, create **one native task per task found**:
167
-
168
- ```
169
- # For each task in tasks.md (T001, T002, ..., T00N):
170
- TaskCreate: "{T001}: {task title}" → description: full description → activeForm: "Implementing T001"
171
- TaskCreate: "{T002}: {task title}" → description: full description → activeForm: "Implementing T002"
172
- ... (one TaskCreate per task)
173
-
174
- # Orchestral tasks always at the end:
175
- TaskCreate: "Checkpoints and validation" → activeForm: "Validating checkpoint"
176
- TaskCreate: "Generate recap.md" → activeForm: "Generating recap"
177
- ```
178
-
179
- **After creating all tasks, configure dependencies mirroring `tasks.md`:**
180
- ```
181
- # For each task with `dependencies: [T00X, T00Y]` in tasks.md:
182
- TaskUpdate(taskId="<id of T003>", addBlockedBy=["<id of T001>", "<id of T002>"])
183
- ```
184
-
185
- ### 3. Detect architecture style
186
-
187
- ```bash
188
- cat .morph/config/config.json | grep architecture
189
- ```
190
-
191
- If `config.architecture.style === "vertical-slice"` → follow **Step 1.5** before implementing.
192
- Otherwise → go directly to the task loop.
193
-
194
- ### Step 1.5: VSA Implementation Guide (only if `style: "vertical-slice"`)
195
-
196
- > For the complete slice structure and VSA rules, see `references/vsa-implementation-guide.md`
197
-
198
- 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.
199
-
200
- ---
201
-
202
- ## Workflow
203
-
204
- ### Step 0.5: Plan Execution Mode
205
-
206
- **Read the plan's execution strategy:**
207
- ```
208
- Read: .morph/features/{feature}/3-plan/plan.md → extract "Execution Strategy" field
209
- ```
210
-
211
- The strategy was defined and approved in the Plan phase. Use it directly:
212
-
213
- | Strategy | Action |
214
- |----------|--------|
215
- | `"single"` | → Continue to the sequential task loop (Step 2) |
216
- | `"subagents"` | → Dispatch Task subagents in parallel (below) |
217
- | `"agent-teams"` | → Create Agent Team with plan approval (Step 0.5b) |
218
-
219
- If `plan.md` doesn't exist or the field is missing, auto-detect via dispatch-agents:
220
-
221
- ```bash
222
- npx morph-spec dispatch-agents $ARGUMENTS implement
223
- ```
224
-
225
- Check the `mode` field in the JSON output to determine the execution strategy.
226
-
227
- ---
228
-
229
- #### Subagents Mode (if strategy is `"subagents"`):
230
-
231
- **Step 0.5a: Get dispatch config:**
232
-
233
- ```bash
234
- npx morph-spec dispatch-agents $ARGUMENTS implement
235
- ```
236
-
237
- Parse the JSON output. Extract `taskGroups` and each group's `subagentType`.
238
-
239
- **Step 0.5b: Verify agent files exist:**
240
-
241
- For each group, verify `.claude/agents/{subagentType}.md` exists:
242
-
243
- ```bash
244
- ls .claude/agents/{subagentType}.md
245
- ```
246
-
247
- If missing → **STOP** with: `"Agent file .claude/agents/{subagentType}.md not found. Run: npx morph-spec setup-infra"`. Do NOT fall back to general-purpose agents for missing files.
248
-
249
- **Step 0.5c: Dispatch subagents:**
250
-
251
- 1. For each group with >= 3 tasks and no cross-group dependencies, use **Agent tool** with `subagent_type` from dispatch config:
252
-
253
- > **Mapping:** `taskGroups[group].subagentType` = `subagent_type` in Agent tool.
254
- > Example: `subagentType: "morph-dotnet-senior"` → `Agent(subagent_type="morph-dotnet-senior", prompt=taskPrompt)`.
255
- >
256
- > **MANDATORY:** Use the exact `subagentType` value. Do NOT use `general-purpose` agents when a `subagentType` is available.
257
-
258
- Each subagent receives a prompt with:
259
- - Full spec.md and contracts.cs/.ts content
260
- - The group's task list
261
- - Instructions to create native tasks, follow the task loop (start → implement → verify → done), checkpoint every 3 tasks
262
- - Domain isolation: modify ONLY files in their domain
263
- - **MANDATORY verification before every `task done`** (see Step 2, item 6b)
264
-
265
- 2. Dispatch subagents for groups in **parallel** (when no cross-group dependencies)
266
- 3. After all complete, validate integration: `npx morph-spec validate-feature $ARGUMENTS --phase implement`
267
-
268
- **Fallback:** If `dispatch-agents` fails (non-zero exit or invalid JSON), log a warning and fall back to sequential single-agent mode (Step 2).
269
-
270
- **If strategy is `"single"`** → continue to sequential task loop below.
271
-
272
- ---
273
-
274
- #### Step 0.5b: Agent Teams (critical multi-domain features)
275
-
276
- **When:** strategy is `"agent-teams"`
277
- **Requirement:** `CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1` in `.claude/settings.local.json`
278
-
279
- **Why Agent Teams over subagents:**
280
- 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.
281
-
282
- Create the team with natural language specifying:
283
- - Backend teammate (dotnet-senior): backend/domain/application files only
284
- - Frontend teammate (blazor-builder or nextjs-expert): UI/components/pages files only
285
- - Quality teammate (standards-architect): review + validate-feature after each implementation
286
- - Enable **plan approval**: teammates must get plans approved before implementing
287
- - Gate: only approve plans matching contracts.cs/.ts and spec.md
288
-
289
- After all teammates complete: `npx morph-spec validate-feature $ARGUMENTS --phase implement`
290
-
291
- ---
292
-
293
- ### Step 2: Task Loop
294
-
295
- ```bash
296
- npx morph-spec task next $ARGUMENTS
297
- ```
298
-
299
- For each task (T001 → T00N):
300
-
301
- 1. **Mark as in-progress (native task):**
302
- ```
303
- TaskUpdate(taskId="<native id>", status="in_progress")
304
- ```
305
- 2. **Start via CLI:**
306
- ```bash
307
- npx morph-spec task start $ARGUMENTS T001
308
- ```
309
- 3. **Read the task description** + contracts.cs/.ts for relevant DTOs/interfaces
310
- 4. **Implement** using Write (new) or Edit (existing)
311
- 5. **Verify** — build, lint, tests
312
- 6. **MANDATORY — Verification before `task done`:**
313
- 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.
314
- ```bash
315
- npx morph-spec validate-feature $ARGUMENTS --phase implement
316
- ```
317
- Only proceed to step 7 if verification passes. If it fails → fix before marking `task done`.
318
- 7. **Mark as done via CLI:**
319
- ```bash
320
- npx morph-spec task done $ARGUMENTS T001
321
- ```
322
- 8. **If `task done` returns without error, mark native task as completed:**
323
- ```
324
- TaskUpdate(taskId="<native id>", status="completed")
325
- ```
326
- > `TaskUpdate(completed)` only happens if `task done` returns without error (validation passed).
327
-
328
- ### Step 3: Checkpoint Every 3 Tasks
329
-
330
- **After every 3 completed tasks:**
331
-
332
- ```bash
333
- # Save checkpoint
334
- npx morph-spec checkpoint-save $ARGUMENTS
335
-
336
- # Run validation
337
- npx morph-spec validate-feature $ARGUMENTS --phase implement
338
- ```
339
-
340
- **If validation fails:**
341
- 1. Do NOT advance to the next task
342
- 2. Fix reported issues
343
- 3. Re-run validation
344
- 4. Only then proceed
345
-
346
- ### Step 4: Test-Driven Development (Recommended)
347
-
348
- For each implementation task:
349
-
350
- 1. **Write test first** (unit test for service/domain)
351
- 2. **Run test** — should fail (RED)
352
- 3. **Implement** the minimum to pass
353
- 4. **Run test** — should pass (GREEN)
354
- 5. **Refactor** if needed (REFACTOR)
355
-
356
- ```bash
357
- # .NET
358
- dotnet test --filter "FullyQualifiedName~{TestClass}"
359
-
360
- # Node.js
361
- npm test -- test/path/to/test.js
362
- ```
363
-
364
- ### Step 5: Smoke Test with Playwright (if UI)
365
-
366
- After implementing visual components:
367
-
368
- ```javascript
369
- // Navigate to the page
370
- await mcp__playwright__browser_navigate({ url: 'http://localhost:5000/feature-page' });
371
-
372
- // Capture page state
373
- await mcp__playwright__browser_snapshot();
374
-
375
- // Check console errors
376
- await mcp__playwright__browser_console_messages({ level: 'error' });
377
-
378
- // Screenshot for recap
379
- await mcp__playwright__browser_take_screenshot({ type: 'png' });
380
- ```
381
-
382
- ### Step 6: Generate `recap.md`
383
-
384
- After ALL tasks completed:
385
-
386
- ```bash
387
- npx morph-spec generate recap $ARGUMENTS
388
- ```
389
-
390
- > For the full recap format, see `references/recap-example.md`
391
-
392
- ### Step 7: Update State
393
-
394
- ```bash
395
- npx morph-spec state set $ARGUMENTS status done
396
- npx morph-spec state mark-output $ARGUMENTS recap
397
- ```
398
-
399
- ### Step 8: Post-Implementation Review (mandatory before PR)
400
-
401
- ```bash
402
- /post-implementation $ARGUMENTS
403
- ```
404
-
405
- Run the `post-implementation` skill before creating the PR. It orchestrates:
406
- - Automated scans (CRITICAL findings block PR)
407
- - Full test suite
408
- - Final `validate-feature`
409
- - Smoke test via Playwright (mandatory if dev server active)
410
- - Code review checklist (CRITICAL + HIGH)
411
- - **`morph-checklist`** — compliance (security, SEO, performance, accessibility, LGPD)
412
- - Checkpoint + final recap
413
-
414
- ### Step 9: Frontend Review (NEXTJS/FULLSTACK)
415
-
416
- If stack is NEXTJS or FULLSTACK:
417
-
418
- ```bash
419
- /frontend-review $ARGUMENTS
420
- ```
421
-
422
- Complements `post-implementation` with: accessibility scan (static + axe-core runtime),
423
- responsive screenshots (mobile/tablet/desktop), and SEO metadata verification.
424
-
425
- ---
426
-
427
- ## Morph-Native Dispatch
428
-
429
- morph-spec uses its own agents and validators for implementation, dispatch, and review.
430
-
431
- ### Implementation
432
-
433
- Implementers are dispatched via `dispatch-agents`:
434
- ```bash
435
- npx morph-spec dispatch-agents $ARGUMENTS implement
436
- ```
437
-
438
- Use the `subagentType` from each group in the Agent tool:
439
- ```
440
- Agent(subagent_type=<subagentType>, prompt=<filled prompts/implementer-prompt.md>)
441
- ```
442
-
443
- > The `subagentType` maps agent IDs to `.claude/agents/` filenames:
444
- > - Tier 1-3: `morph-{id}` (e.g., `morph-dotnet-senior`)
445
- > - Tier 4: `morph-validator-{id}` (e.g., `morph-validator-architecture-expert`)
446
-
447
- ### Review (Two-Stage)
448
-
449
- **Stage 1 — Spec Compliance (mandatory):**
450
- ```
451
- Agent(subagent_type=<validator subagentType>, prompt=<filled prompts/spec-reviewer-prompt.md>)
452
- ```
453
- Use validators from `dispatch-agents --mode validate`. Spec compliance MUST pass before proceeding.
454
-
455
- **Stage 2 — Code Quality (mandatory):**
456
- ```
457
- Agent(subagent_type=morph-standards-architect, prompt=<filled prompts/code-quality-reviewer-prompt.md>)
458
- ```
459
- `critical` issues block. `important` issues must be fixed. `suggestion` is optional.
460
-
461
- ### Prompt Templates
462
-
463
- | Template | Usage |
464
- |----------|-------|
465
- | `prompts/implementer-prompt.md` | Dispatch to implementer agents |
466
- | `prompts/spec-reviewer-prompt.md` | Spec compliance review |
467
- | `prompts/code-quality-reviewer-prompt.md` | Code quality review |
468
-
469
- ---
470
-
471
- ## Outputs
472
-
473
- - Implemented source code (various files)
474
- - Unit and integration tests
475
- - `.morph/features/$ARGUMENTS/5-implement/recap.md` — Implementation summary
476
-
477
- ## Completion Criteria
478
-
479
- - [x] All tasks completed
480
- - [x] Build compiles without errors
481
- - [x] Tests passing
482
- - [x] Validation pipeline passes
483
- - [x] `recap.md` generated
484
- - [x] State updated to `status: done`
485
- - [x] Checkpoints saved every 3 tasks
486
- - [x] `/post-implementation` executed without BLOCKs
487
-
488
- ---
489
-
490
- ## Phase Outputs
491
-
492
- <!-- morph-outputs:implement -->
493
- | Output | Path |
494
- |--------|------|
495
- | `recap` | `.morph/features/{feature}/5-implement/recap.md` |
496
- <!-- /morph-outputs -->
497
-
498
- ---
499
-
500
- Feature complete! Consider creating a PR and running `morph-spec generate recap $ARGUMENTS`.
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
+ context: fork
6
+ agent: general-purpose
7
+ user-invocable: false
8
+ cliVersion: "4.10.9"
9
+ allowed-tools: Read, Write, Edit, Bash, Glob, Grep, AskUserQuestion, Agent
10
+ ---
11
+
12
+ # MORPH Implement — Phase 5
13
+
14
+ > INTERNAL: Workflow skill used by /morph-apply during automated phase orchestration. Not a user command.
15
+
16
+ Implement the tasks defined in Phase 4, with checkpoints every 3 tasks and a final recap.
17
+
18
+ ## Prerequisites
19
+
20
+ - [ ] Phase 4 (Tasks) completed
21
+ - [ ] `tasks.md` approved by user
22
+ - [ ] Tasks gate approved (`morph-spec approve $ARGUMENTS tasks`)
23
+ - [ ] All design outputs exist (spec.md, contracts.cs/.ts, decisions.md)
24
+
25
+ ## Step 0: Ensure Implement Phase
26
+
27
+ **Before any reads or writes — verify the current phase:**
28
+
29
+ ```bash
30
+ npx morph-spec state get $ARGUMENTS
31
+ ```
32
+
33
+ Check the `"phase"` field:
34
+
35
+ **If `"phase": "implement"`** → correct phase, proceed.
36
+
37
+ **If `"phase": "tasks"`** → run in sequence:
38
+ 1. `npx morph-spec state mark-output $ARGUMENTS tasks`
39
+ 2. `npx morph-spec approve $ARGUMENTS tasks`
40
+ 3. `npx morph-spec phase advance $ARGUMENTS` (→ implement)
41
+
42
+ **Any other value** → STOP — inconsistent state, report to user.
43
+
44
+ > **Rule:** Never write to `5-implement/` until the phase is `implement`. The hook will block writes.
45
+
46
+ ---
47
+
48
+ ## Pre-flight Validation (MANDATORY)
49
+
50
+ Before any task work, validate that prior phases are truly complete. `state.json` may have been set manually — these commands verify actual filesystem artifacts.
51
+
52
+ ```bash
53
+ # 1. Verify mandatory outputs from all prior phases
54
+ npx morph-spec validate-feature $ARGUMENTS
55
+
56
+ # 2. Confirm all approval gates passed
57
+ npx morph-spec approval-status $ARGUMENTS
58
+
59
+ # 3. Verify activeAgents are populated
60
+ npx morph-spec state get $ARGUMENTS | grep -A5 activeAgents
61
+ ```
62
+
63
+ If any check fails → **STOP**. Do not start any task. Report what's missing:
64
+
65
+ | Problem | Resolution |
66
+ |---------|-----------|
67
+ | Missing output (spec.md, contracts, etc.) | Return to corresponding phase and generate it |
68
+ | Gate not approved (design, plan, tasks) | `npx morph-spec approve $ARGUMENTS <gate>` |
69
+ | Invalid phase | `npx morph-spec phase advance $ARGUMENTS` |
70
+ | Empty activeAgents | Run `/phase-setup $ARGUMENTS` first |
71
+
72
+ **This step is not optional.** Only proceed when all commands return without errors.
73
+
74
+ ---
75
+
76
+ ## Pre-flight MCP — Connection Validation
77
+
78
+ Before starting tasks, verify that MCPs needed for the implement phase are working.
79
+
80
+ **1. Collect MCPs for the implement phase:**
81
+ - Read `framework/skills/level-0-meta/mcp-registry.json` → `phaseMatrix.implement`
82
+ - Read `.claude/settings.local.json` → identify configured MCPs
83
+
84
+ **2. For each CONFIGURED MCP in `phaseMatrix.implement`:**
85
+ 1. Look for a tool matching `healthCheck.toolPattern`
86
+ 2. If found → run `healthCheck.testCall` with `healthCheck.testParams`
87
+ 3. Evaluate:
88
+
89
+ | Result | Action |
90
+ |--------|--------|
91
+ | **Success** | `✓ {MCP} — ready` |
92
+ | **Tool not found** | `○ {MCP} — needs restart` |
93
+ | **Error** | → **AskUserQuestion** (below) |
94
+
95
+ **On error — ask the user:**
96
+
97
+ Use `AskUserQuestion` with header `"{MCP}"` and options:
98
+ - **Continue without {MCP}** — Show `fallback` from registry. Implementation will use the fallback automatically.
99
+ - **Reconfigure credentials** — Collect credentials and update `.claude/settings.local.json`. Re-test after reconfiguring.
100
+ - **Stop implementation** — Abort. User must fix the MCP and re-run `/morph-apply`.
101
+
102
+ > **Design:** This check is fail-open — consistent with morph-spec philosophy. The user gets explicit choice instead of tasks failing silently.
103
+
104
+ ---
105
+
106
+ ## Recommended Tools
107
+
108
+ > **Ref:** `framework/skills/level-0-meta/morph-tool-usage-guide/SKILL.md` for complete guide.
109
+ > **Ref:** `framework/standards/integration/mcp/mcp-tools.md` for MCP reference.
110
+ > **Example:** `references/recap-example.md` — filled-in recap.md showing expected output quality.
111
+
112
+ | Action | Tool | Alternative |
113
+ |--------|------|-------------|
114
+ | Check execution mode (single/subagents/agent-teams) | **Bash** `npx morph-spec dispatch-agents $ARGUMENTS implement` | Task groups + subagent prompts |
115
+ | **Dispatch implementers by domain** (subagents) | **Agent** `subagent_type=<taskGroups[group].subagentType>` + `prompt=taskPrompt` from dispatch config | Backend + frontend + infra in parallel |
116
+ | **Create Agent Team** (critical multi-domain features) | Natural language — see Step 0.5b | — |
117
+ | Read task details | **Read** tasks.md, spec.md, contracts.cs/.ts | — |
118
+ | Create new files | **Write** source files | — |
119
+ | Modify existing files | **Edit** source files | — |
120
+ | Look up library API | **Context7 MCP** `query_docs()` | **WebSearch** + **WebFetch** |
121
+ | Run migrations | **Supabase MCP** `query()` | **Bash** `npx supabase migration ...` |
122
+ | Build project | **Bash** `dotnet build` or `npm run build` | — |
123
+ | Run tests | **Bash** `dotnet test` or `npm test` | — |
124
+ | Checkpoint validation | **Bash** `npx morph-spec validate-feature ...` | — |
125
+ | Mark task complete | **Bash** `npx morph-spec task done $ARGUMENTS T001` | — |
126
+ | Smoke test in browser | **Playwright MCP** `browser_navigate()` + `browser_snapshot()` | Manual |
127
+ | Check console errors | **Playwright MCP** `browser_console_messages()` | — |
128
+ | Screenshot for recap | **Playwright MCP** `browser_take_screenshot()` | — |
129
+ | Deploy and logs Vercel | **Vercel MCP** `list_projects()`, `get_deployments()`, `manage_env_vars()` | **Bash** `vercel deploy` |
130
+ | Create PR | **Bash** `gh pr create ...` | **GitHub MCP** `create_pull_request()` |
131
+ | Update state | **Bash** `npx morph-spec state set ...` | — |
132
+
133
+ **Phase MCPs:** Supabase (migrations, RLS), Context7 (API lookup), Playwright (smoke test), GitHub (PRs), Vercel (deploy, logs, env vars).
134
+
135
+ **Anti-patterns:**
136
+ - Task agent for editing a single file (use Edit directly)
137
+ - Agent Teams for single-domain features (subagents suffice)
138
+ - Agent Teams without plan approval (creates risk of divergent implementations)
139
+ - `Bash cat` to create files (use Write tool)
140
+ - `Bash sed` to modify code (use Edit tool)
141
+ - Implementing without reading contracts.cs/.ts first (contracts are the source of truth!)
142
+ - Running backend and frontend tasks sequentially when they are independent
143
+ - **(VSA)** Creating Application Service layer — handler accesses IRepository directly
144
+ - **(VSA)** Manually registering handlers/endpoints in Program.cs — use auto-discovery via reflection
145
+ - **(VSA)** Placing Request/Response in separate files from Handler
146
+ - **(VSA)** Using `Guid.NewGuid()` — use `Guid.CreateVersion7()`
147
+ - Trying to fix a bug without invoking `systematic-debugging` first
148
+
149
+ ---
150
+
151
+ ## Context Loading
152
+
153
+ ### 1. Read full context in PARALLEL
154
+
155
+ ```
156
+ # Single parallel call, not sequential:
157
+ Read: .morph/features/{feature}/4-tasks/tasks.md
158
+ + Read: .morph/features/{feature}/1-design/spec.md
159
+ + Read: .morph/features/{feature}/1-design/contracts.cs (or contracts.ts for TypeScript projects)
160
+ + Read: .morph/config/config.json (→ architecture.style)
161
+ + Read: .morph/features/{feature}/3-plan/plan.md
162
+ ```
163
+
164
+ ### 2. Create native tasks for each T001-T00N
165
+
166
+ Create one native task per task found in `tasks.md`, mirroring `tasks.md` exactly:
167
+
168
+ ```
169
+ # one native task per task found — loop over every T001-T00N:
170
+ TaskCreate: "T001: {title}"
171
+ → description: "{full task description from tasks.md}"
172
+ → activeForm: "Implementing T001"
173
+
174
+ TaskCreate: "T002: {title}"
175
+ → activeForm: "Implementing T002"
176
+
177
+ # ... repeat for each task ...
178
+
179
+ # Orchestral tasks (always at the end):
180
+ TaskCreate: "Checkpoints and validation" → activeForm: "Validating checkpoint"
181
+ TaskCreate: "Generate recap.md" → activeForm: "Generating recap"
182
+ ```
183
+
184
+ **After creating all tasks, wire up dependencies using `addBlockedBy`**, mirroring `tasks.md` dependency fields:
185
+
186
+ ```
187
+ # For each task with dependencies (e.g., T003 depends on T001, T002):
188
+ TaskUpdate: taskId="{T003 native id}" addBlockedBy=["{T001 native id}", "{T002 native id}"]
189
+ ```
190
+
191
+ > Map T-codes to native task IDs as you create them (keep a local `{ T001: id, T002: id, ... }` map).
192
+
193
+ ### 3. Detect architecture style
194
+
195
+ ```bash
196
+ cat .morph/config/config.json | grep architecture
197
+ ```
198
+
199
+ If `config.architecture.style === "vertical-slice"` → follow **Step 1.5** before implementing.
200
+ Otherwise → go directly to the task loop.
201
+
202
+ ### Step 1.5: VSA Implementation Guide (only if `style: "vertical-slice"`)
203
+
204
+ > For the complete slice structure and VSA rules, see `references/vsa-implementation-guide.md`
205
+
206
+ 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.
207
+
208
+ ---
209
+
210
+ ## Workflow
211
+
212
+ ### Step 0.5: Plan Execution Mode
213
+
214
+ **Read the plan's execution strategy:**
215
+ ```
216
+ Read: .morph/features/{feature}/3-plan/plan.md → extract "Execution Strategy" field
217
+ ```
218
+
219
+ The strategy was defined and approved in the Plan phase. Use it directly:
220
+
221
+ | Strategy | Action |
222
+ |----------|--------|
223
+ | `"single"` | → Continue to the sequential task loop (Step 2) |
224
+ | `"subagents"` | → Dispatch Task subagents in parallel (below) |
225
+ | `"agent-teams"` | → Create Agent Team with plan approval (Step 0.5b) |
226
+
227
+ If `plan.md` doesn't exist or the field is missing, auto-detect via dispatch-agents:
228
+
229
+ ```bash
230
+ npx morph-spec dispatch-agents $ARGUMENTS implement
231
+ ```
232
+
233
+ Check the `mode` field in the JSON output to determine the execution strategy.
234
+
235
+ ---
236
+
237
+ #### Subagents Mode (if strategy is `"subagents"`):
238
+
239
+ **Step 0.5a: Get dispatch config:**
240
+
241
+ ```bash
242
+ npx morph-spec dispatch-agents $ARGUMENTS implement
243
+ ```
244
+
245
+ Parse the JSON output. Extract `taskGroups` and each group's `subagentType`.
246
+
247
+ **Step 0.5b: Verify agent files exist:**
248
+
249
+ For each group, verify `.claude/agents/{subagentType}.md` exists:
250
+
251
+ ```bash
252
+ ls .claude/agents/{subagentType}.md
253
+ ```
254
+
255
+ If missing → **STOP** with: `"Agent file .claude/agents/{subagentType}.md not found. Run: npx morph-spec setup-infra"`. Do NOT fall back to general-purpose agents for missing files.
256
+
257
+ **Step 0.5c: Dispatch subagents:**
258
+
259
+ 1. For each group with >= 3 tasks and no cross-group dependencies, use **Agent tool** with `subagent_type` from dispatch config:
260
+
261
+ > **Mapping:** `taskGroups[group].subagentType` = `subagent_type` in Agent tool.
262
+ > Example: `subagentType: "morph-dotnet-senior"` → `Agent(subagent_type="morph-dotnet-senior", prompt=taskPrompt)`.
263
+ >
264
+ > **MANDATORY:** Use the exact `subagentType` value. Do NOT use `general-purpose` agents when a `subagentType` is available.
265
+
266
+ Each subagent receives a prompt with:
267
+ - Full spec.md and contracts.cs/.ts content
268
+ - The group's task list
269
+ - Instructions to create native tasks, follow the task loop (start → implement → verify → done), checkpoint every 3 tasks
270
+ - Domain isolation: modify ONLY files in their domain
271
+ - **MANDATORY verification before every `task done`** (see Step 2, item 6b)
272
+
273
+ 2. Dispatch subagents for groups in **parallel** (when no cross-group dependencies)
274
+ 3. After all complete, validate integration: `npx morph-spec validate-feature $ARGUMENTS --phase implement`
275
+
276
+ **Fallback:** If `dispatch-agents` fails (non-zero exit or invalid JSON), log a warning and fall back to sequential single-agent mode (Step 2).
277
+
278
+ **If strategy is `"single"`** → continue to sequential task loop below.
279
+
280
+ ---
281
+
282
+ #### Step 0.5b: Agent Teams (critical multi-domain features)
283
+
284
+ **When:** strategy is `"agent-teams"`
285
+ **Requirement:** `CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1` in `.claude/settings.local.json`
286
+
287
+ **Why Agent Teams over subagents:**
288
+ 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.
289
+
290
+ Create the team with natural language specifying:
291
+ - Backend teammate (dotnet-senior): backend/domain/application files only
292
+ - Frontend teammate (blazor-builder or nextjs-expert): UI/components/pages files only
293
+ - Quality teammate (standards-architect): review + validate-feature after each implementation
294
+ - Enable **plan approval**: teammates must get plans approved before implementing
295
+ - Gate: only approve plans matching contracts.cs/.ts and spec.md
296
+
297
+ After all teammates complete: `npx morph-spec validate-feature $ARGUMENTS --phase implement`
298
+
299
+ ---
300
+
301
+ ### Step 2: Task Loop
302
+
303
+ ```bash
304
+ npx morph-spec task next $ARGUMENTS
305
+ ```
306
+
307
+ For each task (T001 → T00N):
308
+
309
+ 1. **Mark as in-progress (native task):**
310
+ ```
311
+ TaskUpdate(taskId="<native id>", status="in_progress")
312
+ ```
313
+ 2. **Start via CLI:**
314
+ ```bash
315
+ npx morph-spec task start $ARGUMENTS T001
316
+ ```
317
+ 3. **Read the task description** + contracts.cs/.ts for relevant DTOs/interfaces
318
+ 4. **Implement** using Write (new) or Edit (existing)
319
+ 5. **Verify** — build, lint, tests
320
+ 6. **MANDATORY — Verification before `task done`:**
321
+ 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.
322
+ ```bash
323
+ npx morph-spec validate-feature $ARGUMENTS --phase implement
324
+ ```
325
+ Only proceed to step 7 if verification passes. If it fails → fix before marking `task done`.
326
+ 7. **Mark as done via CLI:**
327
+ ```bash
328
+ npx morph-spec task done $ARGUMENTS T001
329
+ ```
330
+ 8. **If `task done` returns without error, update group task progress:**
331
+ - Increment completed count for the task's group
332
+ - `TaskUpdate(groupTaskId, subject="{Group} tasks ({first}-{last}) — {completed}/{total}")`
333
+ - If all tasks in the group are done: `TaskUpdate(groupTaskId, status="completed")`
334
+ > Progress update only happens if `task done` returns without error (validation passed).
335
+
336
+ ### Step 3: Checkpoint Every 3 Tasks
337
+
338
+ **After every 3 completed tasks:**
339
+
340
+ ```bash
341
+ # Save checkpoint
342
+ npx morph-spec checkpoint-save $ARGUMENTS
343
+
344
+ # Run validation
345
+ npx morph-spec validate-feature $ARGUMENTS --phase implement
346
+ ```
347
+
348
+ **If validation fails:**
349
+ 1. Do NOT advance to the next task
350
+ 2. Fix reported issues
351
+ 3. Re-run validation
352
+ 4. Only then proceed
353
+
354
+ ### Step 4: Test-Driven Development (Recommended)
355
+
356
+ For each implementation task:
357
+
358
+ 1. **Write test first** (unit test for service/domain)
359
+ 2. **Run test** — should fail (RED)
360
+ 3. **Implement** the minimum to pass
361
+ 4. **Run test** — should pass (GREEN)
362
+ 5. **Refactor** if needed (REFACTOR)
363
+
364
+ ```bash
365
+ # .NET
366
+ dotnet test --filter "FullyQualifiedName~{TestClass}"
367
+
368
+ # Node.js
369
+ npm test -- test/path/to/test.js
370
+ ```
371
+
372
+ ### Step 5: Smoke Test with Playwright (if UI)
373
+
374
+ After implementing visual components:
375
+
376
+ ```javascript
377
+ // Navigate to the page
378
+ await mcp__playwright__browser_navigate({ url: 'http://localhost:5000/feature-page' });
379
+
380
+ // Capture page state
381
+ await mcp__playwright__browser_snapshot();
382
+
383
+ // Check console errors
384
+ await mcp__playwright__browser_console_messages({ level: 'error' });
385
+
386
+ // Screenshot for recap
387
+ await mcp__playwright__browser_take_screenshot({ type: 'png' });
388
+ ```
389
+
390
+ ### Step 6: Generate `recap.md`
391
+
392
+ After ALL tasks completed:
393
+
394
+ ```bash
395
+ npx morph-spec generate recap $ARGUMENTS
396
+ ```
397
+
398
+ > For the full recap format, see `references/recap-example.md`
399
+
400
+ ### Step 7: Update State
401
+
402
+ ```bash
403
+ npx morph-spec state set $ARGUMENTS status done
404
+ npx morph-spec state mark-output $ARGUMENTS recap
405
+ ```
406
+
407
+ ### Step 8: Post-Implementation Review (mandatory before PR)
408
+
409
+ ```bash
410
+ /post-implementation $ARGUMENTS
411
+ ```
412
+
413
+ Run the `post-implementation` skill before creating the PR. It orchestrates:
414
+ - Automated scans (CRITICAL findings block PR)
415
+ - Full test suite
416
+ - Final `validate-feature`
417
+ - Smoke test via Playwright (mandatory if dev server active)
418
+ - Code review checklist (CRITICAL + HIGH)
419
+ - **`morph-checklist`** — compliance (security, SEO, performance, accessibility, LGPD)
420
+ - Checkpoint + final recap
421
+
422
+ ### Step 9: Frontend Review (NEXTJS/FULLSTACK)
423
+
424
+ If stack is NEXTJS or FULLSTACK:
425
+
426
+ ```bash
427
+ /frontend-review $ARGUMENTS
428
+ ```
429
+
430
+ Complements `post-implementation` with: accessibility scan (static + axe-core runtime),
431
+ responsive screenshots (mobile/tablet/desktop), and SEO metadata verification.
432
+
433
+ ---
434
+
435
+ ## Morph-Native Dispatch
436
+
437
+ morph-spec uses its own agents and validators for implementation, dispatch, and review.
438
+
439
+ ### Implementation
440
+
441
+ Implementers are dispatched via `dispatch-agents`:
442
+ ```bash
443
+ npx morph-spec dispatch-agents $ARGUMENTS implement
444
+ ```
445
+
446
+ Use the `subagentType` from each group in the Agent tool:
447
+ ```
448
+ Agent(subagent_type=<subagentType>, prompt=<filled prompts/implementer-prompt.md>)
449
+ ```
450
+
451
+ > The `subagentType` maps agent IDs to `.claude/agents/` filenames:
452
+ > - Tier 1-3: `morph-{id}` (e.g., `morph-dotnet-senior`)
453
+ > - Tier 4: `morph-validator-{id}` (e.g., `morph-validator-architecture-expert`)
454
+
455
+ ### Review (Two-Stage)
456
+
457
+ **Stage 1 — Spec Compliance (mandatory):**
458
+ ```
459
+ Agent(subagent_type=<validator subagentType>, prompt=<filled prompts/spec-reviewer-prompt.md>)
460
+ ```
461
+ Use validators from `dispatch-agents --mode validate`. Spec compliance MUST pass before proceeding.
462
+
463
+ **Stage 2 — Code Quality (mandatory):**
464
+ ```
465
+ Agent(subagent_type=morph-standards-architect, prompt=<filled prompts/code-quality-reviewer-prompt.md>)
466
+ ```
467
+ `critical` issues block. `important` issues must be fixed. `suggestion` is optional.
468
+
469
+ ### Prompt Templates
470
+
471
+ | Template | Usage |
472
+ |----------|-------|
473
+ | `prompts/implementer-prompt.md` | Dispatch to implementer agents |
474
+ | `prompts/spec-reviewer-prompt.md` | Spec compliance review |
475
+ | `prompts/code-quality-reviewer-prompt.md` | Code quality review |
476
+
477
+ ---
478
+
479
+ ## Outputs
480
+
481
+ - Implemented source code (various files)
482
+ - Unit and integration tests
483
+ - `.morph/features/$ARGUMENTS/5-implement/recap.md` — Implementation summary
484
+
485
+ ## Completion Criteria
486
+
487
+ - [x] All tasks completed
488
+ - [x] Build compiles without errors
489
+ - [x] Tests passing
490
+ - [x] Validation pipeline passes
491
+ - [x] `recap.md` generated
492
+ - [x] State updated to `status: done`
493
+ - [x] Checkpoints saved every 3 tasks
494
+ - [x] `/post-implementation` executed without BLOCKs
495
+
496
+ ---
497
+
498
+ ## Phase Outputs
499
+
500
+ <!-- morph-outputs:implement -->
501
+ | Output | Caminho |
502
+ |--------|---------|
503
+ | `recap` | `.morph/features/{feature}/5-implement/recap.md` |
504
+ <!-- /morph-outputs -->
505
+
506
+ ---
507
+
508
+ Feature complete! Consider creating a PR and running `morph-spec generate recap $ARGUMENTS`.