@polymorphism-tech/morph-spec 4.8.1 → 4.8.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/claude-plugin.json +1 -1
- package/docs/CHEATSHEET.md +1 -1
- package/docs/QUICKSTART.md +1 -1
- package/framework/hooks/dev/guard-version-numbers.js +1 -1
- package/framework/skills/level-1-workflows/phase-clarify/SKILL.md +1 -1
- package/framework/skills/level-1-workflows/phase-codebase-analysis/SKILL.md +1 -1
- package/framework/skills/level-1-workflows/phase-design/SKILL.md +1 -1
- package/framework/skills/level-1-workflows/phase-implement/SKILL.md +1 -1
- package/framework/skills/level-1-workflows/phase-setup/SKILL.md +1 -1
- package/framework/skills/level-1-workflows/phase-tasks/SKILL.md +1 -1
- package/framework/skills/level-1-workflows/phase-uiux/SKILL.md +1 -1
- package/package.json +4 -4
- package/.morph/analytics/threads-log.jsonl +0 -54
- package/.morph/state.json +0 -198
- package/docs/ARCHITECTURE.md +0 -328
- package/docs/COMMAND-FLOWS.md +0 -398
- package/docs/plans/2026-02-22-claude-docs-morph-alignment-analysis.md +0 -514
- package/docs/plans/2026-02-22-claude-settings.md +0 -517
- package/docs/plans/2026-02-22-morph-cc-alignment-impl.md +0 -730
- package/docs/plans/2026-02-22-morph-spec-next.md +0 -480
- package/docs/plans/2026-02-22-native-alignment-design.md +0 -201
- package/docs/plans/2026-02-22-native-alignment-impl.md +0 -927
- package/docs/plans/2026-02-22-native-enrichment-design.md +0 -246
- package/docs/plans/2026-02-22-native-enrichment.md +0 -737
- package/docs/plans/2026-02-23-ddd-architecture-refactor.md +0 -1155
- package/docs/plans/2026-02-23-ddd-nextsteps.md +0 -684
- package/docs/plans/2026-02-23-infra-architect-refactor.md +0 -439
- package/docs/plans/2026-02-23-nextjs-code-review-design.md +0 -157
- package/docs/plans/2026-02-23-nextjs-code-review-impl.md +0 -1256
- package/docs/plans/2026-02-23-nextjs-standards-design.md +0 -150
- package/docs/plans/2026-02-23-nextjs-standards-impl.md +0 -1848
- package/docs/plans/2026-02-24-cli-radical-simplification.md +0 -592
- package/docs/plans/2026-02-24-framework-failure-points.md +0 -125
- package/docs/plans/2026-02-24-morph-init-design.md +0 -337
- package/docs/plans/2026-02-24-morph-init-impl.md +0 -1269
- package/docs/plans/2026-02-24-tutorial-command-design.md +0 -71
- package/docs/plans/2026-02-24-tutorial-command.md +0 -298
- package/scripts/bump-version.js +0 -248
- package/scripts/generate-refs.js +0 -336
- package/scripts/generate-standards-registry.js +0 -44
- package/scripts/install-dev-hooks.js +0 -138
- package/scripts/scan-nextjs.mjs +0 -169
- package/scripts/validate-real.mjs +0 -255
package/docs/ARCHITECTURE.md
DELETED
|
@@ -1,328 +0,0 @@
|
|
|
1
|
-
# morph-spec Architecture
|
|
2
|
-
|
|
3
|
-
> System design reference for morph-spec v4.8.1
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## Overview
|
|
8
|
-
|
|
9
|
-
morph-spec is a CLI tool that scaffolds a spec-driven development workflow on top of Claude Code. It installs a structured set of files into `.morph/` and `.claude/`, then lets the AI orchestrate feature development through well-defined phases with approval gates.
|
|
10
|
-
|
|
11
|
-
The framework has three main concerns:
|
|
12
|
-
|
|
13
|
-
1. **State** — tracking features, phases, and outputs in `.morph/state.json`
|
|
14
|
-
2. **Agents** — 38 specialized agents organized in 4 tiers, installed as native Claude Code subagents
|
|
15
|
-
3. **Workflow** — 8 phases from proposal through implementation, enforced via hooks and guards
|
|
16
|
-
|
|
17
|
-
---
|
|
18
|
-
|
|
19
|
-
## Agent hierarchy
|
|
20
|
-
|
|
21
|
-
```
|
|
22
|
-
Tier 1 — Orchestrators (3)
|
|
23
|
-
standards-architect always active — Chief Architect, enforces standards
|
|
24
|
-
ai-system-architect on-demand — multi-agent / AI system design
|
|
25
|
-
po-pm-advisor on-demand — requirements, business value
|
|
26
|
-
|
|
27
|
-
Tier 2 — Domain Leaders (4)
|
|
28
|
-
dotnet-senior always active — Backend Squad lead (skipped for non-.NET)
|
|
29
|
-
infra-architect always active — Infrastructure Squad Leader (cloud-agnostic)
|
|
30
|
-
domain-architect on-demand — DDD analysis and bounded context design
|
|
31
|
-
ui-designer on-demand — UI/UX Squad lead
|
|
32
|
-
|
|
33
|
-
Tier 3 — Specialists (26)
|
|
34
|
-
Backend (10) ef-modeler, event-architect, api-designer, nosql-cache-expert,
|
|
35
|
-
hangfire-orchestrator, ms-agent-expert,
|
|
36
|
-
asaas-financial, clerk-auth, resend-email, ddd-expert
|
|
37
|
-
Frontend (3) blazor-builder, nextjs-expert, css-specialist
|
|
38
|
-
Infrastructure (6) azure-architect, bicep-architect, devops-engineer,
|
|
39
|
-
container-specialist, observability-expert, azure-identity
|
|
40
|
-
Quality/Cross (7) testing-specialist, code-analyzer, troubleshooting-expert,
|
|
41
|
-
load-testing-expert, documentation-specialist,
|
|
42
|
-
migration-specialist, integration-specialist
|
|
43
|
-
|
|
44
|
-
Tier 4 — Validators (5)
|
|
45
|
-
security-expert SQL injection, XSS, hardcoded secrets
|
|
46
|
-
architecture-expert DbContext, async/await, DI order
|
|
47
|
-
packages-validator NuGet conflicts, .NET 10 compatibility
|
|
48
|
-
design-system-validator CSS palette, spacing, typography
|
|
49
|
-
blazor-concurrency-validator DbContext lifecycle, async void, JSInterop
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
### Agent installation
|
|
53
|
-
|
|
54
|
-
Tier 1–2 agents are installed to `.claude/agents/morph-{id}.md` with YAML frontmatter:
|
|
55
|
-
|
|
56
|
-
```yaml
|
|
57
|
-
---
|
|
58
|
-
name: morph-standards-architect
|
|
59
|
-
description: Chief Architect...
|
|
60
|
-
model: sonnet
|
|
61
|
-
---
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
Tier 3 domain agents are installed to `.claude/agents/morph-domain-{name}.md` with:
|
|
65
|
-
|
|
66
|
-
```yaml
|
|
67
|
-
---
|
|
68
|
-
model: sonnet
|
|
69
|
-
memory: project
|
|
70
|
-
maxTurns: 20
|
|
71
|
-
---
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
Both sets are updated by `morph-spec update`.
|
|
75
|
-
|
|
76
|
-
### Agent detection
|
|
77
|
-
|
|
78
|
-
When a feature is created, Claude reads `agents.json` directly and matches keywords in the feature description against each agent's keyword list. Matched agents are stored in `state.json` under the feature's `activeAgents` array. The active agent set determines which standards are loaded and which validators run.
|
|
79
|
-
|
|
80
|
-
> Note: Some skill files reference `npx morph-spec detect-agents --json` — this is not a real CLI command. Agent detection is performed by Claude reading `agents.json` inline, not by a subprocess.
|
|
81
|
-
|
|
82
|
-
---
|
|
83
|
-
|
|
84
|
-
## Phase pipeline
|
|
85
|
-
|
|
86
|
-
```
|
|
87
|
-
0-proposal → 1-setup → [1.5-uiux] → 2-design → 3-clarify → 4-tasks → 5-implement → [6-sync]
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
| Phase | ID | Optional | Approval gate | Output directory |
|
|
91
|
-
|-------|-----|----------|--------------|-----------------|
|
|
92
|
-
| Proposal | `proposal` | No | Yes | `0-proposal/` |
|
|
93
|
-
| Setup | `setup` | No | No | — |
|
|
94
|
-
| UI/UX | `uiux` | Yes | Yes | `2-ui/` |
|
|
95
|
-
| Design | `design` | No | Yes | `1-design/` |
|
|
96
|
-
| Clarify | `clarify` | No | No | `1-design/` (updates) |
|
|
97
|
-
| Tasks | `tasks` | No | Yes | `3-tasks/` |
|
|
98
|
-
| Implement | `implement` | No | No | `4-implement/` |
|
|
99
|
-
| Sync | `sync` | Yes | No | `.morph/context/` |
|
|
100
|
-
|
|
101
|
-
Phase transitions are controlled by the state machine in `src/lib/state/`. Advancing to a phase with an approval gate is blocked until the gate is explicitly passed. `protect-spec-files.js` (hook) guards spec/contracts from edits after the design gate is passed.
|
|
102
|
-
|
|
103
|
-
Canonical phase definitions live in `framework/phases.json`.
|
|
104
|
-
|
|
105
|
-
---
|
|
106
|
-
|
|
107
|
-
## File structure
|
|
108
|
-
|
|
109
|
-
### Framework source (this repo)
|
|
110
|
-
|
|
111
|
-
```
|
|
112
|
-
framework/
|
|
113
|
-
├── agents.json # 38 agents definition (v3.2.0)
|
|
114
|
-
├── phases.json # 8 phase definitions
|
|
115
|
-
├── CLAUDE_runtime.md # copied to .claude/CLAUDE.md on init
|
|
116
|
-
├── agents/ # tier 1-2 agent markdown files
|
|
117
|
-
├── hooks/
|
|
118
|
-
│ ├── claude-code/ # 10 Claude Code hook scripts
|
|
119
|
-
│ │ └── shared/ # state-reader, phase-utils, hook-response, stdin-reader
|
|
120
|
-
│ └── git/ # pre-commit, commit-msg, pre-push
|
|
121
|
-
├── rules/ # 6 rule files (copied to .claude/rules/)
|
|
122
|
-
├── skills/
|
|
123
|
-
│ ├── README.md
|
|
124
|
-
│ ├── level-0-meta/ # 7 meta skills (brainstorming, code-review, etc.)
|
|
125
|
-
│ │ └── {skill}/
|
|
126
|
-
│ │ ├── SKILL.md # skill content
|
|
127
|
-
│ │ ├── scripts/ # optional helper scripts
|
|
128
|
-
│ │ └── references/ # optional reference materials
|
|
129
|
-
│ └── level-1-workflows/ # 8 workflow skills (phase-proposal, phase-design, etc.)
|
|
130
|
-
│ └── {skill}/
|
|
131
|
-
│ └── SKILL.md
|
|
132
|
-
├── standards/ # 82 standards, 11 categories
|
|
133
|
-
│ ├── STANDARDS.json # registry (regenerate: node scripts/generate-standards-registry.js)
|
|
134
|
-
│ ├── core/
|
|
135
|
-
│ ├── backend/
|
|
136
|
-
│ ├── frontend/
|
|
137
|
-
│ ├── infrastructure/
|
|
138
|
-
│ └── integration/
|
|
139
|
-
├── templates/ # Handlebars v2.0 code and IaC templates
|
|
140
|
-
│ ├── infrastructure/ # Bicep, Docker, GitHub Actions
|
|
141
|
-
│ └── ...
|
|
142
|
-
└── workflows/
|
|
143
|
-
└── configs/ # 10 workflow configs (express, spec-only, zero-touch, fusion, ...)
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
### Installed into a project (after init)
|
|
147
|
-
|
|
148
|
-
```
|
|
149
|
-
.morph/
|
|
150
|
-
├── config/config.json # editable project config
|
|
151
|
-
├── framework/ # READ-ONLY copy from package
|
|
152
|
-
│ ├── agents.json
|
|
153
|
-
│ ├── standards/
|
|
154
|
-
│ └── templates/
|
|
155
|
-
├── context/ # editable project context
|
|
156
|
-
│ ├── README.md # loaded at every SessionStart
|
|
157
|
-
│ └── standards.md
|
|
158
|
-
├── features/{feature}/ # feature outputs
|
|
159
|
-
│ ├── 0-proposal/
|
|
160
|
-
│ ├── 1-design/
|
|
161
|
-
│ ├── 2-ui/
|
|
162
|
-
│ ├── 3-tasks/
|
|
163
|
-
│ └── 4-implement/
|
|
164
|
-
├── checkpoints/
|
|
165
|
-
├── logs/tool-failures.log
|
|
166
|
-
└── state.json # READ-ONLY — gitignored, managed by CLI only
|
|
167
|
-
|
|
168
|
-
.claude/
|
|
169
|
-
├── CLAUDE.md # runtime instructions
|
|
170
|
-
├── commands/ # slash command .md files
|
|
171
|
-
├── skills/ # flat install of framework/skills/
|
|
172
|
-
│ └── {skill-name}/
|
|
173
|
-
│ └── SKILL.md
|
|
174
|
-
├── agents/ # native subagents
|
|
175
|
-
│ ├── morph-{id}.md # tier 1-2 (from framework/agents/)
|
|
176
|
-
│ └── morph-domain-{name}.md # tier 3 (from framework/skills/level-2-domains/)
|
|
177
|
-
├── rules/ # path-scoped rules (from framework/rules/)
|
|
178
|
-
│ ├── morph-workflow.md # always active (no paths: filter)
|
|
179
|
-
│ ├── csharp-standards.md # paths: **/*.cs, **/*.csproj
|
|
180
|
-
│ ├── frontend-standards.md # paths: **/*.razor, **/*.css, **/*.scss
|
|
181
|
-
│ ├── nextjs-standards.md # paths: **/*.tsx, **/*.ts
|
|
182
|
-
│ ├── testing-standards.md # paths: tests/**, **/*.test.*, **/*Tests.cs
|
|
183
|
-
│ └── infrastructure-standards.md # paths: **/*.bicep, **/Dockerfile, ...
|
|
184
|
-
└── settings.local.json # hooks, permissions.deny, env vars
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
---
|
|
188
|
-
|
|
189
|
-
## Skills system
|
|
190
|
-
|
|
191
|
-
Skills are Markdown files that provide Claude Code with domain knowledge and procedures. They are invoked via the `Skill` tool inside Claude Code.
|
|
192
|
-
|
|
193
|
-
### Directory structure
|
|
194
|
-
|
|
195
|
-
Each skill lives in its own directory under `framework/skills/{level}/{skill-name}/`:
|
|
196
|
-
|
|
197
|
-
```
|
|
198
|
-
{skill-name}/
|
|
199
|
-
├── SKILL.md # required — main content
|
|
200
|
-
├── scripts/ # optional — helper scripts (.mjs)
|
|
201
|
-
└── references/ # optional — reference documents
|
|
202
|
-
```
|
|
203
|
-
|
|
204
|
-
### Levels
|
|
205
|
-
|
|
206
|
-
| Level | Directory | Count | Purpose |
|
|
207
|
-
|-------|-----------|-------|---------|
|
|
208
|
-
| 0 | `level-0-meta/` | 7 | Cross-cutting: brainstorming, code review, verification, tool usage |
|
|
209
|
-
| 1 | `level-1-workflows/` | 8 | Phase workflows: phase-proposal, phase-setup, phase-uiux, phase-design, phase-clarify, phase-tasks, phase-implement, phase-sync |
|
|
210
|
-
|
|
211
|
-
### Installation
|
|
212
|
-
|
|
213
|
-
`installSkills()` in `src/utils/skills-installer.js` flattens all skills to `.claude/skills/{name}/SKILL.md`. Skills become available as `/{name}` slash commands in Claude Code.
|
|
214
|
-
|
|
215
|
-
---
|
|
216
|
-
|
|
217
|
-
## Hooks system
|
|
218
|
-
|
|
219
|
-
10 Claude Code hooks are configured in `.claude/settings.local.json`. All hooks fail-open (catch + exit 0) to prevent blocking Claude Code on errors.
|
|
220
|
-
|
|
221
|
-
| Event | Hook | Function |
|
|
222
|
-
|-------|------|----------|
|
|
223
|
-
| `SessionStart` | `inject-morph-context.js` | Injects active feature `1-design/spec.md` (configurable char limit) into context |
|
|
224
|
-
| `UserPromptSubmit` | `enrich-prompt.js` | Scans prompt for feature names/intent; injects phase hints and approval syntax |
|
|
225
|
-
| `PreToolUse` (Write\|Edit) | `protect-spec-files.js` | Blocks edits to spec/contracts after design gate is approved |
|
|
226
|
-
| `PreToolUse` (Write\|Edit) | `enforce-phase-writes.js` | Validates write targets are in the correct phase subfolder |
|
|
227
|
-
| `PreToolUse` (Bash) | Prompt-type inline guard (`type: "prompt"`) | Detects destructive shell patterns; no subprocess |
|
|
228
|
-
| `PostToolUse` (Bash) | `dispatch.js` | Auto-checkpoint via `morph-spec checkpoint-save` every 3 completed tasks |
|
|
229
|
-
| `PostToolUseFailure` | `handle-tool-failure.js` | Appends failure details to `.morph/logs/tool-failures.log` |
|
|
230
|
-
| `Stop` | `validate-completion.js` | Warns about incomplete tasks, missing outputs, or pending approval gates |
|
|
231
|
-
| `PreCompact` | `save-morph-context.js` | Snapshots state to `.morph/memory/pre-compact-{ts}.json` |
|
|
232
|
-
| `Notification` | `approval-reminder.js` | Reminds about pending approval gates when Claude is idle |
|
|
233
|
-
|
|
234
|
-
> Note: `.morph/state.json` and `.morph/framework/**` are protected via native `permissions.deny` in `settings.local.json` — not a hook.
|
|
235
|
-
|
|
236
|
-
Shared utilities live in `framework/hooks/claude-code/shared/`:
|
|
237
|
-
- `state-reader.js` — reads `.morph/state.json` without subprocess
|
|
238
|
-
- `phase-utils.js` — phase validation helpers
|
|
239
|
-
- `hook-response.js` — standardized hook response formatting
|
|
240
|
-
- `stdin-reader.js` — reads hook event data from stdin
|
|
241
|
-
|
|
242
|
-
Git hooks (`framework/hooks/git/`): `pre-commit`, `commit-msg` (Conventional Commits), `pre-push` (runs tests).
|
|
243
|
-
|
|
244
|
-
### Protected files
|
|
245
|
-
|
|
246
|
-
`permissions.deny` in `settings.local.json` blocks direct edits:
|
|
247
|
-
|
|
248
|
-
```json
|
|
249
|
-
"permissions": {
|
|
250
|
-
"deny": [
|
|
251
|
-
"Write(.morph/state.json)",
|
|
252
|
-
"Edit(.morph/state.json)",
|
|
253
|
-
"Write(.morph/framework/**)",
|
|
254
|
-
"Edit(.morph/framework/**)"
|
|
255
|
-
]
|
|
256
|
-
}
|
|
257
|
-
```
|
|
258
|
-
|
|
259
|
-
---
|
|
260
|
-
|
|
261
|
-
## State machine
|
|
262
|
-
|
|
263
|
-
`.morph/state.json` tracks the state of all features. It is managed exclusively by the CLI — never edited directly.
|
|
264
|
-
|
|
265
|
-
```json
|
|
266
|
-
{
|
|
267
|
-
"version": "4.0.0",
|
|
268
|
-
"features": {
|
|
269
|
-
"my-feature": {
|
|
270
|
-
"phase": "design",
|
|
271
|
-
"status": "in_progress",
|
|
272
|
-
"activeAgents": ["dotnet-senior", "ef-modeler", "testing-specialist"],
|
|
273
|
-
"approvals": {
|
|
274
|
-
"proposal": true,
|
|
275
|
-
"design": false,
|
|
276
|
-
"tasks": false
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
```
|
|
282
|
-
|
|
283
|
-
State auto-migrates from v3.0.0 to v4.0.0 on first CLI access.
|
|
284
|
-
|
|
285
|
-
Feature outputs (spec.md, contracts.cs, tasks.md, etc.) are tracked by scanning the filesystem at runtime — not stored in state. This keeps state lean and avoids the circular tracking bug of earlier versions.
|
|
286
|
-
|
|
287
|
-
---
|
|
288
|
-
|
|
289
|
-
## Standards registry
|
|
290
|
-
|
|
291
|
-
82 standards across 11 categories are registered in `framework/standards/STANDARDS.json`. Each entry has an `id`, `name`, `path`, `scope`, `layer`, and `keywords`.
|
|
292
|
-
|
|
293
|
-
Regenerate the registry after adding standards:
|
|
294
|
-
|
|
295
|
-
```bash
|
|
296
|
-
node scripts/generate-standards-registry.js
|
|
297
|
-
```
|
|
298
|
-
|
|
299
|
-
---
|
|
300
|
-
|
|
301
|
-
## Workflow configs
|
|
302
|
-
|
|
303
|
-
`framework/workflows/configs/` contains 10 workflow configurations that customize how the phase pipeline runs:
|
|
304
|
-
|
|
305
|
-
| Config | Description |
|
|
306
|
-
|--------|-------------|
|
|
307
|
-
| `default` | Full pipeline with all phases |
|
|
308
|
-
| `express` | Condensed pipeline for small features |
|
|
309
|
-
| `spec-only` | Proposal through tasks, no implementation |
|
|
310
|
-
| `zero-touch` | Fully automated (maximum trust level) |
|
|
311
|
-
| `fusion` | Combines setup + design into single phase |
|
|
312
|
-
| ... | + 5 more |
|
|
313
|
-
|
|
314
|
-
Trust levels (`low`, `medium`, `high`, `maximum`) control how many approval gates are enforced automatically vs manually.
|
|
315
|
-
|
|
316
|
-
---
|
|
317
|
-
|
|
318
|
-
## CLI internals
|
|
319
|
-
|
|
320
|
-
- **Entry point:** `bin/morph-spec.js` — Commander.js, ~20 framework-internal commands + 3 user commands (`init`, `update`, `doctor`)
|
|
321
|
-
- **Commands:** `src/commands/` — organized into subdirectories by domain (project, state, tasks, validation, templates, trust, mcp)
|
|
322
|
-
- **Libraries:** `src/lib/` — state, validators, templates, agents, detection
|
|
323
|
-
- **Templates engine:** Handlebars v2.0 with helpers (pascalCase, camelCase, snakeCase, kebabCase, pluralize)
|
|
324
|
-
- **Test suite:** `test/` — Node.js built-in test runner, 670+ tests
|
|
325
|
-
|
|
326
|
-
---
|
|
327
|
-
|
|
328
|
-
*morph-spec v4.8.1 by Polymorphism Tech*
|