@polymorphism-tech/morph-spec 6.0.0 → 7.1.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 (114) hide show
  1. package/README.md +367 -366
  2. package/docs/CHEATSHEET.md +3 -3
  3. package/docs/QUICKSTART.md +4 -4
  4. package/framework/CLAUDE.md +13 -0
  5. package/framework/MORPH.md +57 -36
  6. package/framework/agents.json +132 -127
  7. package/framework/commands/morph-apply.md +4 -21
  8. package/framework/commands/morph-archive.md +1 -1
  9. package/framework/commands/morph-proposal.md +2 -0
  10. package/framework/hooks/claude-code/core/enforce-phase-writes.js +1 -1
  11. package/framework/hooks/claude-code/core/protect-spec-files.js +1 -1
  12. package/framework/hooks/claude-code/core/state-sync.js +212 -0
  13. package/framework/hooks/shared/phase-utils.js +5 -4
  14. package/framework/hooks/shared/state-reader.js +1 -1
  15. package/framework/phases.json +1 -1
  16. package/framework/rubrics/backend.json +41 -36
  17. package/framework/rules/ai-agents-standards.md +45 -15
  18. package/framework/rules/morph-workflow.md +15 -34
  19. package/framework/rules/neon-standards.md +25 -26
  20. package/framework/schemas/tasks.schema.json +35 -0
  21. package/framework/skills/core/morph-apply/SKILL.md +154 -0
  22. package/framework/skills/core/morph-brainstorming/SKILL.md +53 -30
  23. package/framework/skills/core/morph-implement/SKILL.md +25 -14
  24. package/framework/skills/core/morph-plan/SKILL.md +91 -23
  25. package/framework/skills/core/morph-proposal/SKILL.md +137 -0
  26. package/framework/skills/core/morph-review/SKILL.md +43 -7
  27. package/framework/skills/core/morph-stack-scan/SKILL.md +40 -1
  28. package/framework/standards/STANDARDS.json +1729 -1134
  29. package/framework/standards/ai-agents/agent-session.md +160 -0
  30. package/framework/standards/ai-agents/batching.md +193 -0
  31. package/framework/standards/ai-agents/context-providers.md +188 -0
  32. package/framework/standards/ai-agents/mcp-server.md +250 -0
  33. package/framework/standards/ai-agents/mcp-tools.md +197 -0
  34. package/framework/standards/ai-agents/middleware-patterns.md +207 -0
  35. package/framework/standards/ai-agents/modalities-image-gen.md +173 -0
  36. package/framework/standards/ai-agents/modalities-speech-to-text.md +171 -0
  37. package/framework/standards/ai-agents/modalities-text-to-speech.md +181 -0
  38. package/framework/standards/ai-agents/modalities-vision.md +201 -0
  39. package/framework/standards/ai-agents/multi-agent-patterns.md +155 -0
  40. package/framework/standards/ai-agents/production.md +114 -258
  41. package/framework/standards/ai-agents/prompts-in-db.md +214 -0
  42. package/framework/standards/ai-agents/providers/model-registry.md +158 -0
  43. package/framework/standards/ai-agents/rag-custom-pgvector.md +243 -0
  44. package/framework/standards/ai-agents/service-tier-flex.md +135 -0
  45. package/framework/standards/ai-agents/setup.md +142 -316
  46. package/framework/standards/ai-agents/structured-output.md +249 -0
  47. package/framework/standards/ai-agents/sweet-spot.md +109 -0
  48. package/framework/standards/ai-agents/workflows.md +114 -284
  49. package/framework/standards/architecture/vertical-slice/vertical-slice.md +433 -429
  50. package/framework/standards/backend/api/validation.md +92 -88
  51. package/framework/standards/backend/database/postgresql/database.md +336 -332
  52. package/framework/standards/backend/database/vector-search-rag.md +599 -541
  53. package/framework/standards/backend/dotnet/fluent-validation-vsa.md +4 -0
  54. package/framework/standards/backend/dotnet/result-pattern.md +4 -0
  55. package/framework/standards/backend/dotnet/scalar-ui.md +176 -172
  56. package/framework/standards/backend/dotnet/scrutor.md +4 -0
  57. package/framework/standards/backend/dotnet/vsa-handler-patterns.md +278 -274
  58. package/framework/standards/backend/integrations/asaas/asaas-api.md +260 -216
  59. package/framework/standards/backend/integrations/hangfire/hangfire-jobs.md +354 -350
  60. package/framework/standards/backend/integrations/neon-auth/neon-auth.md +30 -19
  61. package/framework/standards/backend/integrations/resend/resend-email.md +400 -385
  62. package/framework/standards/data/nosql/cache/redis.md +106 -97
  63. package/framework/standards/data/nosql/cosmos-db.md +127 -118
  64. package/framework/standards/data/vector-search/rag-chunking.md +113 -104
  65. package/framework/standards/frontend/design-system/ai-image-generation.md +4 -0
  66. package/framework/standards/frontend/design-system/animations.md +164 -160
  67. package/framework/standards/frontend/design-system/naming.md +68 -64
  68. package/framework/standards/frontend/gsap/gsap-core.md +14 -8
  69. package/framework/standards/frontend/gsap/gsap-plugins.md +26 -21
  70. package/framework/standards/frontend/gsap/gsap-scrolltrigger.md +9 -7
  71. package/framework/standards/frontend/nextjs/app-router.md +127 -123
  72. package/framework/standards/frontend/nextjs/components.md +136 -132
  73. package/framework/standards/frontend/nextjs/data-fetching.md +130 -126
  74. package/framework/standards/frontend/nextjs/forms.md +134 -128
  75. package/framework/standards/frontend/nextjs/motion-patterns.md +328 -322
  76. package/framework/standards/frontend/nextjs/naming-conventions.md +71 -67
  77. package/framework/standards/frontend/nextjs/nextjs-patterns.md +229 -225
  78. package/framework/standards/frontend/nextjs/project-structure.md +106 -102
  79. package/framework/standards/frontend/nextjs/state-management.md +76 -72
  80. package/framework/standards/frontend/nextjs/testing.md +115 -111
  81. package/framework/standards/infrastructure/docker/easypanel-deploy.md +196 -192
  82. package/framework/standards/infrastructure/neon/neon-pgrag.md +6 -2
  83. package/framework/standards/infrastructure/neon/neon-pgvector.md +4 -0
  84. package/framework/standards/infrastructure/neon/neon-setup.md +5 -1
  85. package/framework/standards/integration/mcp/mcp-tools.md +471 -462
  86. package/framework/templates/REGISTRY.json +1745 -1239
  87. package/framework/templates/code/dotnet/ai-agents/AgentBootstrap.cs.template +39 -0
  88. package/framework/templates/code/dotnet/ai-agents/EmbeddingService.cs.template +68 -0
  89. package/framework/templates/code/dotnet/ai-agents/ModelRegistry.cs.template +117 -0
  90. package/framework/templates/code/dotnet/ai-agents/PromptRepository.cs.template +95 -0
  91. package/framework/templates/code/dotnet/ai-agents/ResilientToolMiddleware.cs.template +61 -0
  92. package/framework/templates/code/dotnet/ai-agents/VectorSearchTool.cs.template +107 -0
  93. package/framework/templates/code/dotnet/ai-agents/model-registry.json.template +58 -0
  94. package/framework/templates/code/sql/ai-agents/agent-prompts-migration.sql.template +58 -0
  95. package/framework/templates/code/sql/ai-agents/pgvector-embeddings-migration.sql.template +91 -0
  96. package/framework/templates/docs/onboarding.md +4 -4
  97. package/framework/templates/tasks.template.json +17 -0
  98. package/package.json +89 -83
  99. package/src/commands/project/init.js +16 -0
  100. package/src/commands/validation/validate-feature.js +1 -1
  101. package/src/core/paths/output-schema.js +6 -6
  102. package/src/core/state/state-manager.js +1 -1
  103. package/src/core/templates/template-registry.js +289 -256
  104. package/src/lib/detectors/design-system-detector.js +1 -1
  105. package/src/lib/generators/context-generator.js +516 -518
  106. package/src/lib/generators/scaffold-generator.js +23 -26
  107. package/src/lib/installers/memory-installer.js +138 -0
  108. package/src/lib/phase-chain/phase-validator.js +4 -4
  109. package/src/lib/risk-detector.js +80 -0
  110. package/src/lib/tasks/tasks-json-parser.js +185 -0
  111. package/src/scripts/setup-infra.js +25 -0
  112. package/src/utils/hooks-installer.js +59 -10
  113. package/framework/standards/infrastructure/neon/neon-semantic-kernel.md +0 -310
  114. package/framework/templates/integrations/semantic-kernel-neon.cs +0 -125
package/README.md CHANGED
@@ -1,367 +1,368 @@
1
- # morph-spec
2
-
3
- > Spec-driven development framework for multi-stack projects. Turns feature requests into implementation-ready code through structured, AI-orchestrated phases.
4
-
5
- **Package:** `@polymorphism-tech/morph-spec`
6
- **Version:** 4.22.1
7
- **Requires:** Node.js 18+, Claude Code
8
-
9
- ---
10
-
11
- ## What it does
12
-
13
- morph-spec enforces a spec-first development workflow. When you ask for a feature, it does not write code immediately. It runs through structured phases (proposal, design, tasks) with approval gates before a single line of implementation is generated. Each phase produces traceable output files. Every decision is documented.
14
-
15
- It integrates natively with Claude Code: skills become slash commands, agents become native subagents, hooks inject state context automatically, and rules enforce standards based on file paths.
16
-
17
- ---
18
-
19
- ## Requirements
20
-
21
- - [Claude Code](https://claude.ai/code) (latest)
22
- - Node.js 18+
23
- - npm 9+ or pnpm
24
-
25
- ---
26
-
27
- ## Installation
28
-
29
- Install the CLI globally:
30
-
31
- ```bash
32
- npm install -g @polymorphism-tech/morph-spec
33
- ```
34
-
35
- Then initialize in your project:
36
-
37
- ```bash
38
- morph-spec init
39
- ```
40
-
41
- ### Init options
42
-
43
-
44
- | Flag | Description |
45
- | ------------ | ------------------------------------- |
46
- | `--force` | Overwrite existing installation |
47
- | `--skip-mcp` | Skip MCP configuration prompt |
48
- | `--path` | Target directory (default: cwd) |
49
-
50
-
51
- After init, open the project in Claude Code. The framework activates automatically via `.claude/settings.local.json`.
52
-
53
- ---
54
-
55
- ## Project structure (after init)
56
-
57
- ```
58
- your-project/
59
- ├── CLAUDE.md # AI instructions for this project
60
- ├── .morph/
61
- │ ├── config/
62
- │ │ └── config.json # Project configuration
63
- │ ├── framework/
64
- │ │ ├── agents.json # 22 agents in 4 tiers (READ-ONLY)
65
- │ │ ├── standards/ # Coding and architecture standards (READ-ONLY)
66
- │ │ └── templates/ # Code and IaC templates (READ-ONLY)
67
- │ ├── context/ # Project context (README.md, standards.md)
68
- │ ├── features/ # Active features
69
- │ │ └── {feature}/
70
- │ │ ├── 0-proposal/ # User story + acceptance criteria
71
- │ │ ├── 1-ui/ # UI/UX design (optional, UI-heavy features)
72
- │ │ ├── 2-design/ # Technical spec, contracts, decisions
73
- │ │ ├── 3-tasks/ # Atomic task list
74
- │ │ └── 4-implement/ # Recap and implementation notes
75
- │ └── state.json # READ-ONLY — managed by CLI only
76
- └── .claude/
77
- ├── commands/ # Slash commands
78
- ├── skills/ # Framework skills (flat .md files)
79
- ├── agents/ # Native subagents (22 agents)
80
- ├── rules/ # Path-scoped standards rules
81
- └── settings.local.json # Hooks configuration (10 hooks)
82
- ```
83
-
84
- ---
85
-
86
- ## Phase workflow
87
-
88
- Features move through structured phases. Some are optional depending on feature type.
89
-
90
- ```
91
- proposal → [uiux] → design → plan → tasks → implement → [sync]
92
- ```
93
-
94
- Phases in brackets are optional. `uiux` applies to UI-heavy features. `sync` is a post-implementation reconciliation step.
95
-
96
- ### Phase outputs
97
-
98
-
99
- | Phase | Directory | Key files |
100
- | --------- | -------------- | ------------------------------------------------------------- |
101
- | Proposal | `0-proposal/` | `proposal.md` |
102
- | UI/UX | `1-ui/` | `design-system.md`, `mockups.md`, `components.md`, `flows.md` |
103
- | Design | `2-design/` | `spec.md`, `contracts.cs`, `decisions.md` |
104
- | Plan | `3-plan/` | `plan.md` |
105
- | Tasks | `4-tasks/` | `tasks.md` |
106
- | Implement | `5-implement/` | `recap.md` |
107
-
108
-
109
- ### Approval gates
110
-
111
- - **Design gate** — Spec must be approved before moving to Plan.
112
- - **Plan gate** — Plan must be approved before moving to Tasks.
113
- - **Tasks gate** — Task list must be approved before implementation starts.
114
-
115
- Check gate status:
116
-
117
- ```bash
118
- morph-spec approval-status {feature}
119
- ```
120
-
121
- ---
122
-
123
- ## Slash commands
124
-
125
- These commands are available inside Claude Code after init.
126
-
127
-
128
- | Command | Description |
129
- | --------------------------- | --------------------------------------------------------- |
130
- | `/morph-proposal {feature}` | Full spec pipeline (phases 0-4, pauses at approval gates) |
131
- | `/morph-apply {feature}` | Implement approved feature (phase 5) |
132
- | `/morph-status` | Feature status dashboard |
133
- | `/morph-preflight` | Pre-implementation validation |
134
-
135
-
136
- ---
137
-
138
- ## CLI reference
139
-
140
- ### Project management
141
-
142
- ```bash
143
- morph-spec init # Initialize MORPH in current project
144
- morph-spec init --force # Overwrite existing installation
145
- morph-spec update # Update framework files and re-analyze project
146
- morph-spec doctor # Check installation health
147
- morph-spec doctor --full # Full health check (all file verifications)
148
- ```
149
-
150
- ### Feature workflow
151
-
152
- ```bash
153
- morph-spec state list # List all features and their states
154
- morph-spec state get {feature} # Get feature state
155
- morph-spec state set {feature} {key} {value}
156
- morph-spec phase advance {feature} # Advance to next phase
157
- morph-spec task done {feature} # Mark current task complete
158
- morph-spec task start {feature} # Start next task
159
- morph-spec status {feature} # Feature status dashboard
160
- ```
161
-
162
- ### Validation
163
-
164
- ```bash
165
- morph-spec validate # Run all validators
166
- morph-spec validate {validator} # Run specific validator
167
- morph-spec validate-feature {feature} # Content-aware feature validation
168
- ```
169
-
170
- ---
171
-
172
- ## Agent hierarchy
173
-
174
- morph-spec includes 22 agents organized in 4 tiers (2+3+13+4). Tier 1-2 agents are installed as native Claude Code subagents in `.claude/agents/`. Tier 3 domain agents are installed as `.claude/agents/morph-domain-{name}.md`.
175
-
176
- ### Tier 1 — Orchestrators (2)
177
-
178
-
179
- | Agent | Role | Active |
180
- | --------------------- | ------------------------------------------------------ | --------- |
181
- | `standards-architect` | Chief Architect — enforces standards across all phases | Always |
182
- | `ai-system-architect` | AI/Agent system design and orchestration | On-demand |
183
-
184
-
185
- ### Tier 2 — Domain Leaders (3)
186
-
187
-
188
- | Agent | Squad | Active |
189
- | ------------------ | ------------------------- | --------- |
190
- | `dotnet-senior` | Backend squad lead | Always |
191
- | `nextjs-expert` | Frontend squad lead | Always |
192
- | `infra-architect` | Infrastructure squad lead | Always |
193
-
194
-
195
- ### Tier 3 — Specialists (13)
196
-
197
- Organized into squads:
198
-
199
- **Backend (6):** ef-modeler, hangfire-orchestrator, ms-agent-expert, supabase-expert, vector-search-expert, morph-spec-architect
200
-
201
- **Frontend (3):** css-specialist, ui-designer, seo-growth-hacker
202
-
203
- **Integrations (3):** asaas-financial, clerk-auth, resend-email
204
-
205
- **Security (1):** security-expert
206
-
207
- ### Tier 4 — Validators (4)
208
-
209
-
210
- | Agent | Validates |
211
- | ------------------------------ | --------------------------------------- |
212
- | `architecture-expert` | Architectural decisions and constraints |
213
- | `packages-validator` | Package versions and compatibility |
214
- | `design-system-validator` | Design system adherence |
215
- | `nextjs-component-validator` | Next.js component structure and naming |
216
-
217
-
218
- ---
219
-
220
- ## Hooks
221
-
222
- 10 Claude Code hooks are installed into `.claude/settings.local.json` across 8 event types:
223
-
224
-
225
- | Event | Hook | Purpose |
226
- | -------------------- | -------------------------- | ----------------------------------------------------------------- |
227
- | `SessionStart` | `inject-morph-context.js` | Injects active feature spec into context (configurable char max) |
228
- | `UserPromptSubmit` | `enrich-prompt.js` | Context-aware prompt enrichment, wrong-phase warnings |
229
- | `PreToolUse` | Bash guard (prompt type) | Detects destructive patterns inline via Claude's reasoning |
230
- | `PreToolUse` | `protect-spec-files.js` | Blocks edits to spec files after approval gate |
231
- | `PreToolUse` | `enforce-phase-writes.js` | Ensures writes go to the correct phase directory |
232
- | `PostToolUse` | `dispatch.js` | Triggers auto-checkpoints on task completion |
233
- | `PostToolUseFailure` | `handle-tool-failure.js` | Logs failures to `.morph/logs/tool-failures.log` |
234
- | `Stop` | `validate-completion.js` | Warns about incomplete tasks/missing outputs/pending gates |
235
- | `PreCompact` | `save-morph-context.js` | Snapshots state to `.morph/memory/` before compaction |
236
-
237
-
238
- Protected files (via `permissions.deny`):
239
-
240
- - `.morph/state.json` — never edited directly, CLI only
241
- - `.morph/framework/`** — read-only framework content
242
-
243
- ---
244
-
245
- ## Rules
246
-
247
- Path-scoped rules are installed to `.claude/rules/` and activate automatically based on file patterns:
248
-
249
-
250
- | Rule file | Applies to |
251
- | ----------------------------- | -------------------------------------------------------- |
252
- | `morph-workflow.md` | Always active — spec-first mandate, phase commands |
253
- | `csharp-standards.md` | `**/*.cs`, `**/*.csproj` |
254
- | `frontend-standards.md` | `**/*.razor`, `**/*.css`, `**/*.scss` |
255
- | `nextjs-standards.md` | `**/*.tsx`, `**/*.ts` |
256
- | `testing-standards.md` | `tests/`**, `**/*.test.*`, `**/*.spec.*`, `**/*Tests.cs` |
257
- | `infrastructure-standards.md` | `**/*.bicep`, `**/Dockerfile`, `**/pipelines/**` |
258
-
259
-
260
- ---
261
-
262
- ## Stack support
263
-
264
-
265
- | Technology | Support |
266
- | ------------------------------------------- | ------------------------------------------------ |
267
- | .NET 10 / ASP.NET Core | Full — C# contracts, EF Core, CQRS, Minimal API |
268
- | Next.js / React / TypeScript | Full — components, routing, state management |
269
- | Supabase | Supported via CLI (local Docker) |
270
-
271
-
272
- TypeScript strict mode is enforced by default. See `.morph/framework/standards/` for all coding standards.
273
-
274
- ---
275
-
276
- ## Update
277
-
278
- To update the framework files in an existing project:
279
-
280
- ```bash
281
- morph-spec update
282
- ```
283
-
284
- This re-syncs `.morph/framework/`, `.claude/skills/`, `.claude/agents/`, `.claude/rules/`, and `CLAUDE.md` with the installed package version. Your `.morph/config/config.json`, `.morph/context/`, and feature outputs are not touched.
285
-
286
- After updating, run `morph-spec doctor` to confirm the installation is healthy.
287
-
288
- ---
289
-
290
- ## Key rules
291
-
292
- **Never skip phases.** Every feature starts with a proposal. No code is written until the design is approved and a task list exists.
293
-
294
- **Never edit protected files directly:**
295
-
296
- - `.morph/state.json` — use `morph-spec state set`
297
- - `.morph/framework/`** — read-only, updated by `morph-spec update`
298
-
299
- **Always document decisions.** Each feature has a `2-design/decisions.md`. Architectural choices go there, not in commit messages.
300
-
301
- **Checkpoints every 3 tasks.** The framework auto-validates architecture compliance, package versions, and security after every third completed task.
302
-
303
- ---
304
-
305
- ## Troubleshooting
306
-
307
- ### `morph-spec: command not found`
308
-
309
- The installer automatically adds the npm global directory to your PowerShell `$PROFILE`. Open a **new terminal** after installing. If it still doesn't work, add it manually:
310
-
311
- ```bash
312
- npm config get prefix
313
- # Add {prefix} to your PATH
314
- ```
315
-
316
- ### `morph-spec doctor` reports issues
317
-
318
- Run doctor to see all checks:
319
-
320
- ```bash
321
- morph-spec doctor
322
- ```
323
-
324
- Common fixes:
325
-
326
- - **Missing `.claude/agents/`** — run `morph-spec update` to reinstall agents
327
- - **Missing `.claude/rules/`** — run `morph-spec update` to reinstall rules
328
- - **State version mismatch** — state auto-migrates on next CLI command; if it fails, back up and re-init
329
- - **Hooks not firing** — confirm `.claude/settings.local.json` exists and contains the `hooks` key
330
-
331
- ### EPERM on Windows global install
332
-
333
- Windows may block global npm installs without elevated permissions. Options:
334
-
335
- 1. Run terminal as Administrator (not recommended long-term)
336
- 2. Change npm global prefix to a user-writable directory:
337
-
338
- ```bat
339
- mkdir %APPDATA%\npm-global
340
- npm config set prefix %APPDATA%\npm-global
341
- :: Add %APPDATA%\npm-global to your PATH
342
- npm install -g @polymorphism-tech/morph-spec
343
- ```
344
-
345
- 1. Open a new terminal (the installer adds npm to your PATH automatically)
346
-
347
- ### Hook not triggering on SessionStart
348
-
349
- Ensure `.claude/settings.local.json` is not gitignored in your project. The file must be present for Claude Code to load hooks. If it is missing, re-run `morph-spec setup-infra` or `morph-spec init --force`.
350
-
351
- ---
352
-
353
- ## Standards
354
-
355
- The framework ships 82 registered standards across 11 categories, stored in `.morph/framework/standards/STANDARDS.json`. Standards are enforced via path-scoped rules installed to `.claude/rules/` during `morph-spec init`.
356
-
357
- ---
358
-
359
- ## License
360
-
361
- Proprietary — see [LICENSE](./LICENSE).
362
-
363
- Code generated by morph-spec (contracts, templates, implementation output) belongs to you.
364
-
365
- ---
366
-
1
+ # morph-spec
2
+
3
+ > Spec-driven development framework for multi-stack projects. Turns feature requests into implementation-ready code through structured, AI-orchestrated phases.
4
+
5
+ **Package:** `@polymorphism-tech/morph-spec`
6
+ **Version:** 4.22.1
7
+ **Requires:** Node.js 22+, Claude Code
8
+
9
+ ---
10
+
11
+ ## What it does
12
+
13
+ morph-spec enforces a spec-first development workflow. When you ask for a feature, it does not write code immediately. It runs through structured phases (proposal, design, tasks) with approval gates before a single line of implementation is generated. Each phase produces traceable output files. Every decision is documented.
14
+
15
+ It integrates natively with Claude Code: skills become slash commands, agents become native subagents, hooks inject state context automatically, and rules enforce standards based on file paths.
16
+
17
+ ---
18
+
19
+ ## Requirements
20
+
21
+ - [Claude Code](https://claude.ai/code) (latest)
22
+ - Node.js 22+
23
+ - npm 9+ or pnpm
24
+
25
+ ---
26
+
27
+ ## Installation
28
+
29
+ Install the CLI globally:
30
+
31
+ ```bash
32
+ npm install -g @polymorphism-tech/morph-spec
33
+ ```
34
+
35
+ Then initialize in your project:
36
+
37
+ ```bash
38
+ morph-spec init
39
+ ```
40
+
41
+ ### Init options
42
+
43
+
44
+ | Flag | Description |
45
+ | ------------ | ------------------------------------- |
46
+ | `--force` | Overwrite existing installation |
47
+ | `--skip-mcp` | Skip MCP configuration prompt |
48
+ | `--path` | Target directory (default: cwd) |
49
+
50
+
51
+ After init, open the project in Claude Code. The framework activates automatically via `.claude/settings.local.json`.
52
+
53
+ ---
54
+
55
+ ## Project structure (after init)
56
+
57
+ ```
58
+ your-project/
59
+ ├── CLAUDE.md # AI instructions for this project
60
+ ├── .morph/
61
+ │ ├── config/
62
+ │ │ └── config.json # Project configuration
63
+ │ ├── framework/
64
+ │ │ ├── agents.json # 22 agents in 4 tiers (READ-ONLY)
65
+ │ │ ├── standards/ # Coding and architecture standards (READ-ONLY)
66
+ │ │ └── templates/ # Code and IaC templates (READ-ONLY)
67
+ │ ├── context/ # Project context (README.md, standards.md)
68
+ │ ├── features/ # Active features
69
+ │ │ └── {feature}/
70
+ │ │ ├── 0-proposal/ # Problem statement + acceptance criteria
71
+ │ │ ├── 1-design/ # UI/UX design (optional, UI-heavy features)
72
+ │ │ ├── 2-plan/ # spec.md + mandate.md + tasks.json
73
+ │ │ ├── 3-implement/ # Recap and implementation notes
74
+ │ │ └── 4-review/ # Review report + Gate 3
75
+ │ └── state.json # READ-ONLY — managed by CLI only
76
+ └── .claude/
77
+ ├── commands/ # Slash commands
78
+ ├── skills/ # Framework skills (flat .md files)
79
+ ├── agents/ # Native subagents (22 agents)
80
+ ├── rules/ # Path-scoped standards rules
81
+ └── settings.local.json # Hooks configuration (10 hooks)
82
+ ```
83
+
84
+ ---
85
+
86
+ ## Phase workflow
87
+
88
+ Features move through structured phases. Some are optional depending on feature type.
89
+
90
+ ```
91
+ proposal → [design] → plan → implement → review
92
+ ```
93
+
94
+ `design` is optional — applies only to UI-heavy features.
95
+
96
+ ### Phase outputs
97
+
98
+
99
+ | Phase | Directory | Key files |
100
+ | --------- | --------------- | ------------------------------------------------------------------ |
101
+ | Proposal | `0-proposal/` | `proposal.md`, `stack-scan.md`, `migration-plan.md` (optional) |
102
+ | Design | `1-design/` | `design-system.md`, `mockups.md`, `components.md`, `flows.md` |
103
+ | Plan | `2-plan/` | `spec.md`, `mandate.md`, `tasks.json`, `decisions.md` |
104
+ | Implement | `3-implement/` | `recap.md` + source code |
105
+ | Review | `4-review/` | `review-report.md` |
106
+
107
+
108
+ ### Approval gates
109
+
110
+ - **Gate 1 (Proposal)** — Problem statement must be approved before plan.
111
+ - **Gate 2 (Plan)** — Spec + mandate + tasks must be approved before implement.
112
+ - **Gate 3 (Review)** — Review report must be approved before archive.
113
+
114
+ In `trust: "auto"` mode (default), gates auto-pass without risk signals. See `framework/MORPH.md` for risk-signal details.
115
+
116
+ Check gate status:
117
+
118
+ ```bash
119
+ morph-spec approval-status {feature}
120
+ ```
121
+
122
+ ---
123
+
124
+ ## Slash commands
125
+
126
+ These commands are available inside Claude Code after init.
127
+
128
+
129
+ | Command | Description |
130
+ | --------------------------- | --------------------------------------------------------- |
131
+ | `/morph-proposal {feature}` | Full spec pipeline (phases 0-4, pauses at approval gates) |
132
+ | `/morph-apply {feature}` | Implement approved feature (phase 5) |
133
+ | `/morph-status` | Feature status dashboard |
134
+ | `/morph-preflight` | Pre-implementation validation |
135
+
136
+
137
+ ---
138
+
139
+ ## CLI reference
140
+
141
+ ### Project management
142
+
143
+ ```bash
144
+ morph-spec init # Initialize MORPH in current project
145
+ morph-spec init --force # Overwrite existing installation
146
+ morph-spec update # Update framework files and re-analyze project
147
+ morph-spec doctor # Check installation health
148
+ morph-spec doctor --full # Full health check (all file verifications)
149
+ ```
150
+
151
+ ### Feature workflow
152
+
153
+ ```bash
154
+ morph-spec state list # List all features and their states
155
+ morph-spec state get {feature} # Get feature state
156
+ morph-spec state set {feature} {key} {value}
157
+ morph-spec phase advance {feature} # Advance to next phase
158
+ morph-spec task done {feature} # Mark current task complete
159
+ morph-spec task start {feature} # Start next task
160
+ morph-spec status {feature} # Feature status dashboard
161
+ ```
162
+
163
+ ### Validation
164
+
165
+ ```bash
166
+ morph-spec validate # Run all validators
167
+ morph-spec validate {validator} # Run specific validator
168
+ morph-spec validate-feature {feature} # Content-aware feature validation
169
+ ```
170
+
171
+ ---
172
+
173
+ ## Agent hierarchy
174
+
175
+ morph-spec includes 22 agents organized in 4 tiers (2+3+13+4). Tier 1-2 agents are installed as native Claude Code subagents in `.claude/agents/`. Tier 3 domain agents are installed as `.claude/agents/morph-domain-{name}.md`.
176
+
177
+ ### Tier 1 — Orchestrators (2)
178
+
179
+
180
+ | Agent | Role | Active |
181
+ | --------------------- | ------------------------------------------------------ | --------- |
182
+ | `standards-architect` | Chief Architect — enforces standards across all phases | Always |
183
+ | `ai-system-architect` | AI/Agent system design and orchestration | On-demand |
184
+
185
+
186
+ ### Tier 2 — Domain Leaders (3)
187
+
188
+
189
+ | Agent | Squad | Active |
190
+ | ------------------ | ------------------------- | --------- |
191
+ | `dotnet-senior` | Backend squad lead | Always |
192
+ | `nextjs-expert` | Frontend squad lead | Always |
193
+ | `infra-architect` | Infrastructure squad lead | Always |
194
+
195
+
196
+ ### Tier 3 — Specialists (13)
197
+
198
+ Organized into squads:
199
+
200
+ **Backend (6):** ef-modeler, hangfire-orchestrator, ms-agent-expert, supabase-expert, vector-search-expert, morph-spec-architect
201
+
202
+ **Frontend (3):** css-specialist, ui-designer, seo-growth-hacker
203
+
204
+ **Integrations (3):** asaas-financial, clerk-auth, resend-email
205
+
206
+ **Security (1):** security-expert
207
+
208
+ ### Tier 4 — Validators (4)
209
+
210
+
211
+ | Agent | Validates |
212
+ | ------------------------------ | --------------------------------------- |
213
+ | `architecture-expert` | Architectural decisions and constraints |
214
+ | `packages-validator` | Package versions and compatibility |
215
+ | `design-system-validator` | Design system adherence |
216
+ | `nextjs-component-validator` | Next.js component structure and naming |
217
+
218
+
219
+ ---
220
+
221
+ ## Hooks
222
+
223
+ 10 Claude Code hooks are installed into `.claude/settings.local.json` across 8 event types:
224
+
225
+
226
+ | Event | Hook | Purpose |
227
+ | -------------------- | -------------------------- | ----------------------------------------------------------------- |
228
+ | `SessionStart` | `inject-morph-context.js` | Injects active feature spec into context (configurable char max) |
229
+ | `UserPromptSubmit` | `enrich-prompt.js` | Context-aware prompt enrichment, wrong-phase warnings |
230
+ | `PreToolUse` | Bash guard (prompt type) | Detects destructive patterns inline via Claude's reasoning |
231
+ | `PreToolUse` | `protect-spec-files.js` | Blocks edits to spec files after approval gate |
232
+ | `PreToolUse` | `enforce-phase-writes.js` | Ensures writes go to the correct phase directory |
233
+ | `PostToolUse` | `dispatch.js` | Triggers auto-checkpoints on task completion |
234
+ | `PostToolUseFailure` | `handle-tool-failure.js` | Logs failures to `.morph/logs/tool-failures.log` |
235
+ | `Stop` | `validate-completion.js` | Warns about incomplete tasks/missing outputs/pending gates |
236
+ | `PreCompact` | `save-morph-context.js` | Snapshots state to `.morph/memory/` before compaction |
237
+
238
+
239
+ Protected files (via `permissions.deny`):
240
+
241
+ - `.morph/state.json` — never edited directly, CLI only
242
+ - `.morph/framework/`** — read-only framework content
243
+
244
+ ---
245
+
246
+ ## Rules
247
+
248
+ Path-scoped rules are installed to `.claude/rules/` and activate automatically based on file patterns:
249
+
250
+
251
+ | Rule file | Applies to |
252
+ | ----------------------------- | -------------------------------------------------------- |
253
+ | `morph-workflow.md` | Always active — spec-first mandate, phase commands |
254
+ | `csharp-standards.md` | `**/*.cs`, `**/*.csproj` |
255
+ | `frontend-standards.md` | `**/*.razor`, `**/*.css`, `**/*.scss` |
256
+ | `nextjs-standards.md` | `**/*.tsx`, `**/*.ts` |
257
+ | `testing-standards.md` | `tests/`**, `**/*.test.*`, `**/*.spec.*`, `**/*Tests.cs` |
258
+ | `infrastructure-standards.md` | `**/*.bicep`, `**/Dockerfile`, `**/pipelines/**` |
259
+
260
+
261
+ ---
262
+
263
+ ## Stack support
264
+
265
+
266
+ | Technology | Support |
267
+ | ------------------------------------------- | ------------------------------------------------ |
268
+ | .NET 10 / ASP.NET Core | Full — C# contracts, EF Core, CQRS, Minimal API |
269
+ | Next.js / React / TypeScript | Full — components, routing, state management |
270
+ | Supabase | Supported via CLI (local Docker) |
271
+
272
+
273
+ TypeScript strict mode is enforced by default. See `.morph/framework/standards/` for all coding standards.
274
+
275
+ ---
276
+
277
+ ## Update
278
+
279
+ To update the framework files in an existing project:
280
+
281
+ ```bash
282
+ morph-spec update
283
+ ```
284
+
285
+ This re-syncs `.morph/framework/`, `.claude/skills/`, `.claude/agents/`, `.claude/rules/`, and `CLAUDE.md` with the installed package version. Your `.morph/config/config.json`, `.morph/context/`, and feature outputs are not touched.
286
+
287
+ After updating, run `morph-spec doctor` to confirm the installation is healthy.
288
+
289
+ ---
290
+
291
+ ## Key rules
292
+
293
+ **Never skip phases.** Every feature starts with a proposal. No code is written until the design is approved and a task list exists.
294
+
295
+ **Never edit protected files directly:**
296
+
297
+ - `.morph/state.json` — use `morph-spec state set`
298
+ - `.morph/framework/`** — read-only, updated by `morph-spec update`
299
+
300
+ **Always document decisions.** Each feature has a `2-design/decisions.md`. Architectural choices go there, not in commit messages.
301
+
302
+ **Checkpoints every 3 tasks.** The framework auto-validates architecture compliance, package versions, and security after every third completed task.
303
+
304
+ ---
305
+
306
+ ## Troubleshooting
307
+
308
+ ### `morph-spec: command not found`
309
+
310
+ The installer automatically adds the npm global directory to your PowerShell `$PROFILE`. Open a **new terminal** after installing. If it still doesn't work, add it manually:
311
+
312
+ ```bash
313
+ npm config get prefix
314
+ # Add {prefix} to your PATH
315
+ ```
316
+
317
+ ### `morph-spec doctor` reports issues
318
+
319
+ Run doctor to see all checks:
320
+
321
+ ```bash
322
+ morph-spec doctor
323
+ ```
324
+
325
+ Common fixes:
326
+
327
+ - **Missing `.claude/agents/`** — run `morph-spec update` to reinstall agents
328
+ - **Missing `.claude/rules/`** — run `morph-spec update` to reinstall rules
329
+ - **State version mismatch** — state auto-migrates on next CLI command; if it fails, back up and re-init
330
+ - **Hooks not firing** — confirm `.claude/settings.local.json` exists and contains the `hooks` key
331
+
332
+ ### EPERM on Windows global install
333
+
334
+ Windows may block global npm installs without elevated permissions. Options:
335
+
336
+ 1. Run terminal as Administrator (not recommended long-term)
337
+ 2. Change npm global prefix to a user-writable directory:
338
+
339
+ ```bat
340
+ mkdir %APPDATA%\npm-global
341
+ npm config set prefix %APPDATA%\npm-global
342
+ :: Add %APPDATA%\npm-global to your PATH
343
+ npm install -g @polymorphism-tech/morph-spec
344
+ ```
345
+
346
+ 1. Open a new terminal (the installer adds npm to your PATH automatically)
347
+
348
+ ### Hook not triggering on SessionStart
349
+
350
+ Ensure `.claude/settings.local.json` is not gitignored in your project. The file must be present for Claude Code to load hooks. If it is missing, re-run `morph-spec setup-infra` or `morph-spec init --force`.
351
+
352
+ ---
353
+
354
+ ## Standards
355
+
356
+ The framework ships 82 registered standards across 11 categories, stored in `.morph/framework/standards/STANDARDS.json`. Standards are enforced via path-scoped rules installed to `.claude/rules/` during `morph-spec init`.
357
+
358
+ ---
359
+
360
+ ## License
361
+
362
+ Proprietary — see [LICENSE](./LICENSE).
363
+
364
+ Code generated by morph-spec (contracts, templates, implementation output) belongs to you.
365
+
366
+ ---
367
+
367
368
  *morph-spec v4.22.1 by [Polymorphism Tech](https://polymorphism.tech)*