@polymorphism-tech/morph-spec 4.3.6 → 4.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (375) hide show
  1. package/.morph/.morphversion +3 -3
  2. package/.morph/analytics/threads-log.jsonl +44 -9
  3. package/.morph/config/config.json +2 -3
  4. package/.morph/framework/standards/STANDARDS.json +812 -0
  5. package/.morph/{standards → framework/standards}/ai-agents/team-orchestration.md +3 -3
  6. package/.morph/framework/standards/integration/mcp/mcp-tools.md +384 -0
  7. package/.morph/{templates → framework/templates}/README.md +17 -17
  8. package/.morph/{templates → framework/templates}/REGISTRY.json +48 -233
  9. package/.morph/framework/templates/code/dotnet/contracts/contracts.cs.hbs +172 -0
  10. package/.morph/{templates → framework/templates}/context/CONTEXT-FEATURE.md +1 -1
  11. package/.morph/{templates → framework/templates}/context/CONTEXT.md +3 -3
  12. package/.morph/framework/templates/docs/clarifications.md +253 -0
  13. package/.morph/framework/templates/docs/onboarding.md +123 -0
  14. package/.morph/framework/templates/docs/schema-analysis.md +119 -0
  15. package/.morph/{templates → framework/templates}/docs/spec.md +149 -149
  16. package/.morph/framework/templates/docs/ui-components.md +124 -0
  17. package/.morph/framework/templates/docs/ui-design-system.md +76 -0
  18. package/.morph/framework/templates/docs/ui-flows.md +167 -0
  19. package/.morph/framework/templates/docs/ui-mockups.md +98 -0
  20. package/.morph/{templates → framework/templates}/examples/spec-examples.md +1 -1
  21. package/.morph/{templates → framework/templates}/infrastructure/github/README.md +11 -11
  22. package/.morph/{templates → framework/templates}/infrastructure/github/workflows/deploy-azure-app-service.yml.hbs +2 -2
  23. package/.morph/{templates → framework/templates}/meta-prompts/parallel-workers/parallel-worker.md +2 -2
  24. package/.morph/{templates → framework/templates}/meta-prompts/validators/pre-commit-validator.md +1 -1
  25. package/.morph/logs/tool-failures.log +51 -0
  26. package/.morph/memory/pre-compact-2026-02-22T17-01-01-658Z.json +16 -0
  27. package/.morph/state.json +1 -1
  28. package/CLAUDE.md +20 -119
  29. package/README.md +20 -18
  30. package/bin/detect-agents.js +1 -1
  31. package/bin/morph-spec.js +116 -266
  32. package/bin/task-manager.cjs +2 -2
  33. package/bin/validate.js +1 -1
  34. package/claude-plugin.json +14 -0
  35. package/docs/claude-alignment-report.md +137 -0
  36. package/docs/plans/2026-02-22-claude-docs-morph-alignment-analysis.md +512 -0
  37. package/docs/plans/2026-02-22-claude-settings.md +515 -0
  38. package/docs/plans/2026-02-22-morph-cc-alignment-impl.md +728 -0
  39. package/docs/plans/2026-02-22-morph-spec-next.md +478 -0
  40. package/docs/plans/2026-02-22-native-alignment-design.md +199 -0
  41. package/docs/plans/2026-02-22-native-alignment-impl.md +925 -0
  42. package/docs/plans/2026-02-22-native-enrichment-design.md +244 -0
  43. package/docs/plans/2026-02-22-native-enrichment.md +735 -0
  44. package/framework/CLAUDE.md +77 -0
  45. package/framework/commands/morph-apply.md +9 -9
  46. package/framework/commands/morph-archive.md +8 -8
  47. package/framework/commands/morph-infra.md +1 -1
  48. package/framework/commands/morph-proposal.md +9 -9
  49. package/framework/commands/morph-status.md +3 -3
  50. package/framework/commands/morph-troubleshoot.md +1 -1
  51. package/framework/hooks/README.md +201 -282
  52. package/framework/hooks/claude-code/notification/approval-reminder.js +52 -0
  53. package/framework/hooks/claude-code/post-tool-use/dispatch.js +83 -0
  54. package/framework/hooks/claude-code/post-tool-use/handle-tool-failure.js +42 -0
  55. package/framework/hooks/claude-code/pre-compact/save-morph-context.js +61 -0
  56. package/framework/hooks/claude-code/pre-tool-use/enforce-phase-writes.js +71 -0
  57. package/framework/hooks/claude-code/pre-tool-use/protect-readonly-files.js +58 -0
  58. package/framework/hooks/claude-code/pre-tool-use/protect-spec-files.js +64 -0
  59. package/framework/hooks/claude-code/session-start/inject-morph-context.js +94 -0
  60. package/framework/hooks/claude-code/statusline.py +239 -0
  61. package/framework/hooks/claude-code/statusline.sh +7 -0
  62. package/framework/hooks/claude-code/stop/validate-completion.js +88 -0
  63. package/framework/hooks/claude-code/user-prompt/enrich-prompt.js +91 -0
  64. package/framework/hooks/shared/hook-response.js +45 -0
  65. package/framework/hooks/shared/phase-utils.js +129 -0
  66. package/framework/hooks/shared/state-reader.js +138 -0
  67. package/framework/hooks/shared/stdin-reader.js +26 -0
  68. package/framework/phases.json +145 -0
  69. package/framework/rules/csharp-standards.md +10 -0
  70. package/framework/rules/frontend-standards.md +14 -0
  71. package/framework/rules/infrastructure-standards.md +13 -0
  72. package/framework/rules/morph-workflow.md +86 -0
  73. package/framework/rules/testing-standards.md +11 -0
  74. package/framework/skills/level-0-meta/brainstorming.md +133 -0
  75. package/framework/skills/level-0-meta/code-review.md +12 -4
  76. package/framework/skills/level-0-meta/mcp-registry.json +207 -0
  77. package/framework/skills/level-0-meta/morph-checklist.md +9 -1
  78. package/framework/skills/level-0-meta/simulation-checklist.md +9 -1
  79. package/framework/skills/level-0-meta/tool-usage-guide.md +335 -0
  80. package/framework/skills/level-0-meta/verification-before-completion.md +145 -0
  81. package/framework/skills/level-1-workflows/morph-replicate.md +9 -1
  82. package/framework/skills/level-1-workflows/phase-clarify.md +65 -4
  83. package/framework/skills/level-1-workflows/phase-codebase-analysis.md +182 -0
  84. package/framework/skills/level-1-workflows/phase-design.md +342 -80
  85. package/framework/skills/level-1-workflows/phase-implement.md +254 -0
  86. package/framework/skills/level-1-workflows/phase-setup.md +76 -10
  87. package/framework/skills/level-1-workflows/phase-tasks.md +88 -7
  88. package/framework/skills/level-1-workflows/phase-uiux.md +95 -17
  89. package/framework/skills/level-2-domains/ai-agents/ai-system-architect.md +8 -1
  90. package/framework/skills/level-2-domains/architecture/po-pm-advisor.md +8 -1
  91. package/framework/skills/level-2-domains/architecture/prompt-engineer.md +8 -1
  92. package/framework/skills/level-2-domains/architecture/seo-growth-hacker.md +8 -1
  93. package/framework/skills/level-2-domains/architecture/standards-architect.md +11 -4
  94. package/framework/skills/level-2-domains/backend/api-designer.md +8 -1
  95. package/framework/skills/level-2-domains/backend/dotnet-senior.md +8 -1
  96. package/framework/skills/level-2-domains/backend/ef-modeler.md +8 -1
  97. package/framework/skills/level-2-domains/backend/hangfire-orchestrator.md +9 -2
  98. package/framework/skills/level-2-domains/backend/ms-agent-expert.md +8 -1
  99. package/framework/skills/level-2-domains/frontend/blazor-builder.md +8 -1
  100. package/framework/skills/level-2-domains/frontend/nextjs-expert.md +8 -1
  101. package/framework/skills/level-2-domains/frontend/ui-ux-designer.md +9 -2
  102. package/framework/skills/level-2-domains/infrastructure/azure-architect.md +8 -1
  103. package/framework/skills/level-2-domains/infrastructure/azure-deploy-specialist.md +8 -1
  104. package/framework/skills/level-2-domains/infrastructure/bicep-architect.md +8 -1
  105. package/framework/skills/level-2-domains/infrastructure/container-specialist.md +8 -1
  106. package/framework/skills/level-2-domains/infrastructure/devops-engineer.md +8 -1
  107. package/framework/skills/level-2-domains/integrations/asaas-financial.md +8 -1
  108. package/framework/skills/level-2-domains/integrations/azure-identity.md +8 -1
  109. package/framework/skills/level-2-domains/integrations/clerk-auth.md +8 -1
  110. package/framework/skills/level-2-domains/integrations/{hangfire-orchestrator.md → hangfire-integration.md} +8 -1
  111. package/framework/skills/level-2-domains/integrations/resend-email.md +8 -1
  112. package/framework/skills/level-2-domains/quality/code-analyzer.md +10 -3
  113. package/framework/skills/level-2-domains/quality/testing-specialist.md +8 -1
  114. package/framework/standards/STANDARDS.json +812 -0
  115. package/framework/standards/ai-agents/team-orchestration.md +3 -3
  116. package/framework/standards/frontend/nextjs/nextjs-patterns.md +17 -0
  117. package/framework/standards/integration/mcp/mcp-tools.md +384 -0
  118. package/framework/templates/README.md +17 -17
  119. package/framework/templates/REGISTRY.json +48 -233
  120. package/framework/templates/code/dotnet/contracts/contracts.cs.hbs +172 -0
  121. package/framework/templates/context/CONTEXT-FEATURE.md +1 -1
  122. package/framework/templates/context/CONTEXT.md +3 -3
  123. package/framework/templates/docs/clarifications.md +253 -0
  124. package/framework/templates/docs/onboarding.md +123 -0
  125. package/framework/templates/docs/schema-analysis.md +119 -0
  126. package/framework/templates/docs/spec.md +149 -149
  127. package/framework/templates/docs/ui-components.md +124 -0
  128. package/framework/templates/docs/ui-design-system.md +76 -0
  129. package/framework/templates/docs/ui-flows.md +167 -0
  130. package/framework/templates/docs/ui-mockups.md +98 -0
  131. package/framework/templates/docs/user-stories.md +34 -0
  132. package/framework/templates/examples/spec-examples.md +1 -1
  133. package/framework/templates/infrastructure/github/README.md +11 -11
  134. package/framework/templates/infrastructure/github/workflows/deploy-azure-app-service.yml.hbs +2 -2
  135. package/framework/templates/meta-prompts/parallel-workers/parallel-worker.md +2 -2
  136. package/framework/templates/meta-prompts/validators/pre-commit-validator.md +1 -1
  137. package/framework/workflows/configs/express.json +45 -0
  138. package/framework/workflows/configs/spec-only.json +43 -0
  139. package/framework/workflows/docs/enforcement-pipeline.md +8 -8
  140. package/framework/workflows/docs/full-morph.md +3 -3
  141. package/package.json +3 -2
  142. package/scripts/generate-refs.js +336 -0
  143. package/scripts/generate-standards-registry.js +44 -0
  144. package/scripts/validate-real.mjs +255 -0
  145. package/src/commands/feature/create-story.js +362 -361
  146. package/src/commands/feature/shard-spec.js +225 -224
  147. package/src/commands/feature/sprint-status.js +1 -1
  148. package/src/commands/generation/generate-onboarding.js +169 -0
  149. package/src/commands/generation/generate.js +2 -2
  150. package/src/commands/mcp/mcp-setup.js +315 -0
  151. package/src/commands/project/changes.js +66 -0
  152. package/src/commands/project/checkpoint.js +209 -0
  153. package/src/commands/project/cost.js +179 -0
  154. package/src/commands/project/diff.js +278 -0
  155. package/src/commands/project/doctor.js +55 -7
  156. package/src/commands/project/init.js +318 -76
  157. package/src/commands/project/revert.js +173 -0
  158. package/src/commands/project/standards.js +80 -0
  159. package/src/commands/project/status.js +376 -0
  160. package/src/commands/project/update-agents.js +23 -0
  161. package/src/commands/project/update.js +63 -30
  162. package/src/commands/state/advance-phase.js +4 -3
  163. package/src/commands/state/state.js +10 -3
  164. package/src/commands/state/validate-phase.js +19 -2
  165. package/src/commands/templates/template-customize.js +4 -4
  166. package/src/commands/templates/template-render.js +1 -1
  167. package/src/commands/templates/template-show.js +1 -1
  168. package/src/commands/validation/validate-feature.js +359 -0
  169. package/src/core/orchestrator.js +3 -38
  170. package/src/core/paths/output-schema.js +135 -0
  171. package/src/core/state/state-manager.js +831 -592
  172. package/src/core/templates/template-registry.js +2 -2
  173. package/src/core/workflows/workflow-detector.js +17 -1
  174. package/src/lib/agents/micro-agent-factory.js +1 -1
  175. package/src/lib/context/context-bundler.js +2 -1
  176. package/src/lib/detectors/claude-config-detector.js +392 -0
  177. package/src/lib/detectors/conversation-analyzer.js +4 -4
  178. package/src/lib/detectors/design-system-detector.js +6 -5
  179. package/src/lib/detectors/standards-generator.js +2 -2
  180. package/src/lib/generators/context-generator.js +539 -538
  181. package/src/lib/generators/recap-generator.js +1 -1
  182. package/src/lib/generators/settings-generator.js +210 -0
  183. package/src/lib/hooks/hook-executor.js +1 -1
  184. package/src/lib/installers/mcp-installer.js +299 -0
  185. package/src/lib/learning/learning-system.js +3 -3
  186. package/src/lib/orchestration/team-orchestrator.js +1 -1
  187. package/src/lib/standards/standards-context-injector.js +7 -7
  188. package/src/lib/threads/thread-coordinator.js +1 -1
  189. package/src/lib/troubleshooting/troubleshoot-grep.js +1 -1
  190. package/src/lib/validators/contracts/contract-compliance-validator.js +274 -273
  191. package/src/lib/validators/design-system/design-system-validator.js +1 -1
  192. package/src/lib/validators/spec-validator.js +258 -258
  193. package/src/lib/validators/validation-runner.js +270 -269
  194. package/src/utils/agents-installer.js +206 -0
  195. package/src/utils/claude-settings-manager.js +258 -0
  196. package/src/utils/file-copier.js +1 -1
  197. package/src/utils/hooks-installer.js +354 -28
  198. package/src/utils/skills-installer.js +74 -0
  199. package/.morph/project/context/detection-log.md +0 -16
  200. package/.morph/project/standards/inferred.md +0 -59
  201. package/framework/hooks/agent-stop/validate-and-continue.js +0 -96
  202. package/framework/hooks/agent-stop/validate-checkpoints.js +0 -101
  203. package/framework/hooks/agent-stop/validate-tests.js +0 -109
  204. package/framework/hooks/agent-teams/dispatch.js +0 -67
  205. package/framework/hooks/agent-teams/phase-advanced.js +0 -80
  206. package/framework/hooks/agent-teams/task-completed.js +0 -76
  207. package/framework/hooks/agent-teams/teammate-idle.js +0 -70
  208. package/src/commands/agents/agents-fuse.js +0 -97
  209. package/src/commands/agents/micro-agent.js +0 -112
  210. package/src/commands/agents/spawn-team.js +0 -237
  211. package/src/commands/agents/squad-template.js +0 -146
  212. package/src/commands/analytics/analytics.js +0 -176
  213. package/src/commands/context/context-prime.js +0 -63
  214. package/src/commands/context/core-four.js +0 -54
  215. package/src/commands/generation/generate-context.js +0 -40
  216. package/src/commands/project/detect-agents.js +0 -207
  217. package/src/commands/project/detect-workflow.js +0 -174
  218. package/src/commands/threads/thread-template.js +0 -103
  219. package/src/commands/threads/threads.js +0 -261
  220. package/src/commands/utils/session-summary.js +0 -291
  221. package/src/llm/analyzer.js +0 -215
  222. package/src/llm/few-shot-examples.js +0 -216
  223. package/src/llm/project-config-schema.json +0 -188
  224. package/src/llm/prompt-builder.js +0 -96
  225. /package/.morph/{project/context → context}/README.md +0 -0
  226. /package/.morph/{config → framework}/agents.json +0 -0
  227. /package/.morph/{standards → framework/standards}/ai-agents/blazor-ui.md +0 -0
  228. /package/.morph/{standards → framework/standards}/ai-agents/production.md +0 -0
  229. /package/.morph/{standards → framework/standards}/ai-agents/setup.md +0 -0
  230. /package/.morph/{standards → framework/standards}/ai-agents/workflows.md +0 -0
  231. /package/.morph/{standards → framework/standards}/architecture/ddd/aggregates.md +0 -0
  232. /package/.morph/{standards → framework/standards}/architecture/ddd/entities.md +0 -0
  233. /package/.morph/{standards → framework/standards}/architecture/ddd/value-objects.md +0 -0
  234. /package/.morph/{standards → framework/standards}/backend/api/minimal-api.md +0 -0
  235. /package/.morph/{standards → framework/standards}/backend/api/rest.md +0 -0
  236. /package/.morph/{standards → framework/standards}/backend/api/validation.md +0 -0
  237. /package/.morph/{standards → framework/standards}/backend/authentication/passkeys.md +0 -0
  238. /package/.morph/{standards → framework/standards}/backend/database/ef-core.md +0 -0
  239. /package/.morph/{standards → framework/standards}/backend/database/migrations.md +0 -0
  240. /package/.morph/{standards → framework/standards}/backend/database/postgresql/database.md +0 -0
  241. /package/.morph/{standards → framework/standards}/backend/database/repository-patterns.md +0 -0
  242. /package/.morph/{standards → framework/standards}/backend/database/vector-search-rag.md +0 -0
  243. /package/.morph/{standards → framework/standards}/backend/dotnet/async.md +0 -0
  244. /package/.morph/{standards → framework/standards}/backend/dotnet/core.md +0 -0
  245. /package/.morph/{standards → framework/standards}/backend/dotnet/di.md +0 -0
  246. /package/.morph/{standards → framework/standards}/backend/dotnet/program-cs-checklist.md +0 -0
  247. /package/.morph/{standards → framework/standards}/backend/integrations/asaas/asaas-api.md +0 -0
  248. /package/.morph/{standards → framework/standards}/backend/integrations/clerk/clerk-auth.md +0 -0
  249. /package/.morph/{standards → framework/standards}/backend/integrations/hangfire/hangfire-jobs.md +0 -0
  250. /package/.morph/{standards → framework/standards}/backend/integrations/resend/resend-email.md +0 -0
  251. /package/.morph/{standards → framework/standards}/context/analytics.md +0 -0
  252. /package/.morph/{standards → framework/standards}/context/bundles.md +0 -0
  253. /package/.morph/{standards → framework/standards}/context/priming.md +0 -0
  254. /package/.morph/{standards → framework/standards}/core/architecture.md +0 -0
  255. /package/.morph/{standards → framework/standards}/core/coding.md +0 -0
  256. /package/.morph/{standards → framework/standards}/core/git-branching-strategy.md +0 -0
  257. /package/.morph/{standards → framework/standards}/core/git.md +0 -0
  258. /package/.morph/{standards → framework/standards}/core/testing.md +0 -0
  259. /package/.morph/{standards → framework/standards}/data/nosql/blob-storage.md +0 -0
  260. /package/.morph/{standards → framework/standards}/data/nosql/cache/redis.md +0 -0
  261. /package/.morph/{standards → framework/standards}/data/nosql/cosmos-db.md +0 -0
  262. /package/.morph/{standards → framework/standards}/data/vector-search/azure-ai-search.md +0 -0
  263. /package/.morph/{standards → framework/standards}/data/vector-search/rag-chunking.md +0 -0
  264. /package/.morph/{standards → framework/standards}/frontend/blazor/design-checklist.md +0 -0
  265. /package/.morph/{standards → framework/standards}/frontend/blazor/fluent-ui-setup.md +0 -0
  266. /package/.morph/{standards → framework/standards}/frontend/blazor/fluent-ui.md +0 -0
  267. /package/.morph/{standards → framework/standards}/frontend/blazor/html-conversion.md +0 -0
  268. /package/.morph/{standards → framework/standards}/frontend/blazor/lifecycle.md +0 -0
  269. /package/.morph/{standards → framework/standards}/frontend/blazor/pitfalls.md +0 -0
  270. /package/.morph/{standards → framework/standards}/frontend/blazor/state.md +0 -0
  271. /package/.morph/{standards → framework/standards}/frontend/design-system/animations.md +0 -0
  272. /package/.morph/{standards → framework/standards}/frontend/design-system/naming.md +0 -0
  273. /package/.morph/{standards → framework/standards}/frontend/nextjs/nextjs-patterns.md +0 -0
  274. /package/.morph/{standards → framework/standards}/infrastructure/azure/azure.md +0 -0
  275. /package/.morph/{standards → framework/standards}/infrastructure/azure/bicep/bicep-patterns.md +0 -0
  276. /package/.morph/{standards → framework/standards}/infrastructure/azure/devops/azure-devops-setup.md +0 -0
  277. /package/.morph/{standards → framework/standards}/infrastructure/azure/devops/local-development.md +0 -0
  278. /package/.morph/{standards → framework/standards}/infrastructure/azure/services/functions.md +0 -0
  279. /package/.morph/{standards → framework/standards}/infrastructure/azure/services/service-bus.md +0 -0
  280. /package/.morph/{standards → framework/standards}/infrastructure/azure/services/storage.md +0 -0
  281. /package/.morph/{standards → framework/standards}/infrastructure/docker/easypanel-deploy.md +0 -0
  282. /package/.morph/{standards → framework/standards}/infrastructure/supabase/mcp-setup.md +0 -0
  283. /package/.morph/{standards → framework/standards}/infrastructure/supabase/supabase-auth.md +0 -0
  284. /package/.morph/{standards → framework/standards}/infrastructure/supabase/supabase-pgvector.md +0 -0
  285. /package/.morph/{standards → framework/standards}/infrastructure/supabase/supabase-rls.md +0 -0
  286. /package/.morph/{standards → framework/standards}/infrastructure/supabase/supabase-storage.md +0 -0
  287. /package/.morph/{standards → framework/standards}/integration/api/graphql.md +0 -0
  288. /package/.morph/{standards → framework/standards}/integration/api/grpc.md +0 -0
  289. /package/.morph/{standards → framework/standards}/integration/api/rest-design.md +0 -0
  290. /package/.morph/{standards → framework/standards}/integration/event-driven/cqrs.md +0 -0
  291. /package/.morph/{standards → framework/standards}/integration/event-driven/event-sourcing.md +0 -0
  292. /package/.morph/{standards → framework/standards}/integration/event-driven/service-bus.md +0 -0
  293. /package/.morph/{standards → framework/standards}/observability/logging.md +0 -0
  294. /package/.morph/{standards → framework/standards}/observability/metrics.md +0 -0
  295. /package/.morph/{standards → framework/standards}/observability/monitoring.md +0 -0
  296. /package/.morph/{standards → framework/standards}/observability/tracing.md +0 -0
  297. /package/.morph/{standards → framework/standards}/workflows/parallel-execution.md +0 -0
  298. /package/.morph/{standards → framework/standards}/workflows/thread-management.md +0 -0
  299. /package/.morph/{templates → framework/templates}/.idea/morph-templates.xml +0 -0
  300. /package/.morph/{templates → framework/templates}/.vscode/morph-templates.code-snippets +0 -0
  301. /package/.morph/{templates → framework/templates}/IDE-SNIPPETS.md +0 -0
  302. /package/.morph/{templates → framework/templates}/code/dotnet/backend/repository.cs +0 -0
  303. /package/.morph/{templates → framework/templates}/code/dotnet/backend/service.cs +0 -0
  304. /package/.morph/{templates → framework/templates}/code/dotnet/contracts/Commands.cs +0 -0
  305. /package/.morph/{templates → framework/templates}/code/dotnet/contracts/Entities.cs +0 -0
  306. /package/.morph/{templates → framework/templates}/code/dotnet/contracts/Queries.cs +0 -0
  307. /package/.morph/{templates → framework/templates}/code/dotnet/contracts/README.md +0 -0
  308. /package/.morph/{templates → framework/templates}/code/dotnet/contracts/api-contracts.cs +0 -0
  309. /package/.morph/{templates → framework/templates}/code/dotnet/contracts/contracts.cs +0 -0
  310. /package/.morph/{templates → framework/templates}/code/dotnet/database/migration.cs +0 -0
  311. /package/.morph/{templates → framework/templates}/code/dotnet/frontend/component.razor +0 -0
  312. /package/.morph/{templates → framework/templates}/code/dotnet/jobs/agent.cs +0 -0
  313. /package/.morph/{templates → framework/templates}/code/dotnet/jobs/job.cs +0 -0
  314. /package/.morph/{templates → framework/templates}/code/dotnet/test.cs +0 -0
  315. /package/.morph/{templates → framework/templates}/code/sql/rls-policy.sql +0 -0
  316. /package/.morph/{templates → framework/templates}/code/sql/supabase-migration.sql +0 -0
  317. /package/.morph/{templates → framework/templates}/code/sql/supabase-migration.template.sql +0 -0
  318. /package/.morph/{templates → framework/templates}/code/typescript/contracts.ts +0 -0
  319. /package/.morph/{templates → framework/templates}/docs/proposal.md +0 -0
  320. /package/.morph/{templates → framework/templates}/examples/design-system-examples.md +0 -0
  321. /package/.morph/{templates → framework/templates}/feature/decisions.md +0 -0
  322. /package/.morph/{templates → framework/templates}/feature/recap.md +0 -0
  323. /package/.morph/{templates → framework/templates}/feature/tasks.md +0 -0
  324. /package/.morph/{templates → framework/templates}/infrastructure/azure/Dockerfile.example +0 -0
  325. /package/.morph/{templates → framework/templates}/infrastructure/azure/README.md +0 -0
  326. /package/.morph/{templates → framework/templates}/infrastructure/azure/app-insights.bicep +0 -0
  327. /package/.morph/{templates → framework/templates}/infrastructure/azure/app-service.bicep +0 -0
  328. /package/.morph/{templates → framework/templates}/infrastructure/azure/container-app-env.bicep +0 -0
  329. /package/.morph/{templates → framework/templates}/infrastructure/azure/container-app.bicep +0 -0
  330. /package/.morph/{templates → framework/templates}/infrastructure/azure/deploy-checklist.md +0 -0
  331. /package/.morph/{templates → framework/templates}/infrastructure/azure/deploy.ps1 +0 -0
  332. /package/.morph/{templates → framework/templates}/infrastructure/azure/deploy.sh +0 -0
  333. /package/.morph/{templates → framework/templates}/infrastructure/azure/key-vault.bicep +0 -0
  334. /package/.morph/{templates → framework/templates}/infrastructure/azure/main.bicep +0 -0
  335. /package/.morph/{templates → framework/templates}/infrastructure/azure/parameters.dev.json +0 -0
  336. /package/.morph/{templates → framework/templates}/infrastructure/azure/parameters.prod.json +0 -0
  337. /package/.morph/{templates → framework/templates}/infrastructure/azure/parameters.staging.json +0 -0
  338. /package/.morph/{templates → framework/templates}/infrastructure/azure/sql-database.bicep +0 -0
  339. /package/.morph/{templates → framework/templates}/infrastructure/azure/storage.bicep +0 -0
  340. /package/.morph/{templates → framework/templates}/infrastructure/docker/Dockerfile.template +0 -0
  341. /package/.morph/{templates → framework/templates}/infrastructure/docker/docker-compose.template.yml +0 -0
  342. /package/.morph/{templates → framework/templates}/infrastructure/docker/dockerfile-api.dockerfile +0 -0
  343. /package/.morph/{templates → framework/templates}/infrastructure/docker/dockerfile-web.dockerfile +0 -0
  344. /package/.morph/{templates → framework/templates}/infrastructure/docker/easypanel.template.json +0 -0
  345. /package/.morph/{templates → framework/templates}/infrastructure/github/actions/azure-auth/action.yml.hbs +0 -0
  346. /package/.morph/{templates → framework/templates}/infrastructure/github/actions/docker-build-push/action.yml.hbs +0 -0
  347. /package/.morph/{templates → framework/templates}/infrastructure/github/actions/health-check/action.yml.hbs +0 -0
  348. /package/.morph/{templates → framework/templates}/infrastructure/github/workflows/deploy-easypanel.yml.hbs +0 -0
  349. /package/.morph/{templates → framework/templates}/infrastructure/github/workflows/docker-build-push.yml.hbs +0 -0
  350. /package/.morph/{templates → framework/templates}/infrastructure/github/workflows/dotnet-build.yml.hbs +0 -0
  351. /package/.morph/{templates → framework/templates}/integrations/asaas-client.cs +0 -0
  352. /package/.morph/{templates → framework/templates}/integrations/asaas-webhook.cs +0 -0
  353. /package/.morph/{templates → framework/templates}/integrations/azure-identity-config.cs +0 -0
  354. /package/.morph/{templates → framework/templates}/integrations/clerk-config.cs +0 -0
  355. /package/.morph/{templates → framework/templates}/meta-prompts/fusion/fusion-agent.md +0 -0
  356. /package/.morph/{templates → framework/templates}/meta-prompts/fusion/fusion-aggregator.md +0 -0
  357. /package/.morph/{templates → framework/templates}/meta-prompts/hops/hop-retry.md +0 -0
  358. /package/.morph/{templates → framework/templates}/meta-prompts/hops/hop-validation.md +0 -0
  359. /package/.morph/{templates → framework/templates}/meta-prompts/hops/hop-wrapper.md +0 -0
  360. /package/.morph/{templates → framework/templates}/meta-prompts/parallel-workers/parallel-coordinator.md +0 -0
  361. /package/.morph/{templates → framework/templates}/meta-prompts/squad-leaders/backend-squad.md +0 -0
  362. /package/.morph/{templates → framework/templates}/meta-prompts/squad-leaders/frontend-squad.md +0 -0
  363. /package/.morph/{templates → framework/templates}/meta-prompts/squad-leaders/squad-leader.md +0 -0
  364. /package/.morph/{templates → framework/templates}/meta-prompts/validators/checkpoint-validator.md +0 -0
  365. /package/.morph/{templates → framework/templates}/saas/subscription.cs +0 -0
  366. /package/.morph/{templates → framework/templates}/saas/tenant.cs +0 -0
  367. /package/.morph/{templates → framework/templates}/state.template.json +0 -0
  368. /package/.morph/{templates → framework/templates}/ui/FluentDesignTheme.cs +0 -0
  369. /package/.morph/{templates → framework/templates}/ui/MudTheme.cs +0 -0
  370. /package/.morph/{templates → framework/templates}/ui/design-system.css +0 -0
  371. /package/framework/hooks/{commit-msg → git/commit-msg}/conventional-commits.sh +0 -0
  372. /package/framework/hooks/{pre-commit → git/pre-commit}/agents.sh +0 -0
  373. /package/framework/hooks/{pre-commit → git/pre-commit}/orchestrator.sh +0 -0
  374. /package/framework/hooks/{pre-commit → git/pre-commit}/specs.sh +0 -0
  375. /package/framework/hooks/{pre-push → git/pre-push}/run-tests.sh +0 -0
@@ -0,0 +1,137 @@
1
+ # Claude Code Native Alignment Report — Round 2
2
+
3
+ > **Date:** 2026-02-22
4
+ > **Status:** Implemented
5
+ > **Scope:** Memory/rules layer — building on Round 1 (commit 8c806c2)
6
+
7
+ ---
8
+
9
+ ## Summary
10
+
11
+ Round 2 of Claude Code native alignment identifies and adopts two native patterns from the official Claude Code memory documentation that were missed in Round 1:
12
+
13
+ 1. **`.claude/rules/*.md`** — Path-scoped, auto-loading instruction files
14
+ 2. **`@import` in CLAUDE.md** — Auto-import external files into session context
15
+
16
+ ---
17
+
18
+ ## Native Patterns Now Adopted
19
+
20
+ ### 1. Path-Scoped Rules (`.claude/rules/`)
21
+
22
+ **What it is:** Claude Code natively supports modular instruction files placed in `.claude/rules/`. Files without `paths:` frontmatter apply globally; files with `paths:` frontmatter auto-load only when Claude is working with matching files.
23
+
24
+ **What we implemented:**
25
+
26
+ | File | Scope | Paths |
27
+ |------|-------|-------|
28
+ | `morph-workflow.md` | Always active | (none — global) |
29
+ | `csharp-standards.md` | C# files | `**/*.cs`, `**/*.csproj` |
30
+ | `frontend-standards.md` | Blazor/TS/CSS | `**/*.razor`, `**/*.tsx`, `**/*.ts`, `**/*.css` |
31
+ | `testing-standards.md` | Test files | `tests/**`, `**/*.test.*`, `**/*.spec.*`, `**/*Tests.cs` |
32
+ | `infrastructure-standards.md` | Infra files | `**/*.bicep`, `**/Dockerfile`, `**/pipelines/**` |
33
+
34
+ **Source material:** Distilled from `framework/standards/` (core/coding.md, backend/dotnet/core.md, core/testing.md, frontend/blazor/pitfalls.md, infrastructure/azure/azure.md, frontend/nextjs/nextjs-patterns.md).
35
+
36
+ **Why it matters:** Previously, standards were buried in `.morph/framework/standards/` — Claude had to navigate deep paths to access them, and they were never automatically loaded. Path-scoped rules ensure Claude sees the right standards *automatically* when working on the right files, without any manual intervention.
37
+
38
+ **Installation:** `morph-spec init` copies `framework/rules/` → `.claude/rules/` (step 9a in `initCommand()`).
39
+
40
+ ### 2. `@import` in CLAUDE.md
41
+
42
+ **What it is:** Claude Code supports `@path/to/file` syntax inside CLAUDE.md to auto-import external files into the session context at startup.
43
+
44
+ **What we implemented:** Added `@.morph/context/README.md` to `framework/CLAUDE.md`:
45
+
46
+ ```markdown
47
+ ## PROJECT CONTEXT
48
+
49
+ @.morph/context/README.md
50
+ ```
51
+
52
+ **Why it matters:** Previously, `framework/CLAUDE.md` referenced `.morph/context/README.md` only in text (e.g., "run `morph-spec detect` to see your stack"). The file was never actually loaded. Now, every Claude Code session in a user project automatically starts with the project context (stack, architecture, technologies) pre-loaded — no manual reading required.
53
+
54
+ ---
55
+
56
+ ## What Remains Over-Engineered
57
+
58
+ ### Partially Redundant: Session Context Injection vs Auto Memory
59
+
60
+ The `UserPromptSubmit` hook injects context into every session. This overlaps with:
61
+ - Auto memory (`~/.claude/projects/.../memory/`) — Claude Code's native persistent context layer
62
+ - The new `@import` in CLAUDE.md — project context auto-loaded at startup
63
+
64
+ **Verdict:** Keep the hook for now. It handles dynamic state (current feature, active phase) that auto memory doesn't cover. Revisit in Round 3 — the hook may be reducible to only inject feature-specific state, not static project context.
65
+
66
+ ### Level 3–4 Skills Rarely Used
67
+
68
+ `framework/skills/level-3-technologies/` and `level-4-patterns/` contain 30+ files that are rarely invoked. They're installed to `.claude/skills/` via symlinks/copies during init.
69
+
70
+ **Verdict:** Keep for now — they're passive (loaded on-demand via `/skill-name`). Consider documenting them as "on-demand only" in the `morph-workflow.md` rule. Long-term, Level 3–4 could be removed from auto-install and accessed directly from `framework/skills/` when needed.
71
+
72
+ ### 37 Agents in `agents.json`
73
+
74
+ The agent system has 37 agents across 4 tiers. For most projects, only 5–8 agents are active at any given time.
75
+
76
+ **Verdict:** Acceptable complexity. Agents drive spawn prompts and workflow orchestration — they can't be replaced by documentation. The activation-by-keyword system (Tier 3) already limits unnecessary activation.
77
+
78
+ ---
79
+
80
+ ## What Was Intentionally Kept (Justified)
81
+
82
+ | Feature | Justification |
83
+ |---------|--------------|
84
+ | `state.json` + state machine | Claude Code has no native feature-tracking equivalent; phase enforcement requires runtime state |
85
+ | `protect-spec-files.js` hook | Dynamically checks approval gate state before allowing spec file edits — cannot be replaced by static `permissions.deny` |
86
+ | All 12 Claude Code hooks | Context injection (dynamic), output tracking (direct JSON I/O), tool failure logging all provide value beyond native capabilities |
87
+ | `.morph/framework/standards/` | Deep reference library for agents; the rules layer distills it but doesn't replace it |
88
+ | `permissions.deny` for state.json + framework | Already replaced `protect-readonly-files.js` hook in Round 1 — this is the right native approach |
89
+ | Skills hierarchy (Level 0–2) | Level 0 (meta), Level 1 (phase workflows), Level 2 (domains) are actively invoked via `/skill-name` syntax |
90
+
91
+ ---
92
+
93
+ ## Roadmap: Round 3 Candidates
94
+
95
+ In priority order:
96
+
97
+ 1. **Session context hook reduction** — Trim `UserPromptSubmit` hook to inject only feature-specific dynamic state, relying on `@import` + rules for static context. Reduces hook complexity.
98
+
99
+ 2. **Level 3–4 skill audit** — Measure actual usage frequency. If consistently low, move these to a "pull-on-demand" model (reference from framework, not installed to `.claude/skills/`).
100
+
101
+ 3. **`morph-workflow.md` rule enhancement** — Add current workflow/phase detection so the always-active rule provides live feature status context (currently requires `morph-spec status` command).
102
+
103
+ 4. **User-level rules layer (`~/.claude/rules/`)** — A potential personal workflow preferences file for Polymorphism Tech developers (e.g., preferred stack defaults, commit message style). Not currently used.
104
+
105
+ 5. **Rules auto-update on `morph-spec update`** — Currently rules are only installed during `init`. The `update` command should sync `.claude/rules/` when framework rules change.
106
+
107
+ ---
108
+
109
+ ## Files Changed in Round 2
110
+
111
+ | Action | File |
112
+ |--------|------|
113
+ | Created | `framework/rules/morph-workflow.md` |
114
+ | Created | `framework/rules/csharp-standards.md` |
115
+ | Created | `framework/rules/frontend-standards.md` |
116
+ | Created | `framework/rules/testing-standards.md` |
117
+ | Created | `framework/rules/infrastructure-standards.md` |
118
+ | Updated | `framework/CLAUDE.md` — added `@.morph/context/README.md` import |
119
+ | Updated | `src/commands/project/init.js` — added step 9a: rules copy to `.claude/rules/` |
120
+ | Created | `docs/claude-alignment-report.md` (this file) |
121
+
122
+ ---
123
+
124
+ ## Round 1 Reference (commit 8c806c2)
125
+
126
+ Round 1 implemented 7 tasks:
127
+ 1. Fixed circular hook bug in `track-output-creation.js`
128
+ 2. Native `permissions.deny` replaced `protect-readonly-files.js`
129
+ 3. Skills installed to `.claude/skills/` (flat, with symlinks on non-Windows)
130
+ 4. Global statusline installed to `~/.claude/`
131
+ 5. `PostToolUseFailure` hook: `handle-tool-failure.js`
132
+ 6. Standards registry: `framework/standards/STANDARDS.json` (74 entries)
133
+ 7. `framework/phases.json` — canonical phase definitions
134
+
135
+ ---
136
+
137
+ *MORPH-SPEC by Polymorphism Tech*
@@ -0,0 +1,512 @@
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.