dflow-sdd-ddd 0.9.0 → 0.10.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 (46) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/README.en.md +19 -8
  3. package/README.md +12 -5
  4. package/TEMPLATE-COVERAGE.md +0 -1
  5. package/bin/dflow.js +4 -4
  6. package/docs/evaluating-dflow.en.md +11 -7
  7. package/docs/evaluating-dflow.md +9 -4
  8. package/docs/migrating-to-dflow-v1.md +7 -3
  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/lib/init.js +761 -145
  16. package/package.json +2 -2
  17. package/templates/brownfield/references/drift-verification.md +1 -4
  18. package/templates/brownfield/references/finish-feature-flow.md +3 -2
  19. package/templates/brownfield/references/git-integration.md +0 -1
  20. package/templates/brownfield/references/init-project-flow.md +31 -17
  21. package/templates/brownfield/references/modify-existing-flow.md +6 -38
  22. package/templates/brownfield/references/new-feature-flow.md +13 -11
  23. package/templates/brownfield/references/new-phase-flow.md +1 -1
  24. package/templates/brownfield/scaffolding/AI-AGENT-GUIDE.md +253 -2
  25. package/templates/brownfield/scaffolding/CLAUDE-md-snippet.md +5 -8
  26. package/templates/brownfield/scaffolding/_conventions.md +10 -9
  27. package/templates/brownfield/templates/_index.md +1 -1
  28. package/templates/brownfield/templates/lightweight-spec.md +1 -1
  29. package/templates/brownfield/templates/phase-spec.md +1 -1
  30. package/templates/common/skill/SKILL.md +9 -6
  31. package/templates/greenfield/references/drift-verification.md +1 -4
  32. package/templates/greenfield/references/finish-feature-flow.md +3 -2
  33. package/templates/greenfield/references/git-integration.md +0 -1
  34. package/templates/greenfield/references/init-project-flow.md +31 -17
  35. package/templates/greenfield/references/modify-existing-flow.md +5 -7
  36. package/templates/greenfield/references/new-feature-flow.md +14 -12
  37. package/templates/greenfield/references/new-phase-flow.md +1 -1
  38. package/templates/greenfield/scaffolding/AI-AGENT-GUIDE.md +222 -2
  39. package/templates/greenfield/scaffolding/CLAUDE-md-snippet.md +10 -15
  40. package/templates/greenfield/scaffolding/Git-principles-trunk.md +1 -1
  41. package/templates/greenfield/scaffolding/_conventions.md +9 -8
  42. package/templates/greenfield/templates/_index.md +1 -1
  43. package/templates/greenfield/templates/lightweight-spec.md +1 -1
  44. package/templates/greenfield/templates/phase-spec.md +1 -1
  45. package/templates/brownfield/templates/CLAUDE.md +0 -165
  46. package/templates/greenfield/templates/CLAUDE.md +0 -172
@@ -28,7 +28,7 @@ are not available in the current AI tool:
28
28
  | `/dflow:bug-fix` | A defect can be described with expected vs actual behavior. |
29
29
  | `/dflow:new-phase` | An active feature needs another implementation slice. |
30
30
  | `/dflow:finish-feature` | Implementation is complete and needs drift closure. |
31
- | `/dflow:verify` | Specs, domain docs, implementation, and tests need consistency checks. |
31
+ | `/dflow:verify` | A bounded context's domain docs (`rules.md` ↔ `behavior.md`) need a consistency / drift check. |
32
32
  | `/dflow:pr-review` | A change is ready for SDD/DDD review. |
33
33
  | `/dflow:report-dflow-feedback` | You found a Dflow issue or improvement and want a sanitized upstream feedback draft. |
34
34
  | `/dflow:status` | You need the current workflow state, current step, completed work, in-progress work, remaining work, pending decision, and next valid action. |
@@ -45,7 +45,7 @@ Machine-readable source for rendering tool-specific thin wrappers:
45
45
  | bug-fix | /dflow:bug-fix | Investigate a defect described by expected vs actual behavior. | expected vs actual | workflow |
46
46
  | new-phase | /dflow:new-phase | Add another implementation slice to an active feature. | feature id or phase goal | workflow |
47
47
  | finish-feature | /dflow:finish-feature | Close implementation with drift checks and archived feature state. | feature id | workflow |
48
- | verify | /dflow:verify | Check specs, domain docs, implementation, and tests for consistency. | area or feature id | workflow |
48
+ | verify | /dflow:verify | Check a bounded context's domain docs (`rules.md` ↔ `behavior.md`) for consistency. | bounded context or all | workflow |
49
49
  | pr-review | /dflow:pr-review | Review a ready change for SDD/DDD alignment. | change or branch | workflow |
50
50
  | report-dflow-feedback | /dflow:report-dflow-feedback | Draft sanitized upstream feedback about Dflow. | issue or improvement | workflow |
51
51
  | status | /dflow:status | Report current workflow state and next valid action. | - | control |
@@ -53,6 +53,25 @@ Machine-readable source for rendering tool-specific thin wrappers:
53
53
  | cancel | /dflow:cancel | Abort the active workflow and return to free conversation. | - | control |
54
54
  <!-- dflow-command-registry:end -->
55
55
 
56
+ ## Routing Non-Command Input
57
+
58
+ Not every developer message maps to a `/dflow:*` workflow. Route non-command
59
+ input like this (supporting files live in the workflow bundle at
60
+ `dflow/specs/shared/dflow-workflows/`):
61
+
62
+ - **"I'm designing a domain model" / "How should I model X?"** → read
63
+ `references/ddd-modeling-guide.md`.
64
+ - **"Quick question about..." / "How does X work?"** → check
65
+ `dflow/specs/domain/` first and answer from the documented domain knowledge.
66
+ - **"I'm creating a branch"** → read `references/git-integration.md`.
67
+ - **"Dflow seems wrong" / "this template is confusing"** (or you notice Dflow
68
+ guidance drift) → suggest `/dflow:report-dflow-feedback`; never submit
69
+ anything upstream automatically.
70
+ - **Anything else code-related** → assess whether it touches business logic. If
71
+ it does, use the auto-trigger safety net (suggest the matching `/dflow:*`
72
+ command and wait for confirmation — see § Workflow Transparency); if not, help
73
+ directly with no ceremony.
74
+
56
75
  ## Status / Control Commands
57
76
 
58
77
  `/dflow:status` reports active workflow state. Include these fields: workflow,
@@ -71,6 +90,67 @@ workflow was cancelled.
71
90
  When no workflow is active, `/dflow:next` and `/dflow:cancel` must report that
72
91
  there is no active workflow to advance or cancel.
73
92
 
93
+ ## Workflow Transparency
94
+
95
+ Dflow uses a hybrid interaction design: `/dflow:*` commands are the primary
96
+ entry, natural-language auto-trigger is a safety net, and tiered transparency
97
+ keeps the developer aware of where they are in a workflow.
98
+
99
+ ### Auto-Trigger Safety Net
100
+
101
+ When natural language implies a development task, detect the intent — but do
102
+ **not** auto-enter a workflow. Instead:
103
+
104
+ 1. State your judgment clearly:
105
+ > "I think this is a new-feature task."
106
+ 2. Offer the developer three options:
107
+ - Type `/dflow:new-feature` to start explicitly
108
+ - Reply "OK" / "繼續" to confirm this workflow
109
+ - Or correct the workflow (e.g., "no, this is a bug fix")
110
+ 3. Wait for confirmation before entering any workflow.
111
+
112
+ This addresses three failure modes of pure auto-trigger: missed triggers, wrong
113
+ workflow selection, and invisible state.
114
+
115
+ ### Three-Tier Transparency
116
+
117
+ During an active workflow, communicate at three levels — no more, no less:
118
+
119
+ | Level | Trigger point | AI behavior |
120
+ |---|---|---|
121
+ | **Flow entry (must confirm)** | After judging the workflow from NL | Stop and wait for confirmation (command, "OK", or implicit) |
122
+ | **Step gate (notify + optional confirm)** | Before major milestones | Announce the transition; if the developer provides next-step input, treat it as implicit confirmation |
123
+ | **Step-internal (notify only)** | Step N → Step N+1 | Announce "Step N complete, entering Step N+1" — do not wait |
124
+
125
+ The specific step-gate positions for each workflow live in that flow's own file
126
+ (`dflow/specs/shared/dflow-workflows/references/<flow>.md`), which is the source
127
+ of truth for its gate sequence.
128
+
129
+ ### Confirmation Signals (NL ↔ Command Equivalence)
130
+
131
+ Any of these count as "proceed to next step" — accept whichever the developer
132
+ uses:
133
+
134
+ - **Command**: `/dflow:next`
135
+ - **Verbal (English)**: OK / yes / continue / go ahead / sounds good / proceed
136
+ - **Verbal (Chinese)**: 好 / 對 / 繼續 / 可以 / 沒問題
137
+ - **Implicit**: the developer provides the information needed for the next step
138
+ (e.g., the AI asks "Which Aggregate?" and the developer answers with the
139
+ Aggregate name → implicit confirmation)
140
+
141
+ The implicit-confirmation rule matters — do not turn every transition into a
142
+ ceremony where the developer must say "OK" before every sentence.
143
+
144
+ ### Completion Checklist Skip Guard
145
+
146
+ Completion checklists and their step ordering live in the flow files and run at
147
+ the gate each flow specifies (the feature-level completion gate in
148
+ `new-feature-flow` / `modify-existing-flow`, the phase-level gate in
149
+ `new-phase-flow`). Do not run a checklist opportunistically. But if the
150
+ developer skips the gate and commits directly, use the auto-trigger safety net
151
+ to prompt — "It looks like you're wrapping up — should I run the Step N
152
+ completion checklist?" — before giving commit guidance.
153
+
74
154
  ## Source of Truth
75
155
 
76
156
  Dflow-owned project documents live under `dflow/specs/`.
@@ -85,6 +165,41 @@ Dflow-owned project documents live under `dflow/specs/`.
85
165
  | Completed feature snapshots | `dflow/specs/features/completed/` |
86
166
  | Technical debt | `dflow/specs/architecture/tech-debt.md` or `dflow/specs/migration/tech-debt.md` |
87
167
 
168
+ ### Project Structure
169
+
170
+ The full `dflow/specs/` layout Dflow seeds and maintains:
171
+
172
+ ```
173
+ dflow/specs/
174
+ ├── shared/ # Project-level governance docs (seeded by npx dflow-sdd-ddd init)
175
+ │ ├── _overview.md
176
+ │ └── _conventions.md
177
+ ├── domain/
178
+ │ ├── glossary.md
179
+ │ ├── context-map.md # Bounded Context relationships
180
+ │ └── {bounded-context}/
181
+ │ ├── context.md
182
+ │ ├── models.md # Aggregates, Entities, VOs
183
+ │ ├── rules.md # Business rules index (BR-ID + one-line)
184
+ │ ├── behavior.md # Consolidated behavior (Given/When/Then)
185
+ │ └── events.md # Domain Events catalog
186
+ ├── features/
187
+ │ ├── active/
188
+ │ │ └── {SPEC-ID}-{slug}/ # One feature = one directory
189
+ │ │ ├── _index.md # Feature dashboard + BR Snapshot + Resume Pointer
190
+ │ │ ├── phase-spec-YYYY-MM-DD-{slug}.md # T1: 0..N phase specs
191
+ │ │ └── lightweight-YYYY-MM-DD-{slug}.md # T2: 0..N lightweight specs
192
+ │ │ # (or BUG-{NUMBER}-{slug}.md)
193
+ │ ├── completed/ # Done (whole feature directory archived here)
194
+ │ └── backlog/
195
+ │ #
196
+ │ # SPEC-ID format: SPEC-YYYYMMDD-NNN; slug follows discussion language (中文 / 英文 both OK).
197
+ │ # T3 trivial changes have NO independent file — just a row in _index.md Lightweight Changes.
198
+ └── architecture/
199
+ ├── decisions/ # Architecture Decision Records
200
+ └── tech-debt.md
201
+ ```
202
+
88
203
  ## Core Rules
89
204
 
90
205
  1. Spec before code: meaningful behavior changes need a spec or lightweight bug spec before implementation.
@@ -93,6 +208,111 @@ Dflow-owned project documents live under `dflow/specs/`.
93
208
  4. Check drift before calling work complete.
94
209
  5. Follow `dflow/specs/shared/_conventions.md`, especially `## Prose Language`.
95
210
 
211
+ ## Ceremony Scaling
212
+
213
+ Dflow uses three tiers — **T1 Heavy / T2 Light / T3 Trivial** — chosen by the AI
214
+ per change. `/dflow:new-feature` and `/dflow:new-phase` always default to T1 (no
215
+ judgement needed). The criteria below apply when `/dflow:modify-existing` or
216
+ `/dflow:bug-fix` decides which tier fits a modification.
217
+
218
+ | Tier | Scenario | Output | Command / Trigger |
219
+ |---|---|---|---|
220
+ | **T1 Heavy** | New feature, new phase, new Aggregate / BC, architectural change, new BR | Independent `phase-spec-YYYY-MM-DD-{slug}.md` placed in the feature directory + `_index.md` Phase Specs row + refresh BR Snapshot. For a new Aggregate / BC also create an `aggregate-design.md` from `templates/aggregate-design.md` **in the feature directory** (working worksheet; the durable summary stays in `models.md`) + update `context-map.md` + `events.md`. | `/dflow:new-feature` / `/dflow:new-phase` |
221
+ | **T2 Light** | Bug fix (logic error), UI input validation tweak, flow branch change — has BR Delta | Independent `lightweight-{YYYY-MM-DD}-{slug}.md` (or `BUG-{NUMBER}-{slug}.md`) inside the feature directory + `_index.md` Lightweight Changes row (outbound link) + refresh BR Snapshot. Confirm the fix lands in the correct architectural layer. | `/dflow:bug-fix` or `/dflow:modify-existing` (lightweight branch) |
222
+ | **T3 Trivial** | Button colour, copy/text fix, typo, formatting, pure comments — **no BR change, no Domain concept change, no data structure change** | **Inline row in `_index.md` Lightweight Changes only** (no independent spec file) | `/dflow:modify-existing` (`_index-only` branch) |
223
+
224
+ **T3 criteria** (the AI must satisfy **all four** before classifying T3):
225
+
226
+ 1. No BR-ID change (no ADDED / MODIFIED / REMOVED / RENAMED business rule)
227
+ 2. No Domain concept added or changed (Aggregate / Entity / VO / Event)
228
+ 3. No data structure change (table, column, relation, index)
229
+ 4. Only changes UI surface (colour, text, layout), pure comments, or pure formatting
230
+
231
+ If any criterion fails → drop to T2; if Domain / BR / data structure is touched → escalate to T1.
232
+
233
+ **Below T3 — Dflow doesn't track at all**: pure typo fixes, commit-message
234
+ typos, pure formatting commits (e.g. `prettier` / `dotnet format` auto-runs).
235
+ You can `git commit` directly without writing even a T3 inline row.
236
+
237
+ **DDD Modeling Depth (still informs T1 scope)**:
238
+
239
+ - New Aggregate / BC → **Full**: create an `aggregate-design.md` from `templates/aggregate-design.md` in the feature directory (durable summary stays in `models.md`), update `context-map.md`, define Domain Events in `events.md`
240
+ - Feature within an existing BC → **Standard**: confirm Aggregate ownership, update `models.md` and `rules.md`
241
+ - T2 / T3 → confirm the fix lands in the correct architectural layer; no design-level updates required
242
+
243
+ ## Behavior Source of Truth (rules.md + behavior.md)
244
+
245
+ Each Bounded Context has two complementary files that together describe the
246
+ system's current behavior:
247
+
248
+ - **`rules.md`** — declarative index: lists each BR-ID with a one-line summary.
249
+ Quick lookup, easy to scan.
250
+ - **`behavior.md`** — scenario-level detail: the full Given/When/Then scenarios
251
+ for each BR-ID, including Aggregate state transitions and Domain Events. This
252
+ is the consolidated source of truth for "what does the system actually do
253
+ right now?"
254
+
255
+ `dflow/specs/features/completed/` is a historical archive (individual change
256
+ records). `behavior.md` is the **merged current state** — when a feature is
257
+ completed, the AI merges its scenarios into `behavior.md`; when behavior is
258
+ modified, the AI updates the corresponding section to reflect the new behavior
259
+ (git preserves history). See the `behavior.md` template in the workflow bundle
260
+ at `dflow/specs/shared/dflow-workflows/templates/behavior.md`.
261
+
262
+ ## Guiding Questions by Activity
263
+
264
+ SDD has five conceptual activities (Understanding / Domain Modeling / Spec
265
+ Writing / Implementation Planning / Testing Strategy) that the AI walks the
266
+ developer through inside a workflow. They cut across workflow steps — Activity 2
267
+ (Domain Modeling) might span Step 2 and Step 3 of new-feature-flow, for example.
268
+
269
+ **Activity markers in the phase-spec template**: each section in
270
+ `templates/phase-spec.md` carries an HTML comment (e.g.,
271
+ `<!-- Fill timing: Activity 2: Domain Modeling -->`) indicating the activity in
272
+ which that section should be filled. These markers align with the activities
273
+ below and are used by `/dflow:status` and the completion checklist to track
274
+ progress. When guiding a developer, fill sections in activity order; do not jump
275
+ ahead to Activity 4 (Implementation Planning) before Activity 3 (Spec Writing)
276
+ is agreed. The `Implementation Tasks` section at the end of the template is
277
+ produced by the AI at the end of Activity 4 — see new-feature-flow.md Step 5 /
278
+ new-phase-flow.md Step 4 / modify-existing-flow.md Step 3.
279
+
280
+ Note: the phase-spec template HTML comments cover Activity 1–4; Activity 5
281
+ (Testing Strategy) is a conceptual category folded into the Test Strategy
282
+ section that the template marks with Activity 4 timing. In `new-phase-flow`,
283
+ Activity 5 is exercised operationally in Step 6 when implementation and tests
284
+ are verified against the phase-spec before Step 7 completion.
285
+
286
+ ### Activity 1: Understanding (What & Why)
287
+ - What problem does this solve? Who asked for it?
288
+ - What's the expected behavior from the user's perspective?
289
+ - Are there existing specs or domain docs related to this?
290
+
291
+ ### Activity 2: Domain Modeling (DDD)
292
+ - Which Bounded Context? (Check context-map.md)
293
+ - What Aggregate does this belong to? Or is it a new Aggregate?
294
+ - What are the invariants this Aggregate must protect?
295
+ - Are there Value Objects to extract? (Money, DateRange, Address...)
296
+ - Will this produce Domain Events? Who consumes them?
297
+ - Does this cross Aggregate / Context boundaries? → Need an integration strategy
298
+
299
+ ### Activity 3: Spec Writing
300
+ - Write the spec using the template (see `templates/phase-spec.md`)
301
+ - Define Given/When/Then with Aggregate state transitions
302
+ - Document Domain Events produced and consumed
303
+ - Identify edge cases around Aggregate invariants
304
+
305
+ ### Activity 4: Implementation Planning
306
+ - Domain layer: Aggregate design, Value Objects, Domain Events
307
+ - Application layer: Command / Query, handlers, validation
308
+ - Infrastructure: Repository implementation, persistence / ORM configuration
309
+ - Presentation: API endpoint design
310
+
311
+ ### Activity 5: Testing Strategy
312
+ - Domain unit tests: invariants, business rules, value object equality
313
+ - Application tests: command / query handler behavior
314
+ - Integration tests: repository, external services
315
+
96
316
  ## Pre-V1 Artifacts Detection
97
317
 
98
318
  When working in a project that adopted Dflow before `dflow-sdd-ddd@0.1.0`,
@@ -5,12 +5,10 @@
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 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.
8
+ > New CLI init output uses `dflow/specs/shared/AI-AGENT-GUIDE.md` as the
9
+ > canonical guide plus a thin generated `CLAUDE.md` shim. This snippet is
10
+ > only the older Claude-specific two-H2 layout, for when you intentionally
11
+ > want that shape in your project's root `CLAUDE.md`.
14
12
 
15
13
  ---
16
14
 
@@ -23,8 +21,7 @@
23
21
  Claude-specific two-H2 layout in your project's root `CLAUDE.md`.
24
22
 
25
23
  The two-H2 structure (`System Context` / `Development Workflow`) is intentional and must be
26
- preserved — it matches the Dflow skill's `templates/CLAUDE.md` and
27
- keeps every project's `CLAUDE.md` scannable for AI in the same shape.
24
+ preserved — it keeps every project's `CLAUDE.md` scannable for AI in the same shape.
28
25
 
29
26
  ---
30
27
 
@@ -67,7 +64,7 @@ Presentation → Application → Domain ← Infrastructure
67
64
 
68
65
  ### Project Structure
69
66
 
70
- 完整 specs 目錄結構見 Dflow skill `SKILL.md` § "Project Structure"。
67
+ 完整 specs 目錄結構見 `AI-AGENT-GUIDE.md` § Source of Truth。
71
68
  以下只列本專案當前狀態(Dflow CLI init 建立後可能還未全填):
72
69
 
73
70
  ```
@@ -161,13 +158,11 @@ AI 的完整決策樹、Workflow Transparency、Ceremony Scaling 三層判準
161
158
 
162
159
  ## Notes
163
160
 
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
161
+ - This snippet is intentionally minimal — the older Claude-specific two-H2
162
+ layout, not a full restatement of Dflow's logic
168
163
  - The snippet does NOT re-copy the Dflow decision tree, Ceremony
169
- Scaling criteria, or per-flow step details — those live in the
170
- skill and change when the skill evolves
164
+ Scaling criteria, or per-flow step details — those live in
165
+ `AI-AGENT-GUIDE.md` and the workflow bundle, and change as Dflow evolves
171
166
  - Re-running the Dflow CLI init command (`dflow init`, or `npx dflow-sdd-ddd init`
172
167
  when using the no-install path) will NOT overwrite an existing `CLAUDE.md`;
173
168
  if you want to re-sync, merge manually
@@ -58,7 +58,7 @@ gh pr create --base main --fill
58
58
 
59
59
  - **Short-lived feature branches**: typically hours to a few days, not
60
60
  weeks. Encourage splitting large features into multiple phase-specs
61
- and merging each phase to `main` (see Dflow's Ceremony Scaling +
61
+ and merging each phase to `main` (see `AI-AGENT-GUIDE.md` § Ceremony Scaling +
62
62
  `/dflow:new-phase`)
63
63
  - **Main is always releasable**: feature flags or dark launches for
64
64
  incomplete functionality; CI must be green on `main` at all times
@@ -8,15 +8,16 @@
8
8
  > Audience: engineers writing specs; AI assistants producing spec drafts.
9
9
 
10
10
  This file captures **project-level** conventions only. Template shapes
11
- and Ceremony criteria are defined by the Dflow skill; here we just
12
- record how *this* project fills them in.
11
+ and Ceremony criteria are defined by Dflow itself (the Ceremony tier criteria
12
+ live in `AI-AGENT-GUIDE.md` § Ceremony Scaling; template shapes live in the
13
+ workflow bundle); here we just record how *this* project fills them in.
13
14
 
14
15
  ---
15
16
 
16
17
  ## Where Specs Live
17
18
 
18
19
  All spec documents live under `dflow/specs/`. The feature directory pattern
19
- and file names follow Dflow (see the Dflow skill § "Project Structure"
20
+ and file names follow Dflow (see `AI-AGENT-GUIDE.md` § Source of Truth
20
21
  for the full tree):
21
22
 
22
23
  ```
@@ -119,8 +120,8 @@ Project-specific guidance when filling these templates:
119
120
 
120
121
  ## Ceremony Scaling (Project Application)
121
122
 
122
- The Dflow skill defines three tiers — **T1 Heavy / T2 Light / T3
123
- Trivial**. See the Dflow skill § "Ceremony Scaling" for the full
123
+ Dflow defines three tiers — **T1 Heavy / T2 Light / T3
124
+ Trivial**. See `AI-AGENT-GUIDE.md` § Ceremony Scaling for the full
124
125
  criteria table. We do not re-define the tier criteria here; this
125
126
  section records how *this* project applies them in borderline
126
127
  situations.
@@ -132,9 +133,9 @@ situations.
132
133
  | {e.g. EF configuration tweak in Infrastructure} | T3 if no Domain change | Infra-only; inline row in `_index.md` |
133
134
  | {e.g. Domain Event payload extension} | T1 | Event contract change affects cross-context consumers |
134
135
 
135
- ### DDD Modeling Depth (Dflow skill § Ceremony Scaling)
136
+ ### DDD Modeling Depth (`AI-AGENT-GUIDE.md` § Ceremony Scaling)
136
137
 
137
- The Dflow skill further distinguishes:
138
+ Dflow further distinguishes:
138
139
 
139
140
  - **Full** (new Aggregate / new BC): use `templates/aggregate-design.md`
140
141
  + update `context-map.md` + define events in `events.md`
@@ -170,7 +171,7 @@ and `/dflow:new-phase` flows; the project-level convention is simply
170
171
  - [Git principles](Git-principles-{gitflow|trunk}.md)
171
172
  - [Context map](../domain/context-map.md)
172
173
  - [Glossary](../domain/glossary.md)
173
- - Dflow skill `SKILL.md` — canonical source for Ceremony Scaling, flow
174
+ - `AI-AGENT-GUIDE.md` — canonical source for Ceremony Scaling, flow
174
175
  selection, and template shapes.
175
176
  - Dflow skill `references/ddd-modeling-guide.md` — DDD tactical
176
177
  pattern reference.
@@ -89,7 +89,7 @@ Template note (for AI):
89
89
  > T3 行:inline 完整描述一句話 + 標籤(如 `[cosmetic]` / `[text]` /
90
90
  > `[format]`);T3 不產獨立 spec 檔
91
91
  >
92
- > Tier 判準見 SKILL.md § Ceremony Scaling 三層表。
92
+ > Tier 判準見 AI-AGENT-GUIDE.md § Ceremony Scaling 三層表。
93
93
 
94
94
  | Date | Tier | Description | Commit |
95
95
  |---|---|---|---|
@@ -11,7 +11,7 @@ branch: bugfix/BUG-{NUMBER}-{short-description}
11
11
  Template note (for AI):
12
12
  This is the **lightweight-spec** template — it corresponds to T2 Light
13
13
  ceremony in the three-tier Ceremony Scaling (T1 Heavy / T2 Light /
14
- T3 Trivial; see SKILL.md § Ceremony Scaling for the tier criteria).
14
+ T3 Trivial; see AI-AGENT-GUIDE.md § Ceremony Scaling for the tier criteria).
15
15
 
16
16
  - T1 Heavy → use templates/phase-spec.md instead
17
17
  - T2 Light → THIS template; produces an independent file
@@ -21,7 +21,7 @@ Template note (for AI):
21
21
 
22
22
  Each section below carries an HTML comment indicating its fill-in activity (Activity 1-4).
23
23
  These activity markers let /dflow:status and the completion checklist track progress.
24
- Activities correspond to SKILL.md § Guiding Questions by Activity:
24
+ Activities correspond to AI-AGENT-GUIDE.md § Guiding Questions by Activity:
25
25
  Activity 1: Understanding (What & Why)
26
26
  Activity 2: Domain Modeling (BC, Aggregate, VO, Events)
27
27
  Activity 3: Spec Writing (Behavior + Rules + Edge Cases)
@@ -1,165 +0,0 @@
1
- # Project: {系統名稱} — {Framework}
2
-
3
- **重要:所有開發工作都必須遵循本文件定義的流程。**
4
-
5
- ---
6
-
7
- ## System Context
8
-
9
- > 技術棧、業務領域、目錄結構
10
-
11
- ### Background
12
-
13
- 這是一個運行中的既有系統,使用 {Framework} / {Language},目前持續新增與修改功能。
14
- 目前採用 SDD 流程,同時為 DDD 與 target architecture 做準備。
15
-
16
- ### Project Structure
17
-
18
- ```
19
- dflow/specs/
20
- ├── shared/ # 專案級治理文件(由 dflow init 寫入)
21
- │ ├── _overview.md # 系統現況與 target architecture
22
- │ └── _conventions.md # 規格撰寫慣例與模板
23
- ├── domain/ # 領域知識
24
- │ ├── glossary.md # 術語表(Ubiquitous Language)
25
- │ └── {context}/ # 按 Bounded Context 分
26
- │ ├── context.md # Context 邊界與職責
27
- │ ├── models.md # 領域模型定義
28
- │ └── rules.md # 業務規則目錄
29
- ├── features/
30
- │ ├── active/ # 進行中的 feature
31
- │ │ └── {SPEC-ID}-{slug}/ # 一個 feature 一個目錄
32
- │ │ ├── _index.md # Feature dashboard:Goals & Scope / Phase Specs / Current BR Snapshot / Lightweight Changes / Resume Pointer
33
- │ │ ├── phase-spec-YYYY-MM-DD-{slug}.md # T1 Heavy:每 phase 一份
34
- │ │ └── lightweight-YYYY-MM-DD-{slug}.md # T2 Light(或 BUG-NNN-{slug}.md)
35
- │ ├── completed/ # 整個 feature 目錄 git mv 到這裡
36
- │ └── backlog/ # 待處理
37
- │ # SPEC-ID 格式:SPEC-YYYYMMDD-NNN;slug 跟隨討論語言(中文/英文皆可)
38
- │ # T3 無獨立檔,只在 _index.md Lightweight Changes 寫一列
39
- └── migration/
40
- └── tech-debt.md # 技術債與遷移備忘
41
-
42
- src/
43
- ├── Domain/ # 抽離的領域邏輯(framework-pure)
44
- │ ├── {Context}/
45
- │ │ ├── Entities/
46
- │ │ ├── ValueObjects/
47
- │ │ ├── Services/
48
- │ │ └── Interfaces/
49
- │ └── SharedKernel/
50
- └── Delivery/ # delivery-layer code(entrypoints, controllers, handlers)
51
- ```
52
-
53
- > **目錄命名說明**:上方 `src/Domain/` / `src/Delivery/` 是 Clean
54
- > Architecture 通用示意,不限 stack。請依專案實際慣例對應(例:Java/Spring 用
55
- > `src/main/java/com/example/domain/`、Node/TS 用 `src/domain/` /
56
- > `src/routes/`、Python 用 `domain/` package、Go 用 `internal/domain/` /
57
- > `internal/handler/`、.NET 用 `src/{Project}.Domain/` + `.csproj` 分層)。
58
- > 完整 per-stack 範例見 `docs/examples-by-stack.md`。重點是
59
- > `src/Domain/`(或對應命名)保持與 delivery/entrypoint code 獨立。
60
-
61
- ---
62
-
63
- ## Development Workflow
64
-
65
- > SDD 流程、Git 整合、Domain 層規範、術語表、AI 協作
66
-
67
- ### Core Principles
68
- 1. **Spec Before Code** — 沒有規格就不寫實作
69
- 2. **Domain Extraction** — 業務邏輯屬於 `src/Domain/`,不屬於 delivery/entrypoint code(presentation/UI layer、controllers、handlers、jobs、message consumers、data pipelines、stored procedures)
70
- 3. **Ubiquitous Language** — 使用 `dflow/specs/domain/glossary.md` 中定義的術語
71
- 4. **Migration Awareness** — 每個決策都要考慮 target architecture
72
-
73
- ### Three Ceremony Tiers
74
-
75
- 不是每次修改都要跑完整流程。AI 依下列判準選 tier:
76
-
77
- - **T1 Heavy** — 新功能、新 phase、架構變動、新增 BR → 建獨立 phase-spec,
78
- 走 `/dflow:new-feature` 或 `/dflow:new-phase`
79
- - **T2 Light** — bug fix、UI 輸入驗證、流程分支修改(有 BR Delta 但無 Domain /
80
- 資料結構變動)→ 建獨立 lightweight spec 置於 feature 目錄內
81
- - **T3 Trivial** — 按鈕顏色、文案修正、typo、排版、純註解(無 BR 變動、
82
- 無 Domain 概念動、無資料結構動、只改 UI 表層 / 註解 / 格式化)→
83
- 只在 `_index.md` Lightweight Changes inline 寫一列
84
-
85
- 純 typo / 純格式化 commit(`dotnet format` / `prettier` 自動整理)**低於 T3**:
86
- 直接 `git commit`,不走 Dflow。
87
-
88
- ### New Feature
89
- 1. 建 feature 目錄 `dflow/specs/features/active/{SPEC-ID}-{slug}/`
90
- 2. 建 `_index.md`(feature dashboard)+ 第一份 `phase-spec-YYYY-MM-DD-{slug}.md`
91
- 3. 識別涉及的領域概念,更新 `dflow/specs/domain/` 下的對應文件
92
- 4. 盡可能將業務邏輯實作在 `src/Domain/` 中(語言純粹的 class,不依賴 delivery framework)
93
- 5. Delivery/entrypoint code 僅負責輸入解析、協調流程與輸出綁定,呼叫 Domain 層處理邏輯
94
- 6. 撰寫測試驗證 Domain 層行為符合規格
95
-
96
- ### New Phase
97
- 1. 在已啟動的 active feature 上新增一份 phase-spec(含 Delta-from-prior-phases)
98
- 2. 更新 `_index.md` 的 Phase Specs 表 + regenerate Current BR Snapshot
99
- 3. 嚴格只適用於 active feature;completed 的 feature 不接受新 phase
100
-
101
- ### Modify Existing
102
- 1. AI 依 T1 / T2 / T3 判準分流
103
- 2. 若偵測到改動與 completed feature 相關,主動詢問是否為 follow-up
104
- (follow-up 走新建 feature + `follow-up-of` 鏈回原 feature;不把 T2/T3
105
- 寫回 completed 目錄)
106
- 3. 如果該功能的邏輯還在 delivery/entrypoint code 中,評估是否值得先抽離到 Domain 層
107
- 4. 在 `dflow/specs/migration/tech-debt.md` 記錄發現的技術債
108
-
109
- ### Bug Fix
110
- 1. 建立輕量規格(問題 + 現有行為 + 預期行為 + 修復方式)
111
- 2. 若 bug 不附掛既有 feature,先建最小 feature 目錄再放 lightweight-spec
112
- 3. 修 Bug 時順便記錄發現的技術債
113
-
114
- ### Feature Closeout
115
- 1. 驗證 feature 目錄內所有 phase-spec `status: completed`
116
- 2. 把 `_index.md` Current BR Snapshot 同步到 BC 層 `rules.md` / `behavior.md`
117
- 3. `git mv` 整個 feature 目錄從 `active/` 搬到 `completed/`
118
- 4. 產出 Integration Summary(Git-strategy-neutral;不自動 merge)
119
-
120
- ### Git Integration
121
-
122
- > 本流程只規定 SDD 必要的最小 Git 耦合(feature branch per feature、
123
- > `git mv`、commit 對應 SPEC-ID)。實際採用的分支策略(Git Flow /
124
- > GitHub Flow / trunk-based / 單一 main)由專案決定,不在此強制。
125
- > 若採用 Git Flow,可參考 `scaffolding/Git-principles-gitflow.md` 範本。
126
-
127
- **分支命名**
128
- ```
129
- feature/{SPEC-ID}-{short-description} # 新功能(SDD 必須)
130
- bugfix/{BUG-ID}-{short-description} # Bug 修復(SDD 必須)
131
- ```
132
-
133
- **Commit Message**
134
- ```
135
- [SPEC-ID] 簡述變更
136
- ```
137
-
138
- **分支規則**
139
- - **feature/** — 必須先有 spec 才能開始編碼
140
- - **bugfix/** — 至少要有輕量 spec
141
- - **`/dflow:bug-fix`** 不綁定任何分支策略;採 Git Flow 的專案可選擇把
142
- 緊急修復放在 `hotfix/` 分支,但這是專案決策,Dflow 不代為規定
143
-
144
- ### Domain Layer Rules (`src/Domain/`)
145
-
146
- 此目錄中的程式碼必須遵守:
147
- - ❌ 不可引用任何 delivery-framework 命名空間(例:HTTP 請求/回應物件、Session/Cookie context、job runner context、CLI flag parser、ViewState 類等)
148
- - ❌ 不可直接存取資料庫(使用 interface + Repository pattern)
149
- - ❌ 不可使用 delivery-framework runtime context(例:HTTP request/response、session/cookie、job runner state、CLI args)
150
- - ❌ 不可有 UI / entrypoint 相關邏輯(格式化顯示、controller/page/handler 引用)
151
- - ✅ 語言純粹的 class(不依賴 delivery framework),可直接搬到 target architecture
152
- - ✅ 所有公開行為都能在沒有 delivery infrastructure 的情況下測試
153
-
154
- ### Glossary
155
-
156
- 所有業務術語必須使用 `dflow/specs/domain/glossary.md` 中定義的名稱。
157
- 遇到新術語時,先新增到術語表再使用。
158
-
159
- ### AI Collaboration Notes
160
-
161
- - 開發者提出任何功能需求時,先引導建立 spec
162
- - 在回答 Domain 相關問題時,優先參考 `dflow/specs/domain/` 中的文件
163
- - 發現 delivery/entrypoint code 中的業務邏輯時,建議抽離到 `src/Domain/`
164
- - 每次開發循環結束時,提醒更新術語表和技術債記錄
165
- - 建立分支前,確認命名符合規範且對應 spec 存在