@polymorphism-tech/morph-spec 4.10.7 → 4.10.8
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.
- package/CLAUDE.md +3 -3
- package/LICENSE +71 -71
- package/README.md +379 -379
- package/bin/morph-spec.js +1 -1
- package/claude-plugin.json +14 -14
- package/docs/CHEATSHEET.md +1 -1
- package/docs/QUICKSTART.md +206 -206
- package/framework/agents/README.md +14 -14
- package/framework/agents/architecture/standards-architect.md +159 -159
- package/framework/agents/frontend/blazor-builder.md +13 -0
- package/framework/agents/frontend/css-specialist.md +87 -0
- package/framework/agents/frontend/nextjs-expert.md +13 -0
- package/framework/agents/frontend/nextjs-ui-specialist.md +218 -0
- package/framework/agents/frontend/ui-ux-designer.md +80 -10
- package/framework/agents/infrastructure/azure-architect.md +149 -149
- package/framework/agents/infrastructure/infra-architect.md +48 -48
- package/framework/agents.json +2268 -2204
- package/framework/hooks/README.md +204 -204
- package/framework/hooks/claude-code/session-start/inject-morph-context.js +10 -24
- package/framework/hooks/shared/phase-utils.js +139 -139
- package/framework/hooks/shared/worktree-helpers.js +30 -8
- package/framework/rules/csharp-standards.md +13 -13
- package/framework/rules/frontend-standards.md +13 -13
- package/framework/rules/infrastructure-standards.md +16 -16
- package/framework/rules/testing-standards.md +14 -14
- package/framework/skills/level-0-meta/morph-brainstorming/SKILL.md +12 -0
- package/framework/skills/level-0-meta/morph-code-review-nextjs/references/review-example-nextjs.md +254 -254
- package/framework/skills/level-0-meta/morph-init/SKILL.md +88 -3
- package/framework/skills/level-1-workflows/morph-phase-clarify/SKILL.md +247 -247
- package/framework/skills/level-1-workflows/morph-phase-codebase-analysis/SKILL.md +270 -270
- package/framework/skills/level-1-workflows/morph-phase-design/SKILL.md +515 -499
- package/framework/skills/level-1-workflows/morph-phase-implement/SKILL.md +508 -500
- package/framework/skills/level-1-workflows/morph-phase-plan/SKILL.md +12 -1
- package/framework/skills/level-1-workflows/morph-phase-setup/SKILL.md +272 -262
- package/framework/skills/level-1-workflows/morph-phase-tasks/SKILL.md +317 -311
- package/framework/skills/level-1-workflows/morph-phase-uiux/SKILL.md +424 -323
- package/framework/skills/level-1-workflows/morph-scope-escalation/SKILL.md +1 -1
- package/framework/standards/STANDARDS.json +2040 -2040
- package/framework/standards/frontend/nextjs/motion-patterns.md +321 -0
- package/framework/standards/frontend/nextjs/nextjs-patterns.md +17 -17
- package/framework/templates/README.md +814 -814
- package/framework/templates/code/dotnet/contracts/Commands.cs +74 -74
- package/framework/templates/code/dotnet/contracts/Entities.cs +25 -25
- package/framework/templates/code/dotnet/contracts/Queries.cs +74 -74
- package/framework/templates/code/dotnet/contracts/README.md +74 -74
- package/framework/templates/code/dotnet/contracts/api-contracts.cs +173 -173
- package/framework/templates/code/dotnet/frontend/component.razor +239 -239
- package/framework/templates/code/dotnet/jobs/agent.cs +163 -163
- package/framework/templates/code/dotnet/jobs/job.cs +171 -171
- package/framework/templates/code/dotnet/test.cs +239 -239
- package/framework/templates/code/sql/rls-policy.sql +57 -57
- package/framework/templates/code/sql/supabase-migration.sql +100 -100
- package/framework/templates/code/sql/supabase-migration.template.sql +113 -113
- package/framework/templates/code/typescript/contracts.ts +168 -168
- package/framework/templates/context/CONTEXT.md +181 -181
- package/framework/templates/context/design-system.md +211 -0
- package/framework/templates/docs/proposal.md +182 -182
- package/framework/templates/docs/user-stories.md +34 -34
- package/framework/templates/examples/design-system-examples.md +357 -357
- package/framework/templates/examples/spec-examples.md +90 -90
- package/framework/templates/feature/decisions.md +187 -187
- package/framework/templates/feature/recap.md +146 -146
- package/framework/templates/feature/tasks.md +199 -199
- package/framework/templates/infrastructure/azure/README.md +286 -286
- package/framework/templates/infrastructure/azure/deploy-checklist.md +426 -426
- package/framework/templates/infrastructure/azure/parameters.dev.json +29 -29
- package/framework/templates/infrastructure/azure/parameters.prod.json +29 -29
- package/framework/templates/infrastructure/azure/parameters.staging.json +29 -29
- package/framework/templates/infrastructure/docker/docker-compose.template.yml +67 -67
- package/framework/templates/infrastructure/docker/dockerfile-api.dockerfile +38 -38
- package/framework/templates/infrastructure/docker/dockerfile-web.dockerfile +48 -48
- package/framework/templates/infrastructure/docker/easypanel.template.json +54 -54
- package/package.json +82 -82
- package/src/commands/agents/index.js +13 -13
- package/src/commands/project/install-plugin-cmd.js +28 -28
- package/src/commands/project/setup-infra-cmd.js +12 -12
- package/src/commands/project/worktree.js +58 -2
- package/src/commands/tasks/index.js +4 -4
- package/src/commands/templates/index.js +5 -5
- package/src/commands/utils/index.js +3 -3
- package/src/commands/validation/index.js +4 -4
- package/src/core/state/phase-state-machine.js +217 -217
- package/src/lib/generators/design-system-generator.js +298 -298
- package/src/lib/generators/index.js +10 -10
- package/src/lib/generators/metadata-extractor.js +387 -387
- package/src/lib/stack-filter.js +65 -65
- package/src/lib/standards/index.js +7 -7
- package/src/lib/standards/standards-context-injector.js +302 -302
- package/src/lib/validators/architecture/architecture-validator.js +387 -387
- package/src/lib/validators/architecture/index.js +7 -7
- package/src/lib/validators/blazor/blazor-concurrency-analyzer.js +316 -316
- package/src/lib/validators/blazor/blazor-state-validator.js +279 -279
- package/src/lib/validators/blazor/blazor-validator.js +369 -369
- package/src/lib/validators/blazor/index.js +9 -9
- package/src/lib/validators/content/content-validator.js +287 -287
- package/src/lib/validators/content/index.js +7 -7
- package/src/lib/validators/contracts/index.js +7 -7
- package/src/lib/validators/css/css-validator.js +352 -352
- package/src/lib/validators/css/index.js +7 -7
- package/src/lib/validators/design-system/design-system-validator.js +231 -231
- package/src/lib/validators/design-system/index.js +7 -7
- package/src/lib/validators/nextjs/index.js +6 -6
- package/src/lib/validators/nextjs/next-component-validator.js +183 -183
- package/src/lib/validators/packages/index.js +7 -7
- package/src/lib/validators/packages/package-validator.js +360 -360
- package/src/lib/validators/shared/index.js +12 -12
- package/src/lib/validators/shared/issue-counter.js +18 -18
- package/src/lib/validators/shared/result-formatter.js +124 -124
- package/src/lib/validators/ui/index.js +7 -7
- package/src/lib/validators/ui/ui-contrast-validator.js +422 -422
- package/src/scripts/global-install.js +58 -58
- package/src/scripts/install-plugin.js +126 -126
- package/src/utils/claude-md-injector.js +90 -90
- package/src/utils/file-copier.js +200 -196
- package/src/utils/hooks-installer.js +556 -494
- package/src/utils/logger.js +32 -32
- package/src/utils/skills-installer.js +178 -178
- package/src/utils/version-checker.js +175 -175
- package/framework/skills/level-1-workflows/morph-phase-implement/.morph/logs/activity.json +0 -38
- package/framework/skills/level-1-workflows/morph-phase-tasks/.morph/logs/activity.json +0 -14
- package/framework/templates/.idea/morph-templates.xml +0 -92
- 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.
|
|
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
|
-
|
|
167
|
-
|
|
168
|
-
```
|
|
169
|
-
#
|
|
170
|
-
TaskCreate: "
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
**Step 0.
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
```
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
**
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
```bash
|
|
315
|
-
npx morph-spec
|
|
316
|
-
```
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
**
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
```
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
```bash
|
|
395
|
-
npx morph-spec
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
```
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
-
|
|
474
|
-
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
-
|
|
482
|
-
-
|
|
483
|
-
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
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.8"
|
|
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`.
|