@polymorphism-tech/morph-spec 4.21.0 → 5.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (213) hide show
  1. package/CLAUDE.md +57 -71
  2. package/README.md +2 -2
  3. package/bin/morph-spec.js +224 -491
  4. package/claude-plugin.json +1 -1
  5. package/docs/CHEATSHEET.md +1 -1
  6. package/docs/QUICKSTART.md +1 -1
  7. package/framework/CLAUDE.md +55 -38
  8. package/framework/MORPH.md +244 -0
  9. package/framework/agents.json +127 -1183
  10. package/framework/commands/morph-apply.md +56 -240
  11. package/framework/commands/morph-archive.md +48 -85
  12. package/framework/commands/morph-preflight.md +7 -7
  13. package/framework/commands/morph-proposal.md +35 -191
  14. package/framework/commands/morph-status.md +19 -50
  15. package/framework/commands/morph-troubleshoot.md +2 -2
  16. package/framework/evals/rubrics/README.md +44 -0
  17. package/framework/evals/rubrics/architecture.md +46 -0
  18. package/framework/evals/rubrics/code-quality.md +50 -0
  19. package/framework/evals/rubrics/contracts.md +47 -0
  20. package/framework/evals/rubrics/test-coverage.md +50 -0
  21. package/framework/evals/scenarios/dotnet-crud.yaml +42 -0
  22. package/framework/evals/scenarios/nextjs-auth.yaml +38 -0
  23. package/framework/evals/suites/standard.yaml +5 -0
  24. package/framework/evals/trace-schema.md +67 -0
  25. package/framework/hooks/claude-code/core/README.md +3 -0
  26. package/framework/hooks/claude-code/core/denylist.json +14 -0
  27. package/framework/hooks/claude-code/{pre-tool-use → core}/enforce-phase-writes.js +5 -5
  28. package/framework/hooks/claude-code/core/post-edit-typecheck.js +69 -0
  29. package/framework/hooks/claude-code/core/pre-bash-denylist.js +29 -0
  30. package/framework/hooks/claude-code/{pre-tool-use → core}/protect-spec-files.js +4 -6
  31. package/framework/hooks/claude-code/{stop → core}/validate-completion.js +13 -82
  32. package/framework/hooks/shared/phase-utils.js +20 -28
  33. package/framework/hooks/shared/state-reader.js +4 -5
  34. package/framework/{skills/level-0-meta/mcp-registry.json → mcp/registry.json} +254 -210
  35. package/framework/phases.json +40 -114
  36. package/framework/rubrics/eval-rubric.json +66 -0
  37. package/framework/skills/README.md +39 -64
  38. package/framework/skills/core/README.md +3 -0
  39. package/framework/skills/core/morph-brainstorming/SKILL.md +102 -0
  40. package/framework/skills/core/morph-eval/SKILL.md +57 -0
  41. package/framework/skills/core/morph-implement/SKILL.md +83 -0
  42. package/framework/skills/core/morph-plan/SKILL.md +64 -0
  43. package/framework/skills/core/morph-review/SKILL.md +62 -0
  44. package/framework/skills/core/morph-stack-scan/SKILL.md +109 -0
  45. package/framework/skills/core/morph-standards/SKILL.md +49 -0
  46. package/framework/standards/STANDARDS.json +32 -0
  47. package/framework/standards/frontend/design-system/ai-image-generation.md +244 -0
  48. package/framework/standards/integration/mcp/mcp-tools.md +48 -0
  49. package/framework/templates/CLAUDE.md.core.guide.md +29 -0
  50. package/framework/templates/CLAUDE.md.core.template +22 -0
  51. package/framework/templates/REGISTRY.json +4 -4
  52. package/framework/workflows/configs/fast-track.json +5 -10
  53. package/framework/workflows/configs/full.json +4 -8
  54. package/framework/workflows/configs/quick.json +32 -0
  55. package/framework/workflows/configs/standard.json +57 -64
  56. package/package.json +7 -6
  57. package/src/commands/mcp/mcp-setup.js +58 -31
  58. package/src/commands/project/doctor.js +69 -70
  59. package/src/commands/project/init.js +26 -5
  60. package/src/commands/project/status.js +18 -19
  61. package/src/commands/state/approve.js +1 -1
  62. package/src/commands/validation/validate-feature.js +18 -112
  63. package/src/core/paths/output-schema.js +133 -151
  64. package/src/core/state/phase-state-machine.js +10 -24
  65. package/src/core/state/state-manager.js +17 -17
  66. package/src/core/workflows/workflow-detector.js +214 -31
  67. package/src/core/workflows/workflow-router.js +204 -0
  68. package/src/dashboard/app/pages/AgentMap.jsx +32 -33
  69. package/src/dashboard/app/pages/LiveState.jsx +1 -1
  70. package/src/dashboard/app/pages/PhasePipeline.jsx +2 -4
  71. package/src/dashboard/app/pages/SkillsLibrary.jsx +2 -3
  72. package/src/dashboard/app/pages/Workflows.jsx +2 -2
  73. package/src/dashboard/scanner/agents-scanner.js +30 -35
  74. package/src/lib/agents/metrics-aggregator.js +1 -1
  75. package/src/lib/agents/output-collector.js +7 -8
  76. package/src/lib/context/context-builder.js +289 -0
  77. package/src/lib/detectors/claude-config-detector.js +19 -3
  78. package/src/lib/generators/context-generator.js +20 -42
  79. package/src/lib/generators/index.js +1 -0
  80. package/src/lib/generators/mandate-generator.js +512 -0
  81. package/src/lib/generators/metadata-extractor.js +1 -1
  82. package/src/lib/generators/recap-generator.js +3 -4
  83. package/src/lib/installers/mcp-installer.js +300 -92
  84. package/src/lib/phase-chain/phase-validator.js +36 -40
  85. package/src/lib/stack/stack-profile.js +74 -91
  86. package/src/lib/tasks/task-parser.js +1 -1
  87. package/src/lib/tasks/wave-resolver.js +353 -0
  88. package/src/lib/validators/checkpoint-persistence.js +2 -2
  89. package/src/lib/validators/content/cross-phase-validator.js +281 -0
  90. package/src/lib/validators/content/index.js +1 -0
  91. package/src/lib/validators/shared/emit-validator-dispatch.js +6 -56
  92. package/src/scripts/global-install.js +2 -27
  93. package/src/utils/agents-installer.js +224 -447
  94. package/src/utils/claude-settings-manager.js +57 -15
  95. package/src/utils/file-copier.js +1 -0
  96. package/src/utils/hooks-installer.js +15 -117
  97. package/src/utils/skills-installer.js +12 -18
  98. package/bin/detect-agents.js +0 -226
  99. package/bin/task-manager.js +0 -1036
  100. package/framework/agents/README.md +0 -13
  101. package/framework/agents/ai-agents/ai-system-architect.md +0 -194
  102. package/framework/agents/ai-agents/vector-search-expert.md +0 -247
  103. package/framework/agents/architecture/architecture-expert.md +0 -98
  104. package/framework/agents/architecture/morph-spec-architect.md +0 -66
  105. package/framework/agents/architecture/packages-validator.md +0 -89
  106. package/framework/agents/architecture/security-expert.md +0 -79
  107. package/framework/agents/architecture/seo-growth-hacker.md +0 -168
  108. package/framework/agents/architecture/standards-architect.md +0 -153
  109. package/framework/agents/backend/dotnet-senior.md +0 -163
  110. package/framework/agents/backend/ef-modeler.md +0 -119
  111. package/framework/agents/backend/hangfire-orchestrator.md +0 -133
  112. package/framework/agents/backend/ms-agent-expert.md +0 -55
  113. package/framework/agents/backend/neon-expert.md +0 -379
  114. package/framework/agents/frontend/css-specialist.md +0 -89
  115. package/framework/agents/frontend/design-system-validator.md +0 -100
  116. package/framework/agents/frontend/gsap-animator.md +0 -131
  117. package/framework/agents/frontend/nextjs-component-validator.md +0 -97
  118. package/framework/agents/frontend/nextjs-expert.md +0 -201
  119. package/framework/agents/frontend/ui-designer.md +0 -259
  120. package/framework/agents/infrastructure/infra-architect.md +0 -215
  121. package/framework/agents/integrations/asaas-financial.md +0 -138
  122. package/framework/agents/integrations/neon-auth.md +0 -151
  123. package/framework/agents/integrations/resend-email.md +0 -127
  124. package/framework/hooks/claude-code/post-tool-use/agent-complete.js +0 -122
  125. package/framework/hooks/claude-code/post-tool-use/dispatch.js +0 -363
  126. package/framework/hooks/claude-code/post-tool-use/handle-tool-failure.js +0 -78
  127. package/framework/hooks/claude-code/post-tool-use/validator-feedback.js +0 -194
  128. package/framework/hooks/claude-code/pre-compact/save-morph-context.js +0 -199
  129. package/framework/hooks/claude-code/pre-tool-use/task-tracking-guard.js +0 -55
  130. package/framework/hooks/claude-code/session-start/inject-morph-context.js +0 -323
  131. package/framework/hooks/claude-code/session-start/post-compact-restore.js +0 -41
  132. package/framework/hooks/claude-code/session-start/resume-context.js +0 -77
  133. package/framework/hooks/claude-code/teammate-idle/teammate-idle.js +0 -90
  134. package/framework/hooks/claude-code/user-prompt/enrich-prompt.js +0 -114
  135. package/framework/hooks/shared/compact-restore.js +0 -123
  136. package/framework/hooks/shared/dispatch-helpers.js +0 -147
  137. package/framework/hooks/shared/skill-reminder-helpers.js +0 -79
  138. package/framework/hooks/shared/stale-task-reset.js +0 -57
  139. package/framework/hooks/shared/worktree-helpers.js +0 -75
  140. package/framework/skills/level-0-meta/README.md +0 -7
  141. package/framework/skills/level-0-meta/morph-agent-teams/SKILL.md +0 -472
  142. package/framework/skills/level-0-meta/morph-brainstorming/SKILL.md +0 -174
  143. package/framework/skills/level-0-meta/morph-brainstorming/references/proposal-example.md +0 -138
  144. package/framework/skills/level-0-meta/morph-checklist/SKILL.md +0 -145
  145. package/framework/skills/level-0-meta/morph-code-review/SKILL.md +0 -250
  146. package/framework/skills/level-0-meta/morph-code-review/references/review-example.md +0 -164
  147. package/framework/skills/level-0-meta/morph-code-review/references/review-guidelines.md +0 -100
  148. package/framework/skills/level-0-meta/morph-code-review/scripts/scan-csharp.mjs +0 -151
  149. package/framework/skills/level-0-meta/morph-code-review-nextjs/SKILL.md +0 -165
  150. package/framework/skills/level-0-meta/morph-code-review-nextjs/references/review-example-nextjs.md +0 -254
  151. package/framework/skills/level-0-meta/morph-code-review-nextjs/scripts/scan-nextjs.mjs +0 -189
  152. package/framework/skills/level-0-meta/morph-frontend-review/SKILL.md +0 -344
  153. package/framework/skills/level-0-meta/morph-frontend-review/scripts/scan-accessibility.mjs +0 -376
  154. package/framework/skills/level-0-meta/morph-init/SKILL.md +0 -537
  155. package/framework/skills/level-0-meta/morph-parallel-dispatch/SKILL.md +0 -225
  156. package/framework/skills/level-0-meta/morph-post-implementation/SKILL.md +0 -382
  157. package/framework/skills/level-0-meta/morph-post-implementation/scripts/detect-dev-server.mjs +0 -153
  158. package/framework/skills/level-0-meta/morph-post-implementation/scripts/detect-stack.mjs +0 -234
  159. package/framework/skills/level-0-meta/morph-simulation-checklist/SKILL.md +0 -106
  160. package/framework/skills/level-0-meta/morph-tool-usage-guide/SKILL.md +0 -243
  161. package/framework/skills/level-0-meta/morph-tool-usage-guide/references/tools-per-phase.md +0 -169
  162. package/framework/skills/level-0-meta/morph-verification-before-completion/SKILL.md +0 -148
  163. package/framework/skills/level-0-meta/morph-verification-before-completion/scripts/check-phase-outputs.mjs +0 -110
  164. package/framework/skills/level-1-workflows/README.md +0 -7
  165. package/framework/skills/level-1-workflows/morph-phase-codebase-analysis/SKILL.md +0 -269
  166. package/framework/skills/level-1-workflows/morph-phase-design/SKILL.md +0 -453
  167. package/framework/skills/level-1-workflows/morph-phase-design/references/architecture-analysis-guide.md +0 -44
  168. package/framework/skills/level-1-workflows/morph-phase-design/references/spec-authoring-guide.md +0 -55
  169. package/framework/skills/level-1-workflows/morph-phase-design/references/spec-example.md +0 -253
  170. package/framework/skills/level-1-workflows/morph-phase-implement/.morph/logs/activity.json +0 -38
  171. package/framework/skills/level-1-workflows/morph-phase-implement/SKILL.md +0 -493
  172. package/framework/skills/level-1-workflows/morph-phase-implement/prompts/code-quality-reviewer-prompt.md +0 -50
  173. package/framework/skills/level-1-workflows/morph-phase-implement/prompts/implementer-prompt.md +0 -46
  174. package/framework/skills/level-1-workflows/morph-phase-implement/prompts/spec-reviewer-prompt.md +0 -47
  175. package/framework/skills/level-1-workflows/morph-phase-implement/references/recap-example.md +0 -132
  176. package/framework/skills/level-1-workflows/morph-phase-implement/references/vsa-implementation-guide.md +0 -92
  177. package/framework/skills/level-1-workflows/morph-phase-plan/SKILL.md +0 -257
  178. package/framework/skills/level-1-workflows/morph-phase-tasks/.morph/logs/activity.json +0 -14
  179. package/framework/skills/level-1-workflows/morph-phase-tasks/SKILL.md +0 -291
  180. package/framework/skills/level-1-workflows/morph-phase-tasks/references/task-planning-patterns.md +0 -143
  181. package/framework/skills/level-1-workflows/morph-phase-tasks/references/tasks-example.md +0 -404
  182. package/framework/skills/level-1-workflows/morph-phase-tasks/scripts/validate-tasks.mjs +0 -112
  183. package/framework/skills/level-1-workflows/morph-phase-uiux/SKILL.md +0 -788
  184. package/framework/skills/level-1-workflows/morph-scope-escalation/SKILL.md +0 -147
  185. package/framework/squad-templates/backend-only.json +0 -47
  186. package/framework/squad-templates/frontend-only.json +0 -56
  187. package/framework/squad-templates/full-stack.json +0 -74
  188. package/src/commands/agents/agent-metrics.js +0 -174
  189. package/src/commands/agents/audit-dispatch.js +0 -82
  190. package/src/commands/agents/detect-agents.js +0 -275
  191. package/src/commands/agents/dispatch-agents.js +0 -461
  192. package/src/commands/agents/index.js +0 -13
  193. package/src/commands/agents/manage-agents.js +0 -352
  194. package/src/commands/agents/project-metrics.js +0 -74
  195. package/src/commands/phase/phase-reset.js +0 -74
  196. package/src/commands/scope/escalate.js +0 -217
  197. package/src/commands/state/advance-phase.js +0 -600
  198. package/src/commands/state/phase-runner.js +0 -215
  199. package/src/commands/state/state.js +0 -444
  200. package/src/commands/task/expand.js +0 -100
  201. package/src/commands/tasks/index.js +0 -4
  202. package/src/commands/tasks/task.js +0 -105
  203. package/src/commands/templates/index.js +0 -5
  204. package/src/commands/templates/template-render.js +0 -93
  205. package/src/commands/trust/trust.js +0 -118
  206. package/src/lib/agents/agents-manager.js +0 -349
  207. package/src/lib/build/build-runner.js +0 -99
  208. package/src/lib/checkpoints/checkpoint-hooks.js +0 -111
  209. package/src/lib/contracts/sprint-contract-generator.js +0 -137
  210. package/src/lib/scope/impact-analyzer.js +0 -106
  211. package/src/lib/trust/trust-manager.js +0 -157
  212. package/src/utils/tier-helpers.js +0 -24
  213. /package/framework/hooks/claude-code/{post-tool-use → core}/loop-detect.js +0 -0
@@ -1,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,382 +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
- ---
68
-
69
- ## Step 3 — Test Suite
70
-
71
- Run tests based on stack.
72
-
73
- ### DOTNET:
74
-
75
- ```bash
76
- dotnet test --verbosity minimal
77
- ```
78
-
79
- ### NEXTJS:
80
-
81
- ```bash
82
- npm test -- --watchAll=false
83
- ```
84
-
85
- ### FULLSTACK:
86
-
87
- Run both in parallel (use Task tool with two independent subagents).
88
-
89
- **🚫 BLOCK if tests fail.**
90
-
91
- Do not proceed while tests are failing. Fix failures and re-run before continuing.
92
-
93
- ---
94
-
95
- ## Step 4 — Framework Validation
96
-
97
- ```bash
98
- morph-spec validate-feature $ARGUMENTS
99
- ```
100
-
101
- **🚫 BLOCK if it fails.**
102
-
103
- Read validation output, fix reported issues, and re-run until it passes.
104
-
105
- ---
106
-
107
- ### Step 4b — Verify RLS Policies (Neon/PostgreSQL projects)
108
-
109
- > **Neon CLI (`neonctl`):** If the project uses Neon/PostgreSQL, verify RLS policies on the database:
110
- >
111
- > 1. Get DB URL: `neonctl connection-string`
112
- > 2. Query: `psql <DB_URL> -c "SELECT tablename, policyname, cmd, qual FROM pg_policies WHERE schemaname = 'public'"`
113
- > 3. For each table modified in this feature, verify:
114
- > - [ ] RLS is enabled (`ALTER TABLE ... ENABLE ROW LEVEL SECURITY`)
115
- > - [ ] SELECT policy exists for authenticated users
116
- > - [ ] INSERT/UPDATE/DELETE policies match feature requirements
117
- > 4. If any table is missing RLS → **flag as CRITICAL** (blocks PR)
118
- >
119
- > 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.
120
-
121
- ---
122
-
123
- ## Step 5 — Smoke Test (Playwright MCP)
124
-
125
- > **Docker CLI:** Before smoke testing, verify local services are running: `docker ps --format "table {{.Names}}\t{{.Status}}"` — all expected containers should show "Up".
126
-
127
- > **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).
128
-
129
- ### 5a. Detect Dev Server
130
-
131
- ```bash
132
- node .claude/skills/morph-post-implementation/scripts/detect-dev-server.mjs "<startCommand>"
133
- ```
134
-
135
- Pass the `startCommand` returned by detect-stack in Step 1.
136
-
137
- The script:
138
- 1. Scans ports `[3000, 3001, 4200, 5000, 5001, 7000, 8000, 8080]` with `fetch()` timeout 500ms
139
- 2. If it finds an active server → returns `{ found: true, url }`
140
- 3. If not found and `startCommand` provided → tries to start automatically and waits 30s
141
- 4. Returns exit code 0 (server available) or 1 (not available after attempt)
142
-
143
- ### 5b. If dev server available (exit 0):
144
-
145
- **Smoke test is MANDATORY.**
146
-
147
- 1. Read feature `spec.md` to identify critical happy paths (maximum 3 flows, section Functional Requirements)
148
- 2. Run the smoke test via Playwright MCP:
149
-
150
- ```javascript
151
- // Navigate to the feature
152
- await mcp__playwright__browser_navigate({ url: '<detected-url>' });
153
-
154
- // Capture page state
155
- await mcp__playwright__browser_snapshot();
156
-
157
- // Check for critical console errors
158
- await mcp__playwright__browser_console_messages({ level: 'error' });
159
-
160
- // Screenshot for documentation
161
- await mcp__playwright__browser_take_screenshot({
162
- type: 'png',
163
- filename: '.morph/features/$ARGUMENTS/5-implement/smoke-screenshots/smoke-<timestamp>.png'
164
- });
165
- ```
166
-
167
- For each critical happy path from the spec:
168
- - Navigate to the flow
169
- - Verify key elements are visible (`browser_snapshot`)
170
- - Confirm absence of critical console errors
171
- - Capture screenshot of final state
172
-
173
- **Mandatory checks:**
174
- - [ ] Page loads without 404/500 error
175
- - [ ] Main feature elements visible (per spec)
176
- - [ ] Console without critical errors (level: error)
177
- - [ ] Main happy path functional
178
-
179
- **🚫 BLOCK if any check fails.** Do not create PR with failing smoke test.
180
-
181
- ### 5c. If dev server NOT available (exit 1):
182
-
183
- **⚠️ WARNING: Dev server not found after attempt to start.**
184
-
185
- Request explicit user confirmation before skipping smoke test:
186
-
187
- ```
188
- Dev server not detected on expected port. Smoke test via Playwright is mandatory
189
- to ensure the code works in the browser before creating the PR.
190
-
191
- Options:
192
- 1. Start the server manually (`npm run dev` / `dotnet run`) and re-run /post-implementation
193
- 2. Explicitly confirm you want to skip the smoke test and why
194
-
195
- Cannot proceed to PR creation without smoke test or explicit confirmation.
196
- ```
197
-
198
- **Wait for response before continuing.**
199
-
200
- ---
201
-
202
- ## Step 6 — Code Review Checklist (CRITICAL + HIGH)
203
-
204
- > 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.
205
-
206
- Review the most important items by stack. For complete review, use the dedicated skills.
207
-
208
- ### If FULLSTACK:
209
-
210
- Dispatch two subagents in parallel (Task tool):
211
-
212
- **Subagent 1 — Backend Review:**
213
- > .NET focused reviewer. Scope: ONLY changed .cs files (git diff main...HEAD).
214
- > Run: `node .claude/skills/morph-code-review/scripts/scan-csharp.mjs --diff`
215
- > Then manually review CRITICAL+HIGH checklist items for .NET.
216
- > Apply review-guidelines.md: confidence ≥ 75, skip pre-existing.
217
- > Output: findings with file:line, or "✅ No CRITICAL/HIGH in changed backend."
218
-
219
- **Subagent 2 — Frontend Review:**
220
- > Next.js focused reviewer. Scope: ONLY changed .tsx/.ts files (git diff main...HEAD).
221
- > Run: `node .claude/skills/morph-code-review-nextjs/scripts/scan-nextjs.mjs --diff`
222
- > Then manually review CRITICAL+HIGH checklist items for Next.js.
223
- > Apply review-guidelines.md: confidence ≥ 75, skip pre-existing.
224
- > Output: findings with file:line, or "✅ No CRITICAL/HIGH in changed frontend."
225
-
226
- Wait for both. **🚫 BLOCK if either returns unresolved CRITICAL.**
227
-
228
- ### If DOTNET:
229
-
230
- **CRITICAL and HIGH items — .NET:**
231
-
232
- ```
233
- [ ] CancellationToken propagated through the entire async chain
234
- [ ] No .Result / .Wait() (deadlock risk)
235
- [ ] Domain has zero refs to Infrastructure or Web
236
- [ ] No circular dependencies
237
- [ ] No empty catch blocks
238
- [ ] Background ops use IDbContextFactory + await using
239
- [ ] Async methods have Async suffix
240
- [ ] Interfaces prefixed with I
241
- [ ] No classes > 300 lines
242
- [ ] DTOs with descriptive names + correct types
243
- ```
244
-
245
- > For full list: `/morph-code-review`
246
-
247
- ### If NEXTJS:
248
-
249
- **CRITICAL and HIGH items — Next.js:**
250
-
251
- ```
252
- [ ] node .claude/skills/morph-code-review-nextjs/scripts/scan-nextjs.mjs --diff → 0 CRITICAL
253
- [ ] File names in kebab-case (user-card.tsx, not UserCard.tsx)
254
- [ ] 'use client' only in components with hooks/event handlers
255
- [ ] No useEffect for data fetching → Server Component or useQuery
256
- [ ] Zod schema defined first, type derived with z.infer<>
257
- [ ] zodResolver connected to useForm, useMutation for submit
258
- [ ] Query key factory used (userKeys.lists(), not ['users'])
259
- [ ] Feature public API via features/{name}/index.ts
260
- [ ] components/ui/ untouched (shadcn CLI only)
261
- [ ] No any type annotation
262
- ```
263
-
264
- > For full list: `/morph-code-review-nextjs`
265
-
266
- **🚫 BLOCK if any CRITICAL item is unresolved.**
267
-
268
- ---
269
-
270
- ## Step 7 — Checkpoint + Recap
271
-
272
- ```bash
273
- # Save post-review checkpoint
274
- morph-spec checkpoint-save $ARGUMENTS --note "post-implementation review"
275
-
276
- # Generate final recap
277
- morph-spec generate recap $ARGUMENTS
278
- ```
279
-
280
- ---
281
-
282
- ## Step 8 — Finish Worktree
283
-
284
- Implementation is complete. If the feature was developed in a morph worktree, finalize it now.
285
-
286
- **Check if a worktree exists:**
287
- ```bash
288
- git worktree list | grep morph/
289
- ```
290
-
291
- **If a `morph/{feature}` worktree exists:**
292
-
293
- Invoke the finishing-a-development-branch skill:
294
- ```
295
- Skill(superpowers:finishing-a-development-branch)
296
- ```
297
-
298
- This skill will:
299
- 1. Verify tests pass
300
- 2. Present 4 options:
301
- - **Merge locally** → merge into base branch + delete worktree
302
- - **Push and create PR** → push branch + create GitHub PR (keeps worktree)
303
- - **Keep as-is** → no action (worktree preserved for later)
304
- - **Discard** → delete branch + worktree (requires typed confirmation)
305
- 3. Clean up worktree for options 1 and 4
306
-
307
- **If NOT in a worktree** (legacy mode): skip this step and proceed to Step 9.
308
-
309
- > **Note:** If the `superpowers` plugin is not installed, create the PR manually:
310
- > `gh pr create --title "feat({feature}): <description>" --body "..."`
311
-
312
- ---
313
-
314
- ## Step 9 — Pre-PR Compliance Checklist
315
-
316
- Before creating the PR, invoke the compliance checklist:
317
-
318
- ```
319
- Skill(morph-checklist)
320
- ```
321
-
322
- This skill checks: security, SEO, performance, accessibility, and LGPD compliance.
323
- **🚫 BLOCK if any CRITICAL item is unresolved.**
324
-
325
- ---
326
-
327
- ## Step 10 — PR Suggestion
328
-
329
- When all steps pass, suggest the PR:
330
-
331
- ```bash
332
- gh pr create \
333
- --title "feat($ARGUMENTS): <concise feature description>" \
334
- --body "$(cat <<'EOF'
335
- ## Summary
336
-
337
- - <main implemented changes>
338
- - <completed tasks>
339
-
340
- ## Test Results
341
-
342
- - Build: ✅ passed
343
- - Tests: ✅ X tests passing
344
- - Smoke Test: ✅ happy path verified via Playwright
345
-
346
- ## Screenshots
347
-
348
- <!-- Paste screenshot paths saved in smoke-screenshots/ -->
349
-
350
- ## Checklist
351
-
352
- - [ ] Automated scans: 0 CRITICAL findings
353
- - [ ] All tests passing
354
- - [ ] Smoke test via Playwright: ✅
355
- - [ ] Code review checklist: CRITICAL + HIGH items verified
356
- - [ ] validate-feature: ✅ passed
357
- - [ ] Checkpoint saved
358
- - [ ] recap.md generated
359
- EOF
360
- )"
361
- ```
362
-
363
- ---
364
-
365
- ## Block Summary
366
-
367
- | Step | Block Condition |
368
- |------|-----------------|
369
- | Step 2 | Any CRITICAL finding in automated scans |
370
- | Step 3 | Any test failing |
371
- | Step 4 | `validate-feature` failing |
372
- | Step 5 | Dev server active + smoke test failing |
373
- | Step 5 | Dev server not detected without explicit user confirmation |
374
- | Step 6 | Any unresolved CRITICAL item in manual checklist |
375
- | Step 8 | Tests failing in worktree before merge/PR |
376
- | Step 9 | Unresolved CRITICAL item in `morph-checklist` |
377
-
378
- **All BLOCKs must be resolved before creating the PR.**
379
-
380
- ---
381
-
382
- *MORPH-SPEC by Polymorphism Tech*