dflow-sdd-ddd 0.11.0 → 0.13.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 (55) hide show
  1. package/CHANGELOG.md +127 -0
  2. package/README.en.md +83 -17
  3. package/README.md +39 -9
  4. package/TEMPLATE-COVERAGE.md +1 -0
  5. package/bin/dflow.js +58 -2
  6. package/docs/evaluating-dflow.en.md +21 -2
  7. package/docs/evaluating-dflow.md +17 -3
  8. package/docs/using-with-claude-code.en.md +23 -16
  9. package/docs/using-with-claude-code.md +20 -14
  10. package/docs/using-with-codex.en.md +15 -8
  11. package/docs/using-with-codex.md +10 -7
  12. package/docs/using-with-github-copilot.en.md +8 -3
  13. package/docs/using-with-github-copilot.md +6 -3
  14. package/lib/init.js +93 -8
  15. package/lib/render.js +1263 -0
  16. package/package.json +5 -2
  17. package/templates/brownfield/references/finish-feature-flow.md +85 -29
  18. package/templates/brownfield/references/git-integration.md +29 -9
  19. package/templates/brownfield/references/init-project-flow.md +43 -1
  20. package/templates/brownfield/references/modify-existing-flow.md +23 -0
  21. package/templates/brownfield/references/new-feature-flow.md +34 -1
  22. package/templates/brownfield/references/new-phase-flow.md +12 -1
  23. package/templates/brownfield/scaffolding/AI-AGENT-GUIDE.md +45 -5
  24. package/templates/brownfield/scaffolding/Git-principles-gitflow.md +1 -1
  25. package/templates/brownfield/scaffolding/Git-principles-trunk.md +2 -2
  26. package/templates/brownfield/templates/_index.md +25 -4
  27. package/templates/brownfield/templates/context-definition.md +2 -0
  28. package/templates/brownfield/templates/context-map.md +1 -0
  29. package/templates/brownfield/templates/glossary.md +1 -0
  30. package/templates/brownfield/templates/lightweight-spec.md +3 -3
  31. package/templates/brownfield/templates/models.md +1 -0
  32. package/templates/brownfield/templates/phase-spec.md +5 -3
  33. package/templates/brownfield/templates/rules.md +1 -0
  34. package/templates/brownfield/templates/tech-debt.md +1 -0
  35. package/templates/common/references/ddd-modeling-guide.md +197 -3
  36. package/templates/greenfield/references/finish-feature-flow.md +86 -29
  37. package/templates/greenfield/references/git-integration.md +29 -9
  38. package/templates/greenfield/references/init-project-flow.md +43 -1
  39. package/templates/greenfield/references/modify-existing-flow.md +23 -0
  40. package/templates/greenfield/references/new-feature-flow.md +35 -1
  41. package/templates/greenfield/references/new-phase-flow.md +11 -0
  42. package/templates/greenfield/scaffolding/AI-AGENT-GUIDE.md +45 -5
  43. package/templates/greenfield/scaffolding/Git-principles-gitflow.md +1 -1
  44. package/templates/greenfield/scaffolding/Git-principles-trunk.md +4 -2
  45. package/templates/greenfield/templates/_index.md +25 -4
  46. package/templates/greenfield/templates/aggregate-design.md +4 -1
  47. package/templates/greenfield/templates/context-definition.md +2 -0
  48. package/templates/greenfield/templates/context-map.md +1 -0
  49. package/templates/greenfield/templates/events.md +3 -1
  50. package/templates/greenfield/templates/glossary.md +1 -0
  51. package/templates/greenfield/templates/lightweight-spec.md +3 -3
  52. package/templates/greenfield/templates/models.md +1 -0
  53. package/templates/greenfield/templates/phase-spec.md +5 -3
  54. package/templates/greenfield/templates/rules.md +1 -0
  55. package/templates/greenfield/templates/tech-debt.md +1 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dflow-sdd-ddd",
3
- "version": "0.11.0",
3
+ "version": "0.13.0",
4
4
  "description": "Spec-first SDD/DDD workflow kit for AI-assisted development",
5
5
  "type": "commonjs",
6
6
  "bin": {
@@ -39,10 +39,13 @@
39
39
  },
40
40
  "homepage": "https://github.com/weilung/dflow-sdd-ddd#readme",
41
41
  "scripts": {
42
- "test": "node test/smoke.mjs && node test/registry-parity.mjs && node test/agent-inject.mjs && node test/bundle-guards.mjs"
42
+ "test": "node test/smoke.mjs && node test/skill-default.mjs && node test/registry-parity.mjs && node test/agent-inject.mjs && node test/bundle-guards.mjs && node test/render.mjs"
43
43
  },
44
44
  "license": "AGPL-3.0-or-later",
45
45
  "publishConfig": {
46
46
  "access": "public"
47
+ },
48
+ "dependencies": {
49
+ "marked": "18.0.5"
47
50
  }
48
51
  }
@@ -55,6 +55,10 @@ proceeding (do not flip status, do not archive, do not emit summary).
55
55
  - [ ] Every phase-spec file referenced in the Phase Specs table exists at
56
56
  the path the table claims
57
57
  - [ ] Every phase-spec file's frontmatter has `status: completed`
58
+ - [ ] Every Tier = T2 row in `_index.md` Lightweight Changes references an
59
+ existing `lightweight-*.md` / `BUG-*.md` file in the feature directory
60
+ - [ ] Every such lightweight / BUG spec file's frontmatter has
61
+ `status: completed`
58
62
  - [ ] `_index.md` has no obvious open items in Resume Pointer (e.g. "phase-N
59
63
  drafting" / "implementation pending" / "TODO" markers)
60
64
  - [ ] Current BR Snapshot table is non-empty (or feature is intentionally
@@ -65,6 +69,7 @@ If any check fails:
65
69
  > found:
66
70
  > ✗ phase-spec-2026-04-15-foo.md status is still `in-progress`
67
71
  > ✗ Phase Specs table row 3 references missing file phase-spec-...
72
+ > ✗ lightweight-2026-06-20-rounding.md frontmatter status is still `in-progress`
68
73
  >
69
74
  > Address these (run `/dflow:new-phase` to add missing work, or fix the
70
75
  > stale status manually), then re-run `/dflow:finish-feature`."
@@ -92,11 +97,17 @@ branch: feature/{SPEC-ID}-{slug}
92
97
  ---
93
98
  ```
94
99
 
95
- Also update the **Resume Pointer** to reflect closeout:
100
+ Also update the **Resume Pointer** to reflect closeout — this writes the
101
+ cursor's terminal state (after closeout no workflow is active on this
102
+ feature; do not edit the cursor again after the Step 4 closeout commit):
96
103
 
97
104
  ```
98
105
  **Current Progress**: feature completed ({date}); all phase-specs status = completed.
99
106
  **Next Action**: integration — push / merge / PR per the selected Git policy.
107
+ **Active Workflow**: none
108
+ **Current Step**: n/a
109
+ **Gates Passed**: n/a
110
+ **Awaiting**: none
100
111
  ```
101
112
 
102
113
  **→ Transition (step-internal)**: Step 2 complete. Announce "Step 2 complete (status flipped). Entering Step 3: Sync BR Snapshot to BC layer." and continue.
@@ -170,7 +181,8 @@ AI runs:
170
181
  ```bash
171
182
  git mv dflow/specs/features/active/{SPEC-ID}-{slug} \
172
183
  dflow/specs/features/completed/{SPEC-ID}-{slug}
173
- git status # confirm rename detection
184
+ git status # confirm rename detection AND check for `RM` — an `M` next to
185
+ # a rename means unstaged edits you must re-add before committing
174
186
  ```
175
187
 
176
188
  `git mv` is mandatory — never use plain `mv` + `git add`. This preserves
@@ -179,37 +191,74 @@ PR diff quality stays intact across the move. See
179
191
  `references/git-integration.md` § "Directory Moves Must Use git mv" for
180
192
  the full rule set.
181
193
 
182
- After the move, also `git add` any modified files from Step 3 (the
183
- updated `rules.md`, `behavior.md`, `glossary.md`, `tech-debt.md`, etc.)
184
- into the same stage.
185
-
186
194
  **Closeout commit checkpoint** (completes the offline Local-closeout gate):
187
195
 
188
196
  ```
189
- ✓ Feature archived to completed/ and closeout files staged
197
+ ✓ Feature archived to completed/ and closeout ready to stage
190
198
  Commit this closeout now?
191
199
  [Y] Yes — the AI commits with your Git identity (marker per _conventions.md § AI Commit Policy)
192
200
  [N] No — skip; you commit yourself
193
201
  ```
194
202
 
195
- Whether you choose Y or N, record one row in the feature `_index.md`
196
- Checkpoint Log (`closeout | committed ({hash})` or `closeout | skipped`). Only
197
- write a hash after the commit actually succeeds; if a pre-commit hook rejects it
198
- or the commit fails, record `failed` and surface the error — never write a fake
199
- hash.
200
-
201
- The Local-closeout gate is satisfied **only when the closeout is committed**:
202
- closeout complete, Checkpoint Log updated, and the working tree clean (no
203
- uncommitted changes). If you declined the commit (chose N) or it failed,
204
- Local-closeout is **not** satisfied yet — commit the staged closeout yourself
205
- before continuing; do not enter the Integration / PR gate with uncommitted
206
- changes. Once committed, the gate stands on its own offline; integration happens
207
- in Step 5 when you have network.
208
-
209
- **→ Transition (step-internal)**: Step 4 complete. Branch on whether the closeout commit landed:
210
-
211
- - **Closeout commit landed (working tree clean)** → announce "Step 4 complete (feature archived; Local-closeout gate satisfied). Entering Step 5: Integration / PR gate." and continue.
212
- - **Closeout commit was declined (N) or failed** → **stop here.** Announce "Step 4 complete (feature archived), but the Local-closeout gate is not satisfied yet — the closeout is staged but uncommitted. Commit those changes (or address the failure), then resume to Step 5." Do **not** enter Step 5 with uncommitted closeout changes.
203
+ Then, in this order:
204
+
205
+ 1. **Record the checkpoint row first.** Write one row in the moved
206
+ `_index.md` Checkpoint Log — `closeout | committed` for Y, `closeout |
207
+ skipped` for N. The closeout row carries **no commit hash**: the closeout
208
+ commit cannot contain its own hash. Trace it later via
209
+ `git log -1 -- dflow/specs/features/completed/{SPEC-ID}-{slug}` (or the
210
+ optional `Dflow-Checkpoint` trailer). The "hash only after success" rule
211
+ still applies to spec / implementation rows — closeout is the documented
212
+ exception (see `references/git-integration.md` § Commit Checkpoints,
213
+ Branch Gate & AI Commits).
214
+ 2. **Stage the whole archived feature directory:**
215
+
216
+ ```bash
217
+ git add dflow/specs/features/completed/{SPEC-ID}-{slug}
218
+ ```
219
+
220
+ This is required, not optional: `git mv` stages the rename with the
221
+ **last-committed** content, so working-tree edits made earlier in this
222
+ flow to the moved files — the Step 2 status flip and Resume Pointer
223
+ update, plus the checkpoint row you just wrote — stay **unstaged** until
224
+ this `git add`. In `git status`, the moved `_index.md` showing `RM`
225
+ instead of plain `R` is exactly this signal. Then also `git add` the
226
+ files updated in Step 3 (the updated `rules.md`, `behavior.md`,
227
+ `glossary.md`, `tech-debt.md`, etc.) into the same stage.
228
+ 3. **Commit (Y) or stop (N).** For Y the AI commits. If a pre-commit hook
229
+ rejects it or the commit fails, flip the checkpoint row to `failed` (the
230
+ row is not committed yet — edit it directly), surface the error, and
231
+ treat the gate as unsatisfied.
232
+
233
+ **Post-commit closeout verification** — after a successful commit, and before
234
+ declaring the Local-closeout gate satisfied, AI runs and reports `✓` / `✗` for
235
+ every item:
236
+
237
+ - [ ] `git show HEAD:dflow/specs/features/completed/{SPEC-ID}-{slug}/_index.md`
238
+ — one blob read verifying **two** things: frontmatter `status: completed`
239
+ **and** the Checkpoint Log contains the closeout row. This reads the
240
+ **committed** content, not the working tree — the former catches "rename
241
+ carried stale content", the latter catches "row never made it into the
242
+ commit".
243
+ - [ ] `dflow/specs/features/active/{SPEC-ID}-{slug}/` no longer exists (the
244
+ directory was moved, not copied)
245
+ - [ ] `git status --short` shows no leftovers related to this feature
246
+ (working tree clean; identify any unrelated dirty files explicitly)
247
+
248
+ If any item fails, do **not** declare closeout complete — fix it (re-add and
249
+ amend, or a follow-up commit; the developer chooses) and re-verify.
250
+
251
+ The Local-closeout gate is satisfied **only when the closeout is committed and
252
+ the verification above passes**. If you declined the commit (chose N) or it
253
+ failed, Local-closeout is **not** satisfied yet — commit the staged closeout
254
+ yourself before continuing; do not enter the Integration / PR gate with
255
+ uncommitted changes. Once committed and verified, the gate stands on its own
256
+ offline; integration happens in Step 5 when you have network.
257
+
258
+ **→ Transition (step-internal)**: Step 4 complete. Branch on the verification result:
259
+
260
+ - **Closeout commit landed and post-commit verification passed** → announce "Step 4 complete (feature archived; Local-closeout gate satisfied). Entering Step 5: Integration / PR gate." and continue.
261
+ - **Closeout commit was declined (N), failed, or verification reported `✗`** → **stop here.** Announce "Step 4 complete (feature archived), but the Local-closeout gate is not satisfied yet — the closeout is staged but uncommitted, or the committed content failed verification. Commit the staged changes (or fix the failure), then resume to Step 5." Do **not** enter Step 5 with uncommitted or unverified closeout changes.
213
262
 
214
263
  ## Step 5: Emit Integration Summary (Git-strategy-neutral)
215
264
 
@@ -266,10 +315,17 @@ the developer:
266
315
 
267
316
  If no `follow-up-of` field, skip Step 6 and announce closeout complete:
268
317
  > "`/dflow:finish-feature` complete for `{SPEC-ID}-{slug}`. Feature
269
- > directory is now at `dflow/specs/features/completed/{SPEC-ID}-{slug}/`.
270
- > If you skipped the closeout commit, commit the staged changes first to
271
- > finish the Local-closeout gate. Then integration — merge / push / PR —
272
- > follows the selected Git policy, at your discretion."
318
+ > directory is now at `dflow/specs/features/completed/{SPEC-ID}-{slug}/`,
319
+ > with the Local-closeout gate satisfied (closeout committed and verified).
320
+ > Integration — merge / push / PR — follows the selected Git policy, at
321
+ > your discretion."
322
+
323
+ **In-flight reminder** — after the closeout announcement (with or without
324
+ Step 6), run the in-flight overview scan (see `AI-AGENT-GUIDE.md` § Status /
325
+ Control Commands) and list any other unfinished features in `active/` and any
326
+ in-flight feature / bugfix branches. Surfacing them at closeout is deliberate:
327
+ attention is about to move elsewhere, and this is exactly where half-done work
328
+ sinks.
273
329
 
274
330
  ## Step 6: Reverse-Update Follow-up Tracking (only if follow-up)
275
331
 
@@ -37,9 +37,9 @@ main (or your project's base branch)
37
37
  ```
38
38
  feature/{SPEC-ID}-{slug}
39
39
  Examples:
40
- feature/EXP-001-jpy-currency-support
41
- feature/HR-003-leave-approval-workflow
42
- feature/SHARED-002-audit-logging
40
+ feature/SPEC-20260424-001-jpy-currency-support
41
+ feature/SPEC-20260430-001-leave-approval-workflow
42
+ feature/SPEC-20260502-002-audit-logging
43
43
 
44
44
  bugfix/{BUG-ID}-{slug}
45
45
  Examples:
@@ -148,10 +148,30 @@ existing Step Gate prompt (it does not add a separate question):
148
148
  Tier sets how many checkpoints a change has: T1 three (spec / implementation /
149
149
  closeout), T2 two (spec+implementation merged / closeout), T3 a single commit.
150
150
  Whether you choose Y or N, the AI records one row in the feature `_index.md`
151
- Checkpoint Log. A commit hash is written only after the commit succeeds; a hook
152
- rejection or failed commit is recorded as `failed` (never a fake hash). After
153
- several consecutive skips in a project the AI mentions you can turn checkpoints
154
- off in config — it does not turn them off for you.
151
+ Checkpoint Log — every checkpoint is accounted for (`committed` / `skipped` /
152
+ `failed`), even when no commit happens. A commit hash is written only after the
153
+ commit succeeds; a hook rejection or failed commit is recorded as `failed`
154
+ (never a fake hash). **Exception — the closeout row**: the closeout commit
155
+ cannot contain its own hash, so the closeout row is written before the commit
156
+ as `closeout | committed` with **no hash** (see
157
+ `references/finish-feature-flow.md` Step 4); trace that commit via
158
+ `git log -1 -- dflow/specs/features/completed/{SPEC-ID}-{slug}` or the optional
159
+ `Dflow-Checkpoint` trailer below. After several consecutive skips in a project
160
+ the AI mentions you can turn checkpoints off in config — it does not turn them
161
+ off for you.
162
+
163
+ **Optional machine-greppable trailer.** Teams that want cross-flow checkpoint
164
+ accounting can append a commit trailer at checkpoint commits:
165
+
166
+ ```
167
+ Dflow-Checkpoint: {SPEC-ID} {spec|impl|closeout}
168
+ ```
169
+
170
+ The `_index.md` Checkpoint Log **remains the source of truth**; the trailer is
171
+ a cheap derived mirror (`git log --grep 'Dflow-Checkpoint: {SPEC-ID}'`). Use
172
+ role names, not (k/N) counts — the checkpoint total can change mid-feature
173
+ (tier escalation, follow-ups), and a role gap ("impl exists but no closeout for
174
+ this SPEC-ID") is detectable without predicting N, even across flows.
155
175
 
156
176
  ### AI commits
157
177
 
@@ -325,8 +345,8 @@ Tie commits to specs:
325
345
  [SPEC-ID] Short description
326
346
 
327
347
  Examples:
328
- [EXP-001] Add JPY currency support to Money value object
329
- [EXP-001] Extract exchange rate logic to Domain service
348
+ [SPEC-20260424-001] Add JPY currency support to Money value object
349
+ [SPEC-20260424-001] Extract exchange rate logic to Domain service
330
350
  [BUG-042] Fix rounding inconsistency, extract to Money.Round()
331
351
  ```
332
352
 
@@ -167,6 +167,32 @@ Wait for answers.
167
167
  > and refreshes it in place on re-run. Merge snippets under
168
168
  > `dflow/specs/shared/` are used only if Dflow markers conflict."
169
169
 
170
+ Wait for answers.
171
+
172
+ ### Q9. Project-level skill (agent-gated, default yes)
173
+
174
+ Asked only when Q8 selected at least one agent — with no agents there is no
175
+ projection target and this question is skipped entirely.
176
+
177
+ > "Install the project-level Dflow skill for natural-language auto-trigger?
178
+ > (Y/n)
179
+ >
180
+ > The skill is what makes requests like 'I want to add a feature' surface the
181
+ > matching workflow automatically; without it, triggering relies on the
182
+ > instruction files alone and degrades in long sessions. Skill files are
183
+ > Dflow-generated derivatives — the recommended default is to gitignore them
184
+ > and re-project after cloning."
185
+
186
+ Wait for the answer. **Blank defaults to yes.** On `n`, tell the developer:
187
+
188
+ > "Skipped the project-level skill; add it later with
189
+ > `dflow configure-agents --skills`."
190
+
191
+ CLI note: the CLI asks this question only on an interactive terminal. A
192
+ non-interactive (piped) `dflow init` never reads an extra stdin answer for it
193
+ — existing scripted answer sequences keep their structure and keep working —
194
+ and installs the skill for the selected agents by default.
195
+
170
196
  **→ Transition (step-internal)**: Step 2 complete. Announce
171
197
  > "Step 2 complete (project information captured). Entering Step 3:
172
198
  > File-list preview."
@@ -274,7 +300,7 @@ skip, and wait for developer confirmation:
274
300
  **→ Step Gate: Step 3 → Step 4**
275
301
 
276
302
  Wait for explicit confirmation. If the developer asks to change the
277
- selection, go back to the relevant Step 2 question (Q5–Q8) and re-run Step 3.
303
+ selection, go back to the relevant Step 2 question (Q5–Q9) and re-run Step 3.
278
304
 
279
305
  ---
280
306
 
@@ -346,6 +372,22 @@ For each selected tool-specific file (`AGENTS.md`, `CLAUDE.md`,
346
372
  in the preview, and refresh that same block on re-run. If the developer later
347
373
  deletes the block, a later `init` / `configure-agents` run appends it again
348
374
 
375
+ If the developer chose to install the project-level skill (Q9), the CLI also
376
+ creates the skill file for each selected tool at its native project-level
377
+ path:
378
+
379
+ - `.claude/skills/dflow/SKILL.md` — Claude Code
380
+ - `.agents/skills/dflow/SKILL.md` — Codex
381
+ - `.github/skills/dflow/SKILL.md` — GitHub Copilot
382
+
383
+ All three are the same edition-neutral thin skill projected from the single
384
+ canonical source in the npm package. An existing file at one of those paths
385
+ that is **not** Dflow-generated (missing the
386
+ `<!-- dflow-generated: skill-adapter -->` marker) is left unchanged with a
387
+ warning. Manual AI fallback (no npm available): do **not** hand-write SKILL.md
388
+ content — report that the skill install is deferred and the developer should
389
+ run `dflow configure-agents --skills` once npm is available.
390
+
349
391
  ### 4.4 Directory-only entries
350
392
 
351
393
  For directories that Git otherwise wouldn't track (empty `active/` /
@@ -7,6 +7,8 @@ Step-by-step guide for when a developer triggers `/dflow:modify-existing` or `/d
7
7
  - Step 4 → Step 5 (extraction decision → start implementation)
8
8
  - Step 5 → Step 6 (implementation done → update artifacts)
9
9
 
10
+ Crossing any step gate above also updates the host feature's `_index.md` Resume Pointer cursor (Active Workflow / Current Step / Gates Passed / Awaiting) once the host feature directory exists — fold it into that gate's existing `_index.md` / Resume Pointer edit, no separate ceremony (see the `_index.md` template's Resume Pointer notes).
11
+
10
12
  All other step transitions are **step-internal**: announce "Step N complete, entering Step N+1" and proceed without waiting. See AI-AGENT-GUIDE.md § Workflow Transparency for the full transparency protocol and confirmation signals.
11
13
 
12
14
  **Ceremony adjustment when triggered by `/dflow:bug-fix`**: treat as lightweight — use the Lightweight Spec Template (see `templates/lightweight-spec.md`) 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).
@@ -63,6 +65,16 @@ Walk through these in order:
63
65
  this is a new concern. For T1, use `/dflow:new-feature`. For T2 / T3
64
66
  on a standalone bug, see Step 1.5 — `/dflow:bug-fix` will create a
65
67
  minimal feature directory to host the lightweight-spec.
68
+ 4. **In-flight overlap scan (cross-branch)**: this branch's `active/` is not
69
+ everything in flight. Run the in-flight scan (classification and dedup
70
+ rules in `AI-AGENT-GUIDE.md` § Status / Control Commands) — `git fetch`
71
+ when the network allows, then
72
+ `git branch --all --list '*feature/*' --list '*bugfix/*'` — and also list
73
+ other unfinished features in this branch's `active/` (one cursor line
74
+ each). If a scanned branch classified as in flight elsewhere, closed out
75
+ awaiting integration, or unknown — or an unfinished feature — semantically
76
+ overlaps this change, surface it and wait for the developer to decide
77
+ before creating anything new (stale branches are non-blocking).
66
78
 
67
79
  > **Why scan completed too?** Completed features are frozen history
68
80
  > and **cannot accept** any T2 / T3 directly
@@ -316,6 +328,17 @@ has no separate Aggregates section, do not invent one; update the Repository
316
328
  row if one exists. If the developer defers, **record the emergence observation
317
329
  in `tech-debt.md`** so the boundary decision is not silently lost.
318
330
 
331
+ **Established-model re-read (the emergence check's mirror).** When the rule
332
+ you are extracting lands on an **already-modeled** Aggregate / concept,
333
+ re-read what was recorded when it was shaped (its `models.md` row + Notes
334
+ and the relevant `rules.md` entries) before extending it. If this change
335
+ matches a recorded re-evaluation condition ("revisit when …") or trips a
336
+ model-resistance signal, follow `references/ddd-modeling-guide.md`
337
+ § "Revising an Established Model": record one short passage in the spec's
338
+ design decisions / open questions — proceed as-is, split, or rename, with
339
+ the reason. Deciding to keep the current model, recorded, is a valid
340
+ outcome; extending silently is not.
341
+
319
342
  If the context is **`generic`** (Subdomain Type), emergence is usually a
320
343
  *replacement / adapter-boundary* debt signal, not a cue for deep T1 modeling —
321
344
  record the replacement intent (consistent with the generic extraction fallback
@@ -8,6 +8,8 @@ Step-by-step guide for when a developer triggers `/dflow:new-feature` (or natura
8
8
  - Step 6 → Step 7 (branch ready → start implementation)
9
9
  - Step 7 → Step 8 (implementation done → completion)
10
10
 
11
+ Crossing any step gate above also updates the host feature's `_index.md` Resume Pointer cursor (Active Workflow / Current Step / Gates Passed / Awaiting) once the feature directory exists — fold it into that gate's existing `_index.md` / Resume Pointer edit, no separate ceremony (see the `_index.md` template's Resume Pointer notes).
12
+
11
13
  All other step transitions are **step-internal**: announce "Step N complete, entering Step N+1" and proceed without waiting. See AI-AGENT-GUIDE.md § Workflow Transparency for the full transparency protocol and confirmation signals.
12
14
 
13
15
  **Ceremony**: this flow always defaults to **T1 Heavy** — the first phase of a brand-new feature is by definition a full SDD cycle. Tier judgement (T1 / T2 / T3) only applies to `/dflow:modify-existing` (see `references/modify-existing-flow.md` and AI-AGENT-GUIDE.md § Ceremony Scaling).
@@ -30,6 +32,27 @@ Then check existing assets:
30
32
  - Search `dflow/specs/features/` for related or overlapping features
31
33
  - Check `dflow/specs/domain/glossary.md` for relevant terms
32
34
 
35
+ **In-flight overlap scan (cross-branch + other unfinished features)** — this
36
+ branch's `dflow/specs/` does not show everything in flight. Run the in-flight
37
+ scan (classification and dedup rules in `AI-AGENT-GUIDE.md` § Status / Control
38
+ Commands):
39
+
40
+ ```bash
41
+ git fetch # when the network allows; skip gracefully offline
42
+ git branch --all --list '*feature/*' --list '*bugfix/*'
43
+ ```
44
+
45
+ - List other unfinished features already in this branch's `active/` (one
46
+ cursor line each, from their `_index.md` Resume Pointer).
47
+ - Classify every listed branch by the guide's rules — in flight elsewhere /
48
+ closed out awaiting integration / stale (completed here) / unknown — do
49
+ not shortcut the classification. If a branch classified as **in flight
50
+ elsewhere, closed out awaiting integration, or unknown** has an ID / slug
51
+ that semantically overlaps this request, surface it and wait for the
52
+ developer to decide — continue there / integrate it first / treat as
53
+ related / unrelated — **before creating any new directory, spec, or
54
+ branch**. Only stale (completed here) branches are non-blocking.
55
+
33
56
  Share what you found: "I see we already have [X] documented. This new feature seems to extend
34
57
  that — is that right?"
35
58
 
@@ -90,6 +113,16 @@ classification, set-based / uniqueness rules, value objects, aggregate sizing
90
113
  read `references/ddd-modeling-guide.md` (its **Edition note** maps recording
91
114
  surfaces to brownfield's `models.md` / `rules.md`).
92
115
 
116
+ The mirror case — the concept is **already modeled**: when extending an
117
+ existing Aggregate / modeled concept, re-read what was recorded when it was
118
+ shaped (its `models.md` row + Notes and the relevant `rules.md` entries)
119
+ before extending it. If this change matches a recorded re-evaluation
120
+ condition ("revisit when …") or trips a model-resistance signal, follow
121
+ `references/ddd-modeling-guide.md` § "Revising an Established Model":
122
+ record one short passage in the spec's design decisions / open questions —
123
+ proceed as-is, split, or rename, with the reason. Deciding to keep the
124
+ current model, recorded, is a valid outcome; extending silently is not.
125
+
93
126
  For each new concept:
94
127
  1. Check glossary — add if missing
95
128
  2. Check if it already exists in models.md — extend if needed
@@ -170,7 +203,7 @@ dflow/specs/features/active/{SPEC-ID}-{slug}/
170
203
  - Current BR Snapshot: initialise from the first phase's planned BRs
171
204
  (will be refreshed when the phase-spec finalises)
172
205
  - Lightweight Changes: empty table at start
173
- - Resume Pointer: "phase-1 in progress: drafting phase-spec." / "Next Action: finish phase-spec, then implement."
206
+ - Resume Pointer: "phase-1 in progress: drafting phase-spec." / "Next Action: finish phase-spec, then implement." / cursor fields: Active Workflow `new-feature`, Current Step `Step 4 — write the spec`, Gates Passed `3→3.5`, Awaiting `none (mid-step)`
174
207
  3. **Create the first phase-spec** at `phase-spec-{YYYY-MM-DD}-{slug}.md`
175
208
  using `templates/phase-spec.md`. The "Delta from prior phases" section
176
209
  is filled with "首 phase,無前置 Delta" (first phase has nothing to
@@ -19,6 +19,8 @@ adds a new phase to an in-progress feature only.
19
19
  - Step 5 → Step 6 (`_index.md` refreshed → start implementation)
20
20
  - Step 6 → Step 7 (implementation done → complete the phase)
21
21
 
22
+ Crossing any step gate above also updates the feature's `_index.md` Resume Pointer cursor (Active Workflow / Current Step / Gates Passed / Awaiting) — fold it into that gate's existing `_index.md` / Resume Pointer edit, no separate ceremony (see the `_index.md` template's Resume Pointer notes).
23
+
22
24
  All other step transitions are **step-internal**: announce "Step N complete,
23
25
  entering Step N+1" and proceed without waiting. See AI-AGENT-GUIDE.md § Workflow
24
26
  Transparency for the full transparency protocol and confirmation signals.
@@ -63,6 +65,11 @@ AI must locate the target feature and load its current state:
63
65
  - Read the most recent phase-spec to understand where the prior phase
64
66
  left off (its Business Rules and Delta-from-prior-phases sections in
65
67
  particular)
68
+ - Run the in-flight overlap scan (classification and dedup rules in
69
+ `AI-AGENT-GUIDE.md` § Status / Control Commands): list other unfinished
70
+ features in `active/` and any feature / bugfix branches whose work is
71
+ not visible on this branch — if the incoming phase scope overlaps one
72
+ of them, surface it before writing the phase-spec.
66
73
 
67
74
  4. **Branch gate — ensure you are on this feature's branch (before any commit)**
68
75
 
@@ -99,7 +106,11 @@ Walk the developer through what the new phase covers:
99
106
  Entity row (no separate Aggregates section). For how to model it (invariant
100
107
  classification, set-based / uniqueness rules, aggregate sizing), read
101
108
  `references/ddd-modeling-guide.md` (its **Edition note** maps recording
102
- surfaces to brownfield's `models.md` / `rules.md`).
109
+ surfaces to brownfield's `models.md` / `rules.md`). If the phase **extends
110
+ an already-modeled Aggregate / concept**, apply the established-model
111
+ re-read from `references/ddd-modeling-guide.md` § "Revising an Established
112
+ Model" (match recorded re-evaluation conditions; record proceed / split /
113
+ rename in the phase-spec).
103
114
  4. **Data structure impact?** New tables, columns, indices?
104
115
  5. **Why now?** Priority — informs sequencing relative to other phases.
105
116
 
@@ -108,6 +108,11 @@ input like this (supporting files live in the workflow bundle at
108
108
  is written with Greenfield artifact names; see its **Edition note** for where
109
109
  Brownfield records the same decisions (`models.md` / `rules.md` /
110
110
  `behavior.md` / `migration/tech-debt.md`).
111
+ - **"Turn the specs into HTML" / "make the specs easier to read"** → run the
112
+ CLI command `dflow render` (a human-readability tool, not a `/dflow:*`
113
+ workflow). It mirrors `dflow/specs/` into a browsable static HTML tree
114
+ (default output: `dflow-specs-html/`); re-run it after specs change —
115
+ Markdown stays the AI-facing source of truth.
111
116
  - **"Dflow seems wrong" / "this template is confusing"** (or you notice Dflow
112
117
  guidance drift) → suggest `/dflow:report-dflow-feedback`; never submit
113
118
  anything upstream automatically.
@@ -118,10 +123,43 @@ input like this (supporting files live in the workflow bundle at
118
123
 
119
124
  ## Status / Control Commands
120
125
 
121
- `/dflow:status` reports active workflow state. Include these fields: workflow,
122
- step, completed, in-progress, remaining, pending decision, and next valid action.
123
- If no workflow is active, say that no workflow is active and list valid flow-entry
124
- or standalone commands.
126
+ `/dflow:status` reports in two parts.
127
+
128
+ **Part 1 — in-flight overview (always shown, workflow active or not).**
129
+ Aggregate every in-flight feature so unfinished work surfaces without anyone
130
+ remembering to look:
131
+
132
+ - Scan this branch's `dflow/specs/features/active/*/_index.md` and print one
133
+ line per feature: SPEC-ID / Active Workflow / Current Step / Awaiting / last
134
+ Checkpoint Log row (read from each Resume Pointer cursor).
135
+ - Cross-branch: run `git fetch` when the network allows (skip gracefully
136
+ offline), then `git branch --all --list '*feature/*' --list '*bugfix/*'`,
137
+ deduplicating local and remote refs of the same branch (prefer local). For
138
+ each branch, classify in order: (1) its feature directory exists in this
139
+ branch's `active/` → already covered above; (2) exists in this branch's
140
+ `completed/` → a stale undeleted branch — list as "completed; branch can be
141
+ deleted", **not** in-flight; (3)
142
+ `git show {branch}:dflow/specs/features/active/{dir}/_index.md` is readable
143
+ → in flight on that branch, print its cursor line (no branch switching);
144
+ (4) the `completed/` path is readable on that branch → closed out there,
145
+ awaiting integration; (5) nothing readable → list the branch as unknown
146
+ state.
147
+ - If `features/backlog/` is non-empty, append one count line.
148
+ - Inherent limit: work never committed anywhere is invisible to any git scan.
149
+
150
+ **Part 2 — current feature detail (when a workflow is active).** Read the
151
+ Resume Pointer cursor as the **declared** state, then cross-check it against
152
+ derived evidence (Checkpoint Log, phase-spec statuses, recent git log). On
153
+ mismatch, report both sides explicitly and ask the developer to correct the
154
+ cursor — the cursor is a claim; evidence wins. If the cursor fields are absent
155
+ (an older `_index.md`), fall back to pure derivation. For readability you may
156
+ expand the cursor into a step checklist (done / in progress / not started)
157
+ derived live from the flow file — display only, never stored.
158
+
159
+ Include these fields: workflow, step, completed, in-progress, remaining,
160
+ pending decision, and next valid action. If no workflow is active, say so and
161
+ list valid flow-entry or standalone commands (Part 1 still shows the
162
+ in-flight overview).
125
163
 
126
164
  `/dflow:next` is valid only at a step gate in an active workflow. Treat it as
127
165
  developer confirmation equivalent to "OK" or "continue", then move to the next
@@ -129,7 +167,9 @@ workflow step.
129
167
 
130
168
  `/dflow:cancel` aborts the current workflow and returns to free conversation.
131
169
  Do not rollback changes, delete artifacts, or rewrite specs merely because the
132
- workflow was cancelled.
170
+ workflow was cancelled. If the feature directory exists, set the Resume
171
+ Pointer cursor's Active Workflow to `none` (keep Current Progress as a trace
172
+ of where the cancellation happened).
133
173
 
134
174
  When no workflow is active, `/dflow:next` and `/dflow:cancel` must report that
135
175
  there is no active workflow to advance or cancel.
@@ -140,7 +140,7 @@ When applicable, prefix with a type (conventional commits-style):
140
140
  | test | tests only |
141
141
  | chore | build / tooling |
142
142
 
143
- Example: `[EXP-001] feat: add JPY currency support to Money VO`
143
+ Example: `[SPEC-20260424-001] feat: add JPY currency support to Money VO`
144
144
 
145
145
  ---
146
146
 
@@ -95,8 +95,8 @@ adopted, the format is:
95
95
  | test | tests only |
96
96
  | chore | build / tooling |
97
97
 
98
- Example: `feat(expense): add JPY currency support` with `[EXP-001]` in
99
- the body.
98
+ Example: `feat(expense): add JPY currency support` with
99
+ `[SPEC-20260424-001]` in the body.
100
100
 
101
101
  ---
102
102
 
@@ -39,6 +39,8 @@ Template note (for AI):
39
39
  initial BR Snapshot + Resume Pointer. The other sections can stay empty.
40
40
  -->
41
41
 
42
+ <!-- Formatting convention: keep table cells concise. When one cell holds multiple short items (invariants, rules, steps), separate them with <br> so each renders on its own line - never chain them into one line with ;/; separators. Long narrative detail does not belong in a table cell: keep the cell to a concise summary and put extended detail in an existing section of this document when one fits, or give each item its own row. -->
43
+
42
44
  # {Feature Title}
43
45
 
44
46
  ## Goals & Scope
@@ -97,23 +99,42 @@ Template note (for AI):
97
99
  > T3 單一 commit。
98
100
  >
99
101
  > commit hash 只在 commit 實際成功後填入;pre-commit hook reject 或 commit
100
- > 失敗記 `failed`、不寫假 hash。
102
+ > 失敗記 `failed`、不寫假 hash。**例外:closeout 列不填 hash**——closeout
103
+ > commit 無法自含自身 hash,該列於 commit 前寫入、隨歸檔目錄一起進 commit;
104
+ > 溯源用 `git log -1 -- completed/{SPEC-ID}-{slug}` 或選配的
105
+ > `Dflow-Checkpoint` trailer(見 references/git-integration.md)。
101
106
 
102
107
  | Timestamp | Checkpoint | Result |
103
108
  |---|---|---|
104
109
  | {YYYY-MM-DD HH:MM} | spec-baseline | committed ({hash}) / skipped / failed |
105
110
  | {YYYY-MM-DD HH:MM} | implementation | committed ({hash}) / skipped / failed |
106
- | {YYYY-MM-DD HH:MM} | closeout | committed ({hash}) / skipped / failed |
111
+ | {YYYY-MM-DD HH:MM} | closeout | committed / skipped / failed |
107
112
 
108
113
  ## Resume Pointer
109
114
 
110
- > 一句話:目前進展到哪?下一個動作是什麼?
111
- > 開新對話接續工作時,從這裡讀起。
115
+ > 目前進展到哪?下一個動作是什麼?開新對話接續工作時,從這裡讀起。
116
+ >
117
+ > 下方四個 cursor 欄位是 workflow 進度的**存放層(宣告,claim)**:
118
+ > 進入 flow 時設 Active Workflow;**每過一個 step gate** 更新 Current Step /
119
+ > Gates Passed / Awaiting(與該 gate 既有的 `_index.md` 更新合併,不另加儀式);
120
+ > closeout / `/dflow:cancel` 時 Active Workflow 設回 `none`。
121
+ > `/dflow:status` 讀 cursor 後會與推導證據(Checkpoint Log、phase-spec
122
+ > status、git log)交叉,不一致會明確報 mismatch——cursor 是宣告、證據優先。
123
+ > Phase 粒度進度由上方 Phase Specs 表承載;cursor 只補 workflow step / gate
124
+ > 粒度,不展開成 per-step 全表(步驟線性,游標可推導每一步的完成/未做)。
112
125
 
113
126
  **Current Progress**: {one-line summary}
114
127
 
115
128
  **Next Action**: {suggested next action}
116
129
 
130
+ **Active Workflow**: {new-feature | modify-existing | bug-fix | new-phase | finish-feature | none}
131
+
132
+ **Current Step**: {Step N — short step name | n/a}
133
+
134
+ **Gates Passed**: {e.g. "3→3.5, 4→5" | n/a}
135
+
136
+ **Awaiting**: {step-gate description | none}
137
+
117
138
  <!--
118
139
  ## Follow-up Tracking
119
140
  >(選用段;只有當本 feature 衍生出 follow-up feature 時才填)
@@ -5,6 +5,8 @@ owner: {負責的開發者或團隊}
5
5
  created: {YYYY-MM-DD}
6
6
  ---
7
7
 
8
+ <!-- Formatting convention: keep table cells concise. When one cell holds multiple short items (invariants, rules, steps), separate them with <br> so each renders on its own line - never chain them into one line with ;/; separators. Long narrative detail does not belong in a table cell: keep the cell to a concise summary and put extended detail in an existing section of this document when one fits, or give each item its own row. -->
9
+
8
10
  # {ContextName} Bounded Context
9
11
 
10
12
  ## Responsibilities
@@ -1,4 +1,5 @@
1
1
  <!-- Seeded by Dflow. -->
2
+ <!-- Formatting convention: keep table cells concise. When one cell holds multiple short items (invariants, rules, steps), separate them with <br> so each renders on its own line - never chain them into one line with ;/; separators. Long narrative detail does not belong in a table cell: keep the cell to a concise summary and put extended detail in an existing section of this document when one fits, or give each item its own row. -->
2
3
 
3
4
  # Context Map
4
5
 
@@ -1,4 +1,5 @@
1
1
  <!-- Seeded by Dflow. -->
2
+ <!-- Formatting convention: keep table cells concise. When one cell holds multiple short items (invariants, rules, steps), separate them with <br> so each renders on its own line - never chain them into one line with ;/; separators. Long narrative detail does not belong in a table cell: keep the cell to a concise summary and put extended detail in an existing section of this document when one fits, or give each item its own row. -->
2
3
 
3
4
  # Glossary
4
5