@polymorphism-tech/morph-spec 7.0.0 → 7.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/README.md +368 -368
  2. package/claude-plugin.json +14 -14
  3. package/docs/CHEATSHEET.md +199 -199
  4. package/docs/QUICKSTART.md +200 -200
  5. package/framework/CLAUDE.md +1 -1
  6. package/framework/MORPH.md +4 -1
  7. package/framework/agents.json +132 -127
  8. package/framework/rubrics/backend.json +41 -36
  9. package/framework/rules/ai-agents-standards.md +45 -15
  10. package/framework/rules/neon-standards.md +25 -26
  11. package/framework/skills/core/morph-brainstorming/SKILL.md +1 -1
  12. package/framework/skills/core/morph-plan/SKILL.md +3 -1
  13. package/framework/skills/core/morph-stack-scan/SKILL.md +3 -3
  14. package/framework/standards/STANDARDS.json +1729 -1133
  15. package/framework/standards/ai-agents/agent-session.md +160 -0
  16. package/framework/standards/ai-agents/batching.md +193 -0
  17. package/framework/standards/ai-agents/context-providers.md +188 -0
  18. package/framework/standards/ai-agents/mcp-server.md +250 -0
  19. package/framework/standards/ai-agents/mcp-tools.md +197 -0
  20. package/framework/standards/ai-agents/middleware-patterns.md +207 -0
  21. package/framework/standards/ai-agents/modalities-image-gen.md +173 -0
  22. package/framework/standards/ai-agents/modalities-speech-to-text.md +171 -0
  23. package/framework/standards/ai-agents/modalities-text-to-speech.md +181 -0
  24. package/framework/standards/ai-agents/modalities-vision.md +201 -0
  25. package/framework/standards/ai-agents/multi-agent-patterns.md +155 -0
  26. package/framework/standards/ai-agents/production.md +114 -258
  27. package/framework/standards/ai-agents/prompts-in-db.md +214 -0
  28. package/framework/standards/ai-agents/providers/model-registry.md +158 -0
  29. package/framework/standards/ai-agents/rag-custom-pgvector.md +243 -0
  30. package/framework/standards/ai-agents/service-tier-flex.md +135 -0
  31. package/framework/standards/ai-agents/setup.md +142 -316
  32. package/framework/standards/ai-agents/structured-output.md +249 -0
  33. package/framework/standards/ai-agents/sweet-spot.md +109 -0
  34. package/framework/standards/ai-agents/workflows.md +114 -284
  35. package/framework/standards/architecture/vertical-slice/vertical-slice.md +439 -429
  36. package/framework/standards/backend/api/validation.md +92 -88
  37. package/framework/standards/backend/database/postgresql/database.md +336 -332
  38. package/framework/standards/backend/database/vector-search-rag.md +599 -541
  39. package/framework/standards/backend/dotnet/fluent-validation-vsa.md +4 -0
  40. package/framework/standards/backend/dotnet/result-pattern.md +4 -0
  41. package/framework/standards/backend/dotnet/scalar-ui.md +176 -172
  42. package/framework/standards/backend/dotnet/scrutor.md +4 -0
  43. package/framework/standards/backend/dotnet/vsa-handler-patterns.md +310 -274
  44. package/framework/standards/backend/integrations/asaas/asaas-api.md +260 -216
  45. package/framework/standards/backend/integrations/hangfire/hangfire-jobs.md +354 -350
  46. package/framework/standards/backend/integrations/neon-auth/neon-auth.md +30 -19
  47. package/framework/standards/backend/integrations/resend/resend-email.md +400 -385
  48. package/framework/standards/data/nosql/cache/redis.md +106 -97
  49. package/framework/standards/data/nosql/cosmos-db.md +127 -118
  50. package/framework/standards/data/vector-search/rag-chunking.md +113 -104
  51. package/framework/standards/frontend/design-system/ai-image-generation.md +4 -0
  52. package/framework/standards/frontend/design-system/animations.md +164 -160
  53. package/framework/standards/frontend/design-system/naming.md +68 -64
  54. package/framework/standards/frontend/gsap/gsap-core.md +14 -8
  55. package/framework/standards/frontend/gsap/gsap-plugins.md +26 -21
  56. package/framework/standards/frontend/gsap/gsap-scrolltrigger.md +9 -7
  57. package/framework/standards/frontend/nextjs/app-router.md +127 -123
  58. package/framework/standards/frontend/nextjs/components.md +136 -132
  59. package/framework/standards/frontend/nextjs/data-fetching.md +130 -126
  60. package/framework/standards/frontend/nextjs/forms.md +134 -128
  61. package/framework/standards/frontend/nextjs/motion-patterns.md +328 -322
  62. package/framework/standards/frontend/nextjs/naming-conventions.md +71 -67
  63. package/framework/standards/frontend/nextjs/nextjs-patterns.md +229 -225
  64. package/framework/standards/frontend/nextjs/project-structure.md +106 -102
  65. package/framework/standards/frontend/nextjs/state-management.md +76 -72
  66. package/framework/standards/frontend/nextjs/testing.md +115 -111
  67. package/framework/standards/infrastructure/docker/easypanel-deploy.md +196 -192
  68. package/framework/standards/infrastructure/neon/neon-pgrag.md +6 -2
  69. package/framework/standards/infrastructure/neon/neon-pgvector.md +4 -0
  70. package/framework/standards/infrastructure/neon/neon-setup.md +5 -1
  71. package/framework/standards/integration/mcp/mcp-tools.md +471 -462
  72. package/framework/templates/CLAUDE.md.core.template +1 -1
  73. package/framework/templates/REGISTRY.json +1745 -1239
  74. package/framework/templates/code/dotnet/ai-agents/AgentBootstrap.cs.template +39 -0
  75. package/framework/templates/code/dotnet/ai-agents/EmbeddingService.cs.template +68 -0
  76. package/framework/templates/code/dotnet/ai-agents/ModelRegistry.cs.template +117 -0
  77. package/framework/templates/code/dotnet/ai-agents/PromptRepository.cs.template +95 -0
  78. package/framework/templates/code/dotnet/ai-agents/ResilientToolMiddleware.cs.template +61 -0
  79. package/framework/templates/code/dotnet/ai-agents/VectorSearchTool.cs.template +107 -0
  80. package/framework/templates/code/dotnet/ai-agents/model-registry.json.template +58 -0
  81. package/framework/templates/code/dotnet/backend/repository.cs +3 -10
  82. package/framework/templates/code/sql/ai-agents/agent-prompts-migration.sql.template +58 -0
  83. package/framework/templates/code/sql/ai-agents/pgvector-embeddings-migration.sql.template +91 -0
  84. package/package.json +89 -83
  85. package/src/core/templates/template-registry.js +289 -256
  86. package/src/lib/generators/context-generator.js +516 -518
  87. package/src/lib/generators/scaffold-generator.js +23 -26
  88. package/framework/standards/infrastructure/neon/neon-semantic-kernel.md +0 -310
  89. package/framework/templates/integrations/semantic-kernel-neon.cs +0 -125
package/README.md CHANGED
@@ -1,368 +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/ # 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
-
368
- *morph-spec v4.22.1 by [Polymorphism Tech](https://polymorphism.tech)*
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:** 7.1.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
+
368
+ *morph-spec v7.1.1 by [Polymorphism Tech](https://polymorphism.tech)*