@polymorphism-tech/morph-spec 7.1.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.
- package/README.md +2 -2
- package/claude-plugin.json +14 -14
- package/docs/CHEATSHEET.md +199 -199
- package/docs/QUICKSTART.md +200 -200
- package/framework/CLAUDE.md +1 -1
- package/framework/MORPH.md +4 -1
- package/framework/agents.json +1 -1
- package/framework/skills/core/morph-brainstorming/SKILL.md +1 -1
- package/framework/skills/core/morph-plan/SKILL.md +3 -1
- package/framework/skills/core/morph-stack-scan/SKILL.md +3 -3
- package/framework/standards/architecture/vertical-slice/vertical-slice.md +7 -1
- package/framework/standards/backend/dotnet/vsa-handler-patterns.md +32 -0
- package/framework/templates/CLAUDE.md.core.template +1 -1
- package/framework/templates/code/dotnet/backend/repository.cs +3 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
> Spec-driven development framework for multi-stack projects. Turns feature requests into implementation-ready code through structured, AI-orchestrated phases.
|
|
4
4
|
|
|
5
5
|
**Package:** `@polymorphism-tech/morph-spec`
|
|
6
|
-
**Version:**
|
|
6
|
+
**Version:** 7.1.1
|
|
7
7
|
**Requires:** Node.js 22+, Claude Code
|
|
8
8
|
|
|
9
9
|
---
|
|
@@ -365,4 +365,4 @@ Code generated by morph-spec (contracts, templates, implementation output) belon
|
|
|
365
365
|
|
|
366
366
|
---
|
|
367
367
|
|
|
368
|
-
*morph-spec
|
|
368
|
+
*morph-spec v7.1.1 by [Polymorphism Tech](https://polymorphism.tech)*
|
package/claude-plugin.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "morph-spec",
|
|
3
|
-
"version": "
|
|
4
|
-
"displayName": "MORPH-SPEC Framework",
|
|
5
|
-
"description": "Spec-driven development with 38 agents and 8-phase workflow for .NET/Blazor/Next.js/Azure",
|
|
6
|
-
"publisher": "polymorphism-tech",
|
|
7
|
-
"skills": {
|
|
8
|
-
"directory": "framework/skills",
|
|
9
|
-
"namespace": "morph-spec"
|
|
10
|
-
},
|
|
11
|
-
"hooks": {
|
|
12
|
-
"directory": "framework/hooks/claude-code"
|
|
13
|
-
}
|
|
14
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "morph-spec",
|
|
3
|
+
"version": "7.1.1",
|
|
4
|
+
"displayName": "MORPH-SPEC Framework",
|
|
5
|
+
"description": "Spec-driven development with 38 agents and 8-phase workflow for .NET/Blazor/Next.js/Azure",
|
|
6
|
+
"publisher": "polymorphism-tech",
|
|
7
|
+
"skills": {
|
|
8
|
+
"directory": "framework/skills",
|
|
9
|
+
"namespace": "morph-spec"
|
|
10
|
+
},
|
|
11
|
+
"hooks": {
|
|
12
|
+
"directory": "framework/hooks/claude-code"
|
|
13
|
+
}
|
|
14
|
+
}
|
package/docs/CHEATSHEET.md
CHANGED
|
@@ -1,199 +1,199 @@
|
|
|
1
|
-
# morph-spec Cheat Sheet
|
|
2
|
-
|
|
3
|
-
## Setup
|
|
4
|
-
|
|
5
|
-
```bash
|
|
6
|
-
npm install -g @polymorphism-tech/morph-spec # install globally
|
|
7
|
-
morph-spec init # initialize project
|
|
8
|
-
morph-spec init --wizard # interactive wizard
|
|
9
|
-
morph-spec init --force # overwrite existing
|
|
10
|
-
morph-spec update # sync framework files
|
|
11
|
-
morph-spec doctor # health check
|
|
12
|
-
morph-spec --version
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
---
|
|
16
|
-
|
|
17
|
-
## Phase workflow
|
|
18
|
-
|
|
19
|
-
```
|
|
20
|
-
proposal → [uiux] → design → plan → tasks → implement → [sync]
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
Phases in brackets are optional.
|
|
24
|
-
|
|
25
|
-
| Phase | Directory | Output files | Gate |
|
|
26
|
-
|-------|-----------|--------------|------|
|
|
27
|
-
| proposal | `0-proposal/` | `proposal.md` | ✅ Approval |
|
|
28
|
-
| uiux *(optional)* | `1-design/` | `design-system.md`, `mockups.md`, `components.md`, `flows.md` | ✅ Approval |
|
|
29
|
-
| design | `2-design/` | `spec.md`, `contracts.cs`, `decisions.md` | ✅ Approval |
|
|
30
|
-
| plan | `3-plan/` | `plan.md` | ✅ Approval |
|
|
31
|
-
| tasks | `4-tasks/` | `tasks.md` | ✅ Approval |
|
|
32
|
-
| implement | `3-implement/` | code + `recap.md` | — |
|
|
33
|
-
| sync *(optional)* | — | standards updated | — |
|
|
34
|
-
|
|
35
|
-
---
|
|
36
|
-
|
|
37
|
-
## Slash commands (Claude Code)
|
|
38
|
-
|
|
39
|
-
| Command | Description |
|
|
40
|
-
|---------|-------------|
|
|
41
|
-
| `/morph-proposal {feature}` | Full spec pipeline — phases 0–4 with approval gates |
|
|
42
|
-
| `/morph-apply {feature}` | Implement approved feature — phase 5 |
|
|
43
|
-
| `/morph-status` | Project-wide feature status dashboard |
|
|
44
|
-
| `/morph-preflight` | Pre-implementation validation (7 checks) |
|
|
45
|
-
|
|
46
|
-
---
|
|
47
|
-
|
|
48
|
-
## CLI — project management
|
|
49
|
-
|
|
50
|
-
```bash
|
|
51
|
-
morph-spec init [--force] [--skip-mcp]
|
|
52
|
-
morph-spec update [--templates] [--standards]
|
|
53
|
-
morph-spec doctor
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
---
|
|
57
|
-
|
|
58
|
-
## CLI — feature workflow
|
|
59
|
-
|
|
60
|
-
```bash
|
|
61
|
-
morph-spec state list # all features
|
|
62
|
-
morph-spec state get {feature} [--json] # feature detail
|
|
63
|
-
morph-spec state set {feature} {key} {value} # update property
|
|
64
|
-
morph-spec phase advance {feature} # advance to next phase
|
|
65
|
-
morph-spec status {feature} [--json] [--verbose]
|
|
66
|
-
morph-spec task done {feature} {task-id} # mark task complete
|
|
67
|
-
morph-spec task start {feature} {task-id} # start a task (dispatch gate)
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
---
|
|
71
|
-
|
|
72
|
-
## CLI — validation
|
|
73
|
-
|
|
74
|
-
```bash
|
|
75
|
-
morph-spec validate # all validators
|
|
76
|
-
morph-spec validate architecture
|
|
77
|
-
morph-spec validate packages
|
|
78
|
-
morph-spec validate contrast [--wcag-aaa]
|
|
79
|
-
morph-spec validate-feature {feature} [--phase {phase}] [--json]
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
---
|
|
83
|
-
|
|
84
|
-
## CLI — utilities
|
|
85
|
-
|
|
86
|
-
```bash
|
|
87
|
-
morph-spec generate recap {feature} # auto-generate recap.md
|
|
88
|
-
morph-spec template render {id} {output} {vars-json}
|
|
89
|
-
morph-spec trust status [feature]
|
|
90
|
-
morph-spec trust set {feature} {level} [reason] # level: manual|high|auto
|
|
91
|
-
morph-spec mcp setup [name] [--list] [--auto]
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
---
|
|
95
|
-
|
|
96
|
-
## State — mark-output
|
|
97
|
-
|
|
98
|
-
```bash
|
|
99
|
-
morph-spec state mark-output {feature} proposal
|
|
100
|
-
morph-spec state mark-output {feature} spec
|
|
101
|
-
morph-spec state mark-output {feature} contracts
|
|
102
|
-
morph-spec state mark-output {feature} decisions
|
|
103
|
-
morph-spec state mark-output {feature} tasks
|
|
104
|
-
morph-spec state mark-output {feature} recap
|
|
105
|
-
|
|
106
|
-
# UI outputs (camelCase or kebab-case both work)
|
|
107
|
-
morph-spec state mark-output {feature} uiDesignSystem
|
|
108
|
-
morph-spec state mark-output {feature} uiMockups
|
|
109
|
-
morph-spec state mark-output {feature} uiComponents
|
|
110
|
-
morph-spec state mark-output {feature} uiFlows
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
---
|
|
114
|
-
|
|
115
|
-
## State — agents
|
|
116
|
-
|
|
117
|
-
```bash
|
|
118
|
-
morph-spec state add-agent {feature} {agent-id}
|
|
119
|
-
morph-spec state remove-agent {feature} {agent-id}
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
---
|
|
123
|
-
|
|
124
|
-
## Checkpoints
|
|
125
|
-
|
|
126
|
-
```bash
|
|
127
|
-
morph-spec checkpoint-save {feature}
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
---
|
|
131
|
-
|
|
132
|
-
## Approvals
|
|
133
|
-
|
|
134
|
-
```bash
|
|
135
|
-
morph-spec approve {feature} {gate} # approve a gate
|
|
136
|
-
morph-spec approval-status {feature} # show gate status
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
---
|
|
140
|
-
|
|
141
|
-
## Directory structure
|
|
142
|
-
|
|
143
|
-
```
|
|
144
|
-
.morph/
|
|
145
|
-
├── config/
|
|
146
|
-
│ └── config.json # project config (editable)
|
|
147
|
-
├── framework/ # READ-ONLY
|
|
148
|
-
│ ├── agents.json # 22 agents, 4 tiers
|
|
149
|
-
│ ├── standards/ # 82 standards across 11 categories
|
|
150
|
-
│ └── templates/ # code and IaC templates
|
|
151
|
-
├── context/ # project context (editable)
|
|
152
|
-
│ ├── README.md
|
|
153
|
-
│ └── standards.md
|
|
154
|
-
├── features/
|
|
155
|
-
│ └── {feature}/
|
|
156
|
-
│ ├── 0-proposal/proposal.md
|
|
157
|
-
│ ├── 1-design/design-system.md, mockups.md, components.md, flows.md
|
|
158
|
-
│ ├── 2-design/spec.md, contracts.cs, decisions.md
|
|
159
|
-
│ ├── 3-tasks/tasks.md
|
|
160
|
-
│ └── 4-implement/recap.md
|
|
161
|
-
├── checkpoints/
|
|
162
|
-
├── logs/
|
|
163
|
-
└── state.json # READ-ONLY — CLI managed
|
|
164
|
-
|
|
165
|
-
.claude/
|
|
166
|
-
├── commands/ # slash commands
|
|
167
|
-
├── skills/ # framework skills (SKILL.md per dir)
|
|
168
|
-
├── agents/ # native subagents (22)
|
|
169
|
-
│ ├── morph-{id}.md # tier 1-2 agents
|
|
170
|
-
│ └── morph-domain-{name}.md # tier 3 domain agents
|
|
171
|
-
├── rules/ # path-scoped rules (6 files)
|
|
172
|
-
└── settings.local.json # hooks (10)
|
|
173
|
-
```
|
|
174
|
-
|
|
175
|
-
---
|
|
176
|
-
|
|
177
|
-
## Protected files
|
|
178
|
-
|
|
179
|
-
These files are never edited directly. Use CLI commands or `morph-spec update` instead:
|
|
180
|
-
|
|
181
|
-
| Path | Protected by |
|
|
182
|
-
|------|-------------|
|
|
183
|
-
| `.morph/state.json` | `permissions.deny` |
|
|
184
|
-
| `.morph/framework/**` | `permissions.deny` |
|
|
185
|
-
| Approved spec/contracts | `protect-spec-files.js` hook |
|
|
186
|
-
|
|
187
|
-
---
|
|
188
|
-
|
|
189
|
-
## Links
|
|
190
|
-
|
|
191
|
-
- [QUICKSTART.md](QUICKSTART.md) — step-by-step guide
|
|
192
|
-
- [ARCHITECTURE.md](ARCHITECTURE.md) — system design
|
|
193
|
-
- [CHANGELOG.md](../CHANGELOG.md) — release history
|
|
194
|
-
- [npm](https://www.npmjs.com/package/@polymorphism-tech/morph-spec)
|
|
195
|
-
- support@polymorphism.com.br
|
|
196
|
-
|
|
197
|
-
---
|
|
198
|
-
|
|
199
|
-
*morph-spec
|
|
1
|
+
# morph-spec Cheat Sheet
|
|
2
|
+
|
|
3
|
+
## Setup
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm install -g @polymorphism-tech/morph-spec # install globally
|
|
7
|
+
morph-spec init # initialize project
|
|
8
|
+
morph-spec init --wizard # interactive wizard
|
|
9
|
+
morph-spec init --force # overwrite existing
|
|
10
|
+
morph-spec update # sync framework files
|
|
11
|
+
morph-spec doctor # health check
|
|
12
|
+
morph-spec --version
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Phase workflow
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
proposal → [uiux] → design → plan → tasks → implement → [sync]
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Phases in brackets are optional.
|
|
24
|
+
|
|
25
|
+
| Phase | Directory | Output files | Gate |
|
|
26
|
+
|-------|-----------|--------------|------|
|
|
27
|
+
| proposal | `0-proposal/` | `proposal.md` | ✅ Approval |
|
|
28
|
+
| uiux *(optional)* | `1-design/` | `design-system.md`, `mockups.md`, `components.md`, `flows.md` | ✅ Approval |
|
|
29
|
+
| design | `2-design/` | `spec.md`, `contracts.cs`, `decisions.md` | ✅ Approval |
|
|
30
|
+
| plan | `3-plan/` | `plan.md` | ✅ Approval |
|
|
31
|
+
| tasks | `4-tasks/` | `tasks.md` | ✅ Approval |
|
|
32
|
+
| implement | `3-implement/` | code + `recap.md` | — |
|
|
33
|
+
| sync *(optional)* | — | standards updated | — |
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Slash commands (Claude Code)
|
|
38
|
+
|
|
39
|
+
| Command | Description |
|
|
40
|
+
|---------|-------------|
|
|
41
|
+
| `/morph-proposal {feature}` | Full spec pipeline — phases 0–4 with approval gates |
|
|
42
|
+
| `/morph-apply {feature}` | Implement approved feature — phase 5 |
|
|
43
|
+
| `/morph-status` | Project-wide feature status dashboard |
|
|
44
|
+
| `/morph-preflight` | Pre-implementation validation (7 checks) |
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## CLI — project management
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
morph-spec init [--force] [--skip-mcp]
|
|
52
|
+
morph-spec update [--templates] [--standards]
|
|
53
|
+
morph-spec doctor
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## CLI — feature workflow
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
morph-spec state list # all features
|
|
62
|
+
morph-spec state get {feature} [--json] # feature detail
|
|
63
|
+
morph-spec state set {feature} {key} {value} # update property
|
|
64
|
+
morph-spec phase advance {feature} # advance to next phase
|
|
65
|
+
morph-spec status {feature} [--json] [--verbose]
|
|
66
|
+
morph-spec task done {feature} {task-id} # mark task complete
|
|
67
|
+
morph-spec task start {feature} {task-id} # start a task (dispatch gate)
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## CLI — validation
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
morph-spec validate # all validators
|
|
76
|
+
morph-spec validate architecture
|
|
77
|
+
morph-spec validate packages
|
|
78
|
+
morph-spec validate contrast [--wcag-aaa]
|
|
79
|
+
morph-spec validate-feature {feature} [--phase {phase}] [--json]
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## CLI — utilities
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
morph-spec generate recap {feature} # auto-generate recap.md
|
|
88
|
+
morph-spec template render {id} {output} {vars-json}
|
|
89
|
+
morph-spec trust status [feature]
|
|
90
|
+
morph-spec trust set {feature} {level} [reason] # level: manual|high|auto
|
|
91
|
+
morph-spec mcp setup [name] [--list] [--auto]
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## State — mark-output
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
morph-spec state mark-output {feature} proposal
|
|
100
|
+
morph-spec state mark-output {feature} spec
|
|
101
|
+
morph-spec state mark-output {feature} contracts
|
|
102
|
+
morph-spec state mark-output {feature} decisions
|
|
103
|
+
morph-spec state mark-output {feature} tasks
|
|
104
|
+
morph-spec state mark-output {feature} recap
|
|
105
|
+
|
|
106
|
+
# UI outputs (camelCase or kebab-case both work)
|
|
107
|
+
morph-spec state mark-output {feature} uiDesignSystem
|
|
108
|
+
morph-spec state mark-output {feature} uiMockups
|
|
109
|
+
morph-spec state mark-output {feature} uiComponents
|
|
110
|
+
morph-spec state mark-output {feature} uiFlows
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## State — agents
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
morph-spec state add-agent {feature} {agent-id}
|
|
119
|
+
morph-spec state remove-agent {feature} {agent-id}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
## Checkpoints
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
morph-spec checkpoint-save {feature}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
## Approvals
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
morph-spec approve {feature} {gate} # approve a gate
|
|
136
|
+
morph-spec approval-status {feature} # show gate status
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## Directory structure
|
|
142
|
+
|
|
143
|
+
```
|
|
144
|
+
.morph/
|
|
145
|
+
├── config/
|
|
146
|
+
│ └── config.json # project config (editable)
|
|
147
|
+
├── framework/ # READ-ONLY
|
|
148
|
+
│ ├── agents.json # 22 agents, 4 tiers
|
|
149
|
+
│ ├── standards/ # 82 standards across 11 categories
|
|
150
|
+
│ └── templates/ # code and IaC templates
|
|
151
|
+
├── context/ # project context (editable)
|
|
152
|
+
│ ├── README.md
|
|
153
|
+
│ └── standards.md
|
|
154
|
+
├── features/
|
|
155
|
+
│ └── {feature}/
|
|
156
|
+
│ ├── 0-proposal/proposal.md
|
|
157
|
+
│ ├── 1-design/design-system.md, mockups.md, components.md, flows.md
|
|
158
|
+
│ ├── 2-design/spec.md, contracts.cs, decisions.md
|
|
159
|
+
│ ├── 3-tasks/tasks.md
|
|
160
|
+
│ └── 4-implement/recap.md
|
|
161
|
+
├── checkpoints/
|
|
162
|
+
├── logs/
|
|
163
|
+
└── state.json # READ-ONLY — CLI managed
|
|
164
|
+
|
|
165
|
+
.claude/
|
|
166
|
+
├── commands/ # slash commands
|
|
167
|
+
├── skills/ # framework skills (SKILL.md per dir)
|
|
168
|
+
├── agents/ # native subagents (22)
|
|
169
|
+
│ ├── morph-{id}.md # tier 1-2 agents
|
|
170
|
+
│ └── morph-domain-{name}.md # tier 3 domain agents
|
|
171
|
+
├── rules/ # path-scoped rules (6 files)
|
|
172
|
+
└── settings.local.json # hooks (10)
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
## Protected files
|
|
178
|
+
|
|
179
|
+
These files are never edited directly. Use CLI commands or `morph-spec update` instead:
|
|
180
|
+
|
|
181
|
+
| Path | Protected by |
|
|
182
|
+
|------|-------------|
|
|
183
|
+
| `.morph/state.json` | `permissions.deny` |
|
|
184
|
+
| `.morph/framework/**` | `permissions.deny` |
|
|
185
|
+
| Approved spec/contracts | `protect-spec-files.js` hook |
|
|
186
|
+
|
|
187
|
+
---
|
|
188
|
+
|
|
189
|
+
## Links
|
|
190
|
+
|
|
191
|
+
- [QUICKSTART.md](QUICKSTART.md) — step-by-step guide
|
|
192
|
+
- [ARCHITECTURE.md](ARCHITECTURE.md) — system design
|
|
193
|
+
- [CHANGELOG.md](../CHANGELOG.md) — release history
|
|
194
|
+
- [npm](https://www.npmjs.com/package/@polymorphism-tech/morph-spec)
|
|
195
|
+
- support@polymorphism.com.br
|
|
196
|
+
|
|
197
|
+
---
|
|
198
|
+
|
|
199
|
+
*morph-spec v7.1.1 by Polymorphism Tech*
|
package/docs/QUICKSTART.md
CHANGED
|
@@ -1,200 +1,200 @@
|
|
|
1
|
-
# morph-spec Quick Start
|
|
2
|
-
|
|
3
|
-
## Install
|
|
4
|
-
|
|
5
|
-
```bash
|
|
6
|
-
npm install -g @polymorphism-tech/morph-spec
|
|
7
|
-
```
|
|
8
|
-
|
|
9
|
-
> The installer automatically configures your PowerShell PATH on Windows. If `morph-spec` is not found, open a new terminal window.
|
|
10
|
-
|
|
11
|
-
---
|
|
12
|
-
|
|
13
|
-
## Initialize a project
|
|
14
|
-
|
|
15
|
-
Navigate to your project root and run:
|
|
16
|
-
|
|
17
|
-
```bash
|
|
18
|
-
morph-spec init
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
`init` does the following:
|
|
22
|
-
- Auto-detects your stack (Blazor, Next.js, Node.js, monorepo)
|
|
23
|
-
- Creates `.morph/` with framework files, standards, and templates
|
|
24
|
-
- Creates `.morph/context/` with inferred project context
|
|
25
|
-
- Installs `.claude/skills/`, `.claude/agents/`, `.claude/rules/`
|
|
26
|
-
- Writes `.claude/settings.local.json` with 10 Claude Code hooks
|
|
27
|
-
- Copies `CLAUDE.md` with runtime instructions
|
|
28
|
-
|
|
29
|
-
Verify the installation:
|
|
30
|
-
|
|
31
|
-
```bash
|
|
32
|
-
morph-spec doctor
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
---
|
|
36
|
-
|
|
37
|
-
## Your first feature
|
|
38
|
-
|
|
39
|
-
Open your project in Claude Code and run:
|
|
40
|
-
|
|
41
|
-
```
|
|
42
|
-
/morph-proposal my-feature
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
Replace `my-feature` with a short kebab-case name for your feature (e.g., `user-notifications`, `payment-flow`).
|
|
46
|
-
|
|
47
|
-
The proposal pipeline runs phases 0–6 with three approval gates:
|
|
48
|
-
|
|
49
|
-
### Phase 0 — Proposal
|
|
50
|
-
|
|
51
|
-
Claude analyzes your request, detects which agents are relevant, and produces `0-proposal/proposal.md`. You review it and approve (or request changes).
|
|
52
|
-
|
|
53
|
-
### Phase 1 — Setup
|
|
54
|
-
|
|
55
|
-
Loads project context from `.morph/context/`, confirms stack and active agents. No approval needed.
|
|
56
|
-
|
|
57
|
-
### Phase 2 — UI/UX (conditional)
|
|
58
|
-
|
|
59
|
-
Only runs if frontend agents are active. Claude generates:
|
|
60
|
-
- `1-design/design-system.md` — colors, typography, spacing
|
|
61
|
-
- `1-design/mockups.md` — ASCII wireframes
|
|
62
|
-
- `1-design/components.md` — component specs
|
|
63
|
-
- `1-design/flows.md` — user flows and edge cases
|
|
64
|
-
|
|
65
|
-
You approve the UI design before design phase begins.
|
|
66
|
-
|
|
67
|
-
### Phase 3 — Design
|
|
68
|
-
|
|
69
|
-
Claude produces the technical specification:
|
|
70
|
-
- `2-design/spec.md` — full requirements, use cases, validations
|
|
71
|
-
- `2-design/contracts.cs` — C# interfaces, DTOs, enums
|
|
72
|
-
- `2-design/decisions.md` — architectural decision records (ADRs)
|
|
73
|
-
|
|
74
|
-
You review and approve the design.
|
|
75
|
-
|
|
76
|
-
### Phase 4 — Clarify
|
|
77
|
-
|
|
78
|
-
Claude identifies 3–7 ambiguities in the spec, asks you to resolve them, then updates the spec. No gate.
|
|
79
|
-
|
|
80
|
-
### Phase 6 — Tasks
|
|
81
|
-
|
|
82
|
-
Claude breaks the spec into atomic tasks (`T001`, `T002`, …) saved to `3-tasks/tasks.md`. You approve the task list.
|
|
83
|
-
|
|
84
|
-
At this point, planning is complete:
|
|
85
|
-
|
|
86
|
-
```
|
|
87
|
-
✅ Planning complete — run /morph-apply my-feature to implement
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
---
|
|
91
|
-
|
|
92
|
-
## Implement
|
|
93
|
-
|
|
94
|
-
```
|
|
95
|
-
/morph-apply my-feature
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
Claude reads `spec.md`, `contracts.cs`, and `tasks.md`, then implements task by task:
|
|
99
|
-
- Starts each task, writes the code, marks it done
|
|
100
|
-
- Runs 5 validators automatically after each task: security, architecture, packages, design system, Blazor concurrency
|
|
101
|
-
- Auto-checkpoints every 3 tasks (validates, saves state)
|
|
102
|
-
- Generates `4-implement/recap.md` on completion
|
|
103
|
-
|
|
104
|
-
---
|
|
105
|
-
|
|
106
|
-
## During development
|
|
107
|
-
|
|
108
|
-
Check feature state:
|
|
109
|
-
|
|
110
|
-
```bash
|
|
111
|
-
morph-spec state get my-feature
|
|
112
|
-
morph-spec status my-feature
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
Advance to the next phase manually (when needed):
|
|
116
|
-
|
|
117
|
-
```bash
|
|
118
|
-
morph-spec phase advance my-feature
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
Mark a task complete:
|
|
122
|
-
|
|
123
|
-
```bash
|
|
124
|
-
morph-spec task done my-feature T001
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
Run validators at any time:
|
|
128
|
-
|
|
129
|
-
```bash
|
|
130
|
-
morph-spec validate # all validators
|
|
131
|
-
morph-spec validate architecture # specific validator
|
|
132
|
-
morph-spec validate packages
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
---
|
|
136
|
-
|
|
137
|
-
## Multiple features
|
|
138
|
-
|
|
139
|
-
You can have multiple features in progress simultaneously. Each has its own directory under `.morph/features/`:
|
|
140
|
-
|
|
141
|
-
```
|
|
142
|
-
.morph/features/
|
|
143
|
-
├── user-notifications/
|
|
144
|
-
│ ├── 0-proposal/
|
|
145
|
-
│ ├── 2-design/
|
|
146
|
-
│ └── 3-tasks/
|
|
147
|
-
└── payment-flow/
|
|
148
|
-
├── 0-proposal/
|
|
149
|
-
└── 2-design/
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
See all feature states:
|
|
153
|
-
|
|
154
|
-
```bash
|
|
155
|
-
morph-spec state list
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
---
|
|
159
|
-
|
|
160
|
-
## Keeping up to date
|
|
161
|
-
|
|
162
|
-
When a new version of `@polymorphism-tech/morph-spec` is published:
|
|
163
|
-
|
|
164
|
-
```bash
|
|
165
|
-
# Update the CLI
|
|
166
|
-
npm install -g @polymorphism-tech/morph-spec@latest
|
|
167
|
-
|
|
168
|
-
# Update framework files in your project
|
|
169
|
-
morph-spec update
|
|
170
|
-
|
|
171
|
-
# Verify
|
|
172
|
-
morph-spec doctor
|
|
173
|
-
```
|
|
174
|
-
|
|
175
|
-
`morph-spec update` re-syncs `.morph/framework/`, `.claude/skills/`, `.claude/agents/`, `.claude/rules/`, and `CLAUDE.md`. It does not touch your config, context, or feature outputs.
|
|
176
|
-
|
|
177
|
-
---
|
|
178
|
-
|
|
179
|
-
## Tips
|
|
180
|
-
|
|
181
|
-
**Use `/morph-proposal` even for small features.** The proposal phase catches scope creep, identifies the right agents, and generates contracts early — before implementation makes it expensive to change direction.
|
|
182
|
-
|
|
183
|
-
**Approve explicitly at each gate.** The design gate exists to prevent implementing the wrong thing. If something in `spec.md` or `contracts.cs` looks off, say so before approving.
|
|
184
|
-
|
|
185
|
-
**ADRs belong in `decisions.md`.** When Claude makes an architectural choice, it documents it there. Read it after Design completes. Decisions drive the validators that run during implementation.
|
|
186
|
-
|
|
187
|
-
**`morph-spec doctor` is your first debugging step.** If something is behaving unexpectedly, doctor will surface version mismatches, missing files, and hook configuration issues.
|
|
188
|
-
|
|
189
|
-
---
|
|
190
|
-
|
|
191
|
-
## Next steps
|
|
192
|
-
|
|
193
|
-
- [CHEATSHEET.md](CHEATSHEET.md) — command reference
|
|
194
|
-
- [ARCHITECTURE.md](ARCHITECTURE.md) — system design and agent hierarchy
|
|
195
|
-
- [CHANGELOG.md](../CHANGELOG.md) — release history
|
|
196
|
-
- `.morph/framework/standards/` — all coding and architecture standards
|
|
197
|
-
|
|
198
|
-
---
|
|
199
|
-
|
|
200
|
-
*morph-spec
|
|
1
|
+
# morph-spec Quick Start
|
|
2
|
+
|
|
3
|
+
## Install
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm install -g @polymorphism-tech/morph-spec
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
> The installer automatically configures your PowerShell PATH on Windows. If `morph-spec` is not found, open a new terminal window.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Initialize a project
|
|
14
|
+
|
|
15
|
+
Navigate to your project root and run:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
morph-spec init
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
`init` does the following:
|
|
22
|
+
- Auto-detects your stack (Blazor, Next.js, Node.js, monorepo)
|
|
23
|
+
- Creates `.morph/` with framework files, standards, and templates
|
|
24
|
+
- Creates `.morph/context/` with inferred project context
|
|
25
|
+
- Installs `.claude/skills/`, `.claude/agents/`, `.claude/rules/`
|
|
26
|
+
- Writes `.claude/settings.local.json` with 10 Claude Code hooks
|
|
27
|
+
- Copies `CLAUDE.md` with runtime instructions
|
|
28
|
+
|
|
29
|
+
Verify the installation:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
morph-spec doctor
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Your first feature
|
|
38
|
+
|
|
39
|
+
Open your project in Claude Code and run:
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
/morph-proposal my-feature
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Replace `my-feature` with a short kebab-case name for your feature (e.g., `user-notifications`, `payment-flow`).
|
|
46
|
+
|
|
47
|
+
The proposal pipeline runs phases 0–6 with three approval gates:
|
|
48
|
+
|
|
49
|
+
### Phase 0 — Proposal
|
|
50
|
+
|
|
51
|
+
Claude analyzes your request, detects which agents are relevant, and produces `0-proposal/proposal.md`. You review it and approve (or request changes).
|
|
52
|
+
|
|
53
|
+
### Phase 1 — Setup
|
|
54
|
+
|
|
55
|
+
Loads project context from `.morph/context/`, confirms stack and active agents. No approval needed.
|
|
56
|
+
|
|
57
|
+
### Phase 2 — UI/UX (conditional)
|
|
58
|
+
|
|
59
|
+
Only runs if frontend agents are active. Claude generates:
|
|
60
|
+
- `1-design/design-system.md` — colors, typography, spacing
|
|
61
|
+
- `1-design/mockups.md` — ASCII wireframes
|
|
62
|
+
- `1-design/components.md` — component specs
|
|
63
|
+
- `1-design/flows.md` — user flows and edge cases
|
|
64
|
+
|
|
65
|
+
You approve the UI design before design phase begins.
|
|
66
|
+
|
|
67
|
+
### Phase 3 — Design
|
|
68
|
+
|
|
69
|
+
Claude produces the technical specification:
|
|
70
|
+
- `2-design/spec.md` — full requirements, use cases, validations
|
|
71
|
+
- `2-design/contracts.cs` — C# interfaces, DTOs, enums
|
|
72
|
+
- `2-design/decisions.md` — architectural decision records (ADRs)
|
|
73
|
+
|
|
74
|
+
You review and approve the design.
|
|
75
|
+
|
|
76
|
+
### Phase 4 — Clarify
|
|
77
|
+
|
|
78
|
+
Claude identifies 3–7 ambiguities in the spec, asks you to resolve them, then updates the spec. No gate.
|
|
79
|
+
|
|
80
|
+
### Phase 6 — Tasks
|
|
81
|
+
|
|
82
|
+
Claude breaks the spec into atomic tasks (`T001`, `T002`, …) saved to `3-tasks/tasks.md`. You approve the task list.
|
|
83
|
+
|
|
84
|
+
At this point, planning is complete:
|
|
85
|
+
|
|
86
|
+
```
|
|
87
|
+
✅ Planning complete — run /morph-apply my-feature to implement
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## Implement
|
|
93
|
+
|
|
94
|
+
```
|
|
95
|
+
/morph-apply my-feature
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Claude reads `spec.md`, `contracts.cs`, and `tasks.md`, then implements task by task:
|
|
99
|
+
- Starts each task, writes the code, marks it done
|
|
100
|
+
- Runs 5 validators automatically after each task: security, architecture, packages, design system, Blazor concurrency
|
|
101
|
+
- Auto-checkpoints every 3 tasks (validates, saves state)
|
|
102
|
+
- Generates `4-implement/recap.md` on completion
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## During development
|
|
107
|
+
|
|
108
|
+
Check feature state:
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
morph-spec state get my-feature
|
|
112
|
+
morph-spec status my-feature
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Advance to the next phase manually (when needed):
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
morph-spec phase advance my-feature
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Mark a task complete:
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
morph-spec task done my-feature T001
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Run validators at any time:
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
morph-spec validate # all validators
|
|
131
|
+
morph-spec validate architecture # specific validator
|
|
132
|
+
morph-spec validate packages
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## Multiple features
|
|
138
|
+
|
|
139
|
+
You can have multiple features in progress simultaneously. Each has its own directory under `.morph/features/`:
|
|
140
|
+
|
|
141
|
+
```
|
|
142
|
+
.morph/features/
|
|
143
|
+
├── user-notifications/
|
|
144
|
+
│ ├── 0-proposal/
|
|
145
|
+
│ ├── 2-design/
|
|
146
|
+
│ └── 3-tasks/
|
|
147
|
+
└── payment-flow/
|
|
148
|
+
├── 0-proposal/
|
|
149
|
+
└── 2-design/
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
See all feature states:
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
morph-spec state list
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
## Keeping up to date
|
|
161
|
+
|
|
162
|
+
When a new version of `@polymorphism-tech/morph-spec` is published:
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
# Update the CLI
|
|
166
|
+
npm install -g @polymorphism-tech/morph-spec@latest
|
|
167
|
+
|
|
168
|
+
# Update framework files in your project
|
|
169
|
+
morph-spec update
|
|
170
|
+
|
|
171
|
+
# Verify
|
|
172
|
+
morph-spec doctor
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
`morph-spec update` re-syncs `.morph/framework/`, `.claude/skills/`, `.claude/agents/`, `.claude/rules/`, and `CLAUDE.md`. It does not touch your config, context, or feature outputs.
|
|
176
|
+
|
|
177
|
+
---
|
|
178
|
+
|
|
179
|
+
## Tips
|
|
180
|
+
|
|
181
|
+
**Use `/morph-proposal` even for small features.** The proposal phase catches scope creep, identifies the right agents, and generates contracts early — before implementation makes it expensive to change direction.
|
|
182
|
+
|
|
183
|
+
**Approve explicitly at each gate.** The design gate exists to prevent implementing the wrong thing. If something in `spec.md` or `contracts.cs` looks off, say so before approving.
|
|
184
|
+
|
|
185
|
+
**ADRs belong in `decisions.md`.** When Claude makes an architectural choice, it documents it there. Read it after Design completes. Decisions drive the validators that run during implementation.
|
|
186
|
+
|
|
187
|
+
**`morph-spec doctor` is your first debugging step.** If something is behaving unexpectedly, doctor will surface version mismatches, missing files, and hook configuration issues.
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
## Next steps
|
|
192
|
+
|
|
193
|
+
- [CHEATSHEET.md](CHEATSHEET.md) — command reference
|
|
194
|
+
- [ARCHITECTURE.md](ARCHITECTURE.md) — system design and agent hierarchy
|
|
195
|
+
- [CHANGELOG.md](../CHANGELOG.md) — release history
|
|
196
|
+
- `.morph/framework/standards/` — all coding and architecture standards
|
|
197
|
+
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
*morph-spec v7.1.1 by Polymorphism Tech*
|
package/framework/CLAUDE.md
CHANGED
|
@@ -16,7 +16,7 @@ Se não houver feature ativa, pergunte ao usuário qual feature trabalhar.
|
|
|
16
16
|
- Pular para código sem proposal aprovado (Gate 1) e plano aprovado (Gate 2).
|
|
17
17
|
- Modificar `spec.md`, `mandate.md`, `tasks.md` depois do Gate 2 — eles estão congelados.
|
|
18
18
|
- Listar perguntas em texto simples — sempre use a tool `AskUserQuestion` (1-4 perguntas por chamada).
|
|
19
|
-
- Usar `Guid.NewGuid()`, classes não-sealed sem justificativa, exceptions como fluxo de controle,
|
|
19
|
+
- Usar `Guid.NewGuid()`, classes não-sealed sem justificativa, exceptions como fluxo de controle, camada de Service/Manager entre handler e dados, ou SQL cru sem justificativa.
|
|
20
20
|
|
|
21
21
|
**SEMPRE:**
|
|
22
22
|
- Auto-advance entre tarefas durante a fase implement — não pause sem ambiguidade bloqueante.
|
package/framework/MORPH.md
CHANGED
|
@@ -48,7 +48,10 @@ Padrões proibidos automaticamente injetados no mandate:
|
|
|
48
48
|
- `Guid.NewGuid()` → `Guid.CreateVersion7()`
|
|
49
49
|
- Classes não-sealed sem justificativa
|
|
50
50
|
- Exceptions como fluxo de controle
|
|
51
|
-
-
|
|
51
|
+
- Camada de Service/Manager entre handler e dados — o handler fala com `IRepository<T>` ou `DbContext`, nunca com um service
|
|
52
|
+
- SQL cru (`FromSqlRaw`, `ExecuteQuery(string)`) sem justificativa em `decisions.md` — use LINQ
|
|
53
|
+
|
|
54
|
+
Acesso a dados em VSA é híbrido: `IRepository<T>` + `IUnitOfWork` para CRUD simples; `ApplicationDbContext` injetado direto no slice quando a query for específica (joins, projeção, paginação, filtros compostos).
|
|
52
55
|
|
|
53
56
|
---
|
|
54
57
|
|
package/framework/agents.json
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"backend-dotnet-vsa-handler-patterns",
|
|
22
22
|
"backend-dotnet-fluent-validation-vsa"
|
|
23
23
|
],
|
|
24
|
-
"persona": "Você é um engenheiro .NET sênior. Pensa em VSA com handlers diretos, result pattern, sealed classes, Guid.CreateVersion7().
|
|
24
|
+
"persona": "Você é um engenheiro .NET sênior. Pensa em VSA com handlers diretos, result pattern, sealed classes, Guid.CreateVersion7(). Acesso a dados híbrido: IRepository<T> + IUnitOfWork para CRUD, DbContext direto no slice para queries específicas; nunca uma camada de Service/Manager. Não usa exceptions como fluxo. Consulta o standard antes de escrever cada slice. Nomeia tudo em PascalCase para tipos, camelCase para parâmetros."
|
|
25
25
|
},
|
|
26
26
|
"ef-modeler": {
|
|
27
27
|
"title": "EF Core / Database Modeler",
|
|
@@ -26,7 +26,7 @@ O harness conhece o stack por padrão. Não pergunte sobre tecnologia a menos qu
|
|
|
26
26
|
| Frontend | Next.js App Router + Tailwind + Framer Motion + Shadcn |
|
|
27
27
|
| Jobs async | Hangfire — apenas se a feature requer processamento em background |
|
|
28
28
|
|
|
29
|
-
**Padrões proibidos:** `Guid.NewGuid()`, classes não-sealed sem justificativa, exceptions sem result pattern,
|
|
29
|
+
**Padrões proibidos:** `Guid.NewGuid()`, classes não-sealed sem justificativa, exceptions sem result pattern, camada de Service/Manager entre handler e dados, SQL cru sem justificativa. Acesso a dados em VSA é híbrido: `IRepository<T>` + `IUnitOfWork` para CRUD; `DbContext` direto no slice para queries específicas.
|
|
30
30
|
|
|
31
31
|
## O que fazer
|
|
32
32
|
|
|
@@ -33,7 +33,9 @@ Ao iniciar a fase plan — após o `proposal.md` ser aprovado e antes de qualque
|
|
|
33
33
|
- `Guid.NewGuid()` → usar `Guid.CreateVersion7()`
|
|
34
34
|
- Classes não-sealed sem justificativa documentada
|
|
35
35
|
- Exceptions como fluxo de controle → usar result pattern com `result.Match()`
|
|
36
|
-
-
|
|
36
|
+
- Camada de Service/Manager entre handler e dados → handler usa `IRepository<T>` ou `DbContext` direto
|
|
37
|
+
- SQL cru (`FromSqlRaw`, `ExecuteQuery(string)`) sem justificativa em `decisions.md` → usar LINQ
|
|
38
|
+
- Política de acesso a dados (registre no mandate como orientação, não proibição): `IRepository<T>` + `IUnitOfWork` para CRUD simples; `ApplicationDbContext` injetado direto no slice para queries específicas (joins, projeção, paginação).
|
|
37
39
|
- Checklist de done com critérios verificáveis por tarefa.
|
|
38
40
|
|
|
39
41
|
4. Produza `tasks.json` em `.morph/features/{feature}/2-plan/` seguindo o schema em `.morph/framework/schemas/tasks.schema.json`.
|
|
@@ -28,7 +28,7 @@ Quando o projeto já tem código existente e você precisa entender o estado atu
|
|
|
28
28
|
| Frontend | Next.js App Router + Tailwind + Framer Motion + Shadcn |
|
|
29
29
|
| Jobs | Hangfire (apenas quando necessário) |
|
|
30
30
|
|
|
31
|
-
**Padrões proibidos:** `Guid.NewGuid()`, classes não-sealed sem justificativa, exceptions como fluxo de controle,
|
|
31
|
+
**Padrões proibidos:** `Guid.NewGuid()`, classes não-sealed sem justificativa, exceptions como fluxo de controle, camada de Service/Manager entre handler e dados, SQL cru sem justificativa. Acesso a dados em VSA é híbrido: `IRepository<T>` + `IUnitOfWork` para CRUD; `DbContext` direto no slice para queries específicas.
|
|
32
32
|
|
|
33
33
|
## Greenfield short-circuit
|
|
34
34
|
|
|
@@ -61,7 +61,7 @@ Antes de despachar Explore, verifique se o projeto é greenfield:
|
|
|
61
61
|
- Erros: Result pattern (`result.Match()`)
|
|
62
62
|
|
|
63
63
|
## Padrões proibidos
|
|
64
|
-
`Guid.NewGuid()`, classes não-sealed sem justificativa, exceptions como fluxo de controle,
|
|
64
|
+
`Guid.NewGuid()`, classes não-sealed sem justificativa, exceptions como fluxo de controle, camada de Service/Manager entre handler e dados, SQL cru sem justificativa. Acesso a dados em VSA é híbrido: `IRepository<T>` + `IUnitOfWork` para CRUD; `DbContext` direto no slice para queries específicas.
|
|
65
65
|
|
|
66
66
|
## Recomendação
|
|
67
67
|
Compliance trivial (greenfield). Prosseguir para morph-brainstorming.
|
|
@@ -101,7 +101,7 @@ Antes de despachar Explore, verifique se o projeto é greenfield:
|
|
|
101
101
|
| Severidade | Critério |
|
|
102
102
|
|------------|---------|
|
|
103
103
|
| **Bloqueante** | Runtime diferente (.NET 8 ou anterior), ORM diferente (Dapper puro sem EF Core), banco diferente (MySQL, SQL Server) |
|
|
104
|
-
| **Alto** | `Guid.NewGuid()` generalizado,
|
|
104
|
+
| **Alto** | `Guid.NewGuid()` generalizado, camada de Service/Manager entre handler e dados, SQL cru generalizado, exceptions como fluxo de controle |
|
|
105
105
|
| **Médio** | Classes não-sealed, Pages Router em vez de App Router, biblioteca de UI diferente |
|
|
106
106
|
| **Baixo** | Versões de pacotes desatualizadas mas compatíveis |
|
|
107
107
|
|
|
@@ -323,6 +323,12 @@ public interface IRepository<T> where T : class
|
|
|
323
323
|
}
|
|
324
324
|
```
|
|
325
325
|
|
|
326
|
+
**Quando NÃO usar o repository:** o `IRepository<T>` genérico cobre CRUD por chave.
|
|
327
|
+
Para queries com join, projeção, paginação ou filtros compostos, injete
|
|
328
|
+
`ApplicationDbContext` direto no handler e escreva o LINQ no slice — não polua a
|
|
329
|
+
interface genérica com métodos de um único slice, e não use `ExecuteQuery(string sql)`.
|
|
330
|
+
Veja `backend/dotnet/vsa-handler-patterns.md` → "When to Use DbContext Directly".
|
|
331
|
+
|
|
326
332
|
---
|
|
327
333
|
|
|
328
334
|
## DI Registration (Program.cs)
|
|
@@ -379,7 +385,7 @@ app.MapApiEndpoints();
|
|
|
379
385
|
4. **`result.Match()`** nos endpoints — nunca acessar `result.Value` sem checar `IsSuccess`.
|
|
380
386
|
5. **IApiEndpoint `internal sealed`** — endpoints não são públicos.
|
|
381
387
|
6. **`{Entity}Errors` compartilhado** por todas as operações da feature (1 arquivo por feature, não por slice).
|
|
382
|
-
7. **
|
|
388
|
+
7. **Acesso a dados híbrido**: `IRepository<T>` injetado no handler para CRUD por chave; `ApplicationDbContext` injetado direto no slice para queries específicas (joins, projeção, paginação). Nunca uma Application Service layer entre handler e dados.
|
|
383
389
|
8. **`IUnitOfWork.CommitAsync()`** em operações de escrita (Create, Update, Delete).
|
|
384
390
|
9. **Sem validator em GetAll** — GetAllBooksHandler não tem validator (sem parâmetros para validar).
|
|
385
391
|
|
|
@@ -197,6 +197,36 @@ public interface IUnitOfWork
|
|
|
197
197
|
|
|
198
198
|
**Pattern:** `Repository.AddAsync()` -> `UnitOfWork.CommitAsync()` — always commit explicitly.
|
|
199
199
|
|
|
200
|
+
### When to Use DbContext Directly Instead
|
|
201
|
+
|
|
202
|
+
`IRepository<T>` is the right tool for CRUD by key. It is **not** the right tool for
|
|
203
|
+
slice-specific queries — joins, projections, pagination, composite filters. For those,
|
|
204
|
+
inject `ApplicationDbContext` directly into the handler and write the LINQ in the slice:
|
|
205
|
+
|
|
206
|
+
```csharp
|
|
207
|
+
public sealed class SearchBooksHandler(
|
|
208
|
+
ApplicationDbContext db) : IHandler<SearchBooksRequest, Result<IReadOnlyList<BookDto>>>
|
|
209
|
+
{
|
|
210
|
+
public async Task<Result<IReadOnlyList<BookDto>>> HandleAsync(
|
|
211
|
+
SearchBooksRequest query, CancellationToken cancellationToken)
|
|
212
|
+
{
|
|
213
|
+
var books = await db.Books
|
|
214
|
+
.Where(b => b.Author.Contains(query.Author))
|
|
215
|
+
.OrderBy(b => b.Title)
|
|
216
|
+
.Skip(query.Skip).Take(query.Take)
|
|
217
|
+
.Select(b => new BookDto(b.Id, b.Title, b.Author))
|
|
218
|
+
.ToListAsync(cancellationToken);
|
|
219
|
+
|
|
220
|
+
return Result.Success<IReadOnlyList<BookDto>>(books);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
**Rule of thumb:** CRUD by key → `IRepository<T>` + `IUnitOfWork`. Anything that needs a
|
|
226
|
+
custom query shape → `ApplicationDbContext` in the slice. Never reach for raw SQL
|
|
227
|
+
(`FromSqlRaw`) unless a query genuinely cannot be expressed in LINQ — and document that
|
|
228
|
+
in `decisions.md`.
|
|
229
|
+
|
|
200
230
|
---
|
|
201
231
|
|
|
202
232
|
## Feature Error Factory
|
|
@@ -272,6 +302,8 @@ builder.Services.AddExceptionHandler<CustomExceptionHandler>()
|
|
|
272
302
|
| Share handlers across features | Each feature has its own handler, even if similar |
|
|
273
303
|
| Use constructor + field for DI | Use primary constructors: `class Handler(IDep dep)` |
|
|
274
304
|
| Group by technical concern (Controllers/, Services/) | Group by feature: `Features/BookFeature/CreateBook/` |
|
|
305
|
+
| Force a slice-specific query through `IRepository<T>` | Inject `DbContext` and write LINQ in the slice |
|
|
306
|
+
| Use raw SQL (`FromSqlRaw` / `ExecuteQuery(string)`) by default | Use LINQ; raw SQL only with a `decisions.md` justification |
|
|
275
307
|
|
|
276
308
|
---
|
|
277
309
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
VSA + .NET 10 + EF Core + Neon (Postgres) + Microsoft Agent Framework + Next.js (App Router) + Tailwind + Framer Motion + Shadcn + Hangfire (quando necessário).
|
|
8
8
|
|
|
9
|
-
Padrões proibidos por padrão: `Guid.NewGuid()` (use `Guid.CreateVersion7()`), classes não-sealed sem justificativa, exceptions como fluxo de controle,
|
|
9
|
+
Padrões proibidos por padrão: `Guid.NewGuid()` (use `Guid.CreateVersion7()`), classes não-sealed sem justificativa, exceptions como fluxo de controle, camada de Service/Manager entre handler e dados, SQL cru sem justificativa. Acesso a dados é híbrido: `IRepository<T>` + `IUnitOfWork` para CRUD; `DbContext` direto no slice para queries específicas.
|
|
10
10
|
|
|
11
11
|
## Harness
|
|
12
12
|
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
// Generated by MORPH Framework
|
|
4
4
|
// ============================================================
|
|
5
5
|
|
|
6
|
-
using System.Data.Common;
|
|
7
6
|
using Microsoft.EntityFrameworkCore;
|
|
8
7
|
using {{pascalCase PROJECT_NAME}}.Database;
|
|
9
8
|
|
|
@@ -13,6 +12,9 @@ namespace {{pascalCase PROJECT_NAME}}.Repository;
|
|
|
13
12
|
// IRepository<T> — Generic repository contract
|
|
14
13
|
// ============================================================
|
|
15
14
|
|
|
15
|
+
// Generic CRUD by key. For slice-specific queries (joins, projection, pagination),
|
|
16
|
+
// inject ApplicationDbContext directly into the handler and write LINQ in the slice —
|
|
17
|
+
// do NOT add query methods here, and do NOT use raw SQL.
|
|
16
18
|
public interface IRepository<T> where T : class
|
|
17
19
|
{
|
|
18
20
|
Task<IEnumerable<T>> GetAllAsync(CancellationToken cancellationToken = default);
|
|
@@ -20,7 +22,6 @@ public interface IRepository<T> where T : class
|
|
|
20
22
|
Task<T> AddAsync(T entity, CancellationToken cancellationToken = default);
|
|
21
23
|
Task UpdateAsync(T entity, CancellationToken cancellationToken = default);
|
|
22
24
|
Task DeleteAsync(T entity, CancellationToken cancellationToken = default);
|
|
23
|
-
IEnumerable<T> ExecuteQuery(string query, DbParameter[] dbParams);
|
|
24
25
|
Task AddRangeAsync(IEnumerable<T> entities, CancellationToken cancellationToken = default);
|
|
25
26
|
void RemoveRange(IEnumerable<T> entities);
|
|
26
27
|
}
|
|
@@ -80,14 +81,6 @@ public class Repository<T> : IRepository<T> where T : class
|
|
|
80
81
|
return Task.CompletedTask;
|
|
81
82
|
}
|
|
82
83
|
|
|
83
|
-
public IEnumerable<T> ExecuteQuery(string query, DbParameter[] dbParams)
|
|
84
|
-
{
|
|
85
|
-
return _dbSet
|
|
86
|
-
.FromSqlRaw(query, dbParams)
|
|
87
|
-
.AsNoTracking()
|
|
88
|
-
.AsEnumerable();
|
|
89
|
-
}
|
|
90
|
-
|
|
91
84
|
public async Task AddRangeAsync(IEnumerable<T> entities, CancellationToken cancellationToken = default)
|
|
92
85
|
{
|
|
93
86
|
await _dbSet.AddRangeAsync(entities, cancellationToken);
|