@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,493 +0,0 @@
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.21.0"
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
- 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. `morph-spec state mark-output $ARGUMENTS tasks`
39
- 2. `morph-spec approve $ARGUMENTS tasks`
40
- 3. `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
- morph-spec validate-feature $ARGUMENTS
55
-
56
- # 2. Confirm all approval gates passed
57
- morph-spec approval-status $ARGUMENTS
58
-
59
- # 3. Verify activeAgents are populated
60
- 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) | `morph-spec approve $ARGUMENTS <gate>` |
69
- | Invalid phase | `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 — Tool Availability
77
-
78
- Before starting tasks, verify that CLIs and MCPs needed for this phase are available. The `inject-morph-context` hook reports both at session start.
79
-
80
- **1. Check CLIs (from session context `CLIs:` line):**
81
-
82
- | CLI | Required for | If missing |
83
- |-----|-------------|------------|
84
- | `docker` | Container services (Redis, etc.) | Start Docker Desktop |
85
- | `neonctl` | Neon database management, migrations | `npm install -g neonctl` |
86
- | `psql` | Direct DB queries | Install PostgreSQL client |
87
- | `az` | Azure resource management | `winget install Microsoft.AzureCLI` |
88
- | `gh` | GitHub PRs, issues | `winget install GitHub.cli` |
89
-
90
- If a critical CLI shows `✗`, use `AskUserQuestion` to ask the user:
91
- - **Install now** — provide the install command
92
- - **Continue without it** — use fallback (e.g., WebSearch instead of `az`)
93
- - **Stop implementation** — user must fix and re-run
94
-
95
- **2. Check MCPs (from session context `MCPs:` line):**
96
-
97
- For each MCP showing `✗ (recommended)`:
98
-
99
- | MCP | Fallback |
100
- |-----|----------|
101
- | **Context7** | WebSearch + WebFetch |
102
- | **Playwright** | `curl` / WebFetch (limited — no JS rendering) |
103
- | **GitHub** | `gh` CLI |
104
- | **Vercel** | `vercel` CLI |
105
-
106
- > **Design:** This check is fail-open — consistent with morph-spec philosophy. Missing tools are warnings, not blockers (except `docker` for container-dependent projects).
107
-
108
- ---
109
-
110
- ## Scaffold & Code Templates (MANDATORY before first task)
111
-
112
- Before writing any implementation code, scaffold the feature structure using the CLI.
113
-
114
- ### For .NET backend tasks (VSA):
115
-
116
- **Scaffold all CRUD slices for the feature:**
117
- ```bash
118
- morph-spec scaffold dotnet $ENTITY create-$ENTITY
119
- morph-spec scaffold dotnet $ENTITY get-${ENTITY}-by-id
120
- morph-spec scaffold dotnet $ENTITY get-all-${ENTITY}s
121
- morph-spec scaffold dotnet $ENTITY update-$ENTITY
122
- morph-spec scaffold dotnet $ENTITY delete-$ENTITY
123
- ```
124
-
125
- > Entity and errors are generated with the first slice and auto-skipped on subsequent ones.
126
- > After scaffolding, customize: fill in request/response properties, validation rules, and handler logic per contracts.cs.
127
-
128
- ### For Next.js frontend tasks:
129
-
130
- **Scaffold the feature page:**
131
- ```bash
132
- morph-spec scaffold nextjs $FEATURE
133
- ```
134
-
135
- > After scaffolding, customize: add columns to DataTable, form fields, and Zod schema.
136
-
137
- ### Template reference (for manual adjustments):
138
- ```bash
139
- cat .morph/framework/templates/code/dotnet/feature/endpoint.cs.hbs
140
- cat .morph/framework/templates/frontend/nextjs/page.tsx.hbs
141
- ```
142
-
143
- > **Rule:** All code MUST follow the patterns in these templates. Scaffold guarantees this. Do not invent different patterns.
144
-
145
- See `.morph/framework/templates/` for the full template index (abstractions, extensions, pipelines, jobs, tests).
146
-
147
- ---
148
-
149
- ## Recommended Tools
150
-
151
- > **Ref:** `framework/skills/level-0-meta/morph-tool-usage-guide/SKILL.md` for complete guide.
152
- > **Ref:** `framework/standards/integration/mcp/mcp-tools.md` for MCP reference.
153
- > **Example:** `references/recap-example.md` — filled-in recap.md showing expected output quality.
154
-
155
- | Action | Tool | Alternative |
156
- |--------|------|-------------|
157
- | Get dispatch recommendation | **Bash** `morph-spec dispatch-agents $ARGUMENTS implement` | Agent recommendations + task routing |
158
- | **Dispatch implementers by domain** | **Agent** `subagent_type=<recommended[group][0]>` — agent .md file provides the prompt | Backend + frontend + infra in parallel |
159
- | Read task details | **Read** tasks.md, spec.md, contracts.cs/.ts | — |
160
- | Create new files | **Write** source files | — |
161
- | Modify existing files | **Edit** source files | — |
162
- | Look up library API | **Context7 MCP** `query_docs()` | **WebSearch** + **WebFetch** |
163
- | Run migrations | **Bash** `dotnet ef database update` | `psql <DB_URL>` for verification |
164
- | Build project | **Bash** `dotnet build` or `npm run build` | — |
165
- | Run tests | **Bash** `dotnet test` or `npm test` | — |
166
- | Checkpoint validation | **Bash** `morph-spec validate-feature ...` | — |
167
- | Mark task complete | **Bash** `morph-spec task done $ARGUMENTS T001` | — |
168
- | Smoke test in browser | **Playwright MCP** `browser_navigate()` + `browser_snapshot()` | Manual |
169
- | Check console errors | **Playwright MCP** `browser_console_messages()` | — |
170
- | Screenshot for recap | **Playwright MCP** `browser_take_screenshot()` | — |
171
- | Deploy and logs Vercel | **Vercel MCP** `list_projects()`, `get_deployments()`, `manage_env_vars()` | **Bash** `vercel deploy` |
172
- | Create PR | **Bash** `gh pr create ...` | **GitHub MCP** `create_pull_request()` |
173
- | Update state | **Bash** `morph-spec state set ...` | — |
174
-
175
- **Phase tools:** Docker CLI (container health, logs), Neon CLI (`neonctl`) (database management), EF Core CLI (migrations), Context7 (API lookup), Playwright (smoke test), GitHub (PRs), Vercel (deploy, logs, env vars).
176
-
177
- > **Database Migrations:** When creating or running database migrations, use `dotnet ef migrations add <name>` to create, then `dotnet ef database update` to apply. Verify with `pg_dump $(neonctl connection-string) --schema public` or `psql` against the Neon database (get DB URL from `neonctl connection-string`).
178
-
179
- **Anti-patterns:**
180
- - Task agent for editing a single file (use Edit directly)
181
- - Subagents for single-domain features (sequential suffices)
182
- - `Bash cat` to create files (use Write tool)
183
- - `Bash sed` to modify code (use Edit tool)
184
- - Implementing without reading contracts.cs/.ts first (contracts are the source of truth!)
185
- - Running backend and frontend tasks sequentially when they are independent
186
- - **(VSA)** Creating Application Service layer — handler accesses IRepository directly
187
- - **(VSA)** Manually registering handlers/endpoints in Program.cs — use auto-discovery via reflection
188
- - **(VSA)** Placing Request/Response in separate files from Handler
189
- - **(VSA)** Using `Guid.NewGuid()` — use `Guid.CreateVersion7()`
190
- - Trying to fix a bug without invoking `systematic-debugging` first
191
-
192
- > **Docker CLI:** If a build or test fails with connection errors to local services (Redis, etc.), check container health first: `docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}"`. For debugging: `docker logs <container> --tail 50` to see recent logs. To restart a stuck container: `docker restart <container>`.
193
-
194
- ---
195
-
196
- ## Context Loading
197
-
198
- ### 1. Read full context in PARALLEL
199
-
200
- ```
201
- # Single parallel call, not sequential:
202
- Read: .morph/features/{feature}/4-tasks/tasks.md
203
- + Read: .morph/features/{feature}/2-design/spec.md
204
- + Read: .morph/features/{feature}/2-design/contracts.cs (or contracts.ts for TypeScript projects)
205
- + Read: .morph/config/config.json (→ architecture.style)
206
- + Read: .morph/features/{feature}/3-plan/plan.md
207
- ```
208
-
209
- ### 2. Detect architecture style
210
-
211
- ```bash
212
- cat .morph/config/config.json | grep architecture
213
- ```
214
-
215
- If `config.architecture.style === "vertical-slice"` → follow **Step 1.5** before implementing.
216
- Otherwise → go directly to the task loop.
217
-
218
- ### Step 1.5: VSA Implementation Guide (only if `style: "vertical-slice"`)
219
-
220
- > For the complete slice structure and VSA rules, see `references/vsa-implementation-guide.md`
221
-
222
- 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.
223
-
224
- ---
225
-
226
- ## Workflow
227
-
228
- ### Step 0.5: Dispatch Recommendation
229
-
230
- Get agent dispatch recommendation:
231
-
232
- ```bash
233
- morph-spec dispatch-agents $ARGUMENTS implement
234
- ```
235
-
236
- The output is a JSON advisor — it recommends which agents to use and which tasks they handle:
237
- - `recommended`: `{ [group]: subagentType[] }` — maps groups to agent file names
238
- - `tasks`: `{ [group]: taskId[] }` — maps groups to task IDs from tasks.md
239
- - `shouldDispatch`: true if 2+ agents available (parallel dispatch beneficial)
240
-
241
- **If `shouldDispatch` is true:**
242
-
243
- 1. Read `recommended` — maps groups (backend, frontend, etc.) to agent subagentTypes
244
- 2. Read `tasks` — maps groups to task IDs
245
- 3. For each agent, verify `.claude/agents/{subagentType}.md` exists. If missing → **STOP** with: `"Agent file not found. Run: morph-spec setup-infra"`. Do NOT fall back to general-purpose agents.
246
- 4. Dispatch each group in **parallel** using native Agent tool:
247
-
248
- ```
249
- Agent(subagent_type="morph-dotnet-senior", prompt="Implement tasks T001, T002 for feature {feature}. Read .morph/features/{feature}/4-tasks/tasks.md for task details and .morph/features/{feature}/2-design/ for contracts and spec. Follow the task loop: start → implement → verify → done. Checkpoint every 3 tasks. Domain isolation: modify ONLY files in your domain.")
250
- ```
251
-
252
- > **MANDATORY:** Use the exact `subagentType` value from `recommended`. Do NOT use `general-purpose` agents when a `subagentType` is available.
253
- >
254
- > The agent `.md` file contains the full expertise prompt, task routing, and key standards. No additional prompt injection needed — just provide the task assignment.
255
-
256
- 5. After all subagents complete, validate integration: `morph-spec validate-feature $ARGUMENTS --phase implement`
257
-
258
- **If `shouldDispatch` is false** → continue to sequential task loop (Step 2).
259
-
260
- **Fallback:** If `dispatch-agents` fails (non-zero exit or invalid JSON), log a warning and fall back to sequential single-agent mode (Step 2).
261
-
262
- ---
263
-
264
- ### Step 2: Task Loop
265
-
266
- For each task (T001 → T00N):
267
-
268
- 1. **Start task:**
269
- ```bash
270
- morph-spec task start $ARGUMENTS T001
271
- ```
272
- 2. **Read FR context** (MANDATORY — NON-NEGOTIABLE):
273
- - Parse task's `[FR references]` from tasks.md (e.g., `### T001: Create user endpoint [FR001, FR003]`)
274
- - **Read spec.md** → the sections for those specific FRs (functional requirements, acceptance criteria)
275
- - **Read contracts.cs/.ts** → the DTOs/interfaces referenced by those FRs
276
- - The spec is the source of truth. Code that doesn't match the spec is a bug.
277
- > **MCP:** Before implementing, use **Context7 MCP** (`resolve-library-id` → `query-docs`) to verify the correct API of the libraries being used. If Context7 is not available, use **WebSearch** + **WebFetch** to check official docs.
278
- 3. **Implement** using Write (new) or Edit (existing)
279
- 4. **Verify** — build, lint, tests
280
- 5. **MANDATORY — Verification before `task done`:**
281
- 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.
282
- ```bash
283
- morph-spec validate-feature $ARGUMENTS --phase implement
284
- ```
285
- Only proceed to step 6 if verification passes. If it fails → fix before marking `task done`.
286
- 6. **Mark as done via CLI:**
287
- ```bash
288
- morph-spec task done $ARGUMENTS T001
289
- ```
290
-
291
- ### Step 2.5: Scope Escalation (when task is too complex)
292
-
293
- If during implementation a task reveals significantly more complexity than estimated:
294
-
295
- - **Low impact (1-3 subtasks):** Expand the task directly:
296
- ```bash
297
- morph-spec task expand $ARGUMENTS T001 --into "T001a: First sub" "T001b: Second sub"
298
- ```
299
- Then implement each subtask following the same loop above.
300
-
301
- - **Medium/High impact (4+ tasks or spec is wrong):** Run the scope escalation workflow:
302
- ```bash
303
- /morph-scope-escalation $ARGUMENTS
304
- ```
305
-
306
- **Rule:** Never implement extra functionality within a task without registering it. If a task takes more than expected, expand it into subtasks — this ensures validation gates run for each piece and progress is tracked accurately.
307
-
308
- ### Step 3: Checkpoint Every 3 Tasks
309
-
310
- **After every 3 completed tasks:**
311
-
312
- ```bash
313
- # Save checkpoint
314
- morph-spec checkpoint-save $ARGUMENTS
315
-
316
- # Run validation
317
- morph-spec validate-feature $ARGUMENTS --phase implement
318
- ```
319
-
320
- **If validation fails:**
321
- 1. Do NOT advance to the next task
322
- 2. Fix reported issues
323
- 3. Re-run validation
324
- 4. Only then proceed
325
-
326
- ### Step 4: Test-Driven Development (Recommended)
327
-
328
- For each implementation task:
329
-
330
- 1. **Write test first** (unit test for service/domain)
331
- 2. **Run test** — should fail (RED)
332
- 3. **Implement** the minimum to pass
333
- 4. **Run test** — should pass (GREEN)
334
- 5. **Refactor** if needed (REFACTOR)
335
-
336
- ```bash
337
- # .NET
338
- dotnet test --filter "FullyQualifiedName~{TestClass}"
339
-
340
- # Node.js
341
- npm test -- test/path/to/test.js
342
- ```
343
-
344
- ### Step 5: Smoke Test with Playwright (if UI)
345
-
346
- > **MCP:** After implementing an API endpoint or page, if **Playwright MCP** is available, immediately do a quick smoke test: navigate to the endpoint/page URL, call `browser_snapshot()` to verify it loads, and check `browser_console_messages({ level: 'error' })` for errors. Catch issues while context is fresh rather than waiting for post-implementation. If Playwright is not available, verify manually via `curl` or browser.
347
-
348
- After implementing visual components:
349
-
350
- ```javascript
351
- // Navigate to the page
352
- await mcp__playwright__browser_navigate({ url: 'http://localhost:5000/feature-page' });
353
-
354
- // Capture page state
355
- await mcp__playwright__browser_snapshot();
356
-
357
- // Check console errors
358
- await mcp__playwright__browser_console_messages({ level: 'error' });
359
-
360
- // Screenshot for recap
361
- await mcp__playwright__browser_take_screenshot({ type: 'png' });
362
- ```
363
-
364
- ### Step 6: Generate `recap.md`
365
-
366
- After ALL tasks completed:
367
-
368
- ```bash
369
- morph-spec generate recap $ARGUMENTS
370
- ```
371
-
372
- > For the full recap format, see `references/recap-example.md`
373
-
374
- ### Step 7: Update State
375
-
376
- ```bash
377
- morph-spec state set $ARGUMENTS status done
378
- morph-spec state mark-output $ARGUMENTS recap
379
- ```
380
-
381
- ### Step 8: Post-Implementation Review (mandatory before PR)
382
-
383
- ```bash
384
- /post-implementation $ARGUMENTS
385
- ```
386
-
387
- Run the `post-implementation` skill before creating the PR. It orchestrates:
388
- - Automated scans (CRITICAL findings block PR)
389
- - Full test suite
390
- - Final `validate-feature`
391
- - Smoke test via Playwright (mandatory if dev server active)
392
- - Code review checklist (CRITICAL + HIGH)
393
- - **`morph-checklist`** — compliance (security, SEO, performance, accessibility, LGPD)
394
- - Checkpoint + final recap
395
-
396
- ### Step 9: Frontend Review (NEXTJS/FULLSTACK)
397
-
398
- If stack is NEXTJS or FULLSTACK:
399
-
400
- ```bash
401
- /frontend-review $ARGUMENTS
402
- ```
403
-
404
- Complements `post-implementation` with: accessibility scan (static + axe-core runtime),
405
- responsive screenshots (mobile/tablet/desktop), and SEO metadata verification.
406
-
407
- ---
408
-
409
- ## Morph-Native Dispatch
410
-
411
- morph-spec uses its own agents and validators for implementation, dispatch, and review.
412
-
413
- ### Implementation
414
-
415
- Get dispatch recommendation and use native Agent tool:
416
- ```bash
417
- morph-spec dispatch-agents $ARGUMENTS implement
418
- ```
419
-
420
- Use `recommended[group]` subagentTypes directly:
421
- ```
422
- Agent(subagent_type="morph-dotnet-senior", prompt="Implement tasks T001, T002 for feature X...")
423
- ```
424
-
425
- > Agent `.md` files are self-contained — they include the expertise prompt, task routing, and key standards. The `subagentType` maps to `.claude/agents/` filenames:
426
- > - Tier 1-3: `morph-{id}` (e.g., `morph-dotnet-senior`)
427
- > - Tier 4: `morph-validator-{id}` (e.g., `morph-validator-architecture-expert`)
428
-
429
- ### Review (Two-Stage)
430
-
431
- **Stage 1 — Spec Compliance (mandatory):**
432
- ```
433
- Agent(subagent_type=<validator subagentType>, prompt=<filled prompts/spec-reviewer-prompt.md>)
434
- ```
435
- Use validators from `dispatch-agents --mode validate`. Spec compliance MUST pass before proceeding.
436
-
437
- **Stage 2 — Code Quality (mandatory):**
438
- ```
439
- Agent(subagent_type=morph-standards-architect, prompt=<filled prompts/code-quality-reviewer-prompt.md>)
440
- ```
441
- `critical` issues block. `important` issues must be fixed. `suggestion` is optional.
442
-
443
- ### Prompt Templates
444
-
445
- | Template | Usage |
446
- |----------|-------|
447
- | `prompts/implementer-prompt.md` | Dispatch to implementer agents |
448
- | `prompts/spec-reviewer-prompt.md` | Spec compliance review |
449
- | `prompts/code-quality-reviewer-prompt.md` | Code quality review |
450
-
451
- ---
452
-
453
- ## Outputs
454
-
455
- - Implemented source code (various files)
456
- - Unit and integration tests
457
- - `.morph/features/$ARGUMENTS/5-implement/recap.md` — Implementation summary
458
-
459
- ## Completion Criteria
460
-
461
- - [x] All tasks completed
462
- - [x] Build compiles without errors
463
- - [x] Tests passing
464
- - [x] Validation pipeline passes
465
- - [x] `recap.md` generated
466
- - [x] State updated to `status: done`
467
- - [x] Checkpoints saved every 3 tasks
468
- - [x] `/post-implementation` executed without BLOCKs
469
-
470
- ---
471
-
472
- ## Phase Outputs
473
-
474
- <!-- morph-outputs:implement -->
475
- | Output | Caminho |
476
- |--------|---------|
477
- | `recap` | `.morph/features/{feature}/5-implement/recap.md` |
478
- <!-- /morph-outputs -->
479
-
480
- ---
481
-
482
- ## Relevant Standards
483
-
484
- During implementation, standards auto-load via rules when editing relevant file types.
485
- For proactive reference:
486
- - Architecture: `.morph/framework/standards/architecture/` — structural compliance
487
- - Backend/Frontend: `.morph/framework/standards/backend/` or `.morph/framework/standards/frontend/`
488
- - Security: `.morph/framework/standards/security/` — authentication, authorization patterns
489
- - Testing: follow the project's existing test patterns (check `test/` or `tests/` directory)
490
-
491
- ---
492
-
493
- Feature complete! Consider creating a PR and running `morph-spec generate recap $ARGUMENTS`.
@@ -1,50 +0,0 @@
1
- # Morph-Spec Code Quality Review
2
-
3
- You are the standards-architect reviewer for feature '{{FEATURE_NAME}}'.
4
-
5
- ## Review Scope
6
-
7
- Review the implementation for code quality, architecture compliance, and adherence to project standards.
8
-
9
- ## Reference Documents
10
-
11
- Read these before reviewing:
12
- - `.morph/context/standards.md` — Project coding standards
13
- - `.morph/context/README.md` — Project architecture overview
14
- - `framework/standards/` — Framework-level standards (reference as needed)
15
-
16
- ## Review Checklist
17
-
18
- 1. **Naming Conventions** — PascalCase for types, camelCase for variables, kebab-case for files (or as defined in standards)
19
- 2. **Architecture Compliance** — Code follows the project's VSA architecture pattern (Handler + Validator + Endpoint per feature folder)
20
- 3. **Async Patterns** — CancellationToken propagated, no fire-and-forget, proper await
21
- 4. **Error Handling** — Appropriate exceptions, no swallowed errors, consistent patterns
22
- 5. **Security** — No hardcoded secrets, SQL injection, XSS vectors, or OWASP top 10 issues
23
- 6. **DI Lifetimes** — Correct service registration (Scoped for DB, Singleton for config, etc.)
24
- 7. **Test Quality** — Tests follow Arrange-Act-Assert, meaningful assertions, no test duplication
25
-
26
- ## Output Format
27
-
28
- ```json
29
- {
30
- "passed": true/false,
31
- "issues": [
32
- {
33
- "severity": "critical|important|suggestion",
34
- "file": "path/to/file",
35
- "line": 42,
36
- "description": "What the issue is",
37
- "fix": "How to fix it"
38
- }
39
- ]
40
- }
41
- ```
42
-
43
- ## Rules
44
-
45
- - `critical` issues MUST be fixed before merge
46
- - `important` issues SHOULD be fixed
47
- - `suggestion` issues are optional improvements
48
- - Only `critical` issues cause `passed: false`
49
- - Be specific — always include file path and line number
50
- - Prefer minimal fixes over refactoring
@@ -1,46 +0,0 @@
1
- # Morph-Spec Implementer Dispatch
2
-
3
- You are implementing tasks for the feature '{{FEATURE_NAME}}' as agent '{{AGENT_ID}}'.
4
-
5
- ## Context
6
-
7
- **Spec:** Read `.morph/features/{{FEATURE_NAME}}/2-design/spec.md`
8
- **Contracts:** Read `.morph/features/{{FEATURE_NAME}}/2-design/contracts.cs`
9
- **Plan:** Read `.morph/features/{{FEATURE_NAME}}/3-plan/plan.md`
10
- **Standards:** Read relevant files in `.morph/framework/standards/`
11
- **Code Templates:** Read `.morph/framework/templates/code/dotnet/feature/` (endpoint, handler, validator) — follow these patterns exactly
12
-
13
- ## Agent Briefing
14
-
15
- {{AGENT_BRIEFING}}
16
-
17
- ## Tasks Assigned
18
-
19
- {{TASK_LIST}}
20
-
21
- ## Execution Rules
22
-
23
- 1. Before starting each task:
24
- - Execute: `morph-spec task start {{FEATURE_NAME}} {{TASK_ID}}`
25
-
26
- 2. For each task, follow TDD:
27
- - Write the failing test first
28
- - Run it to verify it fails
29
- - Write minimal implementation to pass
30
- - Run tests to verify they pass
31
- - Commit
32
-
33
- 3. Before marking any task done:
34
- - Verify build compiles: `dotnet build` or `npm run build`
35
- - Run relevant tests
36
- - Execute: `morph-spec task done {{FEATURE_NAME}} {{TASK_ID}}`
37
-
38
- 4. Every 3 tasks:
39
- - Execute: `morph-spec checkpoint-save {{FEATURE_NAME}}`
40
- - Execute: `morph-spec validate-feature {{FEATURE_NAME}} --phase implement`
41
-
42
- 5. Contracts are the source of truth — all DTOs, interfaces, and types MUST match `contracts.cs` exactly
43
-
44
- 6. Modify ONLY files listed in your assigned tasks. Do NOT touch files outside your domain.
45
-
46
- 7. If you encounter a dependency on another agent's work, STOP and report it.
@@ -1,47 +0,0 @@
1
- # Morph-Spec Spec Compliance Review
2
-
3
- You are a Tier-4 spec reviewer for feature '{{FEATURE_NAME}}'.
4
-
5
- ## Review Scope
6
-
7
- Review the implementation against the specification. Your job is to ensure the code matches the spec EXACTLY — no more, no less.
8
-
9
- ## Reference Documents
10
-
11
- Read these before reviewing:
12
- - `.morph/features/{{FEATURE_NAME}}/2-design/spec.md` — The specification
13
- - `.morph/features/{{FEATURE_NAME}}/2-design/contracts.cs` — The contracts (source of truth)
14
- - `.morph/features/{{FEATURE_NAME}}/3-plan/plan.md` — The implementation plan
15
-
16
- ## Review Checklist
17
-
18
- For each task implemented, verify:
19
-
20
- 1. **Completeness** — All acceptance criteria from spec.md are implemented
21
- 2. **Correctness** — DTOs, interfaces, and types match contracts.cs exactly
22
- 3. **No over-building** — No features, flags, or abstractions not in the spec
23
- 4. **No under-building** — No missing error handling, validations, or edge cases from the spec
24
- 5. **Naming** — All names match the contracts (exact casing and spelling)
25
-
26
- ## Output Format
27
-
28
- ```json
29
- {
30
- "passed": true/false,
31
- "issues": [
32
- {
33
- "severity": "error|warning",
34
- "file": "path/to/file",
35
- "description": "What doesn't match the spec",
36
- "specReference": "Which section of spec.md"
37
- }
38
- ]
39
- }
40
- ```
41
-
42
- ## Rules
43
-
44
- - Only flag issues that represent spec non-compliance
45
- - Do NOT flag style preferences or minor improvements
46
- - Every issue MUST reference a specific section of spec.md or contracts.cs
47
- - If the implementation matches the spec, output `{ "passed": true, "issues": [] }`