dflow-sdd-ddd 0.7.0 → 0.8.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 (51) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/docs/evaluating-dflow.en.md +14 -5
  3. package/docs/evaluating-dflow.md +14 -5
  4. package/docs/using-with-claude-code.en.md +17 -9
  5. package/docs/using-with-claude-code.md +15 -8
  6. package/lib/init.js +263 -52
  7. package/package.json +1 -1
  8. package/templates/brownfield/references/dflow-feedback-flow.md +179 -0
  9. package/templates/brownfield/references/drift-verification.md +183 -0
  10. package/templates/brownfield/references/finish-feature-flow.md +259 -0
  11. package/templates/brownfield/references/git-integration.md +312 -0
  12. package/templates/brownfield/references/init-project-flow.md +413 -0
  13. package/templates/brownfield/references/modify-existing-flow.md +444 -0
  14. package/templates/brownfield/references/new-feature-flow.md +367 -0
  15. package/templates/brownfield/references/new-phase-flow.md +259 -0
  16. package/templates/brownfield/references/pr-review-checklist.md +179 -0
  17. package/templates/brownfield/scaffolding/AI-AGENT-GUIDE.md +31 -4
  18. package/templates/brownfield/scaffolding/CLAUDE-md-snippet.md +12 -8
  19. package/templates/brownfield/scaffolding/Git-principles-gitflow.md +1 -1
  20. package/templates/brownfield/scaffolding/Git-principles-trunk.md +1 -1
  21. package/templates/brownfield/scaffolding/_conventions.md +1 -1
  22. package/templates/brownfield/scaffolding/_overview.md +3 -3
  23. package/templates/brownfield/templates/context-map.md +1 -1
  24. package/templates/brownfield/templates/glossary.md +1 -1
  25. package/templates/brownfield/templates/models.md +1 -1
  26. package/templates/brownfield/templates/rules.md +1 -1
  27. package/templates/brownfield/templates/tech-debt.md +1 -1
  28. package/templates/common/skill/SKILL.md +35 -0
  29. package/templates/greenfield/references/ddd-modeling-guide.md +351 -0
  30. package/templates/greenfield/references/dflow-feedback-flow.md +179 -0
  31. package/templates/greenfield/references/drift-verification.md +195 -0
  32. package/templates/greenfield/references/finish-feature-flow.md +280 -0
  33. package/templates/greenfield/references/git-integration.md +285 -0
  34. package/templates/greenfield/references/init-project-flow.md +447 -0
  35. package/templates/greenfield/references/modify-existing-flow.md +362 -0
  36. package/templates/greenfield/references/new-feature-flow.md +397 -0
  37. package/templates/greenfield/references/new-phase-flow.md +273 -0
  38. package/templates/greenfield/references/pr-review-checklist.md +130 -0
  39. package/templates/greenfield/scaffolding/AI-AGENT-GUIDE.md +31 -4
  40. package/templates/greenfield/scaffolding/CLAUDE-md-snippet.md +15 -13
  41. package/templates/greenfield/scaffolding/Git-principles-gitflow.md +1 -1
  42. package/templates/greenfield/scaffolding/Git-principles-trunk.md +1 -1
  43. package/templates/greenfield/scaffolding/_conventions.md +1 -1
  44. package/templates/greenfield/scaffolding/_overview.md +5 -3
  45. package/templates/greenfield/scaffolding/architecture-decisions-README.md +1 -1
  46. package/templates/greenfield/templates/context-map.md +1 -1
  47. package/templates/greenfield/templates/events.md +1 -1
  48. package/templates/greenfield/templates/glossary.md +1 -1
  49. package/templates/greenfield/templates/models.md +1 -1
  50. package/templates/greenfield/templates/rules.md +1 -1
  51. package/templates/greenfield/templates/tech-debt.md +1 -1
@@ -0,0 +1,285 @@
1
+ # Git Integration with SDD/DDD — Greenfield Clean Architecture
2
+
3
+ Same minimal Git coupling as the Brownfield edition. Key difference: gate
4
+ checks validate Clean Architecture layer rules instead of brownfield
5
+ delivery/entrypoint extraction checks. Dflow remains agnostic about the
6
+ project's Git *branching strategy* (Git Flow, GitHub Flow, trunk-based,
7
+ etc.) — it only prescribes the feature-branch-per-feature convention
8
+ that SDD traceability depends on.
9
+
10
+ > If your project adopts Git Flow specifically, see the optional
11
+ > optional `scaffolding/Git-principles-gitflow.md` template
12
+ > for Git-Flow-specific conventions.
13
+
14
+ ## Branch-to-Workflow Mapping
15
+
16
+ Dflow only requires that every SDD feature / bug-fix lives on its own branch
17
+ that links back to a spec. The *base branch* that feature branches are cut
18
+ from (e.g. `main`, `develop`, `trunk`) is a project-level decision that Dflow
19
+ does not mandate.
20
+
21
+ ```
22
+ main (or your project's base branch)
23
+ │
24
+ ├─ feature/{SPEC-ID}-{slug} ← Full SDD + DDD workflow
25
+ │ Gate: spec + Aggregate design before first commit
26
+ │
27
+ └─ bugfix/{BUG-ID}-{slug} ← Lightweight SDD workflow
28
+ Gate: lightweight spec with layer identification
29
+ ```
30
+
31
+ > If your project adopts Git Flow / GitHub Flow / trunk-based, the choice of
32
+ > base branch (and whether you use `develop`, `release/*`, or a single `main`)
33
+ > is up to the project. Dflow does not decide this.
34
+
35
+ ## Branch Naming Convention
36
+
37
+ ```
38
+ feature/{SPEC-ID}-{slug}
39
+ bugfix/{BUG-ID}-{slug}
40
+ ```
41
+
42
+ Examples:
43
+
44
+ ```
45
+ feature/EXP-001-expense-submission-aggregate
46
+ feature/HR-003-leave-approval-workflow
47
+ bugfix/BUG-042-money-rounding
48
+ ```
49
+
50
+ The SPEC-ID / BUG-ID prefix links the branch to its spec document. This is
51
+ the traceability chain:
52
+
53
+ ```
54
+ Git Branch → Spec Document → Domain Concepts → Code Implementation → Tests
55
+ ```
56
+
57
+ ### Slug Language
58
+
59
+ The branch slug follows the language the developer / AI discuss the
60
+ feature in. **Both Chinese and English slugs are valid**; Dflow does not
61
+ force translation in either direction. The same slug is reused for the
62
+ feature directory name and the first phase-spec filename, so consistency
63
+ across branch / dir / phase-spec is automatic.
64
+
65
+ Examples:
66
+
67
+ ```
68
+ feature/SPEC-20260421-001-報表調整 (Chinese discussion)
69
+ feature/SPEC-20260421-002-submit-expense-report (English discussion)
70
+ feature/SPEC-20260423-003-訂單折扣-匯率擴充 (Chinese, hyphenated)
71
+ bugfix/BUG-051-money-rounding (English)
72
+ ```
73
+
74
+ Empirical note: an Obts production team has run Dflow with Chinese
75
+ branch / directory / PR titles in 2026-Q1–Q2 without encountering
76
+ encoding issues on common Git hosts (GitHub, Azure DevOps), CI runners,
77
+ or PR review bots. Other Git platforms may still need spot-checking;
78
+ when in doubt, run a smoke test on the project's CI pipeline with one
79
+ representative Chinese-slug branch before adopting it widely.
80
+
81
+ Slug-shape guidance (regardless of language):
82
+ - Keep it short (2–4 words / 2–6 中文字 plus separators)
83
+ - Avoid characters that break filesystems on contributors' platforms
84
+ (forward slash, backslash, colon, asterisk, question mark, double
85
+ quote, angle brackets, pipe)
86
+ - Avoid leading dots, trailing spaces
87
+ - Lowercase ASCII / 繁體中文 are both fine; mixed-case is OK but be
88
+ consistent within a project
89
+
90
+ ## Feature Branch per Feature (Required)
91
+
92
+ This is the one non-negotiable Git coupling Dflow enforces:
93
+
94
+ - **Every SDD feature must have its own feature branch.** Branch name must
95
+ match its SPEC-ID so that `git log`, PR titles, and spec documents can be
96
+ traced back to one another.
97
+ - **Every bug-fix (SDD-tracked) must have its own bugfix branch** following
98
+ the same pattern.
99
+ - Commits that span multiple specs (accidentally or deliberately) are
100
+ discouraged; if you notice work on a new spec emerging mid-branch, stop
101
+ and create a new branch off the correct base.
102
+
103
+ This requirement is independent of the branching strategy — whether you
104
+ branch off `develop`, `main`, or something else, the feature-per-branch
105
+ convention stays.
106
+
107
+ ## Directory Moves Must Use `git mv`
108
+
109
+ When you rename or move a directory or file that is tracked in Dflow
110
+ (feature directories, spec files, domain knowledge files, reference
111
+ files), **always use `git mv` instead of a plain `mv` + `git add`**.
112
+
113
+ ### Why this is non-negotiable in Dflow
114
+
115
+ Dflow is intentionally tightly coupled to Git for the feature-branch /
116
+ feature-directory pairing (one feature = one branch = one directory).
117
+ This coupling means feature lifecycle events trigger directory moves,
118
+ and rename history is what makes the spec auditable across time.
119
+
120
+ A plain `mv` followed by `git add` shows up as `delete + add` in git's
121
+ diff. That breaks:
122
+ - `git log --follow {path}` (won't trace history across the move)
123
+ - `git blame` on lines that crossed the rename boundary
124
+ - PR diff quality (reviewers see two unrelated big-blob changes
125
+ instead of one rename + small content diff)
126
+ - `/dflow:verify` and other tools that walk feature history
127
+
128
+ This is a known weakness of OpenSpec's directory-rename pattern; Dflow
129
+ deliberately avoids it by mandating `git mv`.
130
+
131
+ ### Where `git mv` is required
132
+
133
+ All of the following situations require `git mv`:
134
+
135
+ ```bash
136
+ # 1. /dflow:finish-feature: archive an entire feature directory
137
+ git mv dflow/specs/features/active/{SPEC-ID}-{slug} \
138
+ dflow/specs/features/completed/{SPEC-ID}-{slug}
139
+
140
+ # 2. Slug correction (rare — done right after Step 3.5 if the developer
141
+ # realises the agreed slug needs a tweak)
142
+ git mv dflow/specs/features/active/{SPEC-ID}-{old-slug} \
143
+ dflow/specs/features/active/{SPEC-ID}-{new-slug}
144
+
145
+ # 3. Phase-spec rename inside a feature directory
146
+ # (e.g. fixing a wrong date in the filename)
147
+ git mv dflow/specs/features/active/{SPEC-ID}-{slug}/phase-spec-2026-04-23-foo.md \
148
+ dflow/specs/features/active/{SPEC-ID}-{slug}/phase-spec-2026-04-24-foo.md
149
+
150
+ # 4. Lightweight-spec rename inside a feature directory
151
+ git mv dflow/specs/features/active/{SPEC-ID}-{slug}/lightweight-2026-04-15-old.md \
152
+ dflow/specs/features/active/{SPEC-ID}-{slug}/lightweight-2026-04-15-new.md
153
+ ```
154
+
155
+ ### Commit-message hint for renames
156
+
157
+ When the rename is the primary action (not a rename + many edits),
158
+ prefer a commit message that calls it out:
159
+
160
+ ```
161
+ [SPEC-ID] git mv {SPEC-ID}-{slug}: active/ → completed/
162
+ ```
163
+
164
+ If the rename is bundled with content edits (e.g. archival commit also
165
+ updates `rules.md`), one commit is fine — git's rename detection still
166
+ holds via similarity index.
167
+
168
+ ### What NOT to do
169
+
170
+ ```bash
171
+ # ❌ Wrong: produces delete + add, loses rename detection
172
+ mv dflow/specs/features/active/{SPEC-ID}-{slug} dflow/specs/features/completed/
173
+ git add -A
174
+ ```
175
+
176
+ ```bash
177
+ # ❌ Also wrong: deleting the source then later adding the destination
178
+ # in a separate commit prevents git rename detection across commits.
179
+ git rm -r dflow/specs/features/active/{SPEC-ID}-{slug}
180
+ # ... commit ...
181
+ # ... later, add the destination: rename trail is now broken
182
+ ```
183
+
184
+ ### Verifying a rename took
185
+
186
+ After `git mv`, run `git status` — a successful rename shows:
187
+
188
+ ```
189
+ Changes to be committed:
190
+ renamed: dflow/specs/features/active/{SPEC-ID}-{slug}/_index.md ->
191
+ dflow/specs/features/completed/{SPEC-ID}-{slug}/_index.md
192
+ ...
193
+ ```
194
+
195
+ If you see `deleted` + `new file` instead, the rename detection failed
196
+ — investigate before committing (most often, the file was edited
197
+ heavily enough that git's similarity index dropped below the rename
198
+ threshold; consider using `git mv` for the move, then making content
199
+ edits in a follow-up commit).
200
+
201
+ ### CI / hook automation (future)
202
+
203
+ A pre-commit hook can refuse commits where `dflow/specs/features/active/` or
204
+ `dflow/specs/features/completed/` show paired `D` + `A` instead of `R` for
205
+ the same feature directory. Not part of Dflow today, but compatible
206
+ with the rule.
207
+
208
+ ## Gate Checks by Branch Type
209
+
210
+ ### feature/ — Before Creating
211
+ - [ ] Feature directory exists at `dflow/specs/features/active/{SPEC-ID}-{slug}/`
212
+ with `_index.md` and at least one phase-spec inside
213
+ - [ ] `_index.md` status: `in-progress`
214
+ - [ ] Bounded Context identified
215
+ - [ ] Aggregate design documented (which Aggregate, what invariants)
216
+ - [ ] Domain Events identified
217
+ - [ ] At least one Given/When/Then scenario in the first phase-spec
218
+
219
+ ### feature/ — Before Merging (Pre-PR / Pre-Integration)
220
+ - [ ] `_index.md` status: completed
221
+ - [ ] All `phase-spec-*.md` in the feature directory have `status: completed`
222
+ - [ ] `_index.md` Current BR Snapshot has been synced to BC layer
223
+ (`rules.md` / `behavior.md` / `events.md` / `context-map.md`) —
224
+ typically by `/dflow:finish-feature`
225
+ - [ ] Whole feature directory ready to `git mv` to `dflow/specs/features/completed/`
226
+ (or already moved if `/dflow:finish-feature` ran)
227
+ - [ ] Domain layer: zero external dependencies
228
+ - [ ] No business logic outside Domain layer
229
+ - [ ] Domain Events documented in events.md
230
+ - [ ] Glossary, models, rules updated
231
+ - [ ] Domain unit tests pass
232
+ - [ ] No ORM/serialization attributes on Domain entities
233
+
234
+ ### bugfix/ — Before Creating
235
+ - [ ] Lightweight spec exists or is created during this session
236
+ - [ ] Root cause is documented
237
+ - [ ] Fix approach is noted (which layer the fix belongs in)
238
+
239
+ ### bugfix/ — Before Merging (Pre-PR / Pre-Integration)
240
+ - [ ] Spec has the fix documented
241
+ - [ ] Tech debt recorded if the underlying issue is broader (record in
242
+ `dflow/specs/architecture/tech-debt.md` if the bug reveals a systemic issue)
243
+ - [ ] Fix is in the correct architectural layer (Domain / Application /
244
+ Infrastructure / Presentation) — no business logic leaked outside
245
+ Domain
246
+
247
+ > The exact merge strategy (merge commit, squash, rebase, fast-forward)
248
+ > is a project-level decision and sits outside Dflow's scope. See your
249
+ > project's Git-principles document (e.g. the optional
250
+ > Git-principles scaffolding) for integration commit conventions.
251
+
252
+ ## Commit Message Convention
253
+
254
+ ```
255
+ [SPEC-ID] Short description
256
+
257
+ [EXP-001] Define ExpenseReport Aggregate with submission invariants
258
+ [EXP-001] Add CreateExpenseReport command and handler
259
+ [EXP-001] Implement persistence configuration for ExpenseReport
260
+ [BUG-042] Fix rounding in Money value object
261
+ ```
262
+
263
+ ## Daily Development Flow
264
+
265
+ ```
266
+ 1. Start: Check spec → Create if missing → Design Aggregate → Create branch
267
+ 2. Implement: Domain first → Application → Infrastructure → Presentation
268
+ 3. Test: Domain unit tests → Application tests → Integration tests
269
+ 4. Review: Layer compliance → Spec compliance → Architecture score
270
+ 5. Before PR/merge: Run through merge checklist → Update docs
271
+ 6. After merge: Confirm artifacts updated → Move spec to completed/
272
+ ```
273
+
274
+ ## Integration with CI/CD (Future Enhancement)
275
+
276
+ These checks could eventually be automated in CI:
277
+ - Verify Domain project has zero external package-manager dependencies (beyond allowed list)
278
+ - Verify no ORM/serialization attributes on Domain entities
279
+ - Verify spec file exists for any branch with feature/ or bugfix/ prefix
280
+ - Verify glossary.md / rules.md / events.md updated when Domain/ files change
281
+ - Lint commit messages for spec ID format
282
+
283
+ For now, the AI handles these checks conversationally during development.
284
+
285
+ <!-- R8b verified: no Chinese structural terms in scope; per F-17 Path A. -->