@polymorphism-tech/morph-spec 4.22.0 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (211) hide show
  1. package/CLAUDE.md +57 -71
  2. package/README.md +2 -2
  3. package/bin/morph-spec.js +224 -491
  4. package/claude-plugin.json +1 -1
  5. package/docs/CHEATSHEET.md +1 -1
  6. package/docs/QUICKSTART.md +1 -1
  7. package/framework/CLAUDE.md +55 -38
  8. package/framework/MORPH.md +244 -0
  9. package/framework/agents.json +127 -1198
  10. package/framework/commands/morph-apply.md +56 -240
  11. package/framework/commands/morph-archive.md +48 -85
  12. package/framework/commands/morph-preflight.md +7 -7
  13. package/framework/commands/morph-proposal.md +35 -191
  14. package/framework/commands/morph-status.md +19 -50
  15. package/framework/commands/morph-troubleshoot.md +2 -2
  16. package/framework/evals/rubrics/README.md +44 -0
  17. package/framework/evals/rubrics/architecture.md +46 -0
  18. package/framework/evals/rubrics/code-quality.md +50 -0
  19. package/framework/evals/rubrics/contracts.md +47 -0
  20. package/framework/evals/rubrics/test-coverage.md +50 -0
  21. package/framework/evals/scenarios/dotnet-crud.yaml +42 -0
  22. package/framework/evals/scenarios/nextjs-auth.yaml +38 -0
  23. package/framework/evals/suites/standard.yaml +5 -0
  24. package/framework/evals/trace-schema.md +67 -0
  25. package/framework/hooks/claude-code/core/README.md +3 -0
  26. package/framework/hooks/claude-code/core/denylist.json +14 -0
  27. package/framework/hooks/claude-code/{pre-tool-use → core}/enforce-phase-writes.js +5 -5
  28. package/framework/hooks/claude-code/core/post-edit-typecheck.js +69 -0
  29. package/framework/hooks/claude-code/core/pre-bash-denylist.js +29 -0
  30. package/framework/hooks/claude-code/{pre-tool-use → core}/protect-spec-files.js +4 -6
  31. package/framework/hooks/claude-code/{stop → core}/validate-completion.js +13 -82
  32. package/framework/hooks/shared/phase-utils.js +20 -31
  33. package/framework/hooks/shared/state-reader.js +4 -5
  34. package/framework/{skills/level-0-meta/mcp-registry.json → mcp/registry.json} +254 -243
  35. package/framework/phases.json +41 -115
  36. package/framework/rubrics/eval-rubric.json +66 -0
  37. package/framework/skills/README.md +39 -64
  38. package/framework/skills/core/README.md +3 -0
  39. package/framework/skills/core/morph-brainstorming/SKILL.md +102 -0
  40. package/framework/skills/core/morph-eval/SKILL.md +57 -0
  41. package/framework/skills/core/morph-implement/SKILL.md +83 -0
  42. package/framework/skills/core/morph-plan/SKILL.md +64 -0
  43. package/framework/skills/core/morph-review/SKILL.md +62 -0
  44. package/framework/skills/core/morph-stack-scan/SKILL.md +109 -0
  45. package/framework/skills/core/morph-standards/SKILL.md +49 -0
  46. package/framework/templates/CLAUDE.md.core.guide.md +29 -0
  47. package/framework/templates/CLAUDE.md.core.template +22 -0
  48. package/framework/templates/REGISTRY.json +4 -4
  49. package/framework/workflows/configs/fast-track.json +5 -10
  50. package/framework/workflows/configs/full.json +4 -8
  51. package/framework/workflows/configs/quick.json +32 -0
  52. package/framework/workflows/configs/standard.json +57 -64
  53. package/package.json +7 -6
  54. package/src/commands/mcp/mcp-setup.js +58 -31
  55. package/src/commands/project/doctor.js +69 -70
  56. package/src/commands/project/init.js +26 -5
  57. package/src/commands/project/status.js +18 -19
  58. package/src/commands/state/approve.js +1 -1
  59. package/src/commands/validation/validate-feature.js +18 -112
  60. package/src/core/paths/output-schema.js +133 -152
  61. package/src/core/state/phase-state-machine.js +10 -24
  62. package/src/core/state/state-manager.js +17 -17
  63. package/src/core/workflows/workflow-detector.js +214 -31
  64. package/src/core/workflows/workflow-router.js +204 -0
  65. package/src/dashboard/app/pages/AgentMap.jsx +32 -33
  66. package/src/dashboard/app/pages/LiveState.jsx +1 -1
  67. package/src/dashboard/app/pages/PhasePipeline.jsx +2 -4
  68. package/src/dashboard/app/pages/SkillsLibrary.jsx +2 -3
  69. package/src/dashboard/app/pages/Workflows.jsx +2 -2
  70. package/src/dashboard/scanner/agents-scanner.js +30 -35
  71. package/src/lib/agents/metrics-aggregator.js +1 -1
  72. package/src/lib/agents/output-collector.js +7 -9
  73. package/src/lib/context/context-builder.js +289 -0
  74. package/src/lib/detectors/claude-config-detector.js +19 -3
  75. package/src/lib/generators/context-generator.js +20 -42
  76. package/src/lib/generators/index.js +1 -0
  77. package/src/lib/generators/mandate-generator.js +512 -0
  78. package/src/lib/generators/metadata-extractor.js +1 -1
  79. package/src/lib/generators/recap-generator.js +3 -4
  80. package/src/lib/installers/mcp-installer.js +300 -92
  81. package/src/lib/phase-chain/phase-validator.js +36 -40
  82. package/src/lib/stack/stack-profile.js +74 -91
  83. package/src/lib/tasks/task-parser.js +1 -1
  84. package/src/lib/tasks/wave-resolver.js +353 -0
  85. package/src/lib/validators/checkpoint-persistence.js +2 -2
  86. package/src/lib/validators/content/cross-phase-validator.js +281 -0
  87. package/src/lib/validators/content/index.js +1 -0
  88. package/src/lib/validators/shared/emit-validator-dispatch.js +6 -56
  89. package/src/scripts/global-install.js +2 -27
  90. package/src/utils/agents-installer.js +224 -447
  91. package/src/utils/claude-settings-manager.js +57 -15
  92. package/src/utils/file-copier.js +1 -0
  93. package/src/utils/hooks-installer.js +15 -117
  94. package/src/utils/skills-installer.js +12 -18
  95. package/bin/detect-agents.js +0 -226
  96. package/bin/task-manager.js +0 -1036
  97. package/framework/agents/README.md +0 -13
  98. package/framework/agents/ai-agents/ai-system-architect.md +0 -194
  99. package/framework/agents/ai-agents/vector-search-expert.md +0 -247
  100. package/framework/agents/architecture/architecture-expert.md +0 -98
  101. package/framework/agents/architecture/morph-spec-architect.md +0 -66
  102. package/framework/agents/architecture/packages-validator.md +0 -89
  103. package/framework/agents/architecture/security-expert.md +0 -79
  104. package/framework/agents/architecture/seo-growth-hacker.md +0 -168
  105. package/framework/agents/architecture/standards-architect.md +0 -153
  106. package/framework/agents/backend/dotnet-senior.md +0 -163
  107. package/framework/agents/backend/ef-modeler.md +0 -119
  108. package/framework/agents/backend/hangfire-orchestrator.md +0 -133
  109. package/framework/agents/backend/ms-agent-expert.md +0 -55
  110. package/framework/agents/backend/neon-expert.md +0 -379
  111. package/framework/agents/frontend/css-specialist.md +0 -89
  112. package/framework/agents/frontend/design-system-validator.md +0 -100
  113. package/framework/agents/frontend/gsap-animator.md +0 -131
  114. package/framework/agents/frontend/nextjs-component-validator.md +0 -97
  115. package/framework/agents/frontend/nextjs-expert.md +0 -201
  116. package/framework/agents/frontend/ui-designer.md +0 -259
  117. package/framework/agents/infrastructure/infra-architect.md +0 -215
  118. package/framework/agents/integrations/asaas-financial.md +0 -138
  119. package/framework/agents/integrations/neon-auth.md +0 -151
  120. package/framework/agents/integrations/resend-email.md +0 -127
  121. package/framework/hooks/claude-code/post-tool-use/agent-complete.js +0 -122
  122. package/framework/hooks/claude-code/post-tool-use/dispatch.js +0 -363
  123. package/framework/hooks/claude-code/post-tool-use/handle-tool-failure.js +0 -78
  124. package/framework/hooks/claude-code/post-tool-use/validator-feedback.js +0 -194
  125. package/framework/hooks/claude-code/pre-compact/save-morph-context.js +0 -199
  126. package/framework/hooks/claude-code/pre-tool-use/task-tracking-guard.js +0 -55
  127. package/framework/hooks/claude-code/session-start/inject-morph-context.js +0 -323
  128. package/framework/hooks/claude-code/session-start/post-compact-restore.js +0 -41
  129. package/framework/hooks/claude-code/session-start/resume-context.js +0 -77
  130. package/framework/hooks/claude-code/teammate-idle/teammate-idle.js +0 -90
  131. package/framework/hooks/claude-code/user-prompt/enrich-prompt.js +0 -114
  132. package/framework/hooks/shared/compact-restore.js +0 -123
  133. package/framework/hooks/shared/dispatch-helpers.js +0 -147
  134. package/framework/hooks/shared/skill-reminder-helpers.js +0 -79
  135. package/framework/hooks/shared/stale-task-reset.js +0 -57
  136. package/framework/hooks/shared/worktree-helpers.js +0 -75
  137. package/framework/skills/level-0-meta/README.md +0 -7
  138. package/framework/skills/level-0-meta/morph-agent-teams/SKILL.md +0 -472
  139. package/framework/skills/level-0-meta/morph-brainstorming/SKILL.md +0 -174
  140. package/framework/skills/level-0-meta/morph-brainstorming/references/proposal-example.md +0 -138
  141. package/framework/skills/level-0-meta/morph-checklist/SKILL.md +0 -145
  142. package/framework/skills/level-0-meta/morph-code-review/SKILL.md +0 -250
  143. package/framework/skills/level-0-meta/morph-code-review/references/review-example.md +0 -164
  144. package/framework/skills/level-0-meta/morph-code-review/references/review-guidelines.md +0 -100
  145. package/framework/skills/level-0-meta/morph-code-review/scripts/scan-csharp.mjs +0 -151
  146. package/framework/skills/level-0-meta/morph-code-review-nextjs/SKILL.md +0 -165
  147. package/framework/skills/level-0-meta/morph-code-review-nextjs/references/review-example-nextjs.md +0 -254
  148. package/framework/skills/level-0-meta/morph-code-review-nextjs/scripts/scan-nextjs.mjs +0 -189
  149. package/framework/skills/level-0-meta/morph-frontend-review/SKILL.md +0 -344
  150. package/framework/skills/level-0-meta/morph-frontend-review/scripts/scan-accessibility.mjs +0 -376
  151. package/framework/skills/level-0-meta/morph-gemini-image/SKILL.md +0 -290
  152. package/framework/skills/level-0-meta/morph-init/SKILL.md +0 -537
  153. package/framework/skills/level-0-meta/morph-parallel-dispatch/SKILL.md +0 -225
  154. package/framework/skills/level-0-meta/morph-post-implementation/SKILL.md +0 -401
  155. package/framework/skills/level-0-meta/morph-post-implementation/scripts/detect-dev-server.mjs +0 -153
  156. package/framework/skills/level-0-meta/morph-post-implementation/scripts/detect-stack.mjs +0 -234
  157. package/framework/skills/level-0-meta/morph-simulation-checklist/SKILL.md +0 -106
  158. package/framework/skills/level-0-meta/morph-tool-usage-guide/SKILL.md +0 -243
  159. package/framework/skills/level-0-meta/morph-tool-usage-guide/references/tools-per-phase.md +0 -169
  160. package/framework/skills/level-0-meta/morph-verification-before-completion/SKILL.md +0 -148
  161. package/framework/skills/level-0-meta/morph-verification-before-completion/scripts/check-phase-outputs.mjs +0 -110
  162. package/framework/skills/level-1-workflows/README.md +0 -7
  163. package/framework/skills/level-1-workflows/morph-phase-codebase-analysis/SKILL.md +0 -269
  164. package/framework/skills/level-1-workflows/morph-phase-design/SKILL.md +0 -453
  165. package/framework/skills/level-1-workflows/morph-phase-design/references/architecture-analysis-guide.md +0 -44
  166. package/framework/skills/level-1-workflows/morph-phase-design/references/spec-authoring-guide.md +0 -55
  167. package/framework/skills/level-1-workflows/morph-phase-design/references/spec-example.md +0 -253
  168. package/framework/skills/level-1-workflows/morph-phase-implement/.morph/logs/activity.json +0 -38
  169. package/framework/skills/level-1-workflows/morph-phase-implement/SKILL.md +0 -634
  170. package/framework/skills/level-1-workflows/morph-phase-implement/prompts/code-quality-reviewer-prompt.md +0 -50
  171. package/framework/skills/level-1-workflows/morph-phase-implement/prompts/implementer-prompt.md +0 -54
  172. package/framework/skills/level-1-workflows/morph-phase-implement/prompts/spec-reviewer-prompt.md +0 -47
  173. package/framework/skills/level-1-workflows/morph-phase-implement/references/recap-example.md +0 -132
  174. package/framework/skills/level-1-workflows/morph-phase-implement/references/vsa-implementation-guide.md +0 -92
  175. package/framework/skills/level-1-workflows/morph-phase-plan/SKILL.md +0 -257
  176. package/framework/skills/level-1-workflows/morph-phase-tasks/.morph/logs/activity.json +0 -14
  177. package/framework/skills/level-1-workflows/morph-phase-tasks/SKILL.md +0 -291
  178. package/framework/skills/level-1-workflows/morph-phase-tasks/references/task-planning-patterns.md +0 -143
  179. package/framework/skills/level-1-workflows/morph-phase-tasks/references/tasks-example.md +0 -404
  180. package/framework/skills/level-1-workflows/morph-phase-tasks/scripts/validate-tasks.mjs +0 -112
  181. package/framework/skills/level-1-workflows/morph-phase-uiux/SKILL.md +0 -995
  182. package/framework/skills/level-1-workflows/morph-scope-escalation/SKILL.md +0 -147
  183. package/framework/squad-templates/backend-only.json +0 -47
  184. package/framework/squad-templates/frontend-only.json +0 -56
  185. package/framework/squad-templates/full-stack.json +0 -74
  186. package/src/commands/agents/agent-metrics.js +0 -174
  187. package/src/commands/agents/audit-dispatch.js +0 -82
  188. package/src/commands/agents/detect-agents.js +0 -275
  189. package/src/commands/agents/dispatch-agents.js +0 -461
  190. package/src/commands/agents/index.js +0 -13
  191. package/src/commands/agents/manage-agents.js +0 -352
  192. package/src/commands/agents/project-metrics.js +0 -74
  193. package/src/commands/phase/phase-reset.js +0 -74
  194. package/src/commands/scope/escalate.js +0 -217
  195. package/src/commands/state/advance-phase.js +0 -600
  196. package/src/commands/state/phase-runner.js +0 -215
  197. package/src/commands/state/state.js +0 -444
  198. package/src/commands/task/expand.js +0 -100
  199. package/src/commands/tasks/index.js +0 -4
  200. package/src/commands/tasks/task.js +0 -105
  201. package/src/commands/templates/index.js +0 -5
  202. package/src/commands/templates/template-render.js +0 -93
  203. package/src/commands/trust/trust.js +0 -118
  204. package/src/lib/agents/agents-manager.js +0 -349
  205. package/src/lib/build/build-runner.js +0 -99
  206. package/src/lib/checkpoints/checkpoint-hooks.js +0 -111
  207. package/src/lib/contracts/sprint-contract-generator.js +0 -137
  208. package/src/lib/scope/impact-analyzer.js +0 -106
  209. package/src/lib/trust/trust-manager.js +0 -157
  210. package/src/utils/tier-helpers.js +0 -24
  211. /package/framework/hooks/claude-code/{post-tool-use → core}/loop-detect.js +0 -0
@@ -1,225 +0,0 @@
1
- ---
2
- name: morph-parallel-dispatch
3
- description: Plan and execute parallel agent dispatch using P-Threads, F-Threads, and squad templates. Covers thread types, file scope isolation, dependency analysis, and conflict resolution for multi-domain features.
4
- user-invocable: true
5
- argument-hint: "[feature-name]"
6
- allowed-tools: Read, Bash, Glob, Grep
7
- ---
8
-
9
- # Parallel Dispatch — MORPH-SPEC Thread Management
10
-
11
- > Orchestrate concurrent agent execution with strict file scope isolation, dependency-aware wave planning, and automatic conflict resolution.
12
-
13
- ## Thread Types
14
-
15
- | Type | Code | Purpose | Lifecycle |
16
- |------|------|---------|-----------|
17
- | Base | B-Thread | Default implementation thread | Bounded by feature phase |
18
- | Parallel | P-Thread | Concurrent isolated execution | Short (1 task scope) |
19
- | Fusion | F-Thread | Best-of-N competing implementations | Short (1 prompt scope) |
20
- | Long-Running | L-Thread | Multi-session persistent work | Days/weeks |
21
- | Zero-Touch | Z-Thread | Fully autonomous execution | Bounded by trust level |
22
-
23
- ## When to Use Parallel Execution
24
-
25
- | Condition | Decision |
26
- |-----------|----------|
27
- | 5+ independent tasks | Use P-Threads |
28
- | Multi-domain (backend + frontend) | Use P-Threads with squad templates |
29
- | 15+ files to create | Use P-Threads |
30
- | Tasks have zero dependency overlap | Use P-Threads |
31
- | Tasks share file scope | Do NOT parallelize |
32
- | Sequential data flow required | Do NOT parallelize |
33
-
34
- ## Thread Lifecycle
35
-
36
- ```
37
- pending --> running --> completed
38
- --> failed --> (retry) --> running
39
- --> killed
40
- ```
41
-
42
- ## Parallelization Planning
43
-
44
- ### Step 1: Dependency Analysis
45
-
46
- ```bash
47
- morph-spec detect-workflow $FEATURE_NAME
48
-
49
- # Identifies: parallelizable tasks, sequential chains, waves
50
- # Output:
51
- # Parallelizable tasks: T001, T002, T003 (no dependencies)
52
- # Sequential: T004 (depends on T001), T005 (depends on T002)
53
- # Execution plan:
54
- # Wave 1: [T001, T002, T003] (parallel)
55
- # Wave 2: [T004, T005] (parallel, after wave 1)
56
- # Wave 3: [T006] (sequential)
57
- ```
58
-
59
- ### Step 2: File Scope Assignment
60
-
61
- Assign exclusive file ownership to each parallel worker. No overlap allowed — if overlap is unavoidable, make it sequential.
62
-
63
- ```
64
- Worker A (Backend): Features/, Services/, Endpoints/, DTOs/
65
- Worker B (Frontend): app/, components/, hooks/, styles/
66
- ```
67
-
68
- **Example — Next.js + .NET VSA feature:**
69
-
70
- ```
71
- P-Thread 1 (VSA Backend):
72
- src/Features/UserAuth/
73
- CreateUser.cs (endpoint + handler)
74
- GetUser.cs (endpoint + handler)
75
- UserValidator.cs (FluentValidation)
76
- Contracts/UserDto.cs (shared DTOs)
77
-
78
- P-Thread 2 (Next.js Frontend):
79
- app/users/
80
- page.tsx (route page)
81
- layout.tsx (layout)
82
- components/users/
83
- user-form.tsx (shadcn/ui form)
84
- user-table.tsx (data table)
85
- hooks/
86
- use-users.ts (React Query hook)
87
- ```
88
-
89
- ### Step 3: Choose Squad Template
90
-
91
- Pre-defined squad configurations for common feature shapes:
92
-
93
- | Template | Agents | Use Case |
94
- |----------|--------|----------|
95
- | `full-stack` | Backend lead + Frontend lead + Coordinator | Full-stack features |
96
- | `backend-only` | Backend specialists (3-4 agents) | API-only work |
97
- | `frontend-only` | Frontend specialists (2-3 agents) | UI-only work |
98
-
99
- ```bash
100
- morph-spec squad-template list
101
- morph-spec squad-template show full-stack
102
- morph-spec squad-template use full-stack --feature=$FEATURE_NAME
103
- ```
104
-
105
- ## Execution Flow
106
-
107
- ```
108
- Orchestrator
109
- |
110
- +-- spawn parallel: Worker A (files: Features/, Services/)
111
- +-- spawn parallel: Worker B (files: app/, components/)
112
- |
113
- | [Workers execute concurrently -- no interaction]
114
- |
115
- +-- wait-all (poll or explicit sync)
116
- |
117
- +-- merge results (check for conflicts)
118
- +-- run integration validation
119
- +-- report consolidated output
120
- ```
121
-
122
- ## P-Thread Rules
123
-
124
- 1. **File scope isolation**: Each P-Thread has exclusive write access to its files
125
- 2. **No cross-thread dependencies**: P-Thread tasks are self-contained
126
- 3. **Shared read access**: All P-Threads can read spec.md, standards, contracts
127
- 4. **Merge on completion**: Coordinator merges results after all P-Threads complete
128
- 5. **Max concurrent**: Default 3, max 5 (configurable in llm-interaction.json)
129
-
130
- ## Parallel vs Fusion
131
-
132
- | Aspect | Parallel (P-Thread) | Fusion (F-Thread) |
133
- |--------|---------------------|-------------------|
134
- | Goal | Divide scope | Compete on same scope |
135
- | Output | Different files | Same files, best one wins |
136
- | Workers collaborate? | No | No |
137
- | Merge | Combine all files | Select best implementation |
138
- | Use case | Large features | Design decisions, quality optimization |
139
-
140
- ## Conflict Resolution
141
-
142
- ### File Conflicts (two workers wrote same file)
143
-
144
- This should NOT happen if scopes are properly defined. If it does:
145
-
146
- ```bash
147
- morph-spec agents review aggregate $FEATURE_NAME \
148
- --agents=dotnet-senior,nextjs-expert \
149
- --strategy=best-of-n
150
- ```
151
-
152
- ### Interface Mismatches (A expects contract B did not fulfill)
153
-
154
- - Document the mismatch in the coordinator report
155
- - Fix in post-merge sequential step
156
- - Update shared contracts/DTOs to reflect actual implementation
157
-
158
- ## Long-Running Threads (L-Threads)
159
-
160
- L-Threads run periodic stop hooks every 30 minutes:
161
-
162
- ```json
163
- {
164
- "stopHooks": {
165
- "enabled": true,
166
- "interval": 30,
167
- "maxRetries": 5,
168
- "hooks": ["validate-and-continue", "validate-checkpoints"]
169
- }
170
- }
171
- ```
172
-
173
- ### Resume Pattern
174
-
175
- ```bash
176
- morph-spec bundle load $FEATURE_NAME
177
- # Load resume context, continue from checkpoint
178
- ```
179
-
180
- ## Thread State in state.json
181
-
182
- ```json
183
- {
184
- "threads": {
185
- "thread-abc12345": {
186
- "id": "thread-abc12345",
187
- "type": "parallel",
188
- "agent": "dotnet-senior",
189
- "feature": "user-auth",
190
- "status": "running",
191
- "startedAt": "2026-02-19T00:00:00Z",
192
- "events": [
193
- { "type": "started", "timestamp": "..." },
194
- { "type": "checkpoint_passed", "timestamp": "...", "checkpointNum": 1 }
195
- ],
196
- "metrics": {
197
- "tasksCompleted": 3,
198
- "checkpointsPassed": 1,
199
- "errors": 0
200
- }
201
- }
202
- }
203
- }
204
- ```
205
-
206
- ## Monitoring
207
-
208
- ```bash
209
- morph-spec threads list $FEATURE_NAME
210
- morph-spec threads analytics $FEATURE_NAME
211
- morph-spec threads wait-all $FEATURE_NAME
212
- morph-spec threads wait-any $FEATURE_NAME
213
- ```
214
-
215
- ## Configuration
216
-
217
- ```json
218
- {
219
- "parallelExecution": {
220
- "enabled": true,
221
- "maxConcurrent": 3,
222
- "defaultStrategy": "best-of-n"
223
- }
224
- }
225
- ```
@@ -1,401 +0,0 @@
1
- ---
2
- name: morph-post-implementation
3
- description: Orchestrates the complete post-implementation flow: stack detection,
4
- automated scans (C#/Next.js), tests, validate-feature, smoke test via Playwright
5
- (mandatory if dev server active), code review checklist by stack, checkpoint, and
6
- recap generation. Use after completing all tasks.
7
- argument-hint: "[feature-name]"
8
- user-invocable: true
9
- allowed-tools: Read, Write, Edit, Bash, Glob, Grep, Task, AskUserQuestion,
10
- mcp__playwright__browser_navigate, mcp__playwright__browser_snapshot,
11
- mcp__playwright__browser_take_screenshot, mcp__playwright__browser_console_messages
12
- ---
13
-
14
- # Post-Implementation Review
15
-
16
- > Post-implementation orchestrator: runs all checks in logical sequence and blocks on failure.
17
- > Use after completing all implementation tasks, before creating the PR.
18
-
19
- ---
20
-
21
- ## Prerequisites
22
-
23
- - All tasks marked as done (`morph-spec task done`)
24
- - Project build compiling without errors
25
-
26
- ---
27
-
28
- ## Step 1 — Detect Stack
29
-
30
- ```bash
31
- node .claude/skills/morph-post-implementation/scripts/detect-stack.mjs
32
- ```
33
-
34
- Output JSON: `{ stack: "DOTNET" | "NEXTJS" | "FULLSTACK" | "UNKNOWN", frontendPath, backendPath, startCommand }`
35
-
36
- Priority order (most reliable first):
37
- 1. `.morph/config/config.json` → `config.project.stack` + `frontendPath`/`backendPath`
38
- 2. `.morph/context/README.md` → section `## Tech Stack`
39
- 3. Fallback: Glob for `*.csproj` and `package.json` with dep `"next"`
40
-
41
- Store the result — all following steps depend on the detected `stack`.
42
-
43
- ---
44
-
45
- ## Step 2 — Automated Scans
46
-
47
- Run automated scans based on detected stack.
48
-
49
- ### If DOTNET or FULLSTACK:
50
-
51
- ```bash
52
- node .claude/skills/morph-code-review/scripts/scan-csharp.mjs --diff
53
- ```
54
-
55
- ### If NEXTJS or FULLSTACK:
56
-
57
- ```bash
58
- node .claude/skills/morph-code-review-nextjs/scripts/scan-nextjs.mjs --diff
59
- ```
60
-
61
- **🚫 BLOCK if any CRITICAL finding found.**
62
-
63
- Fix all CRITICALs before continuing. To review the full checklist:
64
- - .NET: `/morph-code-review`
65
- - Next.js: `/morph-code-review-nextjs`
66
-
67
- ### Asset Completeness Check (if assets.md exists):
68
-
69
- If `.morph/features/{feature}/1-ui/assets.md` exists:
70
-
71
- 1. **Read assets.md** and list all IMG-NNN entries with their `Output Path` values.
72
- 2. **Check each output path exists:**
73
- ```bash
74
- test -f {outputPath} && echo "✓ {IMG-ID}" || echo "✗ {IMG-ID} MISSING: {outputPath}"
75
- ```
76
- 3. **Check for broken Image references:**
77
- ```bash
78
- grep -rn 'src="/images/' src/ --include="*.tsx" --include="*.jsx" | while read line; do
79
- path=$(echo "$line" | grep -oP 'src="(/images/[^"]+)"' | sed 's/src="//;s/"//');
80
- test -f "public$path" || echo "⚠️ Broken ref: $line → public$path not found";
81
- done
82
- ```
83
-
84
- **⚠️ ADVISORY** — missing assets produce warnings, not blocks. Some images may be intentionally deferred or optional.
85
-
86
- ---
87
-
88
- ## Step 3 — Test Suite
89
-
90
- Run tests based on stack.
91
-
92
- ### DOTNET:
93
-
94
- ```bash
95
- dotnet test --verbosity minimal
96
- ```
97
-
98
- ### NEXTJS:
99
-
100
- ```bash
101
- npm test -- --watchAll=false
102
- ```
103
-
104
- ### FULLSTACK:
105
-
106
- Run both in parallel (use Task tool with two independent subagents).
107
-
108
- **🚫 BLOCK if tests fail.**
109
-
110
- Do not proceed while tests are failing. Fix failures and re-run before continuing.
111
-
112
- ---
113
-
114
- ## Step 4 — Framework Validation
115
-
116
- ```bash
117
- morph-spec validate-feature $ARGUMENTS
118
- ```
119
-
120
- **🚫 BLOCK if it fails.**
121
-
122
- Read validation output, fix reported issues, and re-run until it passes.
123
-
124
- ---
125
-
126
- ### Step 4b — Verify RLS Policies (Neon/PostgreSQL projects)
127
-
128
- > **Neon CLI (`neonctl`):** If the project uses Neon/PostgreSQL, verify RLS policies on the database:
129
- >
130
- > 1. Get DB URL: `neonctl connection-string`
131
- > 2. Query: `psql <DB_URL> -c "SELECT tablename, policyname, cmd, qual FROM pg_policies WHERE schemaname = 'public'"`
132
- > 3. For each table modified in this feature, verify:
133
- > - [ ] RLS is enabled (`ALTER TABLE ... ENABLE ROW LEVEL SECURITY`)
134
- > - [ ] SELECT policy exists for authenticated users
135
- > - [ ] INSERT/UPDATE/DELETE policies match feature requirements
136
- > 4. If any table is missing RLS → **flag as CRITICAL** (blocks PR)
137
- >
138
- > If Neon database is not accessible, check for RLS policy files in the `migrations/` directory and verify they cover modified tables. If no Neon/PostgreSQL in the stack, skip this step.
139
-
140
- ---
141
-
142
- ## Step 5 — Smoke Test (Playwright MCP)
143
-
144
- > **Docker CLI:** Before smoke testing, verify local services are running: `docker ps --format "table {{.Names}}\t{{.Status}}"` — all expected containers should show "Up".
145
-
146
- > **MCP:** Smoke testing via **Playwright MCP** is the primary method. If Playwright MCP is not available, fall back to `curl`/`WebFetch` for endpoint verification (limited — cannot test JS-rendered pages or interactions).
147
-
148
- ### 5a. Detect Dev Server
149
-
150
- ```bash
151
- node .claude/skills/morph-post-implementation/scripts/detect-dev-server.mjs "<startCommand>"
152
- ```
153
-
154
- Pass the `startCommand` returned by detect-stack in Step 1.
155
-
156
- The script:
157
- 1. Scans ports `[3000, 3001, 4200, 5000, 5001, 7000, 8000, 8080]` with `fetch()` timeout 500ms
158
- 2. If it finds an active server → returns `{ found: true, url }`
159
- 3. If not found and `startCommand` provided → tries to start automatically and waits 30s
160
- 4. Returns exit code 0 (server available) or 1 (not available after attempt)
161
-
162
- ### 5b. If dev server available (exit 0):
163
-
164
- **Smoke test is MANDATORY.**
165
-
166
- 1. Read feature `spec.md` to identify critical happy paths (maximum 3 flows, section Functional Requirements)
167
- 2. Run the smoke test via Playwright MCP:
168
-
169
- ```javascript
170
- // Navigate to the feature
171
- await mcp__playwright__browser_navigate({ url: '<detected-url>' });
172
-
173
- // Capture page state
174
- await mcp__playwright__browser_snapshot();
175
-
176
- // Check for critical console errors
177
- await mcp__playwright__browser_console_messages({ level: 'error' });
178
-
179
- // Screenshot for documentation
180
- await mcp__playwright__browser_take_screenshot({
181
- type: 'png',
182
- filename: '.morph/features/$ARGUMENTS/5-implement/smoke-screenshots/smoke-<timestamp>.png'
183
- });
184
- ```
185
-
186
- For each critical happy path from the spec:
187
- - Navigate to the flow
188
- - Verify key elements are visible (`browser_snapshot`)
189
- - Confirm absence of critical console errors
190
- - Capture screenshot of final state
191
-
192
- **Mandatory checks:**
193
- - [ ] Page loads without 404/500 error
194
- - [ ] Main feature elements visible (per spec)
195
- - [ ] Console without critical errors (level: error)
196
- - [ ] Main happy path functional
197
-
198
- **🚫 BLOCK if any check fails.** Do not create PR with failing smoke test.
199
-
200
- ### 5c. If dev server NOT available (exit 1):
201
-
202
- **⚠️ WARNING: Dev server not found after attempt to start.**
203
-
204
- Request explicit user confirmation before skipping smoke test:
205
-
206
- ```
207
- Dev server not detected on expected port. Smoke test via Playwright is mandatory
208
- to ensure the code works in the browser before creating the PR.
209
-
210
- Options:
211
- 1. Start the server manually (`npm run dev` / `dotnet run`) and re-run /post-implementation
212
- 2. Explicitly confirm you want to skip the smoke test and why
213
-
214
- Cannot proceed to PR creation without smoke test or explicit confirmation.
215
- ```
216
-
217
- **Wait for response before continuing.**
218
-
219
- ---
220
-
221
- ## Step 6 — Code Review Checklist (CRITICAL + HIGH)
222
-
223
- > Before reviewing, read: `.claude/skills/morph-code-review/references/review-guidelines.md` — apply confidence ≥ 75, ignore pre-existing violations, include file:line in each finding.
224
-
225
- Review the most important items by stack. For complete review, use the dedicated skills.
226
-
227
- ### If FULLSTACK:
228
-
229
- Dispatch two subagents in parallel (Task tool):
230
-
231
- **Subagent 1 — Backend Review:**
232
- > .NET focused reviewer. Scope: ONLY changed .cs files (git diff main...HEAD).
233
- > Run: `node .claude/skills/morph-code-review/scripts/scan-csharp.mjs --diff`
234
- > Then manually review CRITICAL+HIGH checklist items for .NET.
235
- > Apply review-guidelines.md: confidence ≥ 75, skip pre-existing.
236
- > Output: findings with file:line, or "✅ No CRITICAL/HIGH in changed backend."
237
-
238
- **Subagent 2 — Frontend Review:**
239
- > Next.js focused reviewer. Scope: ONLY changed .tsx/.ts files (git diff main...HEAD).
240
- > Run: `node .claude/skills/morph-code-review-nextjs/scripts/scan-nextjs.mjs --diff`
241
- > Then manually review CRITICAL+HIGH checklist items for Next.js.
242
- > Apply review-guidelines.md: confidence ≥ 75, skip pre-existing.
243
- > Output: findings with file:line, or "✅ No CRITICAL/HIGH in changed frontend."
244
-
245
- Wait for both. **🚫 BLOCK if either returns unresolved CRITICAL.**
246
-
247
- ### If DOTNET:
248
-
249
- **CRITICAL and HIGH items — .NET:**
250
-
251
- ```
252
- [ ] CancellationToken propagated through the entire async chain
253
- [ ] No .Result / .Wait() (deadlock risk)
254
- [ ] Domain has zero refs to Infrastructure or Web
255
- [ ] No circular dependencies
256
- [ ] No empty catch blocks
257
- [ ] Background ops use IDbContextFactory + await using
258
- [ ] Async methods have Async suffix
259
- [ ] Interfaces prefixed with I
260
- [ ] No classes > 300 lines
261
- [ ] DTOs with descriptive names + correct types
262
- ```
263
-
264
- > For full list: `/morph-code-review`
265
-
266
- ### If NEXTJS:
267
-
268
- **CRITICAL and HIGH items — Next.js:**
269
-
270
- ```
271
- [ ] node .claude/skills/morph-code-review-nextjs/scripts/scan-nextjs.mjs --diff → 0 CRITICAL
272
- [ ] File names in kebab-case (user-card.tsx, not UserCard.tsx)
273
- [ ] 'use client' only in components with hooks/event handlers
274
- [ ] No useEffect for data fetching → Server Component or useQuery
275
- [ ] Zod schema defined first, type derived with z.infer<>
276
- [ ] zodResolver connected to useForm, useMutation for submit
277
- [ ] Query key factory used (userKeys.lists(), not ['users'])
278
- [ ] Feature public API via features/{name}/index.ts
279
- [ ] components/ui/ untouched (shadcn CLI only)
280
- [ ] No any type annotation
281
- ```
282
-
283
- > For full list: `/morph-code-review-nextjs`
284
-
285
- **🚫 BLOCK if any CRITICAL item is unresolved.**
286
-
287
- ---
288
-
289
- ## Step 7 — Checkpoint + Recap
290
-
291
- ```bash
292
- # Save post-review checkpoint
293
- morph-spec checkpoint-save $ARGUMENTS --note "post-implementation review"
294
-
295
- # Generate final recap
296
- morph-spec generate recap $ARGUMENTS
297
- ```
298
-
299
- ---
300
-
301
- ## Step 8 — Finish Worktree
302
-
303
- Implementation is complete. If the feature was developed in a morph worktree, finalize it now.
304
-
305
- **Check if a worktree exists:**
306
- ```bash
307
- git worktree list | grep morph/
308
- ```
309
-
310
- **If a `morph/{feature}` worktree exists:**
311
-
312
- Invoke the finishing-a-development-branch skill:
313
- ```
314
- Skill(superpowers:finishing-a-development-branch)
315
- ```
316
-
317
- This skill will:
318
- 1. Verify tests pass
319
- 2. Present 4 options:
320
- - **Merge locally** → merge into base branch + delete worktree
321
- - **Push and create PR** → push branch + create GitHub PR (keeps worktree)
322
- - **Keep as-is** → no action (worktree preserved for later)
323
- - **Discard** → delete branch + worktree (requires typed confirmation)
324
- 3. Clean up worktree for options 1 and 4
325
-
326
- **If NOT in a worktree** (legacy mode): skip this step and proceed to Step 9.
327
-
328
- > **Note:** If the `superpowers` plugin is not installed, create the PR manually:
329
- > `gh pr create --title "feat({feature}): <description>" --body "..."`
330
-
331
- ---
332
-
333
- ## Step 9 — Pre-PR Compliance Checklist
334
-
335
- Before creating the PR, invoke the compliance checklist:
336
-
337
- ```
338
- Skill(morph-checklist)
339
- ```
340
-
341
- This skill checks: security, SEO, performance, accessibility, and LGPD compliance.
342
- **🚫 BLOCK if any CRITICAL item is unresolved.**
343
-
344
- ---
345
-
346
- ## Step 10 — PR Suggestion
347
-
348
- When all steps pass, suggest the PR:
349
-
350
- ```bash
351
- gh pr create \
352
- --title "feat($ARGUMENTS): <concise feature description>" \
353
- --body "$(cat <<'EOF'
354
- ## Summary
355
-
356
- - <main implemented changes>
357
- - <completed tasks>
358
-
359
- ## Test Results
360
-
361
- - Build: ✅ passed
362
- - Tests: ✅ X tests passing
363
- - Smoke Test: ✅ happy path verified via Playwright
364
-
365
- ## Screenshots
366
-
367
- <!-- Paste screenshot paths saved in smoke-screenshots/ -->
368
-
369
- ## Checklist
370
-
371
- - [ ] Automated scans: 0 CRITICAL findings
372
- - [ ] All tests passing
373
- - [ ] Smoke test via Playwright: ✅
374
- - [ ] Code review checklist: CRITICAL + HIGH items verified
375
- - [ ] validate-feature: ✅ passed
376
- - [ ] Checkpoint saved
377
- - [ ] recap.md generated
378
- EOF
379
- )"
380
- ```
381
-
382
- ---
383
-
384
- ## Block Summary
385
-
386
- | Step | Block Condition |
387
- |------|-----------------|
388
- | Step 2 | Any CRITICAL finding in automated scans |
389
- | Step 3 | Any test failing |
390
- | Step 4 | `validate-feature` failing |
391
- | Step 5 | Dev server active + smoke test failing |
392
- | Step 5 | Dev server not detected without explicit user confirmation |
393
- | Step 6 | Any unresolved CRITICAL item in manual checklist |
394
- | Step 8 | Tests failing in worktree before merge/PR |
395
- | Step 9 | Unresolved CRITICAL item in `morph-checklist` |
396
-
397
- **All BLOCKs must be resolved before creating the PR.**
398
-
399
- ---
400
-
401
- *MORPH-SPEC by Polymorphism Tech*