dflow-sdd-ddd 0.9.0 → 0.11.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.
Files changed (57) hide show
  1. package/CHANGELOG.md +96 -0
  2. package/README.en.md +73 -48
  3. package/README.md +46 -36
  4. package/TEMPLATE-COVERAGE.md +0 -1
  5. package/TEMPLATE-LANGUAGE-GLOSSARY.md +1 -0
  6. package/bin/dflow.js +7 -11
  7. package/docs/evaluating-dflow.en.md +11 -7
  8. package/docs/evaluating-dflow.md +9 -4
  9. package/docs/using-with-claude-code.en.md +40 -23
  10. package/docs/using-with-claude-code.md +34 -23
  11. package/docs/using-with-codex.en.md +125 -42
  12. package/docs/using-with-codex.md +93 -34
  13. package/docs/using-with-github-copilot.en.md +135 -34
  14. package/docs/using-with-github-copilot.md +120 -43
  15. package/docs/why-dflow.en.md +72 -0
  16. package/docs/why-dflow.md +72 -0
  17. package/lib/init.js +867 -214
  18. package/package.json +2 -2
  19. package/templates/brownfield/references/drift-verification.md +41 -10
  20. package/templates/brownfield/references/finish-feature-flow.md +3 -2
  21. package/templates/brownfield/references/git-integration.md +0 -1
  22. package/templates/brownfield/references/init-project-flow.md +31 -17
  23. package/templates/brownfield/references/modify-existing-flow.md +44 -38
  24. package/templates/brownfield/references/new-feature-flow.md +41 -11
  25. package/templates/brownfield/references/new-phase-flow.md +9 -2
  26. package/templates/brownfield/references/pr-review-checklist.md +7 -1
  27. package/templates/brownfield/scaffolding/AI-AGENT-GUIDE.md +258 -29
  28. package/templates/brownfield/scaffolding/CLAUDE-md-snippet.md +5 -8
  29. package/templates/brownfield/scaffolding/_conventions.md +10 -9
  30. package/templates/brownfield/templates/_index.md +1 -1
  31. package/templates/brownfield/templates/context-map.md +12 -4
  32. package/templates/brownfield/templates/lightweight-spec.md +1 -1
  33. package/templates/brownfield/templates/phase-spec.md +1 -1
  34. package/templates/common/references/ddd-modeling-guide.md +643 -0
  35. package/templates/common/skill/SKILL.md +9 -6
  36. package/templates/greenfield/references/drift-verification.md +60 -15
  37. package/templates/greenfield/references/finish-feature-flow.md +3 -2
  38. package/templates/greenfield/references/git-integration.md +0 -1
  39. package/templates/greenfield/references/init-project-flow.md +31 -17
  40. package/templates/greenfield/references/modify-existing-flow.md +5 -7
  41. package/templates/greenfield/references/new-feature-flow.md +49 -19
  42. package/templates/greenfield/references/new-phase-flow.md +5 -2
  43. package/templates/greenfield/references/pr-review-checklist.md +9 -1
  44. package/templates/greenfield/scaffolding/AI-AGENT-GUIDE.md +221 -29
  45. package/templates/greenfield/scaffolding/CLAUDE-md-snippet.md +10 -15
  46. package/templates/greenfield/scaffolding/Git-principles-trunk.md +1 -1
  47. package/templates/greenfield/scaffolding/_conventions.md +9 -8
  48. package/templates/greenfield/templates/_index.md +1 -1
  49. package/templates/greenfield/templates/aggregate-design.md +6 -0
  50. package/templates/greenfield/templates/context-map.md +13 -4
  51. package/templates/greenfield/templates/events.md +4 -1
  52. package/templates/greenfield/templates/lightweight-spec.md +1 -1
  53. package/templates/greenfield/templates/phase-spec.md +1 -1
  54. package/docs/migrating-to-dflow-v1.md +0 -230
  55. package/templates/brownfield/templates/CLAUDE.md +0 -165
  56. package/templates/greenfield/references/ddd-modeling-guide.md +0 -351
  57. package/templates/greenfield/templates/CLAUDE.md +0 -172
@@ -4,18 +4,24 @@ Triggered by `/dflow:verify` or `/dflow:verify <bounded-context>`.
4
4
 
5
5
  ## Purpose
6
6
 
7
- The A+C structure (`rules.md` as index + `behavior.md` as scenario content) introduces a drift risk — the two files can fall out of sync. This command provides a mechanical verification safety net that developers can run at key moments: before a PR, after a refactor, or when onboarding to an unfamiliar Bounded Context.
7
+ The A+C structure (`rules.md` as index + `behavior.md` as scenario content) introduces a drift risk — the two files can fall out of sync. This command's **core** is a mechanical safety net for that `rules.md` ↔ `behavior.md` correspondence, run at key moments: before a PR, after a refactor, or when onboarding to an unfamiliar Bounded Context. On top of the core it also runs **optional, non-blocking domain-doc hygiene checks** on the BC's other docs (`events.md`, `models.md`) — see Scope.
8
8
 
9
9
  ## Scope
10
10
 
11
- ### This command does (mechanical layer)
11
+ ### This command does (core + optional hygiene)
12
12
 
13
- Three string-matching checks that AI can perform deterministically:
13
+ A small **core** of three deterministic string-matching checks on the
14
+ `rules.md` ↔ `behavior.md` correspondence:
14
15
 
15
16
  1. **BR-ID forward check**: Every `BR-*` declared in `rules.md` has a corresponding section in `behavior.md`
16
17
  2. **Anchor validity**: If `rules.md` links to `behavior.md#section`, that anchor exists
17
18
  3. **BR-ID reverse check**: Every `BR-*` referenced in `behavior.md` is declared in `rules.md`
18
19
 
20
+ Plus **optional domain-doc hygiene** warnings (non-blocking — they never fail the
21
+ command, only surface "confirm this is intentional" signals): the `events.md`
22
+ cross-check (forward + reverse, see Core-Specific Notes) and the `models.md`
23
+ Code-Mapping hygiene check (see Model Catalog Notes).
24
+
19
25
  ### This command does NOT do (semantic layer — explicitly excluded)
20
26
 
21
27
  Semantic verification (LLM reads the one-line summary in `rules.md` vs the Given/When/Then in `behavior.md` and judges whether they contradict) is **out of scope**. Reasons:
@@ -40,9 +46,9 @@ Reasons:
40
46
  - BC-level current state is already maintained by `rules.md` /
41
47
  `behavior.md` / `events.md`, written by the same
42
48
  `/dflow:finish-feature` Step 3
43
- - `/dflow:verify` keeps a small, mechanical scope: just the
44
- `rules.md` ↔ `behavior.md` correspondence inside one BC, plus the
45
- events.md bonus check below
49
+ - `/dflow:verify` keeps a small core: the `rules.md` ↔ `behavior.md`
50
+ correspondence inside one BC, plus the optional domain-doc hygiene
51
+ checks below (events.md, models.md)
46
52
  - Cross-feature / cross-phase aggregation would mix `/dflow:verify`'s
47
53
  job with `/dflow:finish-feature`'s job and produce false positives
48
54
  during in-progress features
@@ -86,6 +92,10 @@ For each Bounded Context:
86
92
  - behavior.md → templates/behavior.md
87
93
  Or run the completion flow to populate it from existing completed specs
88
94
  ```
95
+ - Also locate the **optional** hygiene inputs for this BC — `events.md` and
96
+ `models.md`. They feed the non-blocking hygiene checks (Core-Specific Notes /
97
+ Model Catalog Notes). If either is absent, **skip its hygiene check silently** —
98
+ do not report or stop; they are bonus, not part of the core.
89
99
 
90
100
  ### Step 2: Extract BR-IDs from rules.md
91
101
 
@@ -155,15 +165,52 @@ Issues:
155
165
  remove the stale scenario reference from behavior.md
156
166
  ```
157
167
 
168
+ The optional domain-doc hygiene checks (below) append their non-blocking signals
169
+ to this same report — the `events.md` cross-check as `⚠`, the `models.md`
170
+ Code-Mapping check as `ℹ` — and never change the core pass / fail count.
171
+
158
172
  ## Core-Specific Notes
159
173
 
160
- When verifying a Core context, also check:
161
- - `events.md` references in `behavior.md`: if a scenario says "And {DomainEvent} is raised", confirm the event is listed in `events.md`
162
- - This is a **bonus check**, not a blocking failure — report as a warning:
174
+ When verifying a Core context, also run the `events.md` cross-check — **both
175
+ directions, bonus only** (warnings, never a blocking failure):
176
+
177
+ - **Forward** — `events.md` referenced from `behavior.md`: if a scenario says
178
+ "And {DomainEvent} is raised", confirm the event is listed in `events.md`:
163
179
  ```
164
180
  ⚠ BR-001 scenario references ExpenseReportSubmitted event,
165
181
  but events.md does not list it
166
182
  ```
183
+ - **Reverse** — an `events.md` event with no scenario: for each Event Catalog row
184
+ that is **locally produced** (Producer is this BC's Aggregate / Application
185
+ Service) **and business-significant**, confirm at least one `behavior.md`
186
+ scenario references it; warn if none:
187
+ ```
188
+ ⚠ events.md lists OrderCancelled (produced by Order) but no behavior.md
189
+ scenario references it — confirm intentional (orphan / not yet specced)
190
+ ```
191
+ Exclude (else noisy): the `{EventName}` seed row, and best-effort side-effect
192
+ events (notification / logging) that the modeling guide lets live in
193
+ `events.md` / tech-debt without a BR. The reverse check is deterministic name
194
+ matching **plus** this applicability judgment — not a pure string match.
195
+
196
+ ## Model Catalog Notes
197
+
198
+ A non-blocking **informational** hygiene check on `models.md`:
199
+
200
+ - For each row whose **primary name cell** holds a real value, if the
201
+ `Code Mapping` column is empty or still a `{Namespace.Class}` placeholder,
202
+ surface it:
203
+ ```
204
+ ℹ models.md: Entity "ExpenseReport" has no Code Mapping yet — link it if the
205
+ code exists; if it is deliberately deferred, this is expected
206
+ ```
207
+ - **Skip untouched seed rows by the name cell only**: a row whose name is still a
208
+ `{...}` placeholder is seed scaffolding. But a row with a **real name** and a
209
+ placeholder / empty Code Mapping is exactly the one to surface — do not skip it
210
+ just because that one cell still holds `{...}`.
211
+ - This is **informational, not drift** — a recorded model with no Code Mapping is a
212
+ normal state before the code is written. An explicit "planned / deferred" note on
213
+ the row counts as accounted for; do not surface it.
167
214
 
168
215
  ## When to Run
169
216
 
@@ -178,12 +225,10 @@ Recommended trigger points (not enforced — developer's judgment):
178
225
  ## Path Assumptions
179
226
 
180
227
  This command operates entirely within `dflow/specs/domain/{context}/` files
181
- (`rules.md`, `behavior.md`, and the `events.md` bonus check). It does
182
- **not** read from `dflow/specs/features/active/{SPEC-ID}-{slug}/` directories
183
- — the feature directory layout is not part of verify's input. The only effect of feature directory layout on this
184
- command is ensuring `last-updated` dates in `behavior.md` are bumped at
185
- `/dflow:finish-feature` time (so verify's mechanical drift guard stays
186
- useful).
228
+ (`rules.md` and `behavior.md` for the core check; `events.md` and `models.md`
229
+ for the optional hygiene warnings). It does **not** read from
230
+ `dflow/specs/features/active/{SPEC-ID}-{slug}/` directories — the feature
231
+ directory layout is not part of verify's input.
187
232
 
188
233
  ## Interaction with Other Commands
189
234
 
@@ -35,7 +35,7 @@ state, archives the feature directory, and emits a Git-strategy-neutral
35
35
  - Step 5 → Step 6 (Integration Summary emitted → optional follow-up reverse-link)
36
36
 
37
37
  All other step transitions are **step-internal**: announce "Step N complete,
38
- entering Step N+1" and proceed without waiting. See SKILL.md § Workflow
38
+ entering Step N+1" and proceed without waiting. See AI-AGENT-GUIDE.md § Workflow
39
39
  Transparency for the full transparency protocol and confirmation signals.
40
40
 
41
41
  ## Step 1: Validate Phase Specs and `_index.md`
@@ -127,6 +127,8 @@ For each row in Current BR Snapshot where Status = `active`:
127
127
  `rules.md` (REMOVED rule)
128
128
  - For any RENAMED BR-ID → rename the BR-ID in `rules.md` and update
129
129
  `glossary.md` if the term itself changed
130
+ - For every BR-ID added, modified, or renamed above, set its `Last updated`
131
+ date in `rules.md`'s Rule Index to today
130
132
 
131
133
  For `behavior.md`:
132
134
 
@@ -136,7 +138,6 @@ For `behavior.md`:
136
138
  transitions and Domain Events as appropriate
137
139
  - For REMOVED BR-IDs, delete the corresponding scenario section from
138
140
  `behavior.md`
139
- - Update the BR-ID anchor's `last-updated` date in `behavior.md` to today
140
141
 
141
142
  For `events.md`:
142
143
  - Add any new Domain Events introduced by phase-specs in this feature
@@ -182,7 +182,6 @@ diff. That breaks:
182
182
  - `git blame` on lines that crossed the rename boundary
183
183
  - PR diff quality (reviewers see two unrelated big-blob changes
184
184
  instead of one rename + small content diff)
185
- - `/dflow:verify` and other tools that walk feature history
186
185
 
187
186
  This is a known weakness of OpenSpec's directory-rename pattern; Dflow
188
187
  deliberately avoids it by mandating `git mv`.
@@ -54,8 +54,8 @@ Report findings plainly:
54
54
  > - `src/`: contains `MyApp.Domain`, `MyApp.Application`,
55
55
  > `MyApp.Infrastructure`, `MyApp.WebAPI` → Clean Architecture layout
56
56
  > detected
57
- > - `CLAUDE.md`: present → will not overwrite; I'll offer a snippet
58
- > to merge into it"
57
+ > - `CLAUDE.md`: present → I'll append a marked Dflow block (shown in
58
+ > the preview); a merge snippet only if there's a marker conflict"
59
59
 
60
60
  Or:
61
61
 
@@ -173,9 +173,10 @@ Wait for answers.
173
173
  >
174
174
  > If you select any agent, Dflow will create
175
175
  > `dflow/specs/shared/AI-AGENT-GUIDE.md` as the canonical guide. Root-level
176
- > tool files stay thin and point back to that guide. Existing tool files are
177
- > never overwritten; Dflow writes merge snippets under `dflow/specs/shared/`
178
- > instead."
176
+ > tool files stay thin and point back to that guide. Existing user content is
177
+ > never overwritten; Dflow appends a marked Dflow block (shown in the preview)
178
+ > and refreshes it in place on re-run. Merge snippets under
179
+ > `dflow/specs/shared/` are used only if Dflow markers conflict."
179
180
 
180
181
  **→ Transition (step-internal)**: Step 2 complete. Announce
181
182
  > "Step 2 complete (project information captured). Entering Step 3:
@@ -246,16 +247,17 @@ vendored workflow bundle). Compute the destination path:
246
247
  | `scaffolding/Git-principles-trunk.md` | `dflow/specs/shared/Git-principles-trunk.md` |
247
248
  | `scaffolding/AI-AGENT-GUIDE.md` | `dflow/specs/shared/AI-AGENT-GUIDE.md` when at least one AI agent is selected |
248
249
  | generated tool shim | `AGENTS.md`, `CLAUDE.md`, or `.github/copilot-instructions.md` when selected and missing |
249
- | generated merge snippet | `dflow/specs/shared/*-snippet.md` when the selected tool file already exists |
250
+ | marked Dflow block | appended to a selected existing tool file unless it already points to `AI-AGENT-GUIDE.md`; refreshed in place on re-run |
251
+ | fallback merge snippet | `dflow/specs/shared/*-snippet.md` only when the selected tool file has conflicting or malformed Dflow markers |
250
252
 
251
253
  ### 3.3 Present the preview
252
254
 
253
- Present the complete file list as two tables, separating create vs
255
+ Present the complete file list as two tables, separating create / update vs
254
256
  skip, and wait for developer confirmation:
255
257
 
256
258
  > "Based on Step 1 inventory + Step 2 answers, here is what I'll do:
257
259
  >
258
- > **Will create ({N} files):**
260
+ > **Will create / update ({N} files):**
259
261
  >
260
262
  > | Path | Source |
261
263
  > |---|---|
@@ -270,7 +272,7 @@ skip, and wait for developer confirmation:
270
272
  > | `dflow/specs/shared/_overview.md` | optional (you picked it) |
271
273
  > | `dflow/specs/shared/Git-principles-trunk.md` | mandatory (selected Git policy) |
272
274
  > | `dflow/specs/shared/AI-AGENT-GUIDE.md` | selected AI agent guide |
273
- > | `CLAUDE.md` | selected tool shim because repo has no CLAUDE.md |
275
+ > | `CLAUDE.md` | marked Dflow block appended to existing CLAUDE.md (shown in preview) |
274
276
  >
275
277
  > **Will skip ({M} files — already present):**
276
278
  >
@@ -346,11 +348,24 @@ guide.
346
348
  For each selected tool-specific file (`AGENTS.md`, `CLAUDE.md`,
347
349
  `.github/copilot-instructions.md`):
348
350
 
351
+ (checked in this order — the first matching rule wins):
352
+
349
353
  - if the target file does not exist, create a small shim at the target
350
354
  path that points to `dflow/specs/shared/AI-AGENT-GUIDE.md`
351
- - if the target file already exists, do not overwrite it; write a merge
352
- snippet under `dflow/specs/shared/` and report that the developer
353
- should merge it manually
355
+ - if the target file contains conflicting or malformed Dflow markers, do not
356
+ edit it; write a fallback merge snippet under `dflow/specs/shared/` and
357
+ report that the developer should merge it manually
358
+ - if the target file already contains a single well-formed Dflow marked block,
359
+ replace that block in place (idempotent refresh) and keep the rest of the
360
+ file unchanged
361
+ - if the target file is an existing whole-file Dflow-generated shim, refresh it
362
+ in place
363
+ - if the target file already points to the guide through the developer's own
364
+ pointer (and has no Dflow marked block), leave it untouched
365
+ - otherwise preserve the existing content and append a marked Dflow block at
366
+ the end of the file, keeping the file's dominant line ending; show that block
367
+ in the preview, and refresh that same block on re-run. If the developer later
368
+ deletes the block, a later `init` / `configure-agents` run appends it again
354
369
 
355
370
  ### 4.4 Directory-only entries
356
371
 
@@ -380,7 +395,7 @@ Summarise what actually happened and point at the next command.
380
395
  ```
381
396
  Init complete. Summary:
382
397
 
383
- Created ({N} files):
398
+ Created / Updated ({N} files):
384
399
  ✓ dflow/specs/features/active/.gitkeep
385
400
  ✓ dflow/specs/features/completed/.gitkeep
386
401
  ✓ dflow/specs/features/backlog/.gitkeep
@@ -391,7 +406,7 @@ Init complete. Summary:
391
406
  ✓ dflow/specs/architecture/decisions/README.md
392
407
  ✓ dflow/specs/shared/_overview.md
393
408
  ✓ dflow/specs/shared/Git-principles-trunk.md
394
- ✓ CLAUDE.md (seeded from scaffolding snippet)
409
+ ✓ CLAUDE.md (marked Dflow block appended)
395
410
 
396
411
  Skipped ({M} files already present):
397
412
  - (none this run)
@@ -445,10 +460,9 @@ Remind the developer to review files that have `{placeholder}` tokens
445
460
  still in them:
446
461
 
447
462
  > "A few files still have `{placeholder}` tokens that need your input:
448
- > - `dflow/specs/shared/_overview.md`: `{業務領域}`, `{團隊}`,
449
- > `{使用者規模}`
463
+ > - `dflow/specs/shared/_overview.md`: the Business Domain and Technical
464
+ > Architecture fields (e.g. primary domain, stakeholders, user scale, stack)
450
465
  > - `dflow/specs/domain/context-map.md`: context list and relationships
451
- > - `CLAUDE.md`: `{業務領域}`
452
466
  >
453
467
  > These are fine to leave for now; fill them in during your next
454
468
  > review pass."
@@ -2,14 +2,14 @@
2
2
 
3
3
  Step-by-step guide for changing or fixing existing functionality.
4
4
 
5
- Triggered by `/dflow:modify-existing` or `/dflow:bug-fix` (or natural language implying a modification task — see SKILL.md § Workflow Transparency for the auto-trigger safety net).
5
+ Triggered by `/dflow:modify-existing` or `/dflow:bug-fix` (or natural language implying a modification task — see AI-AGENT-GUIDE.md § Workflow Transparency for the auto-trigger safety net).
6
6
 
7
7
  **Step Gates** in this flow (stop-and-confirm before proceeding):
8
8
  - Step 2 → Step 3 (baseline captured → assess DDD impact)
9
9
  - Step 3 → Step 4 (DDD impact decision → implement)
10
10
  - Step 4 → Step 5 (implementation done → update documentation)
11
11
 
12
- All other step transitions are **step-internal**: announce "Step N complete, entering Step N+1" and proceed without waiting. See SKILL.md § Workflow Transparency for the full transparency protocol and confirmation signals.
12
+ All other step transitions are **step-internal**: announce "Step N complete, entering Step N+1" and proceed without waiting. See AI-AGENT-GUIDE.md § Workflow Transparency for the full transparency protocol and confirmation signals.
13
13
 
14
14
  **Note on step count**: Greenfield edition has 5 steps (Brownfield has
15
15
  6) because Clean Architecture's layered structure already separates
@@ -29,7 +29,7 @@ This step has three parallel concerns:
29
29
 
30
30
  **Part A — Determine the Ceremony Tier (T1 / T2 / T3)**
31
31
 
32
- Dflow runs three ceremony tiers (full table in SKILL.md § Ceremony Scaling).
32
+ Dflow runs three ceremony tiers (full table in AI-AGENT-GUIDE.md § Ceremony Scaling).
33
33
  For a modification, AI judges which tier fits before deciding what to
34
34
  produce:
35
35
 
@@ -147,7 +147,7 @@ add a row:
147
147
  | {新 SPEC-ID} | {新 slug} | {today} | in-progress |
148
148
  ```
149
149
 
150
- This update is **part of the same change set** (the developer commits
150
+ This update is **part of the same change set** (offer to commit
151
151
  both at once; commit message should mention "Add follow-up reference to
152
152
  `{新 SPEC-ID}`"). The reverse link is a derived index — the new
153
153
  feature's `follow-up-of` field is the authoritative source.
@@ -158,8 +158,6 @@ phase's content).
158
158
 
159
159
  ## Step 2: Check Documentation
160
160
 
161
- ## Step 2: Check Documentation
162
-
163
161
  - Spec in `dflow/specs/features/completed/`?
164
162
  - Domain model in `dflow/specs/domain/{context}/models.md`?
165
163
  - Business rules in `rules.md`?
@@ -305,7 +303,7 @@ Items marked *(post-5.3)* are re-verified after the documentation merge in 5.3 l
305
303
  - [ ] ORM / persistence mapping is kept outside Domain entities (no persistence attributes/annotations on Domain entities)
306
304
  - [ ] `Implementation Tasks` section (`phase-spec.md` or `lightweight-spec.md`): all tasks checked, or unchecked items explicitly labelled as follow-up
307
305
  - [ ] *(post-5.3)* `dflow/specs/domain/{context}/behavior.md` has a section anchor for every `BR-*` in ADDED / MODIFIED entries; REMOVED entries' anchors have been deleted (mechanical input for `/dflow:verify`)
308
- - [ ] *(post-5.3)* `dflow/specs/domain/{context}/behavior.md` `last-updated` is later than this spec's `created` date (mechanical drift guard)
306
+ - [ ] *(post-5.3)* every ADDED / MODIFIED / RENAMED BR's `Last updated` in `dflow/specs/domain/{context}/rules.md` is later than this spec's `created` date (mechanical drift guard)
309
307
 
310
308
  If any item fails, report the gap and pause — don't proceed to 5.2.
311
309
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Step-by-step guide for adding a new feature with full DDD and Clean Architecture.
4
4
 
5
- Triggered by `/dflow:new-feature` (or natural language implying a new-feature task — see SKILL.md § Workflow Transparency for the auto-trigger safety net behavior).
5
+ Triggered by `/dflow:new-feature` (or natural language implying a new-feature task — see AI-AGENT-GUIDE.md § Workflow Transparency for the auto-trigger safety net behavior).
6
6
 
7
7
  **Step Gates** in this flow (stop-and-confirm before proceeding):
8
8
  - Step 3 → Step 3.5 (Aggregate / VO / Events identified → confirm slug + directory + branch names)
@@ -10,9 +10,9 @@ Triggered by `/dflow:new-feature` (or natural language implying a new-feature ta
10
10
  - Step 6 → Step 7 (branch ready → start implementation)
11
11
  - Step 7 → Step 8 (implementation done → completion)
12
12
 
13
- All other step transitions are **step-internal**: announce "Step N complete, entering Step N+1" and proceed without waiting. See SKILL.md § Workflow Transparency for the full transparency protocol and confirmation signals.
13
+ All other step transitions are **step-internal**: announce "Step N complete, entering Step N+1" and proceed without waiting. See AI-AGENT-GUIDE.md § Workflow Transparency for the full transparency protocol and confirmation signals.
14
14
 
15
- **Ceremony**: this flow always defaults to **T1 Heavy** — the first phase of a brand-new feature is by definition a full SDD cycle. Tier judgement (T1 / T2 / T3) only applies to `/dflow:modify-existing` (see `references/modify-existing-flow.md` and SKILL.md § Ceremony Scaling).
15
+ **Ceremony**: this flow always defaults to **T1 Heavy** — the first phase of a brand-new feature is by definition a full SDD cycle. Tier judgement (T1 / T2 / T3) only applies to `/dflow:modify-existing` (see `references/modify-existing-flow.md` and AI-AGENT-GUIDE.md § Ceremony Scaling).
16
16
 
17
17
  ## Step 1: Intake — Understand the Request
18
18
 
@@ -42,7 +42,7 @@ Check `dflow/specs/domain/context-map.md`:
42
42
  [Context] bounded context. Does that match your understanding?"
43
43
  ```
44
44
 
45
- If new context needed → use context-definition template.
45
+ If a new context is needed → create `dflow/specs/domain/{new-context}/context.md` using the context-definition template (`templates/context-definition.md`).
46
46
 
47
47
  If it crosses contexts:
48
48
  ```
@@ -52,13 +52,36 @@ If it crosses contexts:
52
52
  - Do we need an Anti-Corruption Layer?"
53
53
  ```
54
54
 
55
+ Once the BC is confirmed, classify and record its **Subdomain Type** as part
56
+ of the same confirmation (not a separate gate):
57
+
58
+ ```
59
+ "Is this capability core (差異化來源), supporting (必要但非差異化),
60
+ or generic (可買 / 可套件 / 簡單 CRUD)? I'll record it in context-map.md."
61
+ ```
62
+
63
+ If the BC already has a Subdomain Type in `context-map.md`, reuse it — don't
64
+ re-ask unless the developer wants to reclassify. Record it in
65
+ `dflow/specs/domain/context-map.md`:
66
+
67
+ - If the **Subdomain Type column is missing** (an older context-map), add the
68
+ column **preserving every existing row** — do not rewrite their content.
69
+ - The greenfield context-map is created at init, so the file normally exists;
70
+ if for any reason it is absent, create it from `templates/context-map.md`.
71
+
72
+ The classification sets the modeling depth used in Step 3 (see
73
+ `references/ddd-modeling-guide.md` § Subdomain-Aware Modeling Depth).
74
+
55
75
  **→ Transition (step-internal)**: Step 2 complete. Announce "Step 2 complete (BC identified). Entering Step 3: Domain Modeling." and continue.
56
76
 
57
77
  ## Step 3: Domain Modeling
58
78
 
59
79
  This is where the Greenfield Clean Architecture workflow diverges
60
80
  significantly from the Brownfield edition.
61
- Read `references/ddd-modeling-guide.md` for detailed patterns.
81
+ Read `references/ddd-modeling-guide.md` for detailed patterns. Apply the
82
+ modeling depth set by this BC's Subdomain Type from Step 2 (see that guide's
83
+ § Subdomain-Aware Modeling Depth): a `generic` context gets a thin model, not
84
+ the full tactical treatment below.
62
85
 
63
86
  Walk through:
64
87
 
@@ -174,12 +197,17 @@ dflow/specs/features/active/{SPEC-ID}-{slug}/
174
197
  using `templates/phase-spec.md`. The "Delta from prior phases" section
175
198
  is filled with "首 phase,無前置 Delta" (first phase has nothing to
176
199
  delta against).
177
- 4. **If this feature introduces a new Aggregate**, also create an
178
- `aggregate-design.md` from `templates/aggregate-design.md` **inside this
179
- feature directory** as the per-Aggregate design worksheet. It is a working
180
- artifact scoped to the feature; the Aggregate's durable, long-lived catalog
181
- entry still lives in `dflow/specs/domain/{context}/models.md`.
182
- `aggregate-design.md` complements `models.md`, it does not replace it.
200
+ 4. **If this feature introduces a new Aggregate**, whether to create an
201
+ `aggregate-design.md` worksheet from `templates/aggregate-design.md`
202
+ **inside this feature directory** follows the BC's Subdomain Type (Step 2;
203
+ see `references/ddd-modeling-guide.md` § Subdomain-Aware Modeling Depth):
204
+ **core** → create it; **supporting** → create it but keep it lean;
205
+ **generic** → skip by default (a thin wrapper needs no design worksheet)
206
+ unless the developer explicitly opts into deeper modeling and records why.
207
+ When created, it is a working artifact scoped to the feature; the
208
+ Aggregate's durable, long-lived catalog entry still lives in
209
+ `dflow/specs/domain/{context}/models.md` — `aggregate-design.md`
210
+ complements `models.md`, it does not replace it.
183
211
 
184
212
  Key additions compared to Brownfield edition:
185
213
  - **Aggregate State Transitions**: Document how Aggregate state changes
@@ -201,7 +229,7 @@ Scenario: Submit expense report
201
229
  Announce to developer:
202
230
  > "Spec is drafted — behavior scenarios, Aggregate state transitions, Domain Events, and CQRS split are captured. Ready to plan the layer-by-layer implementation (Domain → Application → Infrastructure → Presentation)? `/dflow:next` or reply 'OK' to continue, or tell me if the spec needs another iteration first."
203
231
 
204
- Wait for confirmation (`/dflow:next`, verbal OK, or implicit — see SKILL.md § Confirmation Signals) before entering Step 5.
232
+ Wait for confirmation (`/dflow:next`, verbal OK, or implicit — see AI-AGENT-GUIDE.md § Confirmation Signals) before entering Step 5.
205
233
 
206
234
  ## Step 5: Plan the Implementation (Layer by Layer)
207
235
 
@@ -352,7 +380,7 @@ AI reports `✓` / `✗` for every item before touching docs. Items marked *(pos
352
380
  - [ ] Aggregate invariants still hold after the change (all state changes go through methods, no public setters)
353
381
  - [ ] ORM / persistence mapping is kept outside Domain entities (no persistence attributes/annotations on Domain entities)
354
382
  - [ ] *(post-8.3)* `dflow/specs/domain/{context}/behavior.md` contains a section anchor for every `BR-*` introduced by this spec (mechanical input for `/dflow:verify`)
355
- - [ ] *(post-8.3)* `dflow/specs/domain/{context}/behavior.md` `last-updated` is later than this spec's `created` date (mechanical drift guard)
383
+ - [ ] *(post-8.3)* `dflow/specs/domain/{context}/rules.md` `last-updated` is later than this spec's `created` date (mechanical drift guard)
356
384
 
357
385
  If any item fails, report the gap and pause — don't proceed to 8.2.
358
386
 
@@ -384,12 +412,14 @@ Ask these one-by-one; do not dump all six at once.
384
412
 
385
413
  ### 8.4 Archival
386
414
 
387
- For a single-phase feature, this is the closeout point. For a multi-phase
388
- feature, the developer typically reaches this point at the end of the
389
- final phase — at which time `/dflow:finish-feature` is the recommended
390
- trigger (it bundles steps 8.1 / 8.2 verification, BC sync, and archival
391
- into one explicit ceremony). Either path is acceptable; pick the one
392
- that matches the developer's habit.
415
+ For a single-phase feature, this is the closeout point. If the feature has
416
+ later phases still ahead, this phase is complete but the feature is not —
417
+ don't archive yet; run `/dflow:new-phase` to start the next phase, not
418
+ `/dflow:finish-feature` yet. For a multi-phase feature, the developer
419
+ typically reaches this point at the end of the final phase — at which time
420
+ `/dflow:finish-feature` is the recommended trigger (it bundles steps 8.1 /
421
+ 8.2 verification, BC sync, and archival into one explicit ceremony). Either
422
+ path is acceptable; pick the one that matches the developer's habit.
393
423
 
394
424
  - [ ] `_index.md` `status` field changed to `completed`
395
425
  - [ ] All `phase-spec-*.md` files in the feature directory have `status:
@@ -20,7 +20,7 @@ adds a new phase to an in-progress feature only.
20
20
  - Step 6 → Step 7 (implementation done → complete the phase)
21
21
 
22
22
  All other step transitions are **step-internal**: announce "Step N complete,
23
- entering Step N+1" and proceed without waiting. See SKILL.md § Workflow
23
+ entering Step N+1" and proceed without waiting. See AI-AGENT-GUIDE.md § Workflow
24
24
  Transparency for the full transparency protocol and confirmation signals.
25
25
 
26
26
  ## Step 1: Read Active Feature Context
@@ -95,7 +95,10 @@ Walk the developer through what the new phase covers:
95
95
  BRs (ADDED), changed BRs (MODIFIED), removed BRs (REMOVED), renamed
96
96
  (RENAMED). Items not mentioned stay UNCHANGED implicitly.
97
97
  3. **Any Aggregate / Domain concepts introduced or changed?** New
98
- Aggregates, Value Objects, Domain Events, or invariants?
98
+ Aggregates, Value Objects, Domain Events, or invariants? Model new concepts
99
+ at the depth set by the BC's Subdomain Type (see
100
+ `references/ddd-modeling-guide.md` § Subdomain-Aware Modeling Depth) — don't
101
+ bypass the classification just because this is a phase, not a new feature.
99
102
  4. **Cross-context impact?** Does this phase introduce / change Domain
100
103
  Events that other contexts consume? (If yes, plan for `context-map.md`
101
104
  updates at finish-feature time.)
@@ -116,7 +116,15 @@ If the closeout commit is in this PR (`/dflow:finish-feature` was run):
116
116
 
117
117
  ## Cross-Cutting
118
118
 
119
- - [ ] **Glossary consistency** — new terms documented?
119
+ - [ ] **Glossary consistency** — any new business concept added to `glossary.md`?
120
+ - [ ] **Naming matches the Ubiquitous Language** — for each **domain-facing** type
121
+ or member the diff introduces (skip DTO / test / framework names), is there a
122
+ matching term in `glossary.md`? The `Code Mapping` column maps each term to
123
+ its `{Namespace/Class/Member}` — a domain name in the diff with no glossary
124
+ term, or a term whose Code Mapping is now stale, is the signal.
125
+ - [ ] **No synonym drift** — is the code naming a concept with a different word than
126
+ the glossary (e.g. "reimbursement" in code vs "報銷 / Expense Claim" in the
127
+ glossary)? Align it. (Judgment call, not a string match.)
120
128
  - [ ] **Context boundaries respected** — no reaching into another context's internals
121
129
  - [ ] **Domain Events documented** — events.md updated?
122
130
  - [ ] **Tests cover invariants** — not just happy path