dflow-sdd-ddd 0.7.0 → 0.9.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 (59) hide show
  1. package/CHANGELOG.md +73 -0
  2. package/LICENSE +679 -21
  3. package/README.en.md +5 -4
  4. package/README.md +3 -3
  5. package/bin/dflow.js +3 -2
  6. package/docs/evaluating-dflow.en.md +14 -5
  7. package/docs/evaluating-dflow.md +14 -5
  8. package/docs/using-with-claude-code.en.md +17 -9
  9. package/docs/using-with-claude-code.md +15 -8
  10. package/docs/using-with-codex.en.md +12 -8
  11. package/docs/using-with-codex.md +8 -6
  12. package/lib/init.js +480 -87
  13. package/package.json +2 -2
  14. package/templates/brownfield/references/dflow-feedback-flow.md +251 -0
  15. package/templates/brownfield/references/drift-verification.md +183 -0
  16. package/templates/brownfield/references/finish-feature-flow.md +294 -0
  17. package/templates/brownfield/references/git-integration.md +371 -0
  18. package/templates/brownfield/references/init-project-flow.md +430 -0
  19. package/templates/brownfield/references/modify-existing-flow.md +448 -0
  20. package/templates/brownfield/references/new-feature-flow.md +382 -0
  21. package/templates/brownfield/references/new-phase-flow.md +274 -0
  22. package/templates/brownfield/references/pr-review-checklist.md +179 -0
  23. package/templates/brownfield/scaffolding/AI-AGENT-GUIDE.md +31 -4
  24. package/templates/brownfield/scaffolding/CLAUDE-md-snippet.md +12 -8
  25. package/templates/brownfield/scaffolding/Git-principles-gitflow.md +14 -13
  26. package/templates/brownfield/scaffolding/Git-principles-trunk.md +14 -17
  27. package/templates/brownfield/scaffolding/_conventions.md +1 -1
  28. package/templates/brownfield/scaffolding/_overview.md +3 -3
  29. package/templates/brownfield/templates/_index.md +20 -2
  30. package/templates/brownfield/templates/context-map.md +1 -1
  31. package/templates/brownfield/templates/glossary.md +1 -1
  32. package/templates/brownfield/templates/models.md +1 -1
  33. package/templates/brownfield/templates/rules.md +1 -1
  34. package/templates/brownfield/templates/tech-debt.md +1 -1
  35. package/templates/common/skill/SKILL.md +35 -0
  36. package/templates/greenfield/references/ddd-modeling-guide.md +351 -0
  37. package/templates/greenfield/references/dflow-feedback-flow.md +251 -0
  38. package/templates/greenfield/references/drift-verification.md +195 -0
  39. package/templates/greenfield/references/finish-feature-flow.md +314 -0
  40. package/templates/greenfield/references/git-integration.md +344 -0
  41. package/templates/greenfield/references/init-project-flow.md +464 -0
  42. package/templates/greenfield/references/modify-existing-flow.md +366 -0
  43. package/templates/greenfield/references/new-feature-flow.md +412 -0
  44. package/templates/greenfield/references/new-phase-flow.md +288 -0
  45. package/templates/greenfield/references/pr-review-checklist.md +130 -0
  46. package/templates/greenfield/scaffolding/AI-AGENT-GUIDE.md +31 -4
  47. package/templates/greenfield/scaffolding/CLAUDE-md-snippet.md +15 -13
  48. package/templates/greenfield/scaffolding/Git-principles-gitflow.md +14 -13
  49. package/templates/greenfield/scaffolding/Git-principles-trunk.md +14 -18
  50. package/templates/greenfield/scaffolding/_conventions.md +1 -1
  51. package/templates/greenfield/scaffolding/_overview.md +5 -3
  52. package/templates/greenfield/scaffolding/architecture-decisions-README.md +1 -1
  53. package/templates/greenfield/templates/_index.md +20 -2
  54. package/templates/greenfield/templates/context-map.md +1 -1
  55. package/templates/greenfield/templates/events.md +1 -1
  56. package/templates/greenfield/templates/glossary.md +1 -1
  57. package/templates/greenfield/templates/models.md +1 -1
  58. package/templates/greenfield/templates/rules.md +1 -1
  59. package/templates/greenfield/templates/tech-debt.md +1 -1
@@ -0,0 +1,288 @@
1
+ # New Phase Workflow — Greenfield Clean Architecture
2
+
3
+ Step-by-step guide for when a developer triggers `/dflow:new-phase` —
4
+ adding a new phase-spec to an **active** feature directory.
5
+
6
+ A phase-spec captures one full "Kickoff → Domain → Design → Build → Verify"
7
+ cycle. A feature can have N phase-specs over its lifetime; together they
8
+ build up the feature in iterations. The `_index.md` dashboard aggregates
9
+ their state.
10
+
11
+ **Distinction from `/dflow:new-feature`**: this command does NOT create a
12
+ branch and does NOT create a feature directory. Both must already exist
13
+ (produced by the original `/dflow:new-feature` invocation). This command
14
+ adds a new phase to an in-progress feature only.
15
+
16
+ **Step Gates** in this flow (stop-and-confirm before proceeding):
17
+ - Step 3 → Step 4 (phase scope confirmed → write the phase-spec)
18
+ - Step 4 → Step 5 (phase-spec drafted → refresh `_index.md`)
19
+ - Step 5 → Step 6 (`_index.md` refreshed → start implementation)
20
+ - Step 6 → Step 7 (implementation done → complete the phase)
21
+
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
24
+ Transparency for the full transparency protocol and confirmation signals.
25
+
26
+ ## Step 1: Read Active Feature Context
27
+
28
+ Before producing any spec prose, read `dflow/specs/shared/_conventions.md`
29
+ and apply the `## Prose Language` setting. If the setting is missing or not
30
+ an explicit language tag, ask the developer to update `_conventions.md`
31
+ before continuing.
32
+
33
+ AI must locate the target feature and load its current state:
34
+
35
+ 1. **Identify the target feature**
36
+ - If the developer is on a `feature/{SPEC-ID}-{slug}` branch → infer the
37
+ feature directory at `dflow/specs/features/active/{SPEC-ID}-{slug}/`
38
+ - Otherwise → ask the developer which feature this phase is for
39
+
40
+ 2. **Refuse if the feature is in `completed/`**
41
+
42
+ `/dflow:new-phase` strictly applies to **active features only**. If the
43
+ target feature directory is found at `dflow/specs/features/completed/...`
44
+ instead of `dflow/specs/features/active/...`, refuse with:
45
+
46
+ ```
47
+ "Feature `{SPEC-ID}-{slug}` is in completed/ — completed features are
48
+ frozen history and cannot accept new phases.
49
+
50
+ If you need to extend this feature's behavior, run /dflow:modify-existing
51
+ and choose the 'follow-up' branch — that creates a new follow-up feature
52
+ with a fresh SPEC-ID and a `follow-up-of: {SPEC-ID}` link back to this
53
+ one."
54
+ ```
55
+
56
+ Do NOT offer to `git mv` the feature back to `active/` — that breaks the
57
+ completed = frozen-history semantic and produces confusing dir-rename
58
+ history. The follow-up path is the only correct route.
59
+
60
+ 3. **Load context for the new phase**
61
+ - Read the feature's `_index.md` — Metadata, Goals & Scope, Phase Specs,
62
+ Current BR Snapshot, Resume Pointer
63
+ - Read the most recent phase-spec to understand where the prior phase
64
+ left off (its Business Rules and Delta-from-prior-phases sections in
65
+ particular)
66
+ - Cross-reference the bounded context's `dflow/specs/domain/{context}/rules.md`
67
+ and `behavior.md` if the new phase is likely to touch system-level
68
+ state (BC-level current state lives there, not in `_index.md`)
69
+
70
+ 4. **Branch gate — ensure you are on this feature's branch (before any commit)**
71
+
72
+ This phase's commits must land on the active feature's
73
+ `feature/{SPEC-ID}-{slug}` branch. If you are not already on it (you
74
+ identified the feature by name, or are on a base / unrelated branch),
75
+ switch to the existing branch — or override and record it in the
76
+ `_index.md` Checkpoint Log. **Never create a new feature branch here:**
77
+ `new-phase` extends an existing active feature, it does not start one. See
78
+ `references/git-integration.md` § Commit Checkpoints, Branch Gate & AI
79
+ Commits.
80
+
81
+ Share what you found:
82
+
83
+ > "OK — `{SPEC-ID}-{slug}` has {N} prior phases in BC `{context}`. The
84
+ > most recent (phase-{N}) ended with {一句話 from Resume Pointer}. Current BR
85
+ > Snapshot has {count} active BRs. Ready to scope the new phase."
86
+
87
+ **→ Transition (step-internal)**: Step 1 complete. Announce "Step 1 complete (active feature context loaded). Entering Step 2: Confirm Phase Scope." and continue.
88
+
89
+ ## Step 2: Confirm the Phase Scope
90
+
91
+ Walk the developer through what the new phase covers:
92
+
93
+ 1. **What does this phase add or change?** Plain-language description.
94
+ 2. **Which BRs are touched?** Compare against the current BR Snapshot. New
95
+ BRs (ADDED), changed BRs (MODIFIED), removed BRs (REMOVED), renamed
96
+ (RENAMED). Items not mentioned stay UNCHANGED implicitly.
97
+ 3. **Any Aggregate / Domain concepts introduced or changed?** New
98
+ Aggregates, Value Objects, Domain Events, or invariants?
99
+ 4. **Cross-context impact?** Does this phase introduce / change Domain
100
+ Events that other contexts consume? (If yes, plan for `context-map.md`
101
+ updates at finish-feature time.)
102
+ 5. **Data structure impact?** New tables, columns, indices, EF
103
+ configuration changes?
104
+ 6. **Why now?** Priority — informs sequencing relative to other phases.
105
+
106
+ This is also the moment to ask: "Should this be its own follow-up feature
107
+ instead of a phase here?" — useful when the scope drift suggests a
108
+ separate concern (different Aggregate, different BC, etc.).
109
+
110
+ **→ Transition (step-internal)**: Step 2 complete. Announce "Step 2 complete (phase scope agreed). Entering Step 3: Phase Slug Confirmation." and continue.
111
+
112
+ ## Step 3: Phase Slug Confirmation
113
+
114
+ AI proposes the new phase-spec filename and asks the developer to confirm
115
+ before any file is written.
116
+
117
+ > "Proposed phase-spec for `{SPEC-ID}-{slug}`:
118
+ >
119
+ > phase-spec-{YYYY-MM-DD}-{phase-slug}.md
120
+ >
121
+ > Phase slug follows our discussion language (中文/英文皆可). Do you want
122
+ > to keep `{phase-slug}`, or use a different slug?"
123
+
124
+ Slug rules (matches the feature-level slug rule):
125
+ - Follows the language the developer / AI discuss the phase in (no forced
126
+ translation)
127
+ - Keep it short (2–4 words / 2–6 中文字)
128
+ - Avoid characters that would break filesystems on the developer's
129
+ platform (slashes, colons, etc.)
130
+
131
+ Wait for the developer to confirm before proceeding.
132
+
133
+ **→ Step Gate: Step 3 → Step 4**
134
+
135
+ Announce to developer:
136
+ > "Phase slug confirmed as `{phase-slug}`. Ready to draft the phase-spec
137
+ > (`phase-spec-{date}-{phase-slug}.md`) — I'll cover problem / domain
138
+ > modeling / behavior (with Aggregate transitions + Events) / business
139
+ > rules / Delta-from-prior-phases / edge cases / layer-by-layer
140
+ > implementation plan? `/dflow:next` to proceed, or adjust the scope
141
+ > first."
142
+
143
+ Wait for confirmation before entering Step 4.
144
+
145
+ ## Step 4: Write the Phase Spec
146
+
147
+ Create the file at:
148
+
149
+ ```
150
+ dflow/specs/features/active/{SPEC-ID}-{slug}/phase-spec-{YYYY-MM-DD}-{phase-slug}.md
151
+ ```
152
+
153
+ Use the `templates/phase-spec.md` template and set the phase-spec
154
+ frontmatter `status` to `in-progress`. Phase-2-onward specs **must** fill
155
+ in the **Delta from prior phases** section (the first phase typically has
156
+ just "首 phase,無前置 Delta"; this is phase 2+, so the section is required).
157
+
158
+ Walk the developer through each section, in the same way `new-feature-flow`
159
+ Step 4 does — Behavior (with Aggregate state transitions and Domain
160
+ Events) / Business Rules / Delta / Edge Cases / Domain Events / layer-by-
161
+ layer implementation plan — but only list NEW or MODIFIED BRs in Business Rules;
162
+ UNCHANGED BRs from prior phases stay in the Current BR Snapshot table on
163
+ `_index.md` and are NOT re-copied here. The Delta section uses the same
164
+ ADDED / MODIFIED / REMOVED / RENAMED + optional UNCHANGED format defined
165
+ in `references/modify-existing-flow.md` (Aggregate state transitions and
166
+ Domain Events go in the Given/When/Then within each Delta entry).
167
+
168
+ After the spec body is drafted, generate the `Implementation Tasks` section
169
+ (format `[LAYER]-[NUMBER]:description` with Core layer tags
170
+ DOMAIN / APP / INFRA / API / TEST — see `new-feature-flow.md` Step 5 for
171
+ the detailed list, recommended order: DOMAIN → APP → INFRA → API).
172
+
173
+ **→ Step Gate: Step 4 → Step 5**
174
+
175
+ Announce to developer:
176
+ > "Phase-spec drafted at
177
+ > `dflow/specs/features/active/{SPEC-ID}-{slug}/phase-spec-{date}-{phase-slug}.md`.
178
+ > Ready to refresh `_index.md` (add Phase Specs row, regenerate Current BR
179
+ > Snapshot from the Delta)? `/dflow:next` to proceed."
180
+
181
+ > Commit checkpoint (per `references/git-integration.md` § Commit Checkpoints, Branch Gate & AI Commits): with the Step 1 branch gate satisfied (you are on the feature's branch), offer to commit the phase-spec baseline and record the result in the `_index.md` Checkpoint Log.
182
+
183
+ Wait for confirmation before entering Step 5.
184
+
185
+ ## Step 5: Refresh `_index.md`
186
+
187
+ Update the feature's `_index.md`:
188
+
189
+ 1. **Phase Specs table** — add a new row for this phase:
190
+ ```
191
+ | {N+1} | {YYYY-MM-DD} | {phase-slug} | in-progress | [phase-spec-{date}-{phase-slug}.md](./phase-spec-{date}-{phase-slug}.md) |
192
+ ```
193
+
194
+ 2. **Current BR Snapshot table** — regenerate to reflect the new phase's
195
+ Delta:
196
+ - **ADDED** entries → new rows (First Seen = `phase-{N+1}`, Last Updated =
197
+ `phase-{N+1}`, Status = `active`)
198
+ - **MODIFIED** entries → update Current Rule + bump Last Updated to `phase-{N+1}`
199
+ - **REMOVED** entries → flip Status to `removed`, bump Last Updated to
200
+ `phase-{N+1}` (do NOT delete the row — keep the audit trail)
201
+ - **RENAMED** entries → update BR-ID / Current Rule as appropriate; bump
202
+ Last Updated
203
+
204
+ 3. **Resume Pointer** — update to "phase-{N+1} in progress:
205
+ {one-line about what's actively being worked on}" and "Next Action:
206
+ implement DOMAIN-1 / write Aggregate ... / etc."
207
+
208
+ The Snapshot is the feature-level CURRENT STATE, not history. Do not let
209
+ it grow into a cumulative log; the per-phase Delta sections are the
210
+ historical audit trail. The bounded context's `rules.md` / `behavior.md`
211
+ remain the system-level current state and are NOT updated here — that
212
+ synchronisation happens at `/dflow:finish-feature`.
213
+
214
+ After the refresh, summarize for the developer:
215
+ > "Phase-spec ready, `_index.md` refreshed. Snapshot now shows
216
+ > {n_active} active BRs ({n_added} added in this phase, {n_modified}
217
+ > modified, {n_removed} removed). Ready to enter Step 6 —
218
+ > follow the phase-spec's Implementation Tasks list (DOMAIN → APP → INFRA → API)?
219
+ > `/dflow:next` to proceed, or adjust the plan first."
220
+
221
+ **→ Step Gate: Step 5 → Step 6**
222
+
223
+ Wait for confirmation before entering Step 6.
224
+
225
+ ## Step 6: Implement and Verify the Phase
226
+
227
+ Follow the phase-spec's `Implementation Tasks` in the recommended layer order:
228
+ DOMAIN → APP → INFRA → API, with TEST tasks interleaved where they prove the
229
+ layer behavior.
230
+
231
+ During implementation, continuously verify:
232
+
233
+ - [ ] `Implementation Tasks` are checked off as they complete, or unchecked
234
+ items are explicitly labelled as follow-up
235
+ - [ ] Every ADDED / MODIFIED / REMOVED / RENAMED Delta entry is covered by
236
+ implementation or tests
237
+ - [ ] Every affected `BR-*` business rule is covered by implementation or tests
238
+ - [ ] Every affected Given/When/Then scenario is covered by implementation or tests
239
+ - [ ] New or changed Domain Events are raised in the implementation
240
+ - [ ] Aggregate invariants still hold after the change
241
+ - [ ] Domain layer remains framework-pure; EF configuration stays in Infrastructure
242
+ - [ ] No business logic leaks into Application handlers, Infrastructure queries,
243
+ or Presentation controllers
244
+ - [ ] Test failures have been resolved or explicitly recorded as follow-up
245
+
246
+ If implementation changes the agreed Delta, update the phase-spec before
247
+ continuing. Do not let code and spec diverge silently.
248
+
249
+ **→ Step Gate: Step 6 → Step 7**
250
+
251
+ Announce to developer:
252
+ > "Phase implementation appears complete and verified against the phase-spec.
253
+ > Ready to mark this phase completed and update `_index.md`? `/dflow:next`
254
+ > to proceed."
255
+
256
+ > Commit checkpoint (per `references/git-integration.md` § Commit Checkpoints, Branch Gate & AI Commits): offer to commit the phase implementation, then record the result in the `_index.md` Checkpoint Log.
257
+
258
+ Wait for confirmation before entering Step 7.
259
+
260
+ ## Step 7: Complete the Phase
261
+
262
+ Update the feature artifacts:
263
+
264
+ 1. **Phase spec status** — change this phase-spec's frontmatter `status`
265
+ from `in-progress` to `completed`.
266
+ 2. **Implementation Tasks** — keep completed tasks checked. If any task is not
267
+ done, mark it explicitly as follow-up and link to the relevant future
268
+ phase, issue, or tech-debt entry.
269
+ 3. **Phase Specs table** — update this phase's `_index.md` row from
270
+ `in-progress` to `completed`.
271
+ 4. **Current BR Snapshot** — reconcile the snapshot against the implemented
272
+ Delta. If implementation changed the Delta, update the phase-spec first,
273
+ then regenerate the snapshot.
274
+ 5. **Resume Pointer** — update to one of:
275
+ - "phase-{N+1} completed; next action: run `/dflow:new-phase` for the next
276
+ slice"
277
+ - "phase-{N+1} completed; next action: run `/dflow:finish-feature` if the
278
+ feature is ready to wrap up"
279
+
280
+ The bounded context's `rules.md` / `behavior.md` / `events.md` and the
281
+ feature directory move to `completed/` remain `/dflow:finish-feature`
282
+ responsibilities. Do not sync BC-level current state or archive the whole
283
+ feature from `/dflow:new-phase`.
284
+
285
+ After completion, summarize for the developer:
286
+ > "Phase {N+1} is implemented and marked completed. `_index.md` is refreshed.
287
+ > If another slice is needed, run `/dflow:new-phase`; if the feature is done,
288
+ > run `/dflow:finish-feature`."
@@ -0,0 +1,130 @@
1
+ # PR Review Checklist — Greenfield Clean Architecture
2
+
3
+ `/dflow:pr-review` enters this checklist starting from **Step 0**. Do not skip Step 0 — reviewing code without first understanding spec intent breaks the SDD feedback loop (all the upstream spec work loses its verification mechanism).
4
+
5
+ ## Step 0: Understand the Change Intent (before code review)
6
+
7
+ Ground yourself in the spec *before* looking at the diff. A feature
8
+ directory may contain multiple spec files; identify which ones this PR
9
+ touches and read them all.
10
+
11
+ - [ ] Locate the feature directory at
12
+ `dflow/specs/features/active/{SPEC-ID}-{slug}/` (or
13
+ `dflow/specs/features/completed/{SPEC-ID}-{slug}/` if the PR is the
14
+ closeout commit and the dir was already `git mv`d)
15
+ - [ ] Read `_index.md` first — it gives you the feature-level overview,
16
+ Current BR Snapshot, list of phase-specs, and Resume Pointer (where the
17
+ author left off)
18
+ - [ ] Identify which **phase-spec(s)** and / or **lightweight-spec(s)**
19
+ this PR diff touches. There may be:
20
+ - A new phase-spec being introduced (T1) — read in full,
21
+ including Aggregate state transitions and Domain Events
22
+ - An existing phase-spec being marked `completed` — verify its
23
+ Delta-from-prior-phases section reads correctly relative to the
24
+ prior phase
25
+ - A new lightweight-spec (T2) — read in full
26
+ - Just T3 inline rows added to `_index.md` Lightweight Changes (no
27
+ spec file changed) — confirm the row description is precise
28
+ - [ ] If a `Behavior Delta` / Delta-from-prior-phases section exists,
29
+ read **ADDED / MODIFIED / REMOVED / RENAMED** — pay attention to
30
+ any Aggregate state transitions and Domain Events listed in the
31
+ Delta; note any **UNCHANGED** scope declaration
32
+ - [ ] State in one sentence: "This PR intends to {change} because
33
+ {reason}." (If you can't, pause and ask the author.)
34
+ - [ ] Cross-reference `dflow/specs/domain/{context}/behavior.md` if it exists
35
+ — confirm the Delta has been reflected or is scheduled to be
36
+ (draft vs finalized; finalisation usually happens at
37
+ `/dflow:finish-feature` time)
38
+ - [ ] Only then proceed to the code-review sections below
39
+
40
+ If the PR has no spec or no `_index.md`:
41
+ ```
42
+ "I don't see a feature directory or _index.md for this PR. Before I
43
+ review the code, can you point me to it, or run /dflow:new-feature
44
+ (or /dflow:bug-fix for a small fix) to create the feature directory
45
+ and at least a lightweight spec? SDD relies on the spec being the
46
+ review anchor."
47
+ ```
48
+
49
+ ## Spec Compliance
50
+
51
+ Per-feature checks:
52
+ - [ ] **Feature directory exists** with `_index.md` + at least one
53
+ phase-spec (or one lightweight-spec for a T2-only feature)
54
+ - [ ] **`_index.md` Current BR Snapshot is up to date** — reflects
55
+ the cumulative effect of all phase-specs / lightweight-specs in
56
+ the directory
57
+ - [ ] **`_index.md` Phase Specs table** — every row's referenced
58
+ phase-spec file exists and its `status` matches the row's claim
59
+ - [ ] **For follow-up features**: `_index.md` Metadata has `follow-up-of:
60
+ {原 SPEC-ID}` AND the original feature's `_index.md`
61
+ Follow-up Tracking row references this feature
62
+
63
+ Per-phase-spec / lightweight-spec checks (run for **each** spec file the
64
+ PR touches, not just one):
65
+ - [ ] Spec matches code
66
+ - [ ] Implementation matches Given/When/Then scenarios (including
67
+ Aggregate state transitions and Domain Events)
68
+ - [ ] All business rules (BR-*) in this spec implemented
69
+ - [ ] Edge cases (EC-*) in this spec handled
70
+ - [ ] **Delta integrity** (phase 2+ only) — the Delta-from-prior-phases
71
+ section's ADDED / MODIFIED / REMOVED / RENAMED entries actually
72
+ match the diff against the prior phase-spec's BR set
73
+
74
+ If the closeout commit is in this PR (`/dflow:finish-feature` was run):
75
+ - [ ] **BC layer sync landed** — `dflow/specs/domain/{context}/rules.md` /
76
+ `behavior.md` / `events.md` / `context-map.md` reflect the
77
+ feature's net effect (compare against `_index.md` Current BR
78
+ Snapshot)
79
+ - [ ] **Whole feature directory `git mv`'d** to `completed/` — git
80
+ shows `renamed:` (not `deleted:` + `new file:`)
81
+ - [ ] **Integration Summary** was emitted to the conversation (not
82
+ written to a file — it's ephemeral)
83
+
84
+ ## Domain Layer Quality
85
+
86
+ - [ ] **Zero external dependencies** — check the Domain package/module manifest; no external dependencies beyond the language/runtime baseline
87
+ - [ ] **No ORM attributes** — no [Table], [Column], [Key] on domain classes
88
+ - [ ] **No serialization attributes** — no [JsonProperty], [JsonIgnore]
89
+ - [ ] **Private setters** — state changes through methods only
90
+ - [ ] **Invariants enforced** — constructor and methods reject invalid state
91
+ - [ ] **Value Objects immutable** — using `record` or readonly properties
92
+ - [ ] **Domain Events raised** — significant state changes produce events
93
+ - [ ] **Other Aggregates referenced by ID** — not by direct object reference
94
+
95
+ ## Application Layer Quality
96
+
97
+ - [ ] **No business logic** — handlers only orchestrate, not decide
98
+ - [ ] **CQRS respected** — Commands for writes, Queries for reads
99
+ - [ ] **Validation in Validator** — not in handler or controller
100
+ - [ ] **No Domain objects in DTOs** — proper mapping between layers
101
+ - [ ] **Event handlers are idempotent** — safe to replay
102
+
103
+ ## Infrastructure Layer Quality
104
+
105
+ - [ ] **EF config in Fluent API** — not attributes on Domain entities
106
+ - [ ] **Repository only for Aggregate Roots** — not for child entities
107
+ - [ ] **No business logic in SQL/LINQ** — complex filtering via Specifications
108
+ - [ ] **External service behind interface** — mockable for tests
109
+
110
+ ## Presentation Layer Quality
111
+
112
+ - [ ] **Thin controllers** — parse, dispatch, respond
113
+ - [ ] **No domain objects exposed** — only DTOs/ViewModels in API
114
+ - [ ] **Proper status codes** — 201 Created, 404 Not Found, 422 Unprocessable
115
+ - [ ] **No business logic** — not even validation beyond format checking
116
+
117
+ ## Cross-Cutting
118
+
119
+ - [ ] **Glossary consistency** — new terms documented?
120
+ - [ ] **Context boundaries respected** — no reaching into another context's internals
121
+ - [ ] **Domain Events documented** — events.md updated?
122
+ - [ ] **Tests cover invariants** — not just happy path
123
+
124
+ ## Architecture Score
125
+
126
+ - **A**: Clean layer separation, Domain-first design, full spec, comprehensive tests
127
+ - **B**: Mostly clean, minor layer bleed, spec exists, good test coverage
128
+ - **C**: Some business logic in wrong layer, spec exists
129
+ - **D**: Working code but architecture concerns, needs refactoring
130
+ - **F**: Business logic in controller/infrastructure, no spec — push back
@@ -121,12 +121,39 @@ Recommend `docs/migrating-to-dflow-v1.md` for the manual migration
121
121
  checklist. Migration affects every spec the team has written; manual
122
122
  review is required.
123
123
 
124
+ ## Workflow Steps
125
+
126
+ This guide is the **command registry, routing rules, and project context**.
127
+ Executable workflow steps (Step 1→N, step gates, completion checklists) are
128
+ **not** defined here. They live in the vendored workflow bundle projected into
129
+ this project at:
130
+
131
+ - `dflow/specs/shared/dflow-workflows/`
132
+
133
+ When executing a `/dflow:*` command, read the matching flow file from that
134
+ directory first. For example:
135
+
136
+ | Command | Flow file |
137
+ |---|---|
138
+ | `/dflow:new-feature` | `dflow/specs/shared/dflow-workflows/references/new-feature-flow.md` |
139
+ | `/dflow:modify-existing` | `dflow/specs/shared/dflow-workflows/references/modify-existing-flow.md` |
140
+ | `/dflow:bug-fix` | `dflow/specs/shared/dflow-workflows/references/modify-existing-flow.md` (lightweight-ceremony branch) |
141
+ | `/dflow:new-phase` | `dflow/specs/shared/dflow-workflows/references/new-phase-flow.md` |
142
+ | `/dflow:finish-feature` | `dflow/specs/shared/dflow-workflows/references/finish-feature-flow.md` |
143
+ | `/dflow:verify` | `dflow/specs/shared/dflow-workflows/references/drift-verification.md` |
144
+ | `/dflow:pr-review` | `dflow/specs/shared/dflow-workflows/references/pr-review-checklist.md` |
145
+ | `/dflow:report-dflow-feedback` | `dflow/specs/shared/dflow-workflows/references/dflow-feedback-flow.md` |
146
+
147
+ Supporting files (templates, domain modeling guide, drift checklist) are also
148
+ in `dflow/specs/shared/dflow-workflows/` under the same relative paths used
149
+ by the flow files.
150
+
124
151
  ## Tool-Specific Notes
125
152
 
126
- This file is the canonical Dflow guide. Root-level files such as
127
- `AGENTS.md`, `CLAUDE.md`, and `.github/copilot-instructions.md`
153
+ This file is the canonical Dflow guide (registry + rules + router). Root-level
154
+ files such as `AGENTS.md`, `CLAUDE.md`, and `.github/copilot-instructions.md`
128
155
  should stay thin and point back here.
129
156
 
130
157
  If a tool does not support Dflow slash commands, treat the command names as
131
- plain workflow names. This guide contains the installed runtime behavior
132
- contract; execute the workflow semantics defined here directly.
158
+ plain workflow names and follow the matching flow file from the workflow bundle
159
+ at `dflow/specs/shared/dflow-workflows/`.
@@ -1,14 +1,16 @@
1
- <!-- Scaffolding template maintained alongside Dflow skill. See archive/proposals/PROPOSAL-010 for origin. -->
1
+ <!-- Seeded by Dflow. -->
2
2
 
3
3
  # CLAUDE.md Snippet — Dflow Adoption (Greenfield track)
4
4
 
5
5
  > Source: `scaffolding/CLAUDE-md-snippet.md`
6
6
  > Purpose: a minimal block you paste into (or replace with) your
7
7
  > project's root `CLAUDE.md` when adopting Dflow.
8
- > For the Greenfield track, the full reference template lives at
9
- > `sdd-ddd-greenfield-skill/templates/CLAUDE.md` — if you want the complete
10
- > legacy Claude-specific version, use that instead. New CLI init output uses
11
- > `AI-AGENT-GUIDE.md` plus a generated `CLAUDE.md` shim.
8
+ > For the Greenfield track, the full reference template lives in the
9
+ > in-project bundle at
10
+ > `dflow/specs/shared/dflow-workflows/templates/CLAUDE.md` (projected by
11
+ > `dflow init`) — if you want the complete legacy Claude-specific version,
12
+ > use that instead. New CLI init output uses `AI-AGENT-GUIDE.md` plus a
13
+ > generated `CLAUDE.md` shim.
12
14
 
13
15
  ---
14
16
 
@@ -91,14 +93,14 @@ dflow/specs/
91
93
 
92
94
  > SDD 流程、Git 整合、Domain 層規範、AI 協作
93
95
 
94
- ### Dflow Skill — Canonical Decision Logic Lives in the Skill
96
+ ### Dflow Skill — Canonical Decision Logic Lives in the Project
95
97
 
96
98
  AI 的完整決策樹、Workflow Transparency、Ceremony Scaling 三層判準
97
99
  (T1 Heavy / T2 Light / T3 Trivial)、所有 slash command 的 step-by-step
98
- 流程 **不在此重述**,請以 Dflow skill 本體為準:
100
+ 流程 **不在此重述**,請以本專案內的 Dflow 工件為準(init 時投影):
99
101
 
100
- - `sdd-ddd-greenfield-skill/SKILL.md`(決策樹 + Slash Commands 總表)
101
- - `sdd-ddd-greenfield-skill/references/` 內各 flow 文件
102
+ - `dflow/specs/shared/AI-AGENT-GUIDE.md`(決策樹 + Slash Commands 總表 + 路由規則)
103
+ - `dflow/specs/shared/dflow-workflows/references/` 內各 flow 文件(執行步驟定義)
102
104
 
103
105
  本專案採用的 Dflow entry points:
104
106
  - Dflow CLI init command (`dflow init`, or `npx dflow-sdd-ddd init` when using the no-install path) — 專案初始化(一次性,已執行過)
@@ -159,10 +161,10 @@ AI 的完整決策樹、Workflow Transparency、Ceremony Scaling 三層判準
159
161
 
160
162
  ## Notes
161
163
 
162
- - This snippet is intentionally lighter than
163
- `sdd-ddd-greenfield-skill/templates/CLAUDE.md`. If you want the full version
164
- (with detailed flow descriptions per slash command), use that
165
- template instead
164
+ - This snippet is intentionally lighter than the in-project bundle
165
+ template at `dflow/specs/shared/dflow-workflows/templates/CLAUDE.md`. If
166
+ you want the full version (with detailed flow descriptions per slash
167
+ command), use that template instead
166
168
  - The snippet does NOT re-copy the Dflow decision tree, Ceremony
167
169
  Scaling criteria, or per-flow step details — those live in the
168
170
  skill and change when the skill evolves
@@ -1,4 +1,4 @@
1
- <!-- Scaffolding template maintained alongside Dflow skill. See archive/proposals/PROPOSAL-010 for origin. -->
1
+ <!-- Seeded by Dflow. -->
2
2
 
3
3
  # Git Principles — Git Flow edition
4
4
 
@@ -125,8 +125,6 @@ Commits must tie back to a SPEC-ID:
125
125
  [{SPEC-ID}] {short description}
126
126
 
127
127
  {optional detailed body}
128
-
129
- Co-Authored-By: Claude <noreply@anthropic.com> ← suggested, not mandatory
130
128
  ```
131
129
 
132
130
  ### Type prefix (recommended)
@@ -309,19 +307,22 @@ Three categories:
309
307
  | `git stash` (local-only) |
310
308
  | `git branch` (listing only) |
311
309
 
312
- ### AI commit authorship (suggested, not enforced)
310
+ ### AI commit authorship
313
311
 
314
- When an AI assists in producing a commit, appending a `Co-Authored-By`
315
- line is **suggested** but not mandatory. The canonical form for
316
- Claude is:
312
+ How AI-made commits are marked is chosen once at `dflow init` and recorded in
313
+ `dflow/specs/shared/_conventions.md` § AI Commit Policy:
317
314
 
318
- ```
319
- Co-Authored-By: Claude <noreply@anthropic.com>
320
- ```
315
+ - `none` — AI commits carry no extra marker.
316
+ - `co-authored-by` — a `Co-Authored-By: dflow-ai <noreply@dflow.local>` trailer
317
+ (teams may customize the name / email).
318
+ - `prefix` — an `[ai-assisted]` commit-subject prefix.
321
319
 
322
- For other AI assistants, use the vendor-documented author line (or omit
323
- it). This is a project-level transparency convention, not a Dflow
324
- requirement.
320
+ This recorded setting is authoritative and the runtime does not re-ask. The AI
321
+ offers commits at lifecycle checkpoints (see `references/git-integration.md`
322
+ § Commit Checkpoints, Branch Gate & AI Commits) using your Git identity, and you
323
+ can always decline. If your team also wants vendor attribution, appending the
324
+ assistant's documented line (e.g. `Co-Authored-By: Claude
325
+ <noreply@anthropic.com>`) is an independent, optional convention on top.
325
326
 
326
327
  ---
327
328
 
@@ -1,4 +1,4 @@
1
- <!-- Scaffolding template maintained alongside Dflow skill. See archive/proposals/PROPOSAL-010 for origin. -->
1
+ <!-- Seeded by Dflow. -->
2
2
 
3
3
  # Git Principles — Trunk-based / GitHub Flow edition
4
4
 
@@ -77,8 +77,6 @@ recommended but not strictly required:
77
77
  {type}({scope}): {short description}
78
78
 
79
79
  [{SPEC-ID}] {longer description, optional}
80
-
81
- Co-Authored-By: Claude <noreply@anthropic.com> ← suggested, not mandatory
82
80
  ```
83
81
 
84
82
  ### Type prefix (Conventional Commits)
@@ -106,8 +104,6 @@ feat(expense): add ExpenseReport submission invariants
106
104
  [SPEC-20260421-001] Introduce ExpenseReport Aggregate with submission
107
105
  state machine; enforces non-negative Amounts and requires at least one
108
106
  ExpenseItem before submission.
109
-
110
- Co-Authored-By: Claude <noreply@anthropic.com>
111
107
  ```
112
108
 
113
109
  ---
@@ -183,7 +179,6 @@ Related BR-IDs:
183
179
  Domain Events introduced / modified: {Event names, or "(none)"}
184
180
 
185
181
  Related SPEC-IDs: {SPEC-ID}{, follow-up SPEC-IDs if any}
186
- Co-Authored-By: Claude <noreply@anthropic.com>
187
182
  ```
188
183
 
189
184
  GitHub PR editor can be pre-filled with this body; the merge button
@@ -210,8 +205,6 @@ feat({scope}): {Phase N title} — closes {SPEC-ID}
210
205
  Change Scope: ... (as in §4.1)
211
206
  Related BR-IDs: ...
212
207
  Domain Events: ...
213
-
214
- Co-Authored-By: Claude <noreply@anthropic.com>
215
208
  ```
216
209
 
217
210
  ### 4.3 Fast-forward (feature has 1 commit total)
@@ -288,19 +281,22 @@ Three categories:
288
281
  | `git branch` (listing only) |
289
282
  | `gh pr status` / `gh pr view` |
290
283
 
291
- ### AI commit authorship (suggested, not enforced)
284
+ ### AI commit authorship
292
285
 
293
- When an AI assists in producing a commit, appending a `Co-Authored-By`
294
- line is **suggested** but not mandatory. The canonical form for
295
- Claude is:
286
+ How AI-made commits are marked is chosen once at `dflow init` and recorded in
287
+ `dflow/specs/shared/_conventions.md` § AI Commit Policy:
296
288
 
297
- ```
298
- Co-Authored-By: Claude <noreply@anthropic.com>
299
- ```
289
+ - `none` — AI commits carry no extra marker.
290
+ - `co-authored-by` — a `Co-Authored-By: dflow-ai <noreply@dflow.local>` trailer
291
+ (teams may customize the name / email).
292
+ - `prefix` — an `[ai-assisted]` commit-subject prefix.
300
293
 
301
- For other AI assistants, use the vendor-documented author line (or omit
302
- it). This is a project-level transparency convention, not a Dflow
303
- requirement.
294
+ This recorded setting is authoritative and the runtime does not re-ask. The AI
295
+ offers commits at lifecycle checkpoints (see `references/git-integration.md`
296
+ § Commit Checkpoints, Branch Gate & AI Commits) using your Git identity, and you
297
+ can always decline. If your team also wants vendor attribution, appending the
298
+ assistant's documented line (e.g. `Co-Authored-By: Claude
299
+ <noreply@anthropic.com>`) is an independent, optional convention on top.
304
300
 
305
301
  ---
306
302
 
@@ -1,4 +1,4 @@
1
- <!-- Scaffolding template maintained alongside Dflow skill. See archive/proposals/PROPOSAL-010 for origin. -->
1
+ <!-- Seeded by Dflow. -->
2
2
 
3
3
  # Spec Writing Conventions — {System Name}
4
4
 
@@ -1,4 +1,4 @@
1
- <!-- Scaffolding template maintained alongside Dflow skill. See archive/proposals/PROPOSAL-010 for origin. -->
1
+ <!-- Seeded by Dflow. -->
2
2
 
3
3
  # System Overview — {System Name}
4
4
 
@@ -179,5 +179,7 @@ Initial ADRs that typically exist:
179
179
  - [Glossary](../domain/glossary.md)
180
180
  - [Tech debt backlog](../architecture/tech-debt.md)
181
181
  - [Architecture decisions](../architecture/decisions/)
182
- - Dflow skill: see `CLAUDE.md` and the `sdd-ddd-greenfield-skill/` bundle
183
- for the full AI workflow guidance.
182
+ - Dflow workflow guidance: see `CLAUDE.md` (project-level AI rules) and the
183
+ in-project vendored bundle at `dflow/specs/shared/AI-AGENT-GUIDE.md` +
184
+ `dflow/specs/shared/dflow-workflows/references/` for the full AI workflow
185
+ decision tree, slash commands, and step-by-step flow definitions.