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,312 @@
1
+ # Git Integration with SDD/DDD
2
+
3
+ This reference defines the minimal Git coupling Dflow requires for SDD, and
4
+ what checks should happen at key branch transitions. Dflow is intentionally
5
+ agnostic about which Git *branching strategy* your project adopts (Git Flow,
6
+ GitHub Flow, trunk-based, single-`main`, etc.) — it only prescribes the
7
+ feature-branch-per-feature convention that SDD traceability depends on.
8
+
9
+ > If your project adopts Git Flow specifically, see the optional
10
+ > optional `scaffolding/Git-principles-gitflow.md` template
11
+ > for Git-Flow-specific conventions.
12
+
13
+ ## Branch-to-Workflow Mapping
14
+
15
+ Dflow only requires that every SDD feature / bug-fix lives on its own branch
16
+ that links back to a spec. The *base branch* that feature branches are cut
17
+ from (e.g. `main`, `develop`, `trunk`) is a project-level decision that Dflow
18
+ does not mandate.
19
+
20
+ ```
21
+ main (or your project's base branch)
22
+ │
23
+ ├─ feature/{SPEC-ID}-{slug} ← Full SDD workflow
24
+ │ Gate: spec must exist BEFORE first commit
25
+ │
26
+ └─ bugfix/{BUG-ID}-{slug} ← Lightweight SDD workflow
27
+ Gate: at minimum a lightweight spec
28
+ ```
29
+
30
+ > If your project adopts Git Flow / GitHub Flow / trunk-based, the choice of
31
+ > base branch (and whether you use `develop`, `release/*`, or a single `main`)
32
+ > is up to the project. Dflow does not decide this.
33
+
34
+ ## Branch Naming Convention
35
+
36
+ ```
37
+ feature/{SPEC-ID}-{slug}
38
+ Examples:
39
+ feature/EXP-001-jpy-currency-support
40
+ feature/HR-003-leave-approval-workflow
41
+ feature/SHARED-002-audit-logging
42
+
43
+ bugfix/{BUG-ID}-{slug}
44
+ Examples:
45
+ bugfix/BUG-042-rounding-inconsistency
46
+ bugfix/BUG-051-exchange-rate-cache
47
+ ```
48
+
49
+ The SPEC-ID / BUG-ID prefix links the branch to its spec document. This is
50
+ the traceability chain:
51
+
52
+ ```
53
+ Git Branch → Spec Document → Domain Concepts → Code Implementation → Tests
54
+ ```
55
+
56
+ ### Slug Language
57
+
58
+ The branch slug follows the language the developer / AI discuss the
59
+ feature in. **Both Chinese and English slugs are valid**; Dflow does not
60
+ force translation in either direction. The same slug is reused for the
61
+ feature directory name and the first phase-spec filename, so consistency
62
+ across branch / dir / phase-spec is automatic.
63
+
64
+ Examples:
65
+
66
+ ```
67
+ feature/SPEC-20260421-001-報表調整 (Chinese discussion)
68
+ feature/SPEC-20260421-002-jpy-currency-support (English discussion)
69
+ feature/SPEC-20260423-003-訂單折扣-匯率擴充 (Chinese, hyphenated)
70
+ bugfix/BUG-051-rounding-fix (English)
71
+ ```
72
+
73
+ Empirical note: an Obts production team has run Dflow with Chinese
74
+ branch / directory / PR titles in 2026-Q1–Q2 without encountering
75
+ encoding issues on common Git hosts (GitHub, Azure DevOps), CI runners,
76
+ or PR review bots. Other Git platforms may still need spot-checking;
77
+ when in doubt, run a smoke test on the project's CI pipeline with one
78
+ representative Chinese-slug branch before adopting it widely.
79
+
80
+ Slug-shape guidance (regardless of language):
81
+ - Keep it short (2–4 words / 2–6 中文字 plus separators)
82
+ - Avoid characters that break filesystems on contributors' platforms
83
+ (forward slash, backslash, colon, asterisk, question mark, double
84
+ quote, angle brackets, pipe)
85
+ - Avoid leading dots, trailing spaces
86
+ - Lowercase ASCII / 繁體中文 are both fine; mixed-case is OK but be
87
+ consistent within a project
88
+
89
+ ## Feature Branch per Feature (Required)
90
+
91
+ This is the one non-negotiable Git coupling Dflow enforces:
92
+
93
+ - **Every SDD feature must have its own feature branch.** Branch name must
94
+ match its SPEC-ID so that `git log`, PR titles, and spec documents can be
95
+ traced back to one another.
96
+ - **Every bug-fix (SDD-tracked) must have its own bugfix branch** following
97
+ the same pattern.
98
+ - Commits that span multiple specs (accidentally or deliberately) are
99
+ discouraged; if you notice work on a new spec emerging mid-branch, stop
100
+ and create a new branch off the correct base.
101
+
102
+ This requirement is independent of the branching strategy — whether you
103
+ branch off `develop`, `main`, or something else, the feature-per-branch
104
+ convention stays.
105
+
106
+ ## Directory Moves Must Use `git mv`
107
+
108
+ When you rename or move a directory or file that is tracked in Dflow
109
+ (feature directories, spec files, domain knowledge files, reference
110
+ files), **always use `git mv` instead of a plain `mv` + `git add`**.
111
+
112
+ ### Why this is non-negotiable in Dflow
113
+
114
+ Dflow is intentionally tightly coupled to Git for the feature-branch /
115
+ feature-directory pairing (one feature = one branch = one directory).
116
+ This coupling means feature lifecycle events trigger directory moves,
117
+ and rename history is what makes the spec auditable across time.
118
+
119
+ A plain `mv` followed by `git add` shows up as `delete + add` in git's
120
+ diff. That breaks:
121
+ - `git log --follow {path}` (won't trace history across the move)
122
+ - `git blame` on lines that crossed the rename boundary
123
+ - PR diff quality (reviewers see two unrelated big-blob changes
124
+ instead of one rename + small content diff)
125
+ - `/dflow:verify` and other tools that walk feature history
126
+
127
+ This is a known weakness of OpenSpec's directory-rename pattern; Dflow
128
+ deliberately avoids it by mandating `git mv`.
129
+
130
+ ### Where `git mv` is required
131
+
132
+ All of the following situations require `git mv`:
133
+
134
+ ```bash
135
+ # 1. /dflow:finish-feature: archive an entire feature directory
136
+ git mv dflow/specs/features/active/{SPEC-ID}-{slug} \
137
+ dflow/specs/features/completed/{SPEC-ID}-{slug}
138
+
139
+ # 2. Slug correction (rare — done right after Step 3.5 if the developer
140
+ # realises the agreed slug needs a tweak)
141
+ git mv dflow/specs/features/active/{SPEC-ID}-{old-slug} \
142
+ dflow/specs/features/active/{SPEC-ID}-{new-slug}
143
+
144
+ # 3. Phase-spec rename inside a feature directory
145
+ # (e.g. fixing a wrong date in the filename)
146
+ git mv dflow/specs/features/active/{SPEC-ID}-{slug}/phase-spec-2026-04-23-foo.md \
147
+ dflow/specs/features/active/{SPEC-ID}-{slug}/phase-spec-2026-04-24-foo.md
148
+
149
+ # 4. Lightweight-spec rename inside a feature directory
150
+ git mv dflow/specs/features/active/{SPEC-ID}-{slug}/lightweight-2026-04-15-old.md \
151
+ dflow/specs/features/active/{SPEC-ID}-{slug}/lightweight-2026-04-15-new.md
152
+ ```
153
+
154
+ ### Commit-message hint for renames
155
+
156
+ When the rename is the primary action (not a rename + many edits),
157
+ prefer a commit message that calls it out:
158
+
159
+ ```
160
+ [SPEC-ID] git mv {SPEC-ID}-{slug}: active/ → completed/
161
+ ```
162
+
163
+ If the rename is bundled with content edits (e.g. archival commit also
164
+ updates `rules.md`), one commit is fine — git's rename detection still
165
+ holds via similarity index.
166
+
167
+ ### What NOT to do
168
+
169
+ ```bash
170
+ # ❌ Wrong: produces delete + add, loses rename detection
171
+ mv dflow/specs/features/active/{SPEC-ID}-{slug} dflow/specs/features/completed/
172
+ git add -A
173
+ ```
174
+
175
+ ```bash
176
+ # ❌ Also wrong: deleting the source then later adding the destination
177
+ # in a separate commit prevents git rename detection across commits.
178
+ git rm -r dflow/specs/features/active/{SPEC-ID}-{slug}
179
+ # ... commit ...
180
+ # ... later, add the destination: rename trail is now broken
181
+ ```
182
+
183
+ ### Verifying a rename took
184
+
185
+ After `git mv`, run `git status` — a successful rename shows:
186
+
187
+ ```
188
+ Changes to be committed:
189
+ renamed: dflow/specs/features/active/{SPEC-ID}-{slug}/_index.md ->
190
+ dflow/specs/features/completed/{SPEC-ID}-{slug}/_index.md
191
+ ...
192
+ ```
193
+
194
+ If you see `deleted` + `new file` instead, the rename detection failed
195
+ — investigate before committing (most often, the file was edited
196
+ heavily enough that git's similarity index dropped below the rename
197
+ threshold; consider using `git mv` for the move, then making content
198
+ edits in a follow-up commit).
199
+
200
+ ### CI / hook automation (future)
201
+
202
+ A pre-commit hook can refuse commits where `dflow/specs/features/active/` or
203
+ `dflow/specs/features/completed/` show paired `D` + `A` instead of `R` for
204
+ the same feature directory. Not part of Dflow today, but compatible
205
+ with the rule.
206
+
207
+ ## Gate Checks by Branch Type
208
+
209
+ ### feature/ branch — Before Creating
210
+
211
+ AI should verify:
212
+ - [ ] Feature directory exists at `dflow/specs/features/active/{SPEC-ID}-{slug}/`
213
+ with `_index.md` and at least one phase-spec inside
214
+ - [ ] `_index.md` has status: `in-progress`
215
+ - [ ] Bounded Context is identified
216
+ - [ ] At least one Given/When/Then scenario is defined in the first phase-spec
217
+ - [ ] Domain concepts are identified (even if not yet in models.md)
218
+
219
+ If any are missing, guide the developer through creating them BEFORE the branch.
220
+
221
+ ```
222
+ "Before we create the branch, let's set up the spec.
223
+ I see this touches the Expense context. Let me help you draft the
224
+ spec — it should only take a few minutes and it'll keep us focused
225
+ during implementation."
226
+ ```
227
+
228
+ ### feature/ branch — Before Merging (Pre-PR / Pre-Integration)
229
+
230
+ AI should verify:
231
+ - [ ] `_index.md` status updated to `completed`
232
+ - [ ] All `phase-spec-*.md` in the feature directory have `status: completed`
233
+ - [ ] `_index.md` Current BR Snapshot has been synced to BC layer
234
+ (`rules.md` / `behavior.md`) — typically by `/dflow:finish-feature`
235
+ - [ ] Whole feature directory ready to `git mv` to `dflow/specs/features/completed/`
236
+ (or already moved if `/dflow:finish-feature` ran)
237
+ - [ ] All new business logic is in `src/Domain/` (not delivery/entrypoint code — presentation/UI layer, controllers, handlers, jobs, message consumers, data pipelines, or stored procedures)
238
+ - [ ] New terms added to `glossary.md`
239
+ - [ ] `rules.md` and `models.md` updated if applicable
240
+ - [ ] Tech debt recorded for any shortcuts taken
241
+ - [ ] Domain layer code has no delivery-framework references
242
+
243
+ ### bugfix/ branch — Before Creating
244
+
245
+ AI should verify:
246
+ - [ ] Lightweight spec exists or is created during this session
247
+ - [ ] Root cause is documented
248
+ - [ ] Fix approach is noted
249
+
250
+ ### bugfix/ branch — Before Merging (Pre-PR / Pre-Integration)
251
+
252
+ - [ ] Spec has the fix documented
253
+ - [ ] Tech debt recorded if the underlying issue is broader (record in
254
+ `dflow/specs/migration/tech-debt.md` if the bug reveals a systemic issue)
255
+ - [ ] If business logic was touched, evaluate Domain extraction
256
+
257
+ > The exact merge strategy (merge commit, squash, rebase, fast-forward)
258
+ > is a project-level decision and sits outside Dflow's scope. See your
259
+ > project's Git-principles document (e.g. the optional
260
+ > Git-principles scaffolding) for integration commit conventions.
261
+
262
+ ## Commit Message Convention
263
+
264
+ Tie commits to specs:
265
+
266
+ ```
267
+ [SPEC-ID] Short description
268
+
269
+ Examples:
270
+ [EXP-001] Add JPY currency support to Money value object
271
+ [EXP-001] Extract exchange rate logic to Domain service
272
+ [BUG-042] Fix rounding inconsistency, extract to Money.Round()
273
+ ```
274
+
275
+ ## Daily Development Flow
276
+
277
+ ```
278
+ 1. Developer: "I'm starting work on [feature/bug]"
279
+ AI: Check for spec → Guide through spec creation if missing
280
+ → Suggest branch name based on spec ID
281
+
282
+ 2. Developer creates branch
283
+ AI: Confirm branch name matches convention
284
+ → Remind: "Business logic goes in src/Domain/"
285
+
286
+ 3. During development
287
+ AI: Answer questions referencing dflow/specs/domain/ knowledge
288
+ → Flag if business logic is going into delivery/entrypoint code
289
+ → Suggest Domain layer patterns when appropriate
290
+ → Help maintain thin delivery/entrypoint code
291
+
292
+ 4. Before PR/merge
293
+ AI: Run through merge checklist
294
+ → Help update specs, glossary, tech-debt
295
+ → Suggest moving completed spec to completed/
296
+
297
+ 5. After merge
298
+ AI: Confirm all artifacts are updated
299
+ → Suggest next items from backlog/ if relevant
300
+ ```
301
+
302
+ ## Integration with CI/CD (Future Enhancement)
303
+
304
+ These checks could eventually be automated in CI:
305
+ - Verify no delivery-framework references in `src/Domain/` directory
306
+ - Verify spec file exists for any branch with feature/ or bugfix/ prefix
307
+ - Verify glossary.md and rules.md were updated when Domain/ files change
308
+ - Lint commit messages for spec ID format
309
+
310
+ For now, the AI handles these checks conversationally during development.
311
+
312
+ <!-- R8b verified: no Chinese structural terms in scope; per F-17 Path A. -->