moicle 2.0.0 → 2.2.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.
- package/README.md +20 -9
- package/assets/architecture/_shared/severity-levels.md +34 -0
- package/assets/architecture/_shared/stack-detection.md +34 -0
- package/assets/commands/marketing.md +7 -7
- package/assets/skills/docs/sync/SKILL.md +159 -519
- package/assets/skills/docs/write/SKILL.md +89 -186
- package/assets/skills/feature/new/SKILL.md +152 -192
- package/assets/skills/feature/refactor/SKILL.md +152 -233
- package/assets/skills/fix/hotfix/SKILL.md +139 -305
- package/assets/skills/fix/incident/SKILL.md +107 -19
- package/assets/skills/fix/pr-comment/SKILL.md +98 -224
- package/assets/skills/fix/root-cause/SKILL.md +161 -104
- package/assets/skills/{docs → marketing}/content/SKILL.md +4 -4
- package/assets/skills/marketing/logo/SKILL.md +252 -0
- package/assets/skills/marketing/seo-blog/SKILL.md +367 -0
- package/assets/skills/marketing/video/SKILL.md +258 -0
- package/assets/skills/research/onboarding/SKILL.md +127 -510
- package/assets/skills/research/spike/SKILL.md +128 -436
- package/assets/skills/research/web/SKILL.md +124 -83
- package/assets/skills/review/architect/SKILL.md +157 -306
- package/assets/skills/review/branch/SKILL.md +153 -208
- package/assets/skills/review/pr/SKILL.md +129 -519
- package/assets/skills/review/tdd/SKILL.md +108 -69
- package/bin/cli.js +2 -2
- package/dist/commands/install.d.ts.map +1 -1
- package/dist/commands/install.js +176 -8
- package/dist/commands/install.js.map +1 -1
- package/dist/commands/list.d.ts.map +1 -1
- package/dist/commands/list.js +31 -1
- package/dist/commands/list.js.map +1 -1
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/commands/status.js +30 -1
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/uninstall.d.ts.map +1 -1
- package/dist/commands/uninstall.js +64 -8
- package/dist/commands/uninstall.js.map +1 -1
- package/dist/utils/symlink.d.ts +1 -0
- package/dist/utils/symlink.d.ts.map +1 -1
- package/dist/utils/symlink.js +8 -6
- package/dist/utils/symlink.js.map +1 -1
- package/package.json +1 -1
- package/assets/skills/docs/logo/SKILL.md +0 -492
- package/assets/skills/docs/video/SKILL.md +0 -666
|
@@ -6,7 +6,7 @@ args: "[MODULE] [DOMAIN]"
|
|
|
6
6
|
|
|
7
7
|
# DDD Refactor Workflow
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Restructure existing code into DDD layers, or fix drift in an existing DDD module. **Preserves behavior** — refactor structure, never change logic.
|
|
10
10
|
|
|
11
11
|
**ARGUMENTS:** `<module> <domain>` — e.g., `marketing notification`, `users identity`, `products catalog`
|
|
12
12
|
|
|
@@ -16,316 +16,235 @@ Refactor existing code into DDD architecture, or improve existing DDD structure.
|
|
|
16
16
|
- ✅ Existing DDD module has drifted (fat controller, anemic entity, mixed concerns)
|
|
17
17
|
- ✅ Splitting one domain into multiple bounded contexts
|
|
18
18
|
- ❌ Building a brand-new feature → use `/feature:new`
|
|
19
|
-
- ❌ Just renaming files / variables → just do it
|
|
19
|
+
- ❌ Just renaming files / variables → just do it
|
|
20
20
|
- ❌ Fixing a bug → use `/fix:hotfix` or `/fix:root-cause`
|
|
21
21
|
|
|
22
22
|
## Read Architecture First
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
### Stack Detection
|
|
27
|
-
| File | Stack Doc |
|
|
28
|
-
|------|-----------|
|
|
29
|
-
| `go.mod` | `go-backend.md` |
|
|
30
|
-
| `package.json` + NestJS dep | `nodejs-nestjs.md` |
|
|
31
|
-
| `package.json` + `vite.config.*` | `react-frontend.md` |
|
|
32
|
-
| `pubspec.yaml` | `flutter-mobile.md` |
|
|
33
|
-
| `composer.json` | `laravel-backend.md` |
|
|
34
|
-
| `remix.config.*` | `remix-fullstack.md` |
|
|
35
|
-
|
|
36
|
-
Architecture files: `.claude/architecture/{name}.md` (project) → `~/.claude/architecture/{name}.md` (global).
|
|
24
|
+
Detect stack via `~/.claude/architecture/_shared/stack-detection.md`. Load `ddd-architecture.md` + stack doc.
|
|
37
25
|
|
|
38
26
|
---
|
|
39
27
|
|
|
40
28
|
## Workflow
|
|
41
29
|
|
|
42
30
|
```
|
|
43
|
-
|
|
44
|
-
→ PHASE 1: Analyze Current Module
|
|
45
|
-
→ PHASE 2: Build Domain Layer
|
|
46
|
-
→ PHASE 3: Build Infrastructure Layer
|
|
47
|
-
→ PHASE 4: Build Application Layer
|
|
48
|
-
→ PHASE 5: Domain Tests
|
|
49
|
-
→ PHASE 6: Integration & Cleanup
|
|
50
|
-
→ REVIEW LOOP (run /review:architect, fix, repeat until clean)
|
|
31
|
+
0 FOUNDATION → 1 ANALYZE → 2 DOMAIN → 3 INFRA → 4 APP → 5 TESTS → 6 CLEANUP → REVIEW LOOP
|
|
51
32
|
```
|
|
52
33
|
|
|
53
|
-
Each phase has a Rule Check.
|
|
34
|
+
Each phase has a Rule Check. Do not skip any phase.
|
|
54
35
|
|
|
55
36
|
---
|
|
56
37
|
|
|
57
|
-
##
|
|
38
|
+
## Phase 0: FOUNDATION
|
|
58
39
|
|
|
59
|
-
|
|
40
|
+
**New project (no `domain/` yet):** create
|
|
41
|
+
- `domain/shared/` — base event types, event collector, dispatcher interface
|
|
42
|
+
- Event bus infrastructure
|
|
43
|
+
- App bootstrap/config struct
|
|
60
44
|
|
|
61
|
-
|
|
62
|
-
Create shared foundation:
|
|
63
|
-
- `domain/shared/` — base event types, event collector, event dispatcher interface
|
|
64
|
-
- Event bus / dispatcher infrastructure
|
|
65
|
-
- Bootstrap/app config struct
|
|
66
|
-
|
|
67
|
-
### For existing DDD projects
|
|
68
|
-
Verify foundation is intact:
|
|
45
|
+
**Existing project:** verify
|
|
69
46
|
```bash
|
|
70
|
-
|
|
71
|
-
ls {
|
|
72
|
-
|
|
73
|
-
# Check event infrastructure exists (if applicable)
|
|
74
|
-
ls {eventbus_path}/ 2>/dev/null && echo "PASS" || echo "NEED SETUP"
|
|
47
|
+
ls {domain_root}/shared/ 2>/dev/null && echo PASS || echo NEED SETUP
|
|
48
|
+
ls {eventbus_path}/ 2>/dev/null && echo PASS || echo NEED SETUP
|
|
75
49
|
```
|
|
76
50
|
|
|
77
|
-
If
|
|
51
|
+
If FAIL → set up foundation before continuing.
|
|
52
|
+
|
|
53
|
+
### Gate
|
|
54
|
+
- [ ] Shared domain types exist
|
|
55
|
+
- [ ] Event infrastructure exists (if domain raises events)
|
|
78
56
|
|
|
79
57
|
---
|
|
80
58
|
|
|
81
|
-
##
|
|
59
|
+
## Phase 1: ANALYZE
|
|
82
60
|
|
|
83
|
-
|
|
61
|
+
**Goal:** read ALL source files in the old module before touching anything.
|
|
84
62
|
|
|
85
|
-
###
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
63
|
+
### Read
|
|
64
|
+
- All files in the module dir
|
|
65
|
+
- Related models / types / enums
|
|
66
|
+
- Routes / providers / screens for this module
|
|
67
|
+
- Existing tests (CRITICAL — used in Phase 5)
|
|
90
68
|
|
|
91
|
-
### Output
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
-
|
|
97
|
-
-
|
|
98
|
-
-
|
|
99
|
-
-
|
|
69
|
+
### Output to user
|
|
70
|
+
```markdown
|
|
71
|
+
## Refactor Plan: {module} → {domain}
|
|
72
|
+
|
|
73
|
+
### Current state
|
|
74
|
+
- Entities/models: {list with fields}
|
|
75
|
+
- Usecases (functions): {list with 1-line logic summary}
|
|
76
|
+
- DTOs: {list}
|
|
77
|
+
- Cross-module calls: {list}
|
|
78
|
+
- Side-effects: {notifications / SSE / analytics / async jobs}
|
|
79
|
+
- External deps: {DB, cache, messaging}
|
|
80
|
+
- Endpoints/screens: {list with method + path}
|
|
81
|
+
- Test files: {list with case counts}
|
|
82
|
+
|
|
83
|
+
### Proposed DDD structure
|
|
84
|
+
- Value objects to extract: {list}
|
|
85
|
+
- Entities: {list}
|
|
86
|
+
- Events: {list}
|
|
87
|
+
- Ports: {list}
|
|
88
|
+
- Usecases: {list}
|
|
89
|
+
- Listeners: {list}
|
|
90
|
+
```
|
|
100
91
|
|
|
101
|
-
###
|
|
102
|
-
- [ ] All module files read
|
|
103
|
-
- [ ]
|
|
104
|
-
- [ ]
|
|
92
|
+
### Gate
|
|
93
|
+
- [ ] All module files read
|
|
94
|
+
- [ ] Plan presented to user
|
|
95
|
+
- [ ] **User CONFIRMED** before continuing
|
|
105
96
|
|
|
106
97
|
---
|
|
107
98
|
|
|
108
|
-
##
|
|
109
|
-
|
|
110
|
-
Create `domain/{domain}/` (
|
|
111
|
-
|
|
112
|
-
### 2.1 Value Objects (`valueobjects/`)
|
|
113
|
-
- Extract typed values from existing code (status strings, rates, amounts)
|
|
114
|
-
- Immutable with behavior methods
|
|
115
|
-
- **Only stdlib imports** — check Forbidden Imports from architecture doc
|
|
116
|
-
|
|
117
|
-
### 2.2 Entities (`entities/`)
|
|
118
|
-
- Convert existing model fields to domain entity
|
|
119
|
-
- Add constructor function/method
|
|
120
|
-
- Add behavior methods (state transitions, calculations)
|
|
121
|
-
- Add event collection (collect events on state changes)
|
|
122
|
-
- Add mappers to/from persistence models (if applicable)
|
|
123
|
-
- **No framework imports**
|
|
124
|
-
|
|
125
|
-
### 2.3 Events (`events/`)
|
|
126
|
-
- One file per domain event
|
|
127
|
-
- Extend/embed base event type
|
|
128
|
-
- Carry data needed by listeners
|
|
129
|
-
- Extract from existing direct side-effect calls (SSE, notifications, etc.)
|
|
130
|
-
|
|
131
|
-
### 2.4 Ports (`ports/`)
|
|
132
|
-
- One file per port interface
|
|
133
|
-
- Store ports: persistence interface from existing repository/DB calls
|
|
134
|
-
- Adapter ports: external service interfaces
|
|
135
|
-
- Platform-agnostic naming
|
|
136
|
-
- **No infrastructure imports**
|
|
137
|
-
|
|
138
|
-
### 2.5 UseCases (`usecases/`)
|
|
139
|
-
- Extract business logic from existing controllers/handlers/services
|
|
140
|
-
- Import port interfaces from `ports/`
|
|
141
|
-
- Split by concern: one file per action group
|
|
142
|
-
- Business logic lives HERE
|
|
143
|
-
- **No infrastructure imports**
|
|
144
|
-
|
|
145
|
-
### Rule Check Phase 2
|
|
146
|
-
Run check scripts from architecture doc:
|
|
147
|
-
```bash
|
|
148
|
-
# Build domain layer
|
|
149
|
-
{stack_build_command_for_domain}
|
|
99
|
+
## Phase 2: DOMAIN LAYER
|
|
100
|
+
|
|
101
|
+
Create `domain/{domain}/` (or add to existing).
|
|
150
102
|
|
|
151
|
-
|
|
152
|
-
{grep_forbidden_imports_in_domain} && echo "FAIL" || echo "PASS"
|
|
103
|
+
### Order: VO → entities → events → ports → usecases
|
|
153
104
|
|
|
154
|
-
|
|
155
|
-
|
|
105
|
+
- **Value Objects** (`valueobjects/`) — extract typed values (status strings, rates, amounts). Immutable + behavior methods. Stdlib imports only.
|
|
106
|
+
- **Entities** (`entities/`) — convert old models. Constructor + behavior methods + event collection. Add mappers to/from persistence. No framework imports.
|
|
107
|
+
- **Events** (`events/`) — one file per event. Extract from existing direct side-effect calls.
|
|
108
|
+
- **Ports** (`ports/`) — one file per interface. Store ports (persistence), adapter ports (external services). Platform-agnostic naming (`URLParser` not `ShopeeURLParser`). No infra imports.
|
|
109
|
+
- **UseCases** (`usecases/`) — extract business logic from old controllers/handlers/services. Import from `ports/`. Split by concern, ≤200 lines/file. No infra imports.
|
|
110
|
+
|
|
111
|
+
### Gate
|
|
112
|
+
```bash
|
|
113
|
+
{build_domain} && echo PASS || echo FAIL
|
|
114
|
+
{grep_forbidden in domain/} && echo FAIL || echo PASS
|
|
115
|
+
{cross_domain_check} && echo FAIL || echo PASS
|
|
156
116
|
```
|
|
157
117
|
|
|
158
118
|
---
|
|
159
119
|
|
|
160
|
-
##
|
|
120
|
+
## Phase 3: INFRASTRUCTURE LAYER
|
|
161
121
|
|
|
162
|
-
|
|
163
|
-
-
|
|
164
|
-
-
|
|
165
|
-
-
|
|
166
|
-
-
|
|
167
|
-
- Keep existing persistence models where they are
|
|
122
|
+
- Implement port interfaces from `domain/{domain}/ports/`
|
|
123
|
+
- Mapper functions: domain entity ↔ persistence model
|
|
124
|
+
- Compile-time interface check (where supported)
|
|
125
|
+
- NO business logic
|
|
126
|
+
- Keep existing persistence models in place
|
|
168
127
|
|
|
169
|
-
###
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
{stack_build_command_for_infra}
|
|
173
|
-
```
|
|
128
|
+
### Gate
|
|
129
|
+
- [ ] Infra build passes
|
|
130
|
+
- [ ] All port interfaces implemented
|
|
174
131
|
|
|
175
132
|
---
|
|
176
133
|
|
|
177
|
-
##
|
|
134
|
+
## Phase 4: APPLICATION LAYER
|
|
135
|
+
|
|
136
|
+
### 4.1 Listeners (extract side-effects)
|
|
137
|
+
**CRITICAL:** Side-effects (notifications, SSE, analytics, jobs) **MUST NOT** be called directly in usecases or infra. Flow must be: entity collects event → usecase dispatches → listener handles.
|
|
178
138
|
|
|
179
|
-
### 4.1 Listeners (extract from existing side-effects)
|
|
180
|
-
- **CRITICAL:** Side-effects (notifications, SSE, analytics, async jobs) MUST NOT be called directly in usecases or infrastructure
|
|
181
|
-
- They MUST flow through: entity collects events → usecase dispatches → listener handles
|
|
182
139
|
- One file per event listener
|
|
183
|
-
- Register in event bus
|
|
140
|
+
- Register in event bus
|
|
184
141
|
|
|
185
142
|
### 4.2 Service
|
|
186
|
-
- Thin wrapper
|
|
187
|
-
- NO business logic
|
|
143
|
+
- Thin wrapper, delegates to usecases. No business logic.
|
|
188
144
|
|
|
189
|
-
### 4.3 Handler/Controller/Screen
|
|
190
|
-
- Registration/wiring function
|
|
191
|
-
- Thin: parse
|
|
145
|
+
### 4.3 Handler / Controller / Screen
|
|
146
|
+
- Registration / wiring function
|
|
147
|
+
- Thin: parse → service → return
|
|
192
148
|
- DTOs in separate file
|
|
193
|
-
- All endpoints
|
|
149
|
+
- **All endpoints must match the old paths + methods**
|
|
194
150
|
|
|
195
|
-
###
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
{stack_build_command_for_application}
|
|
199
|
-
```
|
|
151
|
+
### Gate
|
|
152
|
+
- [ ] App build passes
|
|
153
|
+
- [ ] Every old endpoint has a new handler at the same path
|
|
200
154
|
|
|
201
155
|
---
|
|
202
156
|
|
|
203
|
-
##
|
|
157
|
+
## Phase 5: TESTS
|
|
204
158
|
|
|
205
|
-
**CRITICAL:**
|
|
159
|
+
**CRITICAL:** read old tests first, copy every scenario. Do not lose coverage.
|
|
206
160
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
3. Write domain tests covering all those scenarios
|
|
211
|
-
4. Focus on business logic (pure unit tests, no integration needed yet)
|
|
161
|
+
1. Read all old test files
|
|
162
|
+
2. List all test cases + business scenarios
|
|
163
|
+
3. Write domain tests covering all of them
|
|
212
164
|
|
|
213
|
-
###
|
|
214
|
-
-
|
|
215
|
-
-
|
|
216
|
-
-
|
|
217
|
-
- NO mocking needed — pure tests
|
|
165
|
+
### What to test
|
|
166
|
+
- **Entities** — behavior methods, edge cases, business rules (pure, no mocks)
|
|
167
|
+
- **UseCases** — happy + error paths, validation, event collection (mock ports)
|
|
168
|
+
- **Value Objects** — transitions, calculations, edge cases (pure)
|
|
218
169
|
|
|
219
|
-
###
|
|
220
|
-
-
|
|
221
|
-
-
|
|
222
|
-
-
|
|
223
|
-
- Domain event collection (if applicable)
|
|
224
|
-
|
|
225
|
-
### Rule Check Phase 5
|
|
226
|
-
```bash
|
|
227
|
-
# Run domain tests
|
|
228
|
-
{stack_test_command_for_domain}
|
|
229
|
-
```
|
|
170
|
+
### Gate
|
|
171
|
+
- [ ] Old test count ≤ new test count
|
|
172
|
+
- [ ] Every old scenario covered
|
|
173
|
+
- [ ] `{test_command}` passes
|
|
230
174
|
|
|
231
175
|
---
|
|
232
176
|
|
|
233
|
-
##
|
|
177
|
+
## Phase 6: INTEGRATION & CLEANUP
|
|
234
178
|
|
|
235
|
-
### 6.1
|
|
236
|
-
- Add
|
|
237
|
-
- Remove old module
|
|
238
|
-
-
|
|
179
|
+
### 6.1 Wire up the new module
|
|
180
|
+
- Add registration calls in router / provider / registry
|
|
181
|
+
- Remove old module registrations
|
|
182
|
+
- Endpoints/screens match old paths
|
|
239
183
|
|
|
240
|
-
### 6.2 Remove
|
|
241
|
-
- Delete old
|
|
242
|
-
-
|
|
184
|
+
### 6.2 Remove old module
|
|
185
|
+
- Delete old directory **only after** build + tests pass
|
|
186
|
+
- Do NOT delete shared models/types other modules still use
|
|
243
187
|
|
|
244
|
-
###
|
|
188
|
+
### Gate
|
|
245
189
|
```bash
|
|
246
|
-
|
|
247
|
-
{
|
|
248
|
-
|
|
249
|
-
# Verify old module removed
|
|
250
|
-
test -d {old_module_path} && echo "FAIL: old module exists" || echo "PASS"
|
|
251
|
-
|
|
252
|
-
# Verify no old imports remain
|
|
253
|
-
grep -r "{old_module_import}" --include="*.{ext}" . && echo "FAIL: old imports" || echo "PASS"
|
|
190
|
+
{full_build} && echo PASS || echo FAIL
|
|
191
|
+
test -d {old_module_path} && echo "FAIL: still there" || echo PASS
|
|
192
|
+
grep -r "{old_import_path}" --include="*.{ext}" . && echo "FAIL: stale imports" || echo PASS
|
|
254
193
|
```
|
|
255
194
|
|
|
256
195
|
---
|
|
257
196
|
|
|
258
|
-
##
|
|
197
|
+
## Review Loop
|
|
259
198
|
|
|
260
|
-
After
|
|
199
|
+
After Phase 6, call `/review:architect {stack} {domain}`. Loop until score ≥ B.
|
|
261
200
|
|
|
262
201
|
```
|
|
263
202
|
LOOP:
|
|
264
|
-
1.
|
|
265
|
-
2.
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
b. Run full build to verify
|
|
269
|
-
c. Run all tests to verify
|
|
270
|
-
d. GOTO 1
|
|
271
|
-
4. IF score >= B:
|
|
272
|
-
BREAK → Final Report
|
|
203
|
+
1. /review:architect {stack} {domain}
|
|
204
|
+
2. IF violations severity ≥ MEDIUM:
|
|
205
|
+
fix all → full build → all tests → GOTO 1
|
|
206
|
+
3. IF score ≥ B → BREAK
|
|
273
207
|
```
|
|
274
208
|
|
|
275
209
|
---
|
|
276
210
|
|
|
277
211
|
## Final Report
|
|
278
212
|
|
|
279
|
-
When review loop passes with score >= B:
|
|
280
|
-
|
|
281
213
|
```markdown
|
|
282
214
|
## Refactor Complete: {module} → {domain}
|
|
283
215
|
|
|
284
|
-
###
|
|
285
|
-
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
###
|
|
294
|
-
|
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
- X test files, Y test functions
|
|
304
|
-
- All old test cases migrated: YES
|
|
305
|
-
- Areas covered: value objects, entities, usecases
|
|
306
|
-
|
|
307
|
-
### Review Status: ALL CHECKS PASS
|
|
308
|
-
- Build: PASS
|
|
309
|
-
- Lint: PASS
|
|
310
|
-
- Domain purity: PASS
|
|
311
|
-
- Old module removed: PASS
|
|
312
|
-
- No old imports: PASS
|
|
313
|
-
- Tests: PASS (X/X)
|
|
314
|
-
- Architecture score: {A/B}
|
|
216
|
+
### Changes
|
|
217
|
+
- Files created: {N}
|
|
218
|
+
- Files modified: {N}
|
|
219
|
+
- Files deleted: {N}
|
|
220
|
+
|
|
221
|
+
### Endpoints preserved
|
|
222
|
+
| Old path | New handler | Status |
|
|
223
|
+
|----------|-------------|--------|
|
|
224
|
+
|
|
225
|
+
### Domain events introduced
|
|
226
|
+
| Event | Listener(s) |
|
|
227
|
+
|-------|-------------|
|
|
228
|
+
|
|
229
|
+
### Tests
|
|
230
|
+
- Files: {N}, cases: {M}
|
|
231
|
+
- All old scenarios migrated: YES
|
|
232
|
+
|
|
233
|
+
### Review score: {A/B}
|
|
234
|
+
- Build / Lint / Domain purity / Old module removed / No stale imports / Tests: all PASS
|
|
315
235
|
```
|
|
316
236
|
|
|
317
237
|
---
|
|
318
238
|
|
|
319
|
-
##
|
|
239
|
+
## Hard Rules
|
|
320
240
|
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
8. After completing a module, ask user if they want to refactor the next module
|
|
241
|
+
- **Preserve behavior** — never change business logic during refactor
|
|
242
|
+
- **MUST read old tests** before writing new ones (no scenario lost)
|
|
243
|
+
- **MUST read old code** carefully — don't invent logic from variable names
|
|
244
|
+
- **All endpoints keep their paths** — refactor is invisible to clients
|
|
245
|
+
- **Don't skip phases** — Rule Checks gate the next phase
|
|
246
|
+
- **Multiple modules → same domain:** first module creates the domain dir, others add to it
|
|
247
|
+
- **One module at a time** — finish one before starting the next
|
|
329
248
|
|
|
330
249
|
---
|
|
331
250
|
|
|
@@ -334,17 +253,17 @@ When review loop passes with score >= B:
|
|
|
334
253
|
| When | Use |
|
|
335
254
|
|------|-----|
|
|
336
255
|
| Building from scratch (no existing code) | `/feature:new` |
|
|
337
|
-
| Just adding tests to
|
|
256
|
+
| Just adding tests to untested code | `/review:tdd` |
|
|
338
257
|
| Reviewing the refactor before merging | `/review:branch` |
|
|
339
|
-
| Final architecture
|
|
258
|
+
| Final architecture check (called automatically in review loop) | `/review:architect` |
|
|
340
259
|
|
|
341
260
|
## Recommended Agents
|
|
342
261
|
|
|
343
262
|
| Phase | Agent | Purpose |
|
|
344
263
|
|-------|-------|---------|
|
|
345
|
-
| ANALYZE | `@refactor` | Identify
|
|
346
|
-
| ANALYZE | `@code-reviewer` |
|
|
264
|
+
| ANALYZE | `@refactor` | Identify refactor scope |
|
|
265
|
+
| ANALYZE | `@code-reviewer` | Smell detection |
|
|
347
266
|
| PLAN | `@clean-architect` | Architecture alignment |
|
|
348
|
-
|
|
|
349
|
-
|
|
|
267
|
+
| BUILD | Stack-specific dev agent | Implementation |
|
|
268
|
+
| TESTS | `@test-writer` | Domain tests |
|
|
350
269
|
| REVIEW | `@code-reviewer` | Final quality check |
|