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,444 @@
1
+ # Modify Existing Feature Workflow
2
+
3
+ Step-by-step guide for when a developer triggers `/dflow:modify-existing` or `/dflow:bug-fix` (or natural language implying a modification task — see SKILL.md § Workflow Transparency for the auto-trigger safety net).
4
+
5
+ **Step Gates** in this flow (stop-and-confirm before proceeding):
6
+ - Step 2 → Step 3 (baseline captured → analyze business logic embedded in delivery/entrypoint code: presentation/UI layer, controllers, handlers, jobs, message consumers, data pipelines, or stored procedures)
7
+ - Step 4 → Step 5 (extraction decision → start implementation)
8
+ - Step 5 → Step 6 (implementation done → update artifacts)
9
+
10
+ All other step transitions are **step-internal**: announce "Step N complete, entering Step N+1" and proceed without waiting. See SKILL.md § Workflow Transparency for the full transparency protocol and confirmation signals.
11
+
12
+ **Ceremony adjustment when triggered by `/dflow:bug-fix`**: treat as lightweight — use the Lightweight Spec Template at the end of this file instead of the full spec, and Step 4 (extraction) may default to "defer and record in tech-debt.md" unless the bug itself is in extractable logic. T2 still generates a concise `Implementation Tasks` checklist (see Step 4).
13
+
14
+ ## Mindset
15
+
16
+ Modifying existing features is your best opportunity to progressively extract domain knowledge
17
+ and business logic. Treat every modification as a chance to:
18
+ 1. Document what currently exists (if no spec exists yet)
19
+ 2. Extract business logic from delivery/entrypoint code to Domain layer
20
+ 3. Record tech debt for the target architecture
21
+
22
+ ## Step 1: Assess the Change — Ceremony Tier + Feature Linkage
23
+
24
+ Before producing any spec prose, read `dflow/specs/shared/_conventions.md`
25
+ and apply the `## Prose Language` setting. If the setting is missing or not
26
+ an explicit language tag, ask the developer to update `_conventions.md`
27
+ before continuing. This requirement also applies when this flow is entered
28
+ through `/dflow:bug-fix`.
29
+
30
+ This step has two parallel concerns:
31
+
32
+ **Part A — Determine the Ceremony Tier (T1 / T2 / T3)**
33
+
34
+ Dflow runs three ceremony tiers (full table in SKILL.md § Ceremony Scaling).
35
+ For a modification, AI judges which tier fits before deciding what to
36
+ produce:
37
+
38
+ | Tier | When to choose | Production |
39
+ |---|---|---|
40
+ | **T1 Heavy** | Architectural change / new BR / new Domain concept / new data structure → escalate to `/dflow:new-phase` (if extending an active feature) or `/dflow:new-feature` (if it's truly a new concern) | Full phase-spec via the appropriate flow |
41
+ | **T2 Light** | Bug fix / UI input validation tweak / flow branch change — **has BR Delta** but no Domain or data-structure overhaul | Independent `lightweight-{date}-{slug}.md` placed in feature directory + outbound-link row in `_index.md` Lightweight Changes |
42
+ | **T3 Trivial** | Button colour / copy fix / typo / formatting / pure comments — **all four T3 criteria** must hold (no BR change, no Domain concept change, no data structure change, only UI surface / comments / formatting) | **Inline row in `_index.md` Lightweight Changes only** (no independent spec file) |
43
+
44
+ If any T3 criterion fails → drop to T2. If Domain / BR / data structure
45
+ is touched → escalate to T1.
46
+
47
+ **Below T3** (pure typo, formatting commit) → tell the developer Dflow
48
+ doesn't track this and they can `git commit` directly.
49
+
50
+ **Part B — Locate the Feature this Change Belongs To**
51
+
52
+ Walk through these in order:
53
+
54
+ 1. **Active features**: scan `dflow/specs/features/active/*/_index.md`. Does
55
+ the change belong inside an existing active feature directory? If
56
+ yes, use that as the host (T1 → `/dflow:new-phase`; T2 → place
57
+ lightweight-spec inside; T3 → inline row in that `_index.md`).
58
+ 2. **Completed features**: scan `dflow/specs/features/completed/*/_index.md`
59
+ Goals & Scope sections. If the change description is semantically
60
+ related to a completed feature, this becomes the **completed feature
61
+ reopen** scenario — go to Step 1.5 below.
62
+ 3. **Standalone**: if no related feature exists (active or completed),
63
+ this is a new concern. For T1, use `/dflow:new-feature`. For T2 / T3
64
+ on a standalone bug, see Step 1.5 — `/dflow:bug-fix` will create a
65
+ minimal feature directory to host the lightweight-spec.
66
+
67
+ > **Why scan completed too?** Completed features are frozen history
68
+ > and **cannot accept** any T2 / T3 directly
69
+ > (would break the "completed = frozen" semantic). Reopen routes through
70
+ > a new follow-up feature instead — see Step 1.5.
71
+
72
+ **→ Transition (step-internal)**: Step 1 complete. Announce "Step 1 complete (tier {T1/T2/T3} decided, host feature {SPEC-ID-slug / new / follow-up} identified). Entering Step 1.5 / Step 2 as appropriate." and continue.
73
+
74
+ ## Step 1.5: Completed-Feature Reopen Detection (only if Step 1 found a related completed feature)
75
+
76
+ If Step 1 Part B identified a semantically related completed feature, AI
77
+ must explicitly disambiguate the user's intent **before** writing any
78
+ files:
79
+
80
+ ```
81
+ "I notice this change overlaps with completed feature
82
+ `{SPEC-ID}-{slug}` (Goals & Scope: '{first 1-2 sentences}', completed on
83
+ {date}).
84
+
85
+ Is this a follow-up to that feature, or an independent new concern?
86
+
87
+ Option A — follow-up of `{SPEC-ID}-{slug}`
88
+ → Build a new feature with a fresh SPEC-ID and `follow-up-of:
89
+ {SPEC-ID}` link back to the original. Inherits BR Snapshot baseline
90
+ from the BC's rules.md.
91
+ Option B — independent new requirement
92
+ → Run /dflow:new-feature normally; no link to the completed feature.
93
+ Option C — actually I think it's just a tiny lightweight tweak, no
94
+ new feature needed
95
+ → Refused. Completed features are frozen — even T3 inline rows must
96
+ live in a new follow-up feature directory. (You can still pick A
97
+ and have the new feature contain only one T3 row in _index.md if
98
+ that fits the change.)"
99
+ ```
100
+
101
+ **Wait for the developer's explicit choice (A / B / C).**
102
+
103
+ If A (follow-up): proceed to **Step 1.6: Create Follow-up Feature**.
104
+ If B (independent): tell the developer to `/dflow:new-feature`; this
105
+ flow ends.
106
+ If C: gently re-explain (per decision 17) that completed features
107
+ cannot accept direct T2 / T3 writes; offer Option A (follow-up with
108
+ just a T3 inline row) as the lightweight equivalent.
109
+
110
+ ## Step 1.6: Create Follow-up Feature (only if user picked Option A)
111
+
112
+ Build the follow-up feature using the same machinery as
113
+ `/dflow:new-feature` (see `new-feature-flow.md` Steps 3.5 and 4), with
114
+ these follow-up-specific differences:
115
+
116
+ - **New SPEC-ID** (today's date sequence — do NOT reuse the original
117
+ SPEC-ID): e.g. original `SPEC-20260201-003-訂單折扣` → follow-up
118
+ `SPEC-20260424-002-訂單折扣-匯率擴充` (or any new slug)
119
+ - **New slug**: not required to equal the original slug; pick whatever
120
+ best describes the follow-up scope
121
+ - **`_index.md` Metadata**: `follow-up-of: {原 SPEC-ID}` is REQUIRED
122
+ (uncomment the optional line in the template; can be a YAML array if
123
+ the follow-up spans multiple originals)
124
+ - **`_index.md` Goals & Scope** auto-prepended note:
125
+ ```
126
+ > 本 feature 為 `{原 SPEC-ID}-{原 slug}` 的 follow-up,原 feature
127
+ > 完成於 `{date}`,詳見 `completed/{原 SPEC-ID}-{原 slug}/_index.md`。
128
+ ```
129
+ - **`_index.md` Current BR Snapshot baseline**: AI reads the BC's
130
+ `dflow/specs/domain/{context}/rules.md` and inherits the BRs that are
131
+ in-scope for this follow-up. Mark each inherited row with First Seen
132
+ = `inherited from rules.md` and Last Updated = (empty until the new
133
+ feature's first phase Delta touches it)
134
+
135
+ **Reverse-link into the old `_index.md`**: AI also updates
136
+ `dflow/specs/features/completed/{原 SPEC-ID}-{原 slug}/_index.md` —
137
+ uncomment the Follow-up Tracking section (if not already present) and
138
+ add a row:
139
+
140
+ ```
141
+ | {新 SPEC-ID} | {新 slug} | {today} | in-progress |
142
+ ```
143
+
144
+ This update is **part of the same change set** (the developer commits
145
+ both at once; commit message should mention "Add follow-up reference to
146
+ `{新 SPEC-ID}`"). The reverse link is a derived index — the new
147
+ feature's `follow-up-of` field is the authoritative source.
148
+
149
+ After the follow-up feature is set up, this flow hands off to the
150
+ `/dflow:new-phase` flow (or stays in this flow at Step 2 for the first
151
+ phase's content).
152
+
153
+ ## Step 2: Document Current Behavior (if no spec exists)
154
+
155
+ ## Step 2: Document Current Behavior (if no spec exists)
156
+
157
+ This is critical. Before changing anything, capture what currently exists:
158
+
159
+ ```
160
+ "Before we change this, let me help you document the current behavior.
161
+ This way we have a baseline and the change is traceable."
162
+ ```
163
+
164
+ Create a spec with status `in-progress` that includes:
165
+ - Current behavior description
166
+ - Current business rules (extracted from delivery/entrypoint code)
167
+ - The proposed change clearly marked — use the **Delta** format below
168
+
169
+ If baseline domain docs are missing, create them from templates before filling content:
170
+ - `dflow/specs/domain/glossary.md` → `templates/glossary.md`
171
+ - `dflow/specs/domain/{context}/models.md` → `templates/models.md`
172
+ - `dflow/specs/domain/{context}/rules.md` → `templates/rules.md`
173
+ - `dflow/specs/domain/{context}/behavior.md` → `templates/behavior.md`
174
+ - `dflow/specs/migration/tech-debt.md` (if missing) → `templates/tech-debt.md`
175
+
176
+ ### Delta Spec Format (for modifications)
177
+
178
+ Use ADDED / MODIFIED / REMOVED / RENAMED + an optional UNCHANGED section. Keep Given/When/Then for each rule; the Delta section lives inside the spec and does not accumulate into `dflow/specs/domain/{context}/behavior.md` (git history already covers the trail).
179
+
180
+ ```markdown
181
+ ## Behavior Delta
182
+
183
+ ### ADDED - BR / behavior added
184
+ #### Rule: BR-NN {規則名稱}
185
+ Given {狀態}
186
+ When {操作}
187
+ Then {新的預期結果}
188
+
189
+ ### MODIFIED - BR / behavior modified
190
+ #### Rule: BR-NN {規則名稱}
191
+ **Before**: Given … When … Then {old result}
192
+ **After**: Given … When … Then {new result}
193
+ **Reason**: {why this change}
194
+
195
+ ### REMOVED - BR removed
196
+ #### Rule: BR-NN {規則名稱}
197
+ **Reason**: {why removed}
198
+
199
+ ### RENAMED - BR renamed
200
+ #### Rule: {old name} -> {new name}
201
+ **Reason**: {why renamed — e.g. terminology evolution / glossary alignment}
202
+
203
+ ### UNCHANGED - explicitly unaffected (optional)
204
+ - BR-003 金額上限
205
+ - BR-005 提交後不可修改
206
+ ```
207
+
208
+ **Section rules**:
209
+ - Use **ADDED / MODIFIED / REMOVED / RENAMED** for every behavioral change; skip a sub-section if it has no entries.
210
+ - `MODIFIED` must keep the "原本 / 改為" pair so reviewers see the before/after without guessing.
211
+ - `RENAMED` is only about naming (e.g., 「簽核」→「審批」). If the behavior also changed, split into RENAMED + MODIFIED entries.
212
+ - `UNCHANGED` is **recommended but optional**; fill it when regression risk is high or MODIFIED entries are many.
213
+ - Always pair with `## Reason for Change` (why this PR exists — ticket / stakeholder ask).
214
+
215
+ ### Systematic Baseline Capture (when no prior spec exists)
216
+
217
+ When the feature being modified has no existing spec, take the opportunity to do a broader baseline capture — not just the single behavior being changed. Proactively:
218
+
219
+ 1. Read the related presentation-layer or entrypoint-layer code (the modified entrypoint plus nearby entrypoints that share logic)
220
+ 2. Extract all business rules found (if/else conditions, calculations, validations)
221
+ 3. Identify domain concepts (potential Entities, Value Objects, Services)
222
+ 4. Check for duplicated logic across pages
223
+ 5. Record findings in the appropriate domain docs (`models.md`, `rules.md`) and `tech-debt.md`
224
+
225
+ This is an **opportunistic** strategy — "capture while we're already here." Do not force a full codebase scan; scope it to the modified feature and its immediate neighbors. Share what you find:
226
+
227
+ ```
228
+ "Since there's no spec for this feature yet, I took a broader look at
229
+ the related delivery/entrypoint code. I found:
230
+ - 3 business rules in {entrypoint file} (documented in rules.md)
231
+ - Duplicated validation logic shared with {other entrypoint} (recorded in tech-debt.md)
232
+ - A potential Money value object hiding in the calculation at line {N}
233
+ This gives us a better baseline before we make our change."
234
+ ```
235
+
236
+ **→ Step Gate: Step 2 → Step 3**
237
+
238
+ Announce to developer:
239
+ > "Baseline captured — current behavior is documented and the proposed change is marked. Ready to analyze the delivery/entrypoint layer to identify business logic and tech debt? `/dflow:next` or reply 'OK' to continue."
240
+
241
+ Wait for confirmation before entering Step 3.
242
+
243
+ ## Step 3: Analyze the Delivery/Entrypoint Layer
244
+
245
+ Read the existing presentation-layer or entrypoint-layer code and identify:
246
+
247
+ ### Business Logic to Extract
248
+ Look for:
249
+ - **Calculations** — anything with math, comparisons, or transformations
250
+ - **Validation rules** — any if/else that checks business conditions
251
+ - **State transitions** — status changes, approval flows
252
+ - **Data transformations** — converting between formats, currencies, units
253
+
254
+ ### Tech Debt to Record
255
+ Look for:
256
+ - Direct SQL queries in delivery/entrypoint code
257
+ - Business logic duplicated across multiple pages
258
+ - Magic numbers (e.g., `if (status == 3)`)
259
+ - Delivery-framework runtime context storing business state (e.g., HTTP session/cookie, job runner state, CLI args)
260
+ - Try/catch blocks swallowing exceptions silently
261
+ - String concatenation for SQL (SQL injection risk)
262
+
263
+ Record each finding in `dflow/specs/migration/tech-debt.md` with:
264
+ ```markdown
265
+ - [ ] {File}:{Line} — {Description} — Severity: {High|Medium|Low}
266
+ ```
267
+
268
+ **→ Transition (step-internal)**: Step 3 complete. Announce "Step 3 complete (delivery/entrypoint layer analyzed, tech debt recorded). Entering Step 4: Evaluate Extraction Opportunity." and continue.
269
+
270
+ ## Step 4: Evaluate Extraction Opportunity
271
+
272
+ For the code being modified, ask:
273
+
274
+ ```
275
+ "The business logic for [X] is currently in {entrypoint file}.
276
+ Since we're already touching this code, should we extract it to
277
+ src/Domain/{Context}/? This would:
278
+ - Make it testable
279
+ - Make it reusable
280
+ - Make it ready for the target architecture"
281
+ ```
282
+
283
+ Decision framework:
284
+ - **Extract now** if: the logic is being significantly modified anyway
285
+ - **Extract now** if: the logic is duplicated elsewhere and we need the single source of truth
286
+ - **Defer extraction** if: the change is a one-line fix and the surrounding code is too tangled
287
+ - **Always record** the extraction opportunity in tech-debt.md even if deferring
288
+
289
+ ### Generate Implementation Tasks List
290
+
291
+ For a phase-spec modification, AI generates a concrete task list and writes it into the spec's `Implementation Tasks` section using `[LAYER]-[NUMBER]:description` (DOMAIN / DELIVERY / DATA / TEST).
292
+
293
+ For a lightweight-spec (T2), AI still generates a concise `Implementation Tasks` checklist instead of skipping task generation.
294
+
295
+ If the lightweight checklist looks larger than a short-fix checklist, AI must pause and ask the developer whether to keep T2 or upgrade to T1. Do not auto-upgrade based on task count alone.
296
+
297
+ **→ Step Gate: Step 4 → Step 5**
298
+
299
+ Announce to developer:
300
+ > "Extraction decision made — {extract now / defer and record}. Ready to start implementation? `/dflow:next` to proceed, or adjust the extraction scope first."
301
+
302
+ Wait for confirmation before entering Step 5.
303
+
304
+ ## Step 5: Implement the Change
305
+
306
+ If extracting to Domain layer:
307
+
308
+ ```csharp
309
+ // BEFORE (delivery/entrypoint code)
310
+ protected void Calculate()
311
+ {
312
+ decimal amount = decimal.Parse(txtAmount.Text);
313
+ decimal rate = GetExchangeRate(ddlCurrency.SelectedValue);
314
+ decimal result = Math.Round(amount * rate, 0); // JPY has no decimals
315
+ lblResult.Text = result.ToString("N0");
316
+ }
317
+
318
+ // AFTER (Domain layer)
319
+ // src/Domain/Expense/ValueObjects/Money.cs
320
+ public record Money(decimal Amount, Currency Currency)
321
+ {
322
+ public Money ConvertTo(Currency target, ExchangeRate rate)
323
+ {
324
+ var converted = Amount * rate.Rate;
325
+ return new Money(target.Round(converted), target);
326
+ }
327
+ }
328
+
329
+ // Delivery/entrypoint code becomes thin:
330
+ protected void Calculate()
331
+ {
332
+ var money = new Money(decimal.Parse(txtAmount.Text), selectedCurrency);
333
+ var rate = _exchangeRateService.GetRate(selectedCurrency, Currency.TWD, reportDate);
334
+ var result = money.ConvertTo(Currency.TWD, rate);
335
+ lblResult.Text = result.Amount.ToString("N0");
336
+ }
337
+ ```
338
+
339
+ **→ Step Gate: Step 5 → Step 6**
340
+
341
+ Announce to developer:
342
+ > "Implementation appears complete. Ready to update artifacts (spec, rules.md, models.md, glossary, tech-debt)? `/dflow:next` to proceed."
343
+
344
+ Wait for confirmation before entering Step 6. This step gate is where the completion checklist is triggered — do not skip.
345
+
346
+ ## Step 6: Update Artifacts
347
+
348
+ Triggered by the Step 5 → Step 6 Step Gate. AI runs the completion checklist in the order below; do **not** skip a section. `Implementation Tasks` checks apply to both `phase-spec.md` and `lightweight-spec.md` (T3 inline-only has no task section).
349
+
350
+ ### 6.1 Verification — AI runs independently
351
+
352
+ Items marked *(post-6.3)* are re-verified after the documentation merge in 6.3 lands:
353
+
354
+ - [ ] Every ADDED / MODIFIED / REMOVED / RENAMED entry in the Delta section is covered by implementation or tests
355
+ - [ ] Domain layer has **no** delivery-framework references (grep `src/Domain/`)
356
+ - [ ] Extracted logic (if Step 4 decided "extract now") lives under `src/Domain/` as framework-pure code
357
+ - [ ] `Implementation Tasks` section (`phase-spec.md` or `lightweight-spec.md`): all tasks checked, or unchecked items explicitly labelled as follow-up
358
+ - [ ] *(post-6.3)* `dflow/specs/domain/{context}/behavior.md` has a section anchor for every `BR-*` in ADDED / MODIFIED entries; REMOVED entries' anchors have been deleted (mechanical input for `/dflow:verify`)
359
+ - [ ] *(post-6.3)* `dflow/specs/domain/{context}/behavior.md` `last-updated` is later than this spec's `created` date (mechanical drift guard)
360
+
361
+ If any item fails, report the gap and pause — don't proceed to 6.2.
362
+
363
+ ### 6.2 Verification — needs developer confirmation
364
+
365
+ - [ ] Does the fix faithfully express the **intent** of the Delta entries? (AI lists delta → impl location; developer judges fit)
366
+ - [ ] Did we miss any tech debt worth recording during the Step 3 analysis pass?
367
+ - [ ] If extraction was deferred, is the tech-debt entry in `tech-debt.md` clear enough for a future picker?
368
+ - [ ] Do the scenarios merged into `behavior.md` faithfully express the Delta's final-state behavior? (AI lists updated anchors; developer judges)
369
+ - [ ] Should the `Implementation Tasks` section in the spec be collapsed / removed now that it's complete? (team convention — developer decides; applies to both phase-spec and lightweight-spec)
370
+
371
+ Ask these one-by-one.
372
+
373
+ ### 6.3 Documentation updates
374
+
375
+ - [ ] Update or create the feature / bug spec; set `status: completed`
376
+ - [ ] `dflow/specs/domain/{context}/rules.md` — business rules updated
377
+ - [ ] `dflow/specs/domain/{context}/models.md` — domain model updated
378
+ - [ ] `dflow/specs/domain/glossary.md` — new / renamed terms (mirror any RENAMED delta entries here)
379
+ - [ ] `dflow/specs/domain/{context}/behavior.md` — update scenarios to reflect Delta result (merge final state, not Delta markup). Sub-steps:
380
+ - Promote any Activity 3 (Spec Writing) draft sections (from B3 mid-sync) to formal sections
381
+ - Update the corresponding `rules.md` anchor's `last-updated` date (B4)
382
+ - [ ] `behavior.md` draft cleanup — if the Delta was abandoned mid-way, keep the `## 提案中變更` section's history or explicitly REMOVE it
383
+ - [ ] `dflow/specs/migration/tech-debt.md` — findings recorded
384
+
385
+ ### 6.4 Archival
386
+
387
+ If this modification was a **T1 new-phase** within an existing active
388
+ feature, archival happens at the *feature* level, not the *phase* level —
389
+ do NOT move individual phase-spec files. Instead:
390
+
391
+ - [ ] Mark this phase-spec's `status` field `completed` in its frontmatter
392
+ - [ ] Keep the phase-spec inside its feature directory at
393
+ `dflow/specs/features/active/{SPEC-ID}-{slug}/` (it stays alongside
394
+ sibling phase-specs)
395
+ - [ ] When the developer is ready to wrap the whole feature, run
396
+ `/dflow:finish-feature` — that command does the BC-layer sync,
397
+ `git mv`s the **whole feature directory** to `completed/`, and
398
+ emits an Integration Summary
399
+
400
+ If this modification was a **T2 lightweight** spec, archival is
401
+ similarly at the feature level — the lightweight-spec stays in the
402
+ feature directory and `_index.md`'s Lightweight Changes row references it. No
403
+ file move at this point. The whole feature directory moves to
404
+ `completed/` when the developer eventually runs `/dflow:finish-feature`.
405
+
406
+ If this modification was a **T3 inline-only** change, no spec file
407
+ exists — archival is just leaving the row in `_index.md` Lightweight Changes.
408
+
409
+ If the modification was a **standalone follow-up feature** (created
410
+ via Step 1.6), the same rule applies: this flow does not archive the
411
+ new follow-up directory; that happens at `/dflow:finish-feature` time.
412
+
413
+ Only announce "change complete" after the appropriate archival step
414
+ above (or the Step 6.3 docs sweep) is done.
415
+
416
+ ## Lightweight Spec Template (for bug fixes)
417
+
418
+ For small bug fixes, a lightweight spec is enough:
419
+
420
+ ```markdown
421
+ ---
422
+ id: BUG-042
423
+ title: Fix rounding inconsistency in expense calculation
424
+ status: in-progress
425
+ bounded-context: Expense
426
+ created: 2025-02-12
427
+ ---
428
+
429
+ ## Problem
430
+ Entrypoint A uses Math.Round(amount, 0, MidpointRounding.AwayFromZero) (四捨五入)
431
+ Entrypoint B uses Math.Floor(amount) (無條件捨去)
432
+ They should both use the same rounding rule.
433
+
434
+ ## Expected Behavior
435
+ Given an expense amount of 123.5 TWD
436
+ When displayed or returned by any entrypoint
437
+ Then it should show 124 (四捨五入 per accounting standard)
438
+
439
+ ## Root Cause
440
+ Duplicated calculation logic — recorded in tech-debt.md
441
+
442
+ ## Fix
443
+ Extract rounding to Money.Round() in Domain layer, both pages call it.
444
+ ```