@polymorphism-tech/morph-spec 4.7.2 → 4.8.4

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 (342) hide show
  1. package/LICENSE +1 -2
  2. package/README.md +379 -414
  3. package/bin/morph-spec.js +57 -394
  4. package/bin/validate.js +2 -26
  5. package/claude-plugin.json +2 -2
  6. package/docs/CHEATSHEET.md +203 -221
  7. package/docs/QUICKSTART.md +2 -8
  8. package/framework/CLAUDE.md +1 -1
  9. package/framework/commands/morph-proposal.md +3 -3
  10. package/framework/hooks/README.md +2 -5
  11. package/framework/hooks/claude-code/pre-tool-use/protect-readonly-files.js +4 -55
  12. package/framework/hooks/claude-code/session-start/inject-morph-context.js +20 -5
  13. package/framework/hooks/claude-code/statusline.py +6 -1
  14. package/framework/hooks/dev/check-sync-health.js +117 -0
  15. package/framework/hooks/dev/guard-version-numbers.js +57 -0
  16. package/framework/hooks/dev/sync-standards-registry.js +60 -0
  17. package/framework/hooks/dev/sync-template-registry.js +60 -0
  18. package/framework/hooks/dev/validate-skill-format.js +70 -0
  19. package/framework/hooks/dev/validate-standard-format.js +73 -0
  20. package/framework/hooks/shared/payload-utils.js +39 -0
  21. package/framework/hooks/shared/state-reader.js +25 -1
  22. package/framework/rules/morph-workflow.md +1 -1
  23. package/framework/skills/level-0-meta/morph-init/SKILL.md +216 -0
  24. package/framework/skills/level-0-meta/morph-replicate/SKILL.md +4 -4
  25. package/framework/skills/level-0-meta/tool-usage-guide/SKILL.md +4 -4
  26. package/framework/skills/level-0-meta/verification-before-completion/SKILL.md +1 -1
  27. package/framework/skills/level-1-workflows/phase-clarify/SKILL.md +192 -191
  28. package/framework/skills/level-1-workflows/phase-codebase-analysis/SKILL.md +181 -180
  29. package/framework/skills/level-1-workflows/phase-design/SKILL.md +339 -338
  30. package/framework/skills/level-1-workflows/phase-implement/SKILL.md +254 -253
  31. package/framework/skills/level-1-workflows/phase-setup/SKILL.md +168 -170
  32. package/framework/skills/level-1-workflows/phase-tasks/SKILL.md +284 -283
  33. package/framework/skills/level-1-workflows/phase-uiux/SKILL.md +246 -245
  34. package/framework/templates/examples/design-system-examples.md +1 -1
  35. package/framework/templates/ui/FluentDesignTheme.cs +1 -1
  36. package/framework/templates/ui/MudTheme.cs +1 -1
  37. package/framework/templates/ui/design-system.css +1 -1
  38. package/package.json +7 -5
  39. package/src/commands/agents/index.js +1 -2
  40. package/src/commands/index.js +13 -16
  41. package/src/commands/project/doctor.js +100 -14
  42. package/src/commands/project/index.js +7 -10
  43. package/src/commands/project/init.js +398 -528
  44. package/src/commands/project/install-plugin-cmd.js +28 -0
  45. package/src/commands/project/setup-infra-cmd.js +12 -0
  46. package/src/commands/project/tutorial.js +115 -0
  47. package/src/commands/state/approve.js +213 -221
  48. package/src/commands/state/index.js +0 -1
  49. package/src/commands/state/state.js +337 -365
  50. package/src/commands/templates/index.js +0 -4
  51. package/src/commands/trust/trust.js +1 -93
  52. package/src/commands/utils/index.js +1 -5
  53. package/src/commands/validation/index.js +1 -5
  54. package/src/core/registry/command-registry.js +11 -285
  55. package/src/core/state/state-manager.js +5 -2
  56. package/src/lib/detectors/index.js +81 -87
  57. package/src/lib/detectors/structure-detector.js +275 -273
  58. package/src/lib/generators/recap-generator.js +232 -225
  59. package/src/scripts/global-install.js +34 -0
  60. package/src/scripts/install-plugin.js +126 -0
  61. package/src/scripts/setup-infra.js +203 -0
  62. package/src/utils/agents-installer.js +10 -1
  63. package/src/utils/hooks-installer.js +66 -3
  64. package/.morph/.morphversion +0 -5
  65. package/.morph/analytics/threads-log.jsonl +0 -5
  66. package/.morph/config/config.json +0 -8
  67. package/.morph/framework/agents.json +0 -1815
  68. package/.morph/framework/hooks/README.md +0 -205
  69. package/.morph/framework/hooks/claude-code/notification/approval-reminder.js +0 -54
  70. package/.morph/framework/hooks/claude-code/post-tool-use/dispatch.js +0 -83
  71. package/.morph/framework/hooks/claude-code/post-tool-use/handle-tool-failure.js +0 -42
  72. package/.morph/framework/hooks/claude-code/pre-compact/save-morph-context.js +0 -61
  73. package/.morph/framework/hooks/claude-code/pre-tool-use/enforce-phase-writes.js +0 -71
  74. package/.morph/framework/hooks/claude-code/pre-tool-use/protect-readonly-files.js +0 -58
  75. package/.morph/framework/hooks/claude-code/pre-tool-use/protect-spec-files.js +0 -64
  76. package/.morph/framework/hooks/claude-code/session-start/inject-morph-context.js +0 -94
  77. package/.morph/framework/hooks/claude-code/statusline.py +0 -538
  78. package/.morph/framework/hooks/claude-code/statusline.sh +0 -7
  79. package/.morph/framework/hooks/claude-code/stop/validate-completion.js +0 -88
  80. package/.morph/framework/hooks/claude-code/user-prompt/enrich-prompt.js +0 -91
  81. package/.morph/framework/hooks/git/commit-msg/conventional-commits.sh +0 -33
  82. package/.morph/framework/hooks/git/pre-commit/agents.sh +0 -25
  83. package/.morph/framework/hooks/git/pre-commit/orchestrator.sh +0 -64
  84. package/.morph/framework/hooks/git/pre-commit/specs.sh +0 -50
  85. package/.morph/framework/hooks/git/pre-push/run-tests.sh +0 -44
  86. package/.morph/framework/hooks/shared/hook-response.js +0 -45
  87. package/.morph/framework/hooks/shared/phase-utils.js +0 -129
  88. package/.morph/framework/hooks/shared/state-reader.js +0 -138
  89. package/.morph/framework/hooks/shared/stdin-reader.js +0 -26
  90. package/.morph/framework/standards/STANDARDS.json +0 -933
  91. package/.morph/framework/standards/ai-agents/blazor-ui.md +0 -364
  92. package/.morph/framework/standards/ai-agents/production.md +0 -415
  93. package/.morph/framework/standards/ai-agents/setup.md +0 -418
  94. package/.morph/framework/standards/ai-agents/team-orchestration.md +0 -479
  95. package/.morph/framework/standards/ai-agents/workflows.md +0 -354
  96. package/.morph/framework/standards/architecture/ddd/aggregates.md +0 -120
  97. package/.morph/framework/standards/architecture/ddd/bounded-contexts.md +0 -105
  98. package/.morph/framework/standards/architecture/ddd/complexity-levels.md +0 -108
  99. package/.morph/framework/standards/architecture/ddd/entities.md +0 -99
  100. package/.morph/framework/standards/architecture/ddd/ubiquitous-language.md +0 -58
  101. package/.morph/framework/standards/architecture/ddd/value-objects.md +0 -124
  102. package/.morph/framework/standards/backend/api/minimal-api.md +0 -494
  103. package/.morph/framework/standards/backend/api/rest.md +0 -492
  104. package/.morph/framework/standards/backend/api/validation.md +0 -88
  105. package/.morph/framework/standards/backend/authentication/passkeys.md +0 -428
  106. package/.morph/framework/standards/backend/database/ef-core.md +0 -199
  107. package/.morph/framework/standards/backend/database/migrations.md +0 -393
  108. package/.morph/framework/standards/backend/database/postgresql/database.md +0 -352
  109. package/.morph/framework/standards/backend/database/repository-patterns.md +0 -528
  110. package/.morph/framework/standards/backend/database/vector-search-rag.md +0 -541
  111. package/.morph/framework/standards/backend/dotnet/async.md +0 -366
  112. package/.morph/framework/standards/backend/dotnet/core.md +0 -117
  113. package/.morph/framework/standards/backend/dotnet/di.md +0 -439
  114. package/.morph/framework/standards/backend/dotnet/program-cs-checklist.md +0 -92
  115. package/.morph/framework/standards/backend/integrations/asaas/asaas-api.md +0 -216
  116. package/.morph/framework/standards/backend/integrations/clerk/clerk-auth.md +0 -290
  117. package/.morph/framework/standards/backend/integrations/hangfire/hangfire-jobs.md +0 -350
  118. package/.morph/framework/standards/backend/integrations/resend/resend-email.md +0 -385
  119. package/.morph/framework/standards/context/analytics.md +0 -96
  120. package/.morph/framework/standards/context/bundles.md +0 -110
  121. package/.morph/framework/standards/context/priming.md +0 -78
  122. package/.morph/framework/standards/core/architecture.md +0 -185
  123. package/.morph/framework/standards/core/coding.md +0 -214
  124. package/.morph/framework/standards/core/git-branching-strategy.md +0 -403
  125. package/.morph/framework/standards/core/git.md +0 -185
  126. package/.morph/framework/standards/core/testing.md +0 -295
  127. package/.morph/framework/standards/data/nosql/blob-storage.md +0 -102
  128. package/.morph/framework/standards/data/nosql/cache/redis.md +0 -97
  129. package/.morph/framework/standards/data/nosql/cosmos-db.md +0 -118
  130. package/.morph/framework/standards/data/vector-search/azure-ai-search.md +0 -121
  131. package/.morph/framework/standards/data/vector-search/rag-chunking.md +0 -104
  132. package/.morph/framework/standards/frontend/blazor/design-checklist.md +0 -222
  133. package/.morph/framework/standards/frontend/blazor/fluent-ui-setup.md +0 -595
  134. package/.morph/framework/standards/frontend/blazor/fluent-ui.md +0 -137
  135. package/.morph/framework/standards/frontend/blazor/html-conversion.md +0 -184
  136. package/.morph/framework/standards/frontend/blazor/lifecycle.md +0 -195
  137. package/.morph/framework/standards/frontend/blazor/pitfalls.md +0 -198
  138. package/.morph/framework/standards/frontend/blazor/state.md +0 -191
  139. package/.morph/framework/standards/frontend/design-system/animations.md +0 -151
  140. package/.morph/framework/standards/frontend/design-system/naming.md +0 -64
  141. package/.morph/framework/standards/frontend/nextjs/app-router.md +0 -123
  142. package/.morph/framework/standards/frontend/nextjs/components.md +0 -132
  143. package/.morph/framework/standards/frontend/nextjs/data-fetching.md +0 -126
  144. package/.morph/framework/standards/frontend/nextjs/forms.md +0 -128
  145. package/.morph/framework/standards/frontend/nextjs/naming-conventions.md +0 -67
  146. package/.morph/framework/standards/frontend/nextjs/nextjs-patterns.md +0 -215
  147. package/.morph/framework/standards/frontend/nextjs/project-structure.md +0 -102
  148. package/.morph/framework/standards/frontend/nextjs/state-management.md +0 -72
  149. package/.morph/framework/standards/frontend/nextjs/testing.md +0 -111
  150. package/.morph/framework/standards/infrastructure/azure/azure.md +0 -624
  151. package/.morph/framework/standards/infrastructure/azure/bicep/bicep-patterns.md +0 -422
  152. package/.morph/framework/standards/infrastructure/azure/devops/azure-devops-setup.md +0 -516
  153. package/.morph/framework/standards/infrastructure/azure/devops/local-development.md +0 -520
  154. package/.morph/framework/standards/infrastructure/azure/services/functions.md +0 -486
  155. package/.morph/framework/standards/infrastructure/azure/services/service-bus.md +0 -459
  156. package/.morph/framework/standards/infrastructure/azure/services/storage.md +0 -407
  157. package/.morph/framework/standards/infrastructure/docker/easypanel-deploy.md +0 -196
  158. package/.morph/framework/standards/infrastructure/supabase/mcp-setup.md +0 -252
  159. package/.morph/framework/standards/infrastructure/supabase/supabase-auth.md +0 -176
  160. package/.morph/framework/standards/infrastructure/supabase/supabase-pgvector.md +0 -169
  161. package/.morph/framework/standards/infrastructure/supabase/supabase-rls.md +0 -184
  162. package/.morph/framework/standards/infrastructure/supabase/supabase-storage.md +0 -153
  163. package/.morph/framework/standards/integration/api/graphql.md +0 -91
  164. package/.morph/framework/standards/integration/api/grpc.md +0 -114
  165. package/.morph/framework/standards/integration/api/rest-design.md +0 -95
  166. package/.morph/framework/standards/integration/event-driven/cqrs.md +0 -101
  167. package/.morph/framework/standards/integration/event-driven/event-sourcing.md +0 -124
  168. package/.morph/framework/standards/integration/event-driven/service-bus.md +0 -95
  169. package/.morph/framework/standards/integration/mcp/mcp-tools.md +0 -384
  170. package/.morph/framework/standards/observability/logging.md +0 -131
  171. package/.morph/framework/standards/observability/metrics.md +0 -121
  172. package/.morph/framework/standards/observability/monitoring.md +0 -114
  173. package/.morph/framework/standards/observability/tracing.md +0 -132
  174. package/.morph/framework/standards/workflows/parallel-execution.md +0 -112
  175. package/.morph/framework/standards/workflows/thread-management.md +0 -113
  176. package/.morph/framework/templates/.idea/morph-templates.xml +0 -92
  177. package/.morph/framework/templates/.vscode/morph-templates.code-snippets +0 -186
  178. package/.morph/framework/templates/IDE-SNIPPETS.md +0 -266
  179. package/.morph/framework/templates/README.md +0 -814
  180. package/.morph/framework/templates/REGISTRY.json +0 -1888
  181. package/.morph/framework/templates/code/dotnet/backend/repository.cs +0 -141
  182. package/.morph/framework/templates/code/dotnet/backend/service.cs +0 -139
  183. package/.morph/framework/templates/code/dotnet/contracts/Commands.cs +0 -74
  184. package/.morph/framework/templates/code/dotnet/contracts/Entities.cs +0 -25
  185. package/.morph/framework/templates/code/dotnet/contracts/Queries.cs +0 -74
  186. package/.morph/framework/templates/code/dotnet/contracts/README.md +0 -74
  187. package/.morph/framework/templates/code/dotnet/contracts/api-contracts.cs +0 -173
  188. package/.morph/framework/templates/code/dotnet/contracts/contracts-level1.cs +0 -69
  189. package/.morph/framework/templates/code/dotnet/contracts/contracts-level2.cs +0 -86
  190. package/.morph/framework/templates/code/dotnet/contracts/contracts-level3.cs +0 -41
  191. package/.morph/framework/templates/code/dotnet/database/migration.cs +0 -83
  192. package/.morph/framework/templates/code/dotnet/frontend/component.razor +0 -239
  193. package/.morph/framework/templates/code/dotnet/jobs/agent.cs +0 -163
  194. package/.morph/framework/templates/code/dotnet/jobs/job.cs +0 -171
  195. package/.morph/framework/templates/code/dotnet/test.cs +0 -239
  196. package/.morph/framework/templates/code/sql/rls-policy.sql +0 -57
  197. package/.morph/framework/templates/code/sql/supabase-migration.sql +0 -100
  198. package/.morph/framework/templates/code/sql/supabase-migration.template.sql +0 -113
  199. package/.morph/framework/templates/code/typescript/contracts.ts +0 -168
  200. package/.morph/framework/templates/context/CONTEXT-FEATURE.md +0 -276
  201. package/.morph/framework/templates/context/CONTEXT.md +0 -181
  202. package/.morph/framework/templates/docs/clarifications.md +0 -253
  203. package/.morph/framework/templates/docs/onboarding.md +0 -123
  204. package/.morph/framework/templates/docs/proposal.md +0 -182
  205. package/.morph/framework/templates/docs/schema-analysis.md +0 -119
  206. package/.morph/framework/templates/docs/spec.md +0 -198
  207. package/.morph/framework/templates/docs/ui-components.md +0 -124
  208. package/.morph/framework/templates/docs/ui-design-system.md +0 -76
  209. package/.morph/framework/templates/docs/ui-flows.md +0 -167
  210. package/.morph/framework/templates/docs/ui-mockups.md +0 -98
  211. package/.morph/framework/templates/docs/user-stories.md +0 -34
  212. package/.morph/framework/templates/examples/design-system-examples.md +0 -357
  213. package/.morph/framework/templates/examples/spec-examples.md +0 -90
  214. package/.morph/framework/templates/feature/decisions.md +0 -187
  215. package/.morph/framework/templates/feature/recap.md +0 -146
  216. package/.morph/framework/templates/feature/tasks.md +0 -199
  217. package/.morph/framework/templates/frontend/nextjs/Dockerfile.nextjs.hbs +0 -43
  218. package/.morph/framework/templates/frontend/nextjs/client-component.tsx.hbs +0 -26
  219. package/.morph/framework/templates/frontend/nextjs/env.mjs.hbs +0 -32
  220. package/.morph/framework/templates/frontend/nextjs/feature-form.tsx.hbs +0 -56
  221. package/.morph/framework/templates/frontend/nextjs/page.tsx.hbs +0 -22
  222. package/.morph/framework/templates/frontend/nextjs/tsconfig.json.hbs +0 -26
  223. package/.morph/framework/templates/frontend/nextjs/use-feature.ts.hbs +0 -54
  224. package/.morph/framework/templates/infrastructure/azure/Dockerfile.example +0 -82
  225. package/.morph/framework/templates/infrastructure/azure/README.md +0 -286
  226. package/.morph/framework/templates/infrastructure/azure/app-insights.bicep +0 -63
  227. package/.morph/framework/templates/infrastructure/azure/app-service.bicep +0 -164
  228. package/.morph/framework/templates/infrastructure/azure/container-app-env.bicep +0 -49
  229. package/.morph/framework/templates/infrastructure/azure/container-app.bicep +0 -156
  230. package/.morph/framework/templates/infrastructure/azure/deploy-checklist.md +0 -426
  231. package/.morph/framework/templates/infrastructure/azure/deploy.ps1 +0 -229
  232. package/.morph/framework/templates/infrastructure/azure/deploy.sh +0 -208
  233. package/.morph/framework/templates/infrastructure/azure/key-vault.bicep +0 -91
  234. package/.morph/framework/templates/infrastructure/azure/main.bicep +0 -189
  235. package/.morph/framework/templates/infrastructure/azure/parameters.dev.json +0 -29
  236. package/.morph/framework/templates/infrastructure/azure/parameters.prod.json +0 -29
  237. package/.morph/framework/templates/infrastructure/azure/parameters.staging.json +0 -29
  238. package/.morph/framework/templates/infrastructure/azure/sql-database.bicep +0 -103
  239. package/.morph/framework/templates/infrastructure/azure/storage.bicep +0 -106
  240. package/.morph/framework/templates/infrastructure/docker/Dockerfile.template +0 -58
  241. package/.morph/framework/templates/infrastructure/docker/docker-compose.template.yml +0 -67
  242. package/.morph/framework/templates/infrastructure/docker/dockerfile-api.dockerfile +0 -38
  243. package/.morph/framework/templates/infrastructure/docker/dockerfile-web.dockerfile +0 -48
  244. package/.morph/framework/templates/infrastructure/docker/easypanel.template.json +0 -54
  245. package/.morph/framework/templates/infrastructure/github/README.md +0 -593
  246. package/.morph/framework/templates/infrastructure/github/actions/azure-auth/action.yml.hbs +0 -22
  247. package/.morph/framework/templates/infrastructure/github/actions/docker-build-push/action.yml.hbs +0 -45
  248. package/.morph/framework/templates/infrastructure/github/actions/health-check/action.yml.hbs +0 -27
  249. package/.morph/framework/templates/infrastructure/github/workflows/deploy-azure-app-service.yml.hbs +0 -61
  250. package/.morph/framework/templates/infrastructure/github/workflows/deploy-easypanel.yml.hbs +0 -31
  251. package/.morph/framework/templates/infrastructure/github/workflows/docker-build-push.yml.hbs +0 -59
  252. package/.morph/framework/templates/infrastructure/github/workflows/dotnet-build.yml.hbs +0 -39
  253. package/.morph/framework/templates/integrations/asaas-client.cs +0 -387
  254. package/.morph/framework/templates/integrations/asaas-webhook.cs +0 -351
  255. package/.morph/framework/templates/integrations/azure-identity-config.cs +0 -288
  256. package/.morph/framework/templates/integrations/clerk-config.cs +0 -258
  257. package/.morph/framework/templates/meta-prompts/fusion/fusion-agent.md +0 -76
  258. package/.morph/framework/templates/meta-prompts/fusion/fusion-aggregator.md +0 -100
  259. package/.morph/framework/templates/meta-prompts/hops/hop-retry.md +0 -78
  260. package/.morph/framework/templates/meta-prompts/hops/hop-validation.md +0 -97
  261. package/.morph/framework/templates/meta-prompts/hops/hop-wrapper.md +0 -36
  262. package/.morph/framework/templates/meta-prompts/parallel-workers/parallel-coordinator.md +0 -113
  263. package/.morph/framework/templates/meta-prompts/parallel-workers/parallel-worker.md +0 -80
  264. package/.morph/framework/templates/meta-prompts/squad-leaders/backend-squad.md +0 -90
  265. package/.morph/framework/templates/meta-prompts/squad-leaders/frontend-squad.md +0 -126
  266. package/.morph/framework/templates/meta-prompts/squad-leaders/squad-leader.md +0 -43
  267. package/.morph/framework/templates/meta-prompts/validators/checkpoint-validator.md +0 -107
  268. package/.morph/framework/templates/meta-prompts/validators/pre-commit-validator.md +0 -95
  269. package/.morph/framework/templates/project-structure/dotnet-ddd.md +0 -70
  270. package/.morph/framework/templates/saas/subscription.cs +0 -347
  271. package/.morph/framework/templates/saas/tenant.cs +0 -338
  272. package/.morph/framework/templates/state.template.json +0 -17
  273. package/.morph/framework/templates/ui/FluentDesignTheme.cs +0 -149
  274. package/.morph/framework/templates/ui/MudTheme.cs +0 -281
  275. package/.morph/framework/templates/ui/design-system.css +0 -226
  276. package/.morph/logs/tool-failures.log +0 -17
  277. package/.morph/memory/pre-compact-2026-02-24T17-43-30-049Z.json +0 -16
  278. package/.morph/plans/eager-watching-bunny.md +0 -105
  279. package/.morph/plans/temporal-seeking-nebula.md +0 -45
  280. package/.morph/state.json +0 -48
  281. package/CLAUDE.md +0 -77
  282. package/docs/ARCHITECTURE.md +0 -331
  283. package/docs/COMMAND-FLOWS.md +0 -368
  284. package/docs/claude-alignment-report.md +0 -137
  285. package/docs/examples/order-management/contracts.cs +0 -84
  286. package/docs/examples/order-management/proposal.md +0 -24
  287. package/docs/examples/order-management/spec.md +0 -162
  288. package/docs/plans/2026-02-22-claude-docs-morph-alignment-analysis.md +0 -512
  289. package/docs/plans/2026-02-22-claude-settings.md +0 -515
  290. package/docs/plans/2026-02-22-morph-cc-alignment-impl.md +0 -728
  291. package/docs/plans/2026-02-22-morph-spec-next.md +0 -478
  292. package/docs/plans/2026-02-22-native-alignment-design.md +0 -199
  293. package/docs/plans/2026-02-22-native-alignment-impl.md +0 -925
  294. package/docs/plans/2026-02-22-native-enrichment-design.md +0 -244
  295. package/docs/plans/2026-02-22-native-enrichment.md +0 -735
  296. package/docs/plans/2026-02-23-ddd-architecture-refactor.md +0 -1153
  297. package/docs/plans/2026-02-23-ddd-nextsteps.md +0 -682
  298. package/docs/plans/2026-02-23-infra-architect-refactor.md +0 -437
  299. package/docs/plans/2026-02-23-nextjs-code-review-design.md +0 -156
  300. package/docs/plans/2026-02-23-nextjs-code-review-impl.md +0 -1254
  301. package/docs/plans/2026-02-23-nextjs-standards-design.md +0 -149
  302. package/docs/plans/2026-02-23-nextjs-standards-impl.md +0 -1846
  303. package/scripts/generate-refs.js +0 -336
  304. package/scripts/generate-standards-registry.js +0 -44
  305. package/scripts/scan-nextjs.mjs +0 -169
  306. package/scripts/validate-real.mjs +0 -255
  307. package/src/commands/feature/create-story.js +0 -362
  308. package/src/commands/feature/index.js +0 -6
  309. package/src/commands/feature/shard-spec.js +0 -225
  310. package/src/commands/feature/sprint-status.js +0 -250
  311. package/src/commands/generation/generate-onboarding.js +0 -169
  312. package/src/commands/generation/generate.js +0 -276
  313. package/src/commands/generation/index.js +0 -5
  314. package/src/commands/learning/capture-pattern.js +0 -121
  315. package/src/commands/learning/index.js +0 -5
  316. package/src/commands/learning/search-patterns.js +0 -126
  317. package/src/commands/mcp/mcp.js +0 -102
  318. package/src/commands/project/changes.js +0 -66
  319. package/src/commands/project/cost.js +0 -179
  320. package/src/commands/project/diff.js +0 -278
  321. package/src/commands/project/revert.js +0 -173
  322. package/src/commands/project/standards.js +0 -80
  323. package/src/commands/project/sync.js +0 -167
  324. package/src/commands/project/update-agents.js +0 -23
  325. package/src/commands/state/rollback-phase.js +0 -185
  326. package/src/commands/templates/template-customize.js +0 -87
  327. package/src/commands/templates/template-list.js +0 -114
  328. package/src/commands/templates/template-show.js +0 -129
  329. package/src/commands/templates/template-validate.js +0 -91
  330. package/src/commands/utils/troubleshoot.js +0 -222
  331. package/src/commands/validation/analyze-blazor-concurrency.js +0 -193
  332. package/src/commands/validation/lint-fluent.js +0 -352
  333. package/src/commands/validation/validate-blazor-state.js +0 -210
  334. package/src/commands/validation/validate-blazor.js +0 -156
  335. package/src/commands/validation/validate-css.js +0 -84
  336. package/src/lib/detectors/conversation-analyzer.js +0 -163
  337. package/src/lib/learning/index.js +0 -7
  338. package/src/lib/learning/learning-system.js +0 -520
  339. package/src/lib/troubleshooting/index.js +0 -8
  340. package/src/lib/troubleshooting/troubleshoot-grep.js +0 -198
  341. package/src/lib/troubleshooting/troubleshoot-index.js +0 -144
  342. package/src/llm/environment-detector.js +0 -43
@@ -1,162 +0,0 @@
1
- # Feature Specification: Order Management
2
-
3
- | Field | Value |
4
- |-------|-------|
5
- | **ID** | order-management |
6
- | **Status** | Approved |
7
- | **Created** | 2026-02-23 |
8
- | **Stack** | .NET 10 / Blazor Server / EF Core |
9
- | **Complexity** | Medium |
10
- | **Agents** | Core: All / Specialists: domain-architect, ef-modeler, event-architect |
11
-
12
- ---
13
-
14
- ## Overview
15
-
16
- **Problem:** Usuários precisam criar e gerenciar pedidos com rastreamento de status.
17
-
18
- **Solution:** Aggregate Order com factory method, invariants de estado, e Domain Events para notificações.
19
-
20
- **Success Criteria:**
21
- - [ ] Order CRUD com validações de negócio
22
- - [ ] Status tracking com transições controladas
23
- - [ ] Notificação ao confirmar pedido
24
-
25
- ---
26
-
27
- ## Requirements
28
-
29
- **Functional:**
30
- FR001: Criar pedido com mínimo 1 item | FR002: Confirmar pedido (Draft → Confirmed) | FR003: Cancelar pedido (Draft/Confirmed → Cancelled) | FR004: Calcular total automaticamente
31
-
32
- **Non-Functional:**
33
- NFR001: Performance - operações < 200ms | NFR002: Consistência - invariants garantidas em toda operação
34
-
35
- ---
36
-
37
- ## User Stories
38
-
39
- ### US001: Criar Pedido
40
- **As** usuário autenticado **I want** criar um pedido com itens **so that** posso comprar produtos
41
-
42
- **Acceptance Criteria:**
43
- 1. Pedido criado com status Draft
44
- 2. Total calculado na criação
45
-
46
- **Edge Cases:** Lista de itens vazia → erro 400
47
-
48
- ---
49
-
50
- ## Technical Design
51
-
52
- ### Stack
53
- | Component | Technology |
54
- |-----------|------------|
55
- | Frontend | Blazor Server |
56
- | Backend | .NET 10 / C# 14 |
57
- | Database | Azure SQL / EF Core |
58
-
59
- ### Data Model
60
-
61
- #### Order
62
- | Column | Type | Constraints |
63
- |--------|------|-------------|
64
- | Id | Guid | PK |
65
- | UserId | Guid | FK (reference by ID — cross-aggregate) |
66
- | Status | OrderStatus | Enum |
67
- | CreatedAt | datetime2 | Default: GETUTCDATE() |
68
- | UpdatedAt | datetime2 | Nullable |
69
-
70
- #### OrderItem (owned entity)
71
- | Column | Type | Constraints |
72
- |--------|------|-------------|
73
- | Id | Guid | PK |
74
- | OrderId | Guid | FK |
75
- | ProductId | Guid | Reference by ID |
76
- | Quantity | int | > 0 |
77
- | UnitPrice | decimal(18,2) | > 0 |
78
-
79
- ### Contracts
80
- > **Ref:** `framework/templates/code/dotnet/contracts/contracts-level2.cs`
81
-
82
- ---
83
-
84
- ## Domain Complexity
85
-
86
- **Nível:** 2 — Business Logic
87
-
88
- **Justificativa:** Order tem estados com transições controladas (Draft → Confirmed → Cancelled),
89
- invariants de negócio (não confirmar sem itens, não adicionar itens a pedido confirmado),
90
- cálculo derivado (Total), e outros módulos precisam reagir (NotificationService ao OrderConfirmed).
91
-
92
- **Padrões Aplicados:**
93
- - AggregateRoot com factory method estático
94
- - Value Objects: Money (UnitPrice, Total)
95
- - Domain Events: OrderCreatedEvent, OrderConfirmedEvent, OrderCancelledEvent
96
- - CQRS com MediatR
97
-
98
- **Padrões Omitidos:**
99
- - Bounded Contexts — sistema single-domain, desnecessário
100
-
101
- ---
102
-
103
- ## Aggregate Blueprint (Nível 2+ apenas)
104
-
105
- ### Aggregate Root: Order
106
-
107
- **Invariants:**
108
- - Order só pode ser Confirmado se Status == Draft E tiver pelo menos 1 item
109
- - Order Confirmado não pode receber mais itens (AddItem lança DomainException)
110
- - Order Cancelado não pode ser reativado (estado terminal)
111
-
112
- **Estados e Transições:**
113
- ```
114
- {Draft} → Confirm() → {Confirmed}
115
- {Draft} → Cancel() → {Cancelled}
116
- {Confirmed} → Cancel() → {Cancelled}
117
- ```
118
-
119
- **Domain Events:**
120
- - `OrderCreatedEvent` — publicado ao criar (Create factory method)
121
- - `OrderConfirmedEvent` — publicado ao confirmar (Confirm method)
122
- - `OrderCancelledEvent` — publicado ao cancelar (Cancel method)
123
-
124
- **Value Objects:**
125
- - `Money` — UnitPrice e Total não são decimals simples: têm validação (> 0) e operações (Add, Multiply)
126
-
127
- **Referências Cross-Aggregate (por ID):**
128
- - `UserId: Guid` — nunca `User User { get; }`
129
- - `ProductId: Guid` em OrderItem — nunca `Product Product { get; }`
130
-
131
- ### Linguagem Ubíqua
132
-
133
- | Termo | Definição | Código |
134
- |-------|-----------|--------|
135
- | Order | Pedido de compra de um usuário | `Order` (AggregateRoot) |
136
- | Draft | Pedido criado, ainda editável | `OrderStatus.Draft` |
137
- | Confirmed | Pedido submetido, não editável | `OrderStatus.Confirmed` |
138
- | Cancelled | Pedido cancelado, estado terminal | `OrderStatus.Cancelled` |
139
- | Confirm | Ato de finalizar e submeter um pedido | `Order.Confirm()` |
140
- | OrderItem | Linha de produto dentro de um pedido | `OrderItem` (Entity owned) |
141
- | Total | Soma calculada de todos os itens | `Order.Total` (property calculada) |
142
-
143
- ---
144
-
145
- ## Flows
146
-
147
- ### Confirmar Pedido
148
- **Trigger:** Usuário clica "Confirmar Pedido"
149
- 1. Frontend → `POST /api/orders/{id}/confirm`
150
- 2. API → `ConfirmOrderCommand(OrderId)`
151
- 3. Handler → `repository.GetAsync(id)` → `order.Confirm()` → `repository.UpdateAsync(order)`
152
- 4. `OrderConfirmedEvent` publicado → NotificationService envia email
153
- **End State:** Order.Status = Confirmed
154
-
155
- ---
156
-
157
- ## Definition of Done
158
- - [ ] Aggregate implementado com todos os invariants
159
- - [ ] Domain Events publicados e consumidos
160
- - [ ] Testes unitários do Aggregate (sem EF)
161
- - [ ] Testes de integração do Handler
162
- - [ ] API endpoint documentado
@@ -1,512 +0,0 @@
1
- # Claude Code Native Alignment Analysis — Morph-Spec Framework
2
-
3
- **Date:** 2026-02-22
4
- **Source docs:** `code.claude.com/docs/en` (common-workflows, hooks-guide, sub-agents, skills, best-practices, settings)
5
- **Scope:** Architectural comparison, gap analysis, concrete improvement recommendations
6
-
7
- ---
8
-
9
- ## 1. Executive Summary
10
-
11
- Morph-Spec has strong alignment in some areas (CLAUDE.md design, native `permissions.deny`, agents installer, rules files) but significant **over-engineering in three zones**: the hooks infrastructure, the skills/agents taxonomy, and the state machine's relationship to Claude Code's own session and permission mechanisms.
12
-
13
- The framework's core value — **spec-driven phase gating** — is real and irreplaceable by anything Claude Code provides natively. The problem is that the scaffolding around it uses complex custom Node.js infrastructure where simple YAML frontmatter or jq one-liners would suffice.
14
-
15
- ---
16
-
17
- ## 2. Claude Code Native Features Reference
18
-
19
- The following features are **platform-native** and require zero custom code:
20
-
21
- | Feature | What CC provides | Location |
22
- |---|---|---|
23
- | **Skills** | SKILL.md files, `/slash-commands`, `$ARGUMENTS`, `context: fork`, scoped hooks, `allowed-tools`, `disable-model-invocation` | `.claude/skills/<name>/SKILL.md` |
24
- | **Subagents** | Markdown+frontmatter, automatic delegation, `tools`, `model`, `permissionMode`, `maxTurns`, `memory`, `isolation: worktree`, scoped hooks, preloaded skills | `.claude/agents/<name>.md` |
25
- | **Hooks** | 17 lifecycle events, `command`/`prompt`/`agent` types, matchers, exit-code control, JSON output for structured decisions, async execution | `settings.json` → `hooks` |
26
- | **Permissions** | `allow/deny/ask` rules with glob patterns, `defaultMode`, `additionalDirectories`, `disableBypassPermissionsMode` | `settings.json` → `permissions` |
27
- | **Memory / CLAUDE.md** | Multi-level CLAUDE.md (`~/.claude/`, `.claude/`, project root, subdirs), `@path/to/import` syntax | Any `CLAUDE.md` |
28
- | **Agent persistent memory** | `memory: user/project/local` in subagent frontmatter, auto-managed `MEMORY.md` per agent | `.claude/agent-memory/<name>/` |
29
- | **Plan Mode** | Read-only exploration before writing, `defaultMode: "plan"`, Shift+Tab toggle, `--permission-mode plan` | Platform |
30
- | **Worktrees** | `--worktree`, `isolation: worktree` in subagent frontmatter, auto-cleanup | Platform |
31
- | **Session management** | `--continue`, `--resume`, `/rename`, session picker, `--from-pr` | Platform |
32
- | **Statusline** | `statusLine.type: "command"` in `settings.json` | `settings.json` |
33
- | **Schema validation** | `$schema` in settings.json | `settings.json` |
34
-
35
- ### Key design principles from CC docs:
36
-
37
- 1. **Hooks are deterministic; CLAUDE.md is advisory** — hooks guarantee enforcement; instructions are guidance
38
- 2. **Skills are context-loaded knowledge; subagents are isolated executors** — different tools for different jobs
39
- 3. **CLAUDE.md should be short** — only things Claude can't infer; bloated CLAUDE.md is ignored
40
- 4. **Subagent description drives delegation** — no manual "tier" system needed; Claude matches by description
41
- 5. **Persistent agent memory** (`memory: project`) replaces custom context persistence
42
- 6. **Skill `context: fork`** runs skills in isolation — subagents aren't always needed
43
- 7. **`prompt`/`agent` hook types** — CC supports LLM-evaluated hooks natively; no custom prompt engineering needed
44
- 8. **`allowed-tools` in skill frontmatter** — scoped permission for skill duration, no custom validation
45
-
46
- ---
47
-
48
- ## 3. Morph-Spec Architecture vs CC Native: Feature-by-Feature
49
-
50
- ### 3.1 Skills System
51
-
52
- **Current:**
53
- ```
54
- framework/skills/
55
- level-0-meta/ → 6 skills (brainstorming, code-review, etc.)
56
- level-1-workflows/ → 8 skills (phase-proposal, phase-design, etc.)
57
- level-2-domains/ → 22 skills (blazor-builder, azure-architect, etc.)
58
- level-3-technologies/ → NOT installed
59
- level-4-patterns/ → NOT installed
60
- ```
61
- `skills-installer.js` copies level-0 + level-1 **FLAT** to `.claude/skills/` (no subdirectories, no supporting files).
62
-
63
- **Assessment:**
64
-
65
- | Aspect | Status | Issue |
66
- |---|---|---|
67
- | YAML frontmatter with `name` + `description` | ✅ Aligned | — |
68
- | `/slash-command` invocation | ✅ Aligned | — |
69
- | Level hierarchy (0–4) | ⚠️ Overhead | CC uses flat dirs + description matching — levels add no CC value |
70
- | Levels 2–4 never installed | ❌ Dead code | 22+ domain skills built but never deployed to users |
71
- | Installed FLAT (no dirs) | ⚠️ Limitation | No supporting files possible; `context: fork`, `allowed-tools`, `hooks` frontmatter unused |
72
- | level-2-domains as skills | ⚠️ Wrong type | Domain specialists (blazor-builder, azure-architect) are **subagents**, not skills — they need isolated execution, tool access, and persistent memory |
73
-
74
- **What's missing from skills:**
75
- - No `context: fork` + `agent:` for isolated phase execution
76
- - No `$ARGUMENTS` in phase workflow skills (could pass feature name)
77
- - No `allowed-tools` scoping per skill
78
- - No `hooks:` frontmatter for skill-scoped lifecycle events
79
- - No `memory:` for persistent skill context
80
- - No `disable-model-invocation: true` on dangerous phase skills (e.g. `phase-implement`)
81
-
82
- ---
83
-
84
- ### 3.2 Agents System
85
-
86
- **Current:**
87
- - `framework/agents.json` — 37 agents in 4 tiers, custom JSON format
88
- - `agents-installer.js` transpiles tier-1/2 agents to `.claude/agents/morph-{id}.md`
89
- - Tiers 3–4 (Specialists + Validators) are NOT installed as agents
90
-
91
- **Assessment:**
92
-
93
- | Aspect | Status | Issue |
94
- |---|---|---|
95
- | Agents installed to `.claude/agents/` | ✅ Aligned | — |
96
- | YAML frontmatter + description | ✅ Aligned | — |
97
- | Tier 1/2 as agents | ✅ Reasonable | These are orchestrators/leaders — appropriate as persistent subagents |
98
- | Tier 3/4 NOT installed | ❌ Dead code | 31 specialists built but unused by CC native delegation |
99
- | Custom 4-tier taxonomy | ⚠️ Overhead | CC delegates by description alone — tiers are an organizational concept with no runtime effect |
100
- | `agents.json` → `.md` transpilation | ⚠️ Adapter complexity | Extra build step; agents could be authored directly as `.md` files |
101
- | No `memory: project` in agents | ❌ Gap | Agents lose context between sessions; CC provides this natively |
102
- | No `isolation: worktree` for parallel work | ❌ Gap | Parallel agent execution doesn't use CC's native worktree isolation |
103
- | No `skills` preloading in agent frontmatter | ❌ Gap | Agents could have domain standards pre-injected from standards library |
104
- | No `maxTurns` guard | ❌ Gap | Runaway agents not bounded |
105
-
106
- ---
107
-
108
- ### 3.3 Hooks System
109
-
110
- **Current:**
111
- ```
112
- framework/hooks/
113
- shared/ → 4 Node.js modules (state-reader, hook-response, stdin-reader, phase-utils)
114
- claude-code/
115
- session-start/inject-morph-context.js
116
- user-prompt/enrich-prompt.js
117
- pre-tool-use/protect-readonly-files.js (deprecated — replaced by permissions.deny)
118
- pre-tool-use/protect-spec-files.js
119
- pre-tool-use/enforce-phase-writes.js
120
- pre-tool-use/validate-bash-commands.js
121
- post-tool-use/dispatch.js
122
- post-tool-use/track-output-creation.js
123
- post-tool-use/handle-tool-failure.js
124
- pre-compact/save-morph-context.js
125
- stop/validate-completion.js
126
- notification/approval-reminder.js
127
- ```
128
-
129
- **Assessment:**
130
-
131
- | Hook | Value | Issue |
132
- |---|---|---|
133
- | `inject-morph-context.js` | ✅ High — state summary is unique | Partially overlaps with CLAUDE.md `@.morph/context/README.md` import; could be a `prompt`-type hook for lighter weight |
134
- | `enrich-prompt.js` | ⚠️ Medium | User prompt enrichment is potentially noisy; a `UserPromptSubmit` hook with `additionalContext` is correct CC pattern |
135
- | `protect-readonly-files.js` | ❌ DEAD — replaced by `permissions.deny` | Remove from installer |
136
- | `protect-spec-files.js` | ✅ Legitimate — approval gate logic | Cannot be replaced by static `permissions.deny`; keep |
137
- | `enforce-phase-writes.js` | ✅ High value — phase enforcement | Core morph-spec logic; irreplaceable |
138
- | `validate-bash-commands.js` | ⚠️ Medium | Could use CC's `PreToolUse` with `prompt` type hook instead of custom Node.js |
139
- | `track-output-creation.js` | ✅ Unique — state sync | Essential morph-specific; direct JSON I/O is correct |
140
- | `dispatch.js` | ❌ Unclear | PostToolUse dispatcher — unclear what it dispatches beyond existing hooks |
141
- | `handle-tool-failure.js` | ✅ Reasonable | Failure logging; CC's `PostToolUseFailure` is the right event |
142
- | `save-morph-context.js` | ✅ Reasonable | Pre-compact state preservation; CC's `PreCompact` with `compact` matcher |
143
- | `validate-completion.js` | ⚠️ Complexity | Stop-hook completion validation; could be `agent`-type hook with tool access |
144
- | `approval-reminder.js` | ⚠️ Low value | Notification hook for approval reminders; CLAUDE.md + phase skill is sufficient |
145
- | **4 shared Node.js modules** | ❌ Over-engineering | Complex infrastructure for what CC recommends as bash/jq scripts; ESM imports add startup overhead |
146
-
147
- **The fundamental problem with the hooks architecture:**
148
-
149
- CC recommends hooks as simple shell commands with `jq` for JSON parsing. Morph-spec has built a custom Node.js framework *around* the hooks with shared utilities, ESM modules, and an internal API (`block()`, `pass()`, `injectContext()`). This:
150
- - Adds ~100ms+ startup overhead per hook invocation (Node.js + ESM)
151
- - Creates a custom abstraction layer that masks what's happening from the hooks documentation
152
- - Makes it hard for users to understand and modify hooks
153
- - Caused the circular bug in `track-output-creation.js` (importing state-manager → subprocess)
154
-
155
- ---
156
-
157
- ### 3.4 State Machine vs CC Native Capabilities
158
-
159
- **Current morph-spec state concepts:**
160
-
161
- | Morph concept | CC native equivalent | Gap |
162
- |---|---|---|
163
- | Phase system (proposal→implement) | No direct equivalent | **Unique value** — keep |
164
- | Phase approval gates | CC's `PreToolUse` hook + `block()` | **Unique value** — morph's approval gates are richer |
165
- | Trust scoring (low/medium/high/maximum) | `permissions.defaultMode` (acceptEdits/askAll/plan) | **Duplication** — trust levels could map directly to CC permission modes |
166
- | Task tracking (total/completed) | CC's `TaskCreate/TaskUpdate` (internal) | Partial overlap |
167
- | Checkpoints (save/restore) | CC's native `/rewind` + checkpointing | **Significant overlap** — morph's checkpoint commands duplicate CC's built-in checkpointing |
168
- | Feature session naming | CC's `/rename` + `--resume session-name` | **Duplication** — morph could use CC sessions as feature sessions |
169
- | LLM workflow-detector | Plan Mode + user choice | Over-engineering |
170
-
171
- ---
172
-
173
- ### 3.5 Standards System
174
-
175
- **Current:**
176
- - 74 standards in `framework/standards/` organized in 11 categories
177
- - `STANDARDS.json` registry with `name/id/category/tags/path`
178
- - `morph-spec standards --list/--search/--show` CLI commands
179
- - Scripts: `generate-standards-registry.js`
180
-
181
- **Assessment:**
182
-
183
- Standards are **domain knowledge** — exactly what CC skills are for. The current system implements a searchable registry with a CLI, but CC provides this through:
184
- - Skill `description` field → automatic loading when relevant
185
- - `/skill-name` for direct invocation
186
- - Skill `user-invocable: false` for background knowledge (no slash command)
187
-
188
- A standard like `csharp-standards.md` would be better as:
189
- ```yaml
190
- ---
191
- name: csharp-standards
192
- description: C# coding standards for this project. Loaded automatically when working on .cs or .csproj files.
193
- user-invocable: false
194
- ---
195
- ```
196
-
197
- With `paths:` scoping (via the morph `rules/` system), this is nearly identical to what morph-spec is doing manually.
198
-
199
- The CLI registry (`--list/--search/--show`) is custom tooling for what `/agents` + skill descriptions already provide natively.
200
-
201
- ---
202
-
203
- ### 3.6 What `.claude/rules/` Actually Is
204
-
205
- **Finding:** The `.claude/rules/` directory with path-scoped rule files is **not a native Claude Code feature** in the official documentation. The CC docs only describe:
206
- - `CLAUDE.md` at various directory levels (auto-loaded)
207
- - `.claude/settings.json` for permissions/hooks
208
- - `.claude/skills/` and `.claude/agents/` for extensions
209
-
210
- The morph-spec `rules/` system appears to be either:
211
- 1. A **CC experimental/preview feature** not yet in stable docs
212
- 2. A **morph-spec custom convention** that isn't actually parsed by Claude Code natively
213
-
214
- If it's the latter, the path-scoped rules (csharp-standards.md with `paths: ["**/*.cs"]`) are written to `.claude/rules/` but have no enforcement mechanism — they'd be documentation-only. The correct CC-native alternative is **skills with `user-invocable: false`** loaded when relevant files are detected.
215
-
216
- **Recommendation:** Verify whether `.claude/rules/` is a CC native feature. If not, migrate rules to skills with appropriate descriptions or `paths`-aware CLAUDE.md imports.
217
-
218
- ---
219
-
220
- ## 4. What Morph-Spec Does Right
221
-
222
- These are **genuinely aligned or uniquely valuable**:
223
-
224
- 1. **`enforce-phase-writes.js` hook** — phase-gated write enforcement is unique, irreplaceable, and correctly implemented as a `PreToolUse` hook
225
- 2. **`track-output-creation.js`** — auto-tracking spec outputs to state.json; the direct JSON I/O approach is correct
226
- 3. **`protect-spec-files.js`** — approval-gate-aware file protection; cannot be replaced by static `permissions.deny`
227
- 4. **`permissions.deny` for framework readonly** — replacing the old hook with native settings; excellent alignment
228
- 5. **CLAUDE.md with `@.morph/context/README.md` import** — using CC's `@` import syntax correctly
229
- 6. **`.claude/CLAUDE.md` runtime reference** — project-level CLAUDE.md for quick reference; correct pattern
230
- 7. **Skills with YAML frontmatter** — proper `name` + `description` in all skill files
231
- 8. **Phase system itself** — the 8-phase spec-driven workflow is unique value with no CC equivalent
232
- 9. **`statusline.py` → `settings.json` statusLine** — using CC's native statusline mechanism correctly
233
- 10. **`update-agents` command** — keeping agents in sync is a good maintenance pattern
234
-
235
- ---
236
-
237
- ## 5. What Should Be Simplified
238
-
239
- ### 5.1 Collapse the skills level hierarchy
240
-
241
- **Current:** 5 levels (0–4), only levels 0–1 installed, installed flat
242
- **Should be:** Two categories, installed as proper directories with supporting files
243
-
244
- ```
245
- framework/skills/
246
- meta/ → brainstorming, code-review, verification (level-0 content)
247
- workflows/ → phase-proposal, phase-design, phase-implement, etc. (level-1 content)
248
- ```
249
-
250
- Benefits:
251
- - Skills installed as directories → supporting files possible → richer skills
252
- - `context: fork` can be added to phase-implement for isolated execution
253
- - `$ARGUMENTS` can be used: `/phase-design my-feature`
254
- - `allowed-tools` can gate what each phase can do
255
- - `disable-model-invocation: true` on implementation phases (don't auto-trigger)
256
-
257
- ### 5.2 Convert domain skills (level-2) to proper subagents
258
-
259
- **Current:** `framework/skills/level-2-domains/` — 22 domain skill files never installed
260
- **Should be:** Proper `.claude/agents/` files with `memory: project`
261
-
262
- Example:
263
- ```markdown
264
- ---
265
- name: blazor-builder
266
- description: Blazor/.NET frontend specialist. Use proactively when working on .razor files, Blazor components, or MudBlazor UI.
267
- tools: Read, Edit, Write, Bash, Grep, Glob
268
- model: sonnet
269
- memory: project
270
- skills:
271
- - csharp-standards
272
- - frontend-standards
273
- ---
274
-
275
- You are a senior Blazor/.NET developer...
276
- ```
277
-
278
- This gives domain specialists:
279
- - Persistent project memory across sessions
280
- - Pre-loaded standards
281
- - Proper tool access control
282
- - CC's automatic delegation by description (no tier system needed)
283
-
284
- ### 5.3 Reduce the hooks Node.js framework to targeted scripts
285
-
286
- The `shared/` modules are well-written but add unnecessary complexity. For the hooks that remain, prefer the CC-recommended pattern:
287
-
288
- **Instead of:**
289
- ```js
290
- import { readStdin } from '../../shared/stdin-reader.js';
291
- import { block, pass } from '../../shared/hook-response.js';
292
- ```
293
-
294
- **Use inline bash/jq:**
295
- ```bash
296
- #!/bin/bash
297
- INPUT=$(cat)
298
- FILE=$(echo "$INPUT" | jq -r '.tool_input.file_path // empty')
299
- # ... logic ...
300
- echo "reason" >&2; exit 2 # block
301
- exit 0 # pass
302
- ```
303
-
304
- Or for LLM-evaluated validation, use CC's native `type: "prompt"` hook.
305
-
306
- ### 5.4 Map trust scoring to CC permission modes
307
-
308
- **Current:** Internal trust levels (low/medium/high/maximum) control auto-approval behavior
309
- **Should be:** Map directly to CC's `permissions.defaultMode` in generated `settings.json`
310
-
311
- | Morph trust level | CC `defaultMode` |
312
- |---|---|
313
- | low | `askAll` (ask for everything) |
314
- | medium | `default` (standard prompting) |
315
- | high | `acceptEdits` (auto-accept file edits) |
316
- | maximum | `bypassPermissions` (skip all checks — use carefully) |
317
-
318
- This eliminates the custom trust scoring machinery and makes the user's experience consistent with how CC presents permission modes.
319
-
320
- ### 5.5 Simplify workflow configs
321
-
322
- **Current:** 10 workflow configs (fast-track, standard, full-morph, design-impl, ui-refresh, express, spec-only, zero-touch, fusion, ...)
323
- **Should be:** 3–4 that map to clearly different phase sequences
324
-
325
- The distinction between "fast-track" and "express" or "zero-touch" is subtle enough to confuse users. More workflows = more surface area for the LLM workflow-detector to get wrong. The workflow-detector's LLM call adds latency for a decision the user could make with a simple prompt.
326
-
327
- ---
328
-
329
- ## 6. What Should Be Removed or Deprecated
330
-
331
- | Item | Reason | Alternative |
332
- |---|---|---|
333
- | `protect-readonly-files.js` hook | Already replaced by `permissions.deny` | Already done — remove from installer |
334
- | Hooks `shared/` Node.js modules | Over-engineered for bash/jq use cases | Inline bash or `type: "prompt"` CC hook |
335
- | Skills "level" naming convention | CC has no tier concept; levels 2–4 never installed | Rename to `meta/` + `workflows/` |
336
- | `STANDARDS.json` registry + `generate-standards-registry.js` | CLI for what CC skill descriptions provide | Migrate standards to skills; `/` menu is the registry |
337
- | `morph-spec standards --list/--search/--show` commands | Replaced by CC's native skill discovery | Remove (3 CLI commands) |
338
- | LLM-powered `workflow-detector.js` | Latency + complexity for a user decision | Ask via `AskUserQuestion` or Plan Mode |
339
- | Trust scoring system | Maps to existing CC permission modes | Write directly to `settings.json` `defaultMode` |
340
- | `dispatch.js` (PostToolUse dispatcher) | Unclear value beyond what hooks already provide | Evaluate and likely remove |
341
- | `approval-reminder.js` (notification hook) | CLAUDE.md + phase workflow covers this | Remove |
342
- | 10 workflow configs → simplify to ≤4 | Cognitive overhead, LLM detection errors | Merge similar workflows |
343
- | `morph-spec checkpoint-save/restore/list` commands | CC has native `/rewind` + checkpointing | Deprecate; document CC's native commands |
344
-
345
- ---
346
-
347
- ## 7. How to Make Morph-Spec Truly Spec-Driven
348
-
349
- The core promise of "spec-driven development" means the **spec file is the source of truth** for all phases. Currently, the spec exists at `.morph/features/{feature}/1-design/spec.md` but Claude has to be told to read it — there's no automatic loading mechanism.
350
-
351
- ### 7.1 Auto-load the active feature spec into every session
352
-
353
- Use CC's `@` import syntax in `framework/CLAUDE.md` with a dynamic reference:
354
-
355
- ```markdown
356
- ## Active Feature Spec
357
-
358
- The current feature spec is loaded from state:
359
-
360
- @.morph/features/__active__/1-design/spec.md
361
- ```
362
-
363
- Problem: CC's `@` syntax uses static paths. But the `inject-morph-context.js` hook already injects state summary. **Extend it** to also include the spec content for the active feature using `additionalContext`. This makes the spec always visible without the user needing to reference it explicitly.
364
-
365
- ### 7.2 Use `context: fork` in phase skills
366
-
367
- Phase skills should run in isolated contexts so the implementation gets a clean view:
368
-
369
- ```yaml
370
- ---
371
- name: phase-implement
372
- description: Execute the implementation phase for a morph-spec feature
373
- context: fork
374
- agent: general-purpose
375
- disable-model-invocation: true
376
- allowed-tools: Read, Edit, Write, Bash, Grep, Glob
377
- ---
378
-
379
- Implement feature $ARGUMENTS according to its spec.
380
-
381
- ## Context loading
382
- 1. Read: .morph/features/$ARGUMENTS/1-design/spec.md
383
- 2. Read: .morph/features/$ARGUMENTS/3-tasks/tasks.md
384
- 3. Read: .morph/config/config.json
385
-
386
- ## Implementation rules
387
- - One task at a time
388
- - Checkpoint every 3 tasks via: morph-spec checkpoint-save $ARGUMENTS
389
- - Mark outputs: morph-spec mark-output $ARGUMENTS recap
390
- ```
391
-
392
- ### 7.3 Enforce spec existence before implementation
393
-
394
- Replace the complex `validate-completion.js` Stop hook with a targeted `PreToolUse` check:
395
-
396
- ```json
397
- {
398
- "hooks": {
399
- "Stop": [{
400
- "hooks": [{
401
- "type": "prompt",
402
- "prompt": "Check if the active morph-spec feature has completed required outputs for its phase. Read .morph/state.json. If required outputs are missing, respond {\"ok\": false, \"reason\": \"Missing: <output> at <path>\"}"
403
- }]
404
- }]
405
- }
406
- }
407
- ```
408
-
409
- This uses CC's native `type: "prompt"` hook instead of a custom Node.js validation chain.
410
-
411
- ### 7.4 Use agent `memory: project` for standards enforcement
412
-
413
- Domain specialist agents should accumulate project-specific pattern knowledge:
414
-
415
- ```markdown
416
- ---
417
- name: morph-csharp-specialist
418
- memory: project
419
- skills:
420
- - csharp-standards
421
- ---
422
-
423
- Maintain your project memory with:
424
- - Naming conventions discovered in this codebase
425
- - Architecture patterns in use
426
- - Known anti-patterns to avoid
427
- - Decision log entries from .morph/features/*/1-design/decisions.md
428
- ```
429
-
430
- ---
431
-
432
- ## 8. How to Implement Native Enforcement and Validations
433
-
434
- ### 8.1 Permission rules as the first enforcement layer
435
-
436
- Replace custom validation hooks where possible with `settings.json` rules:
437
-
438
- ```json
439
- {
440
- "permissions": {
441
- "deny": [
442
- "Write(.morph/state.json)",
443
- "Edit(.morph/state.json)",
444
- "Write(.morph/framework/**)",
445
- "Edit(.morph/framework/**)",
446
- "Bash(rm -rf .morph/**)"
447
- ]
448
- }
449
- }
450
- ```
451
-
452
- Already implemented for state.json and framework/ — extend to cover other dangerous patterns.
453
-
454
- ### 8.2 Phase enforcement as the second layer (keep `enforce-phase-writes.js`)
455
-
456
- This hook provides logic that `permissions.deny` cannot (it reads dynamic state). Keep it, but:
457
- - Convert from Node.js ESM to a Python or bash script (lighter startup)
458
- - Or use CC's `type: "agent"` hook for complex validation (CC manages the LLM call)
459
-
460
- ### 8.3 Approval gates as the third layer (keep `protect-spec-files.js`)
461
-
462
- Keep as-is — this is unique domain logic. But convert to bash/jq for lighter execution.
463
-
464
- ### 8.4 Completion validation as a `type: "prompt"` hook (replace `validate-completion.js`)
465
-
466
- The Stop hook that validates all required outputs are created before Claude can stop is important but currently implemented in complex Node.js. Replace with a CC native `type: "prompt"` hook that reads state.json and checks completion.
467
-
468
- ---
469
-
470
- ## 9. Concrete Action Items (Prioritized)
471
-
472
- ### High Priority — Remove dead code, align native features
473
-
474
- 1. **Remove `protect-readonly-files.js` from hooks installer** — already replaced, still installed
475
- 2. **Remove `dispatch.js` and `approval-reminder.js`** — low value hooks
476
- 3. **Convert `validate-bash-commands.js` to `type: "prompt"` hook** — use CC native LLM evaluation
477
- 4. **Add `$ARGUMENTS` to all phase workflow skills** — enable `/phase-design my-feature` invocation
478
- 5. **Add `disable-model-invocation: true` to `phase-implement` and `phase-tasks`** — prevent accidental trigger
479
- 6. **Install level-2-domains skills as subagents** (`.claude/agents/morph-blazor-builder.md`, etc.) with `memory: project`
480
-
481
- ### Medium Priority — Reduce infrastructure complexity
482
-
483
- 7. **Convert hooks shared modules to inline bash/jq scripts** — remove `shared/` layer
484
- 8. **Map trust scoring directly to `settings.json` `defaultMode`** — eliminate custom trust machinery
485
- 9. **Migrate standards from CLI registry to skills** with `user-invocable: false` descriptions
486
- 10. **Remove `morph-spec standards` CLI commands** (3 commands, replace with skill search)
487
- 11. **Add active feature spec to `inject-morph-context.js` payload** — truly spec-driven context
488
-
489
- ### Low Priority — Architecture improvements
490
-
491
- 12. **Rename skill levels to `meta/` + `workflows/`** — better reflects purpose, removes false hierarchy
492
- 13. **Add `memory: project` to all domain specialist agents** — persistent cross-session learning
493
- 14. **Verify `.claude/rules/` native support** — if not native, migrate to skills with `user-invocable: false`
494
- 15. **Reduce workflow configs from 10 to ≤4** — simplify LLM detection surface
495
- 16. **Replace `workflow-detector.js` LLM call with user question** — use `AskUserQuestion` in phase-setup skill
496
-
497
- ---
498
-
499
- ## 10. Summary Assessment
500
-
501
- | Area | Current State | Target State |
502
- |---|---|---|
503
- | Skills | 2-level deployment, flat, missing CC features | 2-category dirs, `$ARGUMENTS`, `context: fork`, `disable-model-invocation` |
504
- | Agents | Tier 1+2 only, no `memory`, no `isolation` | All domain specialists as agents with `memory: project` + `skills` preload |
505
- | Hooks | Node.js ESM framework, 12 hooks, 4 shared modules | Bash/jq or `type: "prompt"` hooks, 7 core hooks, no shared modules |
506
- | Permissions | `permissions.deny` for state+framework | Extended deny rules + mapped `defaultMode` from trust levels |
507
- | Standards | CLI registry + 74 standards | Skills with `user-invocable: false` + path descriptions |
508
- | State machine | Full phase gating + trust scoring + LLM detection | Keep phase gating, simplify trust → CC modes, remove LLM detection |
509
- | Spec-driven | Spec exists but not auto-loaded | Spec auto-injected via SessionStart hook additionalContext |
510
- | Dead code | 31 agents never installed, 22 skills never deployed, 10 workflows | Remove or deploy everything that's built |
511
-
512
- The framework's **unique value** is the spec-driven phase workflow with approval gates, phase-write enforcement, and output tracking. All of this should be preserved and sharpened. The infrastructure around it should be dramatically simplified by leaning on what Claude Code provides natively.