moicle 2.0.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,308 +6,268 @@ args: "[DOMAIN] [FEATURE]"
6
6
 
7
7
  # DDD Feature Development Workflow
8
8
 
9
- Build a new feature following DDD architecture, with automated checks after each phase and a review loop that keeps fixing until all checks pass.
9
+ Build a new feature following DDD layers with rule checks per phase and a final review loop until score B.
10
10
 
11
11
  **ARGUMENTS:** `<domain> <feature>` — e.g., `wallet savings`, `notification broadcast`, `catalog products`
12
12
 
13
13
  ## When to use this skill
14
14
 
15
- - ✅ Building a feature that spans multiple DDD layers (domain + app + infra)
16
- - ✅ The feature is well-understood (no major research / prototype needed)
15
+ - ✅ Feature spans multiple DDD layers (domain + app + infra)
16
+ - ✅ The approach is well-understood (no major research / prototype needed)
17
17
  - ✅ You want automated architecture review at the end
18
18
  - ❌ Quick bug fix → use `/fix:hotfix`
19
- - ❌ Don't know the right approach yet → use `/research:web` or `/research:spike` first
20
- - ❌ Restructuring existing code → use `refactor`
19
+ - ❌ Don't know the right approach yet → `/research:web` or `/research:spike` first
20
+ - ❌ Restructuring existing code → use `/feature:refactor`
21
21
 
22
22
  ## Read Architecture First
23
23
 
24
- Before starting, read:
25
- 1. `ddd-architecture.md` (core DDD spec)
26
- 2. Stack-specific doc based on detected stack
27
-
28
- ### Stack Detection
29
- | File | Stack Doc |
30
- |------|-----------|
31
- | `go.mod` | `go-backend.md` |
32
- | `package.json` + NestJS dep | `nodejs-nestjs.md` |
33
- | `package.json` + `vite.config.*` | `react-frontend.md` |
34
- | `pubspec.yaml` | `flutter-mobile.md` |
35
- | `composer.json` | `laravel-backend.md` |
36
- | `remix.config.*` | `remix-fullstack.md` |
37
-
38
- Architecture files location: `.claude/architecture/{name}.md` (project) → `~/.claude/architecture/{name}.md` (global).
24
+ Detect stack via `~/.claude/architecture/_shared/stack-detection.md`. Load `ddd-architecture.md` + the stack doc — extract directory layout, layer rules, forbidden imports, check scripts before any code.
39
25
 
40
26
  ---
41
27
 
42
28
  ## Workflow
43
29
 
44
30
  ```
45
- PHASE 1: Analyze & Plan
46
- → PHASE 2: Build Domain Layer
47
- → PHASE 3: Build Infrastructure Layer
48
- → PHASE 4: Build Application Layer
49
- → PHASE 5: Registration & Wiring
50
- → PHASE 6: Domain Tests
51
- → REVIEW LOOP (run /review:architect, fix issues, repeat until clean)
31
+ 1 PLAN 2 DOMAIN → 3 INFRA → 4 APP → 5 WIRE → 6 TESTS → REVIEW LOOP
52
32
  ```
53
33
 
54
34
  ---
55
35
 
56
- ## PHASE 1: Analyze & Plan
57
-
58
- ### 1.1 Read Architecture Docs
59
- 1. Read `ddd-architecture.md` (core DDD rules)
60
- 2. Read stack-specific architecture doc
61
- 3. Extract: DDD directory structure, layer rules, hard rules, forbidden imports, check scripts
62
-
63
- ### 1.2 Read Reference Module
64
- Pick a SMALL existing module in the project as reference. Read ALL its files to understand exact patterns:
65
- - Entities, value objects, events, ports, usecases
66
- - Service, handler, DTOs, listeners
67
- - Infrastructure store/API implementations
68
- - Registration in router/provider/registry
69
-
70
- ### 1.3 Plan Feature
71
- Present to user:
72
- - All entities and their fields
73
- - All endpoints/screens/UI (depending on stack)
74
- - All domain events
75
- - All value objects
76
- - Business rules summary
77
- - Files to create/modify
78
-
79
- ### Rule Check Phase 1
80
- - [ ] Architecture docs read and understood
81
- - [ ] Reference module read
82
- - [ ] Plan presented and **user CONFIRMED** before continuing
36
+ ## Phase 1: PLAN
83
37
 
84
- ---
38
+ ### 1.1 Read a reference module
39
+ Pick the smallest existing module in the project as a template. Read ALL its files end-to-end:
40
+ - entities, value objects, events, ports, usecases
41
+ - service, handler, DTOs, listeners
42
+ - infrastructure store/API
43
+ - registration in router/provider/registry
85
44
 
86
- ## PHASE 2: Build Domain Layer
45
+ ### 1.2 Plan the feature
87
46
 
88
- Create in order: value objects → entities → events → ports → usecases
47
+ Present to the user:
89
48
 
90
- ### 2.1 Value Objects (`valueobjects/`)
91
- - Typed values with behavior methods
92
- - Status with `IsTerminal()`, `CanTransitionTo()`
93
- - **Only stdlib imports** — read Forbidden Imports from architecture doc
49
+ ```markdown
50
+ ## Feature Plan: {domain}/{feature}
51
+
52
+ ### Entities + fields
53
+ - `{Entity}` — {field: type, with constraint}
54
+ - ...
55
+
56
+ ### Value Objects
57
+ - `{Status}` — states: {list}, transitions: {list}
58
+ - ...
59
+
60
+ ### Endpoints / screens / commands
61
+ | Method | Path | Purpose |
62
+ |--------|------|---------|
63
+ | POST | /api/v1/wallets/:id/savings | Open savings account |
64
+
65
+ ### Domain events
66
+ | Event | Triggered when | Listeners |
67
+ |-------|----------------|-----------|
68
+ | `SavingsAccountOpened` | After Account.open() succeeds | NotificationListener |
69
+
70
+ ### Business rules
71
+ - Cannot open savings if main balance < min threshold
72
+ - Interest accrues nightly via scheduled job
73
+ - ...
74
+
75
+ ### Files to create
76
+ - `domain/wallet/entities/savings_account.go`
77
+ - `domain/wallet/valueobjects/savings_status.go`
78
+ - `domain/wallet/ports/savings_store.go`
79
+ - `domain/wallet/usecases/open_savings.go`
80
+ - `application/ports/http/savings_handler.go`
81
+ - `infrastructure/database/savings_store.go`
82
+ - (+ tests for each domain file)
83
+ ```
94
84
 
95
- ### 2.2 Entities (`entities/`)
96
- - Constructor function/method
97
- - Behavior methods that raise events (state transitions, calculations)
98
- - Guard methods (isActive, canXxx)
99
- - Business error types
100
- - Only imports: stdlib + valueobjects + domain/shared
85
+ ### Gate
86
+ - [ ] Architecture docs read
87
+ - [ ] Reference module read end-to-end
88
+ - [ ] Plan presented
89
+ - [ ] **User CONFIRMED** before any code is written
101
90
 
102
- ### 2.3 Events (`events/`)
103
- - One file per event
104
- - Extend/embed base event type
105
- - Carry data needed by listeners (userID, amounts, names)
106
-
107
- ### 2.4 Ports (`ports/`)
108
- - One file per interface
109
- - Store interfaces use domain entity types and value objects
110
- - DTOs for complex query results live here
111
- - No infrastructure imports
112
-
113
- ### 2.5 UseCases (`usecases/`)
114
- - Constructor with port dependencies + event dispatcher
115
- - Split by concern: one file per action group
116
- - Business logic lives HERE
117
- - Dispatch entity events after successful save
118
- - **No infrastructure imports** — read Forbidden Imports from architecture doc
119
-
120
- ### Rule Check Phase 2
121
- Run the **Domain Purity** check scripts from the stack architecture doc:
91
+ ---
92
+
93
+ ## Phase 2: DOMAIN LAYER
94
+
95
+ Build in order: **value objects → entities → events → ports → usecases**.
96
+
97
+ - **Value Objects** typed values with behavior (`IsTerminal()`, `CanTransitionTo()`). Stdlib imports only.
98
+ - **Entities** constructor + behavior methods + guard methods (`isActive()`, `canXxx()`) + business error types. Raise events on state change. Imports: stdlib + valueobjects + domain/shared.
99
+ - **Events** one file per event, extend base event, carry data listeners need.
100
+ - **Ports** — one file per interface. Store ports use domain types. Platform-agnostic naming. No infra imports.
101
+ - **UseCases** — constructor with port deps + event dispatcher. Split by concern. Business logic lives here. Dispatch events after persistence. No infra imports.
102
+
103
+ ### Gate
122
104
  ```bash
123
- # Example (Go):
124
- go build ./internal/domain/$DOMAIN/... && echo "PASS" || echo "FAIL"
125
- go vet ./internal/domain/$DOMAIN/... && echo "PASS" || echo "FAIL"
126
- grep -rn {forbidden_imports} internal/domain/$DOMAIN/ && echo "FAIL" || echo "PASS"
127
-
128
- # Example (React):
129
- npx tsc --noEmit && echo "PASS" || echo "FAIL"
130
- grep -rn "from 'react'" src/domain/$DOMAIN/ && echo "FAIL" || echo "PASS"
131
-
132
- # Example (Flutter):
133
- dart analyze lib/domain/$DOMAIN/ && echo "PASS" || echo "FAIL"
134
- grep -rn "package:flutter" lib/domain/$DOMAIN/ && echo "FAIL" || echo "PASS"
105
+ {build_domain} && echo PASS || echo FAIL
106
+ {grep_forbidden in domain/} && echo FAIL || echo PASS
107
+ {cross_domain_check} && echo FAIL || echo PASS
135
108
  ```
136
109
 
137
110
  ---
138
111
 
139
- ## PHASE 3: Build Infrastructure Layer
112
+ ## Phase 3: INFRASTRUCTURE LAYER
140
113
 
141
- ### 3.1 Persistence Models (if applicable)
114
+ ### 3.1 Persistence models (if applicable)
142
115
  - ORM models, Prisma schema, Freezed classes
143
- - Table/collection configuration
144
- - Helper functions for atomic updates
116
+ - Table/collection config
117
+ - Helpers for atomic updates
145
118
 
146
- ### 3.2 Store/API Implementation
119
+ ### 3.2 Store / API implementations
147
120
  - Implements port interfaces from domain
148
- - Compile-time interface check (where language supports it)
121
+ - Compile-time interface check (where supported)
149
122
  - Mapper functions: domain entity ↔ persistence model
150
- - NO business logic — pure persistence/communication
123
+ - NO business logic
151
124
  - Use context consistently
152
125
 
153
- ### Rule Check Phase 3
154
- ```bash
155
- # Build infrastructure layer
156
- {stack_build_command_for_infra}
157
- ```
126
+ ### Gate
127
+ - [ ] Infra build passes
128
+ - [ ] All ports from Phase 2 have an implementation
158
129
 
159
130
  ---
160
131
 
161
- ## PHASE 4: Build Application Layer
132
+ ## Phase 4: APPLICATION LAYER
162
133
 
163
134
  ### 4.1 Service
164
135
  - Thin wrapper delegating to usecases
165
- - Can orchestrate cross-domain calls if needed
136
+ - Can orchestrate cross-domain calls
166
137
 
167
- ### 4.2 Transport/Handler/Controller/Screen
168
- - Registration/wiring function: create store → usecase → service → handler → routes
169
- - Thin handlers: parse input call service → return output
138
+ ### 4.2 Handler / Controller / Screen
139
+ - Wiring function: store → usecase → service → handler → routes
140
+ - Thin: parse → service → respond
170
141
  - DTOs in separate file
171
142
 
172
- ### 4.3 Listeners (if domain has events)
143
+ ### 4.3 Listeners (if domain raises events)
173
144
  - One file per event
174
- - Side-effects only (notifications, SSE, analytics, async jobs)
175
- - Use background context for async work
176
- - Register in event bus/registry
145
+ - Side-effects only (notifications, SSE, analytics, jobs)
146
+ - Background context for async work
147
+ - Register in event bus
177
148
 
178
- ### Rule Check Phase 4
179
- ```bash
180
- # Build application layer
181
- {stack_build_command_for_application}
182
- ```
149
+ ### Gate
150
+ - [ ] App build passes
151
+ - [ ] Every event has a registered listener (if needed)
183
152
 
184
153
  ---
185
154
 
186
- ## PHASE 5: Registration & Wiring
155
+ ## Phase 5: WIRING
187
156
 
188
- ### 5.1 Router/Provider Registration
189
- - Add routes/screens/providers for the new module
190
- - Wire service dependencies between modules if needed
157
+ ### 5.1 Router / Provider
158
+ - Add routes / screens / providers for the new module
159
+ - Wire service dependencies if cross-module
191
160
 
192
- ### 5.2 Persistence Setup
193
- - Add model migrations/schemas
194
- - Run migrations if needed
161
+ ### 5.2 Persistence setup
162
+ - Add migrations / schema files
163
+ - Run migrations on dev DB
195
164
 
196
- ### 5.3 Event Registry
197
- - Register all new event listeners
198
- - Verify event name strings match between events and registry
165
+ ### 5.3 Event registry
166
+ - Register all new listeners
167
+ - Verify event name strings match across event registry
199
168
 
200
- ### Rule Check Phase 5
201
- ```bash
202
- # Full build
203
- {stack_full_build_command}
204
- ```
169
+ ### Gate
170
+ - [ ] Full build passes
171
+ - [ ] Routes / providers registered
172
+ - [ ] Migrations applied locally
205
173
 
206
174
  ---
207
175
 
208
- ## PHASE 6: Domain Tests
176
+ ## Phase 6: TESTS
209
177
 
210
- ### 6.1 Value Object Tests
178
+ ### Value Object tests
211
179
  - All status transitions
212
180
  - Terminal states
213
181
  - Behavior methods
214
182
  - Edge cases
215
183
 
216
- ### 6.2 Entity Tests
184
+ ### Entity tests
217
185
  - Constructor
218
186
  - State transitions
219
- - Event collection after state change
187
+ - Event collection after change
220
188
  - Guard methods
221
- - Edge cases (boundary values)
189
+ - Boundary values
222
190
 
223
- ### 6.3 UseCase Tests
191
+ ### UseCase tests
224
192
  - Mock port interfaces
225
- - Happy path for each method
193
+ - Happy path per method
226
194
  - Validation errors
227
195
  - Business rules
228
196
  - Event dispatching
229
197
 
230
- ### Rule Check Phase 6
231
- ```bash
232
- # Run domain tests
233
- {stack_test_command_for_domain}
234
- ```
198
+ ### Gate
199
+ - [ ] All domain tests pass
200
+ - [ ] Coverage on new code ≥ 80%
235
201
 
236
202
  ---
237
203
 
238
- ## REVIEW LOOP
239
-
240
- After all phases complete, run the architecture review. **Keep looping until ALL checks pass.**
204
+ ## Review Loop
241
205
 
242
206
  ```
243
207
  LOOP:
244
- 1. Run /review:architect {stack} {domain}
245
- 2. Collect violations
246
- 3. IF violations with severity >= MEDIUM:
247
- a. Fix all violations
248
- b. Run build to verify
249
- c. Run tests to verify
250
- d. GOTO 1
251
- 4. IF score >= B:
252
- BREAK → Final Report
208
+ 1. /review:architect {stack} {domain}
209
+ 2. IF violations severity ≥ MEDIUM:
210
+ fix all build tests → GOTO 1
211
+ 3. IF score ≥ B → BREAK
253
212
  ```
254
213
 
255
214
  ---
256
215
 
257
216
  ## Final Report
258
217
 
259
- When review loop passes:
260
-
261
218
  ```markdown
262
219
  ## Feature Complete: {domain}/{feature}
263
220
 
264
- ### Files Created
265
- - List all new files
266
-
267
- ### Files Modified
268
- - List all modified files
221
+ ### Files
222
+ - Created: {N}, Modified: {N}
269
223
 
270
- ### Endpoints/Screens (depending on stack)
271
- | Method/Route | Description |
272
- |-------------|-------------|
224
+ ### Endpoints / Screens
225
+ | Method | Route | Description |
226
+ |--------|-------|-------------|
273
227
 
274
228
  ### Domain Events
275
229
  | Event | Listeners |
276
230
  |-------|-----------|
277
231
 
278
- ### Test Coverage
279
- - X test files, Y test functions
280
- - Areas covered: value objects, entities, usecases
232
+ ### Test coverage
233
+ - {N} test files, {M} cases — value objects + entities + usecases
281
234
 
282
- ### Review Status: ALL CHECKS PASS
283
- - Build: PASS
284
- - Lint: PASS
285
- - Domain purity: PASS
286
- - Tests: PASS (X/X)
287
- - Architecture score: {A/B}
235
+ ### Review score: {A/B}
236
+ - Build / Lint / Domain purity / Tests: all PASS
288
237
  ```
289
238
 
290
239
  ---
291
240
 
241
+ ## Hard Rules
242
+
243
+ - **Read reference module first** — your code should look like the rest of the codebase
244
+ - **User confirms the plan** before any code is written
245
+ - **Phase order is sequential** — don't skip ahead
246
+ - **Domain has zero framework imports** — enforce via grep in Phase 2 gate
247
+ - **Listeners handle side-effects** — never call notifications/SSE/analytics from usecase
248
+ - **Don't merge with score < B** — fix violations or document the waiver
249
+
250
+ ---
251
+
292
252
  ## Related Skills
293
253
 
294
254
  | When | Use |
295
255
  |------|-----|
296
256
  | Don't know approach yet | `/research:web` → then this skill |
297
- | Want to validate approach with prototype first | `/research:spike` → then this skill |
298
- | Adding only an endpoint, not a whole feature | `/feature:api` |
299
- | Restructuring existing module to DDD | `refactor` |
300
- | Final architecture check (called automatically in Phase 7) | `/review:architect` |
301
- | Write tests inline during build | `/review:tdd` |
257
+ | Want to validate by prototyping | `/research:spike` → then this skill |
258
+ | Adding only an endpoint | `/feature:api` |
259
+ | Restructuring existing module | `/feature:refactor` |
260
+ | Architecture check (called automatically in Phase 7) | `/review:architect` |
261
+ | Write tests inline (TDD style) | `/review:tdd` |
302
262
 
303
263
  ## Recommended Agents
304
264
 
305
265
  | Phase | Agent | Purpose |
306
266
  |-------|-------|---------|
307
267
  | PLAN | `@clean-architect` | Architecture design |
308
- | IMPLEMENT | Stack-specific dev agent | Code per architecture |
309
- | IMPLEMENT | `@db-designer` | Database schema |
310
- | IMPLEMENT | `@api-designer` | API design |
268
+ | BUILD | Stack-specific dev agent | Implementation |
269
+ | BUILD | `@db-designer` | Schema if new tables needed |
270
+ | BUILD | `@api-designer` | API surface if exposed |
271
+ | TESTS | `@test-writer` | Domain tests |
311
272
  | REVIEW | `@code-reviewer` | Code quality |
312
273
  | REVIEW | `@security-audit` | Security check |
313
- | TEST | `@test-writer` | Write tests |