dflow-sdd-ddd 0.8.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 (52) hide show
  1. package/CHANGELOG.md +100 -0
  2. package/LICENSE +679 -21
  3. package/README.en.md +24 -12
  4. package/README.md +15 -8
  5. package/TEMPLATE-COVERAGE.md +0 -1
  6. package/bin/dflow.js +4 -3
  7. package/docs/evaluating-dflow.en.md +11 -7
  8. package/docs/evaluating-dflow.md +9 -4
  9. package/docs/migrating-to-dflow-v1.md +7 -3
  10. package/docs/using-with-claude-code.en.md +40 -23
  11. package/docs/using-with-claude-code.md +34 -23
  12. package/docs/using-with-codex.en.md +135 -48
  13. package/docs/using-with-codex.md +99 -38
  14. package/docs/using-with-github-copilot.en.md +135 -34
  15. package/docs/using-with-github-copilot.md +120 -43
  16. package/lib/init.js +943 -145
  17. package/package.json +3 -3
  18. package/templates/brownfield/references/dflow-feedback-flow.md +135 -63
  19. package/templates/brownfield/references/drift-verification.md +1 -4
  20. package/templates/brownfield/references/finish-feature-flow.md +59 -23
  21. package/templates/brownfield/references/git-integration.md +65 -7
  22. package/templates/brownfield/references/init-project-flow.md +67 -36
  23. package/templates/brownfield/references/modify-existing-flow.md +10 -38
  24. package/templates/brownfield/references/new-feature-flow.md +28 -11
  25. package/templates/brownfield/references/new-phase-flow.md +16 -1
  26. package/templates/brownfield/scaffolding/AI-AGENT-GUIDE.md +253 -2
  27. package/templates/brownfield/scaffolding/CLAUDE-md-snippet.md +5 -8
  28. package/templates/brownfield/scaffolding/Git-principles-gitflow.md +13 -12
  29. package/templates/brownfield/scaffolding/Git-principles-trunk.md +13 -16
  30. package/templates/brownfield/scaffolding/_conventions.md +10 -9
  31. package/templates/brownfield/templates/_index.md +21 -3
  32. package/templates/brownfield/templates/lightweight-spec.md +1 -1
  33. package/templates/brownfield/templates/phase-spec.md +1 -1
  34. package/templates/common/skill/SKILL.md +9 -6
  35. package/templates/greenfield/references/dflow-feedback-flow.md +135 -63
  36. package/templates/greenfield/references/drift-verification.md +1 -4
  37. package/templates/greenfield/references/finish-feature-flow.md +58 -23
  38. package/templates/greenfield/references/git-integration.md +65 -7
  39. package/templates/greenfield/references/init-project-flow.md +67 -36
  40. package/templates/greenfield/references/modify-existing-flow.md +9 -7
  41. package/templates/greenfield/references/new-feature-flow.md +29 -12
  42. package/templates/greenfield/references/new-phase-flow.md +16 -1
  43. package/templates/greenfield/scaffolding/AI-AGENT-GUIDE.md +222 -2
  44. package/templates/greenfield/scaffolding/CLAUDE-md-snippet.md +10 -15
  45. package/templates/greenfield/scaffolding/Git-principles-gitflow.md +13 -12
  46. package/templates/greenfield/scaffolding/Git-principles-trunk.md +14 -18
  47. package/templates/greenfield/scaffolding/_conventions.md +9 -8
  48. package/templates/greenfield/templates/_index.md +21 -3
  49. package/templates/greenfield/templates/lightweight-spec.md +1 -1
  50. package/templates/greenfield/templates/phase-spec.md +1 -1
  51. package/templates/brownfield/templates/CLAUDE.md +0 -165
  52. package/templates/greenfield/templates/CLAUDE.md +0 -172
@@ -54,8 +54,8 @@ Report findings plainly:
54
54
  > - `src/`: contains `MyApp.Domain`, `MyApp.Application`,
55
55
  > `MyApp.Infrastructure`, `MyApp.WebAPI` → Clean Architecture layout
56
56
  > detected
57
- > - `CLAUDE.md`: present → will not overwrite; I'll offer a snippet
58
- > to merge into it"
57
+ > - `CLAUDE.md`: present → I'll append a marked Dflow block (shown in
58
+ > the preview); a merge snippet only if there's a marker conflict"
59
59
 
60
60
  Or:
61
61
 
@@ -128,25 +128,42 @@ blank input, or prose descriptions such as "Traditional Chinese". Dflow
128
128
  templates keep canonical English structural language; this setting controls
129
129
  free prose inside generated spec sections.
130
130
 
131
- ### Q5. Optional starter files (multi-select)
131
+ ### Q5. Git policy (mandatory — pick one)
132
132
 
133
- > "Besides the mandatory baseline, which optional starter files do
134
- > you want me to seed? You can check as many as apply:
133
+ > "Which Git policy does the team follow? This drives the runtime branch gate
134
+ > and the finish-stage merge guidance, so it is required:
135
135
  >
136
- > - [ ] `dflow/specs/shared/_overview.md` — system overview template
137
- > - [ ] Git principles — **pick one** if your project has opinions
138
- > about Git conventions (decision hint: **if you're not sure,
139
- > pick trunk-based** — that's the default for GitHub / GitLab.
140
- > Pick Git Flow only if you have a formal release cycle with
141
- > dedicated release / hotfix branches):
142
- > - [ ] `dflow/specs/shared/Git-principles-gitflow.md`
143
- > - [ ] `dflow/specs/shared/Git-principles-trunk.md`"
136
+ > 1. GitFlow — long-lived develop / release branches
137
+ > 2. Trunk / GitHub Flow — short-lived feature branches (lightest; the
138
+ > default for most GitHub / GitLab teams)"
144
139
 
145
- Wait for answers. If the developer picks both Git-principles flavours,
146
- confirm once more that they really want both (usually a project picks
147
- one).
140
+ Required — do not accept a skip. Both policies use feature branches; the choice
141
+ only changes finish-stage merge guidance. The selected policy seeds exactly one
142
+ `dflow/specs/shared/Git-principles-{gitflow|trunk}.md` (**mandatory, not
143
+ optional**) and is recorded in `_conventions.md` under `## Git Policy`.
148
144
 
149
- ### Q6. AI coding agents (multi-select)
145
+ ### Q6. AI commit marker (mandatory — default None)
146
+
147
+ > "How should AI-made commits be marked? The AI offers to commit at lifecycle
148
+ > checkpoints (you can always decline); this sets how those commits are tagged:
149
+ >
150
+ > 1. None (default) — AI commits look like any other commit
151
+ > 2. Co-Authored-By trailer (`dflow-ai <noreply@dflow.local>`) — filterable
152
+ > 3. `[ai-assisted]` commit-subject prefix — visible at a glance"
153
+
154
+ Recorded in `_conventions.md` under `## AI Commit Policy`; the runtime does not
155
+ re-ask.
156
+
157
+ ### Q7. Optional starter files (multi-select)
158
+
159
+ > "Besides the mandatory baseline, which optional starter files do you want me
160
+ > to seed?
161
+ >
162
+ > - [ ] `dflow/specs/shared/_overview.md` — system overview template"
163
+
164
+ Wait for answers.
165
+
166
+ ### Q8. AI coding agents (multi-select)
150
167
 
151
168
  > "Which AI coding agents should Dflow configure?
152
169
  >
@@ -156,9 +173,10 @@ one).
156
173
  >
157
174
  > If you select any agent, Dflow will create
158
175
  > `dflow/specs/shared/AI-AGENT-GUIDE.md` as the canonical guide. Root-level
159
- > tool files stay thin and point back to that guide. Existing tool files are
160
- > never overwritten; Dflow writes merge snippets under `dflow/specs/shared/`
161
- > instead."
176
+ > tool files stay thin and point back to that guide. Existing user content is
177
+ > never overwritten; Dflow appends a marked Dflow block (shown in the preview)
178
+ > and refreshes it in place on re-run. Merge snippets under
179
+ > `dflow/specs/shared/` are used only if Dflow markers conflict."
162
180
 
163
181
  **→ Transition (step-internal)**: Step 2 complete. Announce
164
182
  > "Step 2 complete (project information captured). Entering Step 3:
@@ -215,7 +233,7 @@ Key Greenfield-track notes:
215
233
  moment the first bounded context is established. Creating empty
216
234
  `behavior.md` files here would create stale placeholders.
217
235
 
218
- ### 3.2 Optional files (from Step 2 Q5)
236
+ ### 3.2 Optional files (from Step 2 Q7)
219
237
 
220
238
  Use the packaged scaffolding templates listed below; their project-local
221
239
  outputs are under `dflow/specs/shared/` (the scaffolding root, not the
@@ -229,16 +247,17 @@ vendored workflow bundle). Compute the destination path:
229
247
  | `scaffolding/Git-principles-trunk.md` | `dflow/specs/shared/Git-principles-trunk.md` |
230
248
  | `scaffolding/AI-AGENT-GUIDE.md` | `dflow/specs/shared/AI-AGENT-GUIDE.md` when at least one AI agent is selected |
231
249
  | generated tool shim | `AGENTS.md`, `CLAUDE.md`, or `.github/copilot-instructions.md` when selected and missing |
232
- | generated merge snippet | `dflow/specs/shared/*-snippet.md` when the selected tool file already exists |
250
+ | marked Dflow block | appended to a selected existing tool file unless it already points to `AI-AGENT-GUIDE.md`; refreshed in place on re-run |
251
+ | fallback merge snippet | `dflow/specs/shared/*-snippet.md` only when the selected tool file has conflicting or malformed Dflow markers |
233
252
 
234
253
  ### 3.3 Present the preview
235
254
 
236
- Present the complete file list as two tables, separating create vs
255
+ Present the complete file list as two tables, separating create / update vs
237
256
  skip, and wait for developer confirmation:
238
257
 
239
258
  > "Based on Step 1 inventory + Step 2 answers, here is what I'll do:
240
259
  >
241
- > **Will create ({N} files):**
260
+ > **Will create / update ({N} files):**
242
261
  >
243
262
  > | Path | Source |
244
263
  > |---|---|
@@ -251,9 +270,9 @@ skip, and wait for developer confirmation:
251
270
  > | `dflow/specs/architecture/tech-debt.md` | `templates/tech-debt.md` (mandatory baseline) |
252
271
  > | `dflow/specs/architecture/decisions/README.md` | `scaffolding/architecture-decisions-README.md` (mandatory baseline) |
253
272
  > | `dflow/specs/shared/_overview.md` | optional (you picked it) |
254
- > | `dflow/specs/shared/Git-principles-trunk.md` | optional (you picked it) |
273
+ > | `dflow/specs/shared/Git-principles-trunk.md` | mandatory (selected Git policy) |
255
274
  > | `dflow/specs/shared/AI-AGENT-GUIDE.md` | selected AI agent guide |
256
- > | `CLAUDE.md` | selected tool shim because repo has no CLAUDE.md |
275
+ > | `CLAUDE.md` | marked Dflow block appended to existing CLAUDE.md (shown in preview) |
257
276
  >
258
277
  > **Will skip ({M} files — already present):**
259
278
  >
@@ -274,7 +293,7 @@ skip, and wait for developer confirmation:
274
293
  **→ Step Gate: Step 3 → Step 4**
275
294
 
276
295
  Wait for explicit confirmation. If the developer asks to change the
277
- selection, go back to Step 2 Q5 or Q6 and re-run Step 3.
296
+ selection, go back to the relevant Step 2 question (Q5–Q8) and re-run Step 3.
278
297
 
279
298
  ---
280
299
 
@@ -322,18 +341,31 @@ notice:
322
341
 
323
342
  ### 4.3 Special case — AI agent instruction files
324
343
 
325
- If the developer selected any AI coding agent in Q6, create
344
+ If the developer selected any AI coding agent in Q8, create
326
345
  `dflow/specs/shared/AI-AGENT-GUIDE.md` as the canonical Dflow project
327
346
  guide.
328
347
 
329
348
  For each selected tool-specific file (`AGENTS.md`, `CLAUDE.md`,
330
349
  `.github/copilot-instructions.md`):
331
350
 
351
+ (checked in this order — the first matching rule wins):
352
+
332
353
  - if the target file does not exist, create a small shim at the target
333
354
  path that points to `dflow/specs/shared/AI-AGENT-GUIDE.md`
334
- - if the target file already exists, do not overwrite it; write a merge
335
- snippet under `dflow/specs/shared/` and report that the developer
336
- should merge it manually
355
+ - if the target file contains conflicting or malformed Dflow markers, do not
356
+ edit it; write a fallback merge snippet under `dflow/specs/shared/` and
357
+ report that the developer should merge it manually
358
+ - if the target file already contains a single well-formed Dflow marked block,
359
+ replace that block in place (idempotent refresh) and keep the rest of the
360
+ file unchanged
361
+ - if the target file is an existing whole-file Dflow-generated shim, refresh it
362
+ in place
363
+ - if the target file already points to the guide through the developer's own
364
+ pointer (and has no Dflow marked block), leave it untouched
365
+ - otherwise preserve the existing content and append a marked Dflow block at
366
+ the end of the file, keeping the file's dominant line ending; show that block
367
+ in the preview, and refresh that same block on re-run. If the developer later
368
+ deletes the block, a later `init` / `configure-agents` run appends it again
337
369
 
338
370
  ### 4.4 Directory-only entries
339
371
 
@@ -363,7 +395,7 @@ Summarise what actually happened and point at the next command.
363
395
  ```
364
396
  Init complete. Summary:
365
397
 
366
- Created ({N} files):
398
+ Created / Updated ({N} files):
367
399
  ✓ dflow/specs/features/active/.gitkeep
368
400
  ✓ dflow/specs/features/completed/.gitkeep
369
401
  ✓ dflow/specs/features/backlog/.gitkeep
@@ -374,7 +406,7 @@ Init complete. Summary:
374
406
  ✓ dflow/specs/architecture/decisions/README.md
375
407
  ✓ dflow/specs/shared/_overview.md
376
408
  ✓ dflow/specs/shared/Git-principles-trunk.md
377
- ✓ CLAUDE.md (seeded from scaffolding snippet)
409
+ ✓ CLAUDE.md (marked Dflow block appended)
378
410
 
379
411
  Skipped ({M} files already present):
380
412
  - (none this run)
@@ -428,10 +460,9 @@ Remind the developer to review files that have `{placeholder}` tokens
428
460
  still in them:
429
461
 
430
462
  > "A few files still have `{placeholder}` tokens that need your input:
431
- > - `dflow/specs/shared/_overview.md`: `{業務領域}`, `{團隊}`,
432
- > `{使用者規模}`
463
+ > - `dflow/specs/shared/_overview.md`: the Business Domain and Technical
464
+ > Architecture fields (e.g. primary domain, stakeholders, user scale, stack)
433
465
  > - `dflow/specs/domain/context-map.md`: context list and relationships
434
- > - `CLAUDE.md`: `{業務領域}`
435
466
  >
436
467
  > These are fine to leave for now; fill them in during your next
437
468
  > review pass."
@@ -2,14 +2,14 @@
2
2
 
3
3
  Step-by-step guide for changing or fixing existing functionality.
4
4
 
5
- Triggered by `/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).
5
+ Triggered by `/dflow:modify-existing` or `/dflow:bug-fix` (or natural language implying a modification task — see AI-AGENT-GUIDE.md § Workflow Transparency for the auto-trigger safety net).
6
6
 
7
7
  **Step Gates** in this flow (stop-and-confirm before proceeding):
8
8
  - Step 2 → Step 3 (baseline captured → assess DDD impact)
9
9
  - Step 3 → Step 4 (DDD impact decision → implement)
10
10
  - Step 4 → Step 5 (implementation done → update documentation)
11
11
 
12
- 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.
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.
13
13
 
14
14
  **Note on step count**: Greenfield edition has 5 steps (Brownfield has
15
15
  6) because Clean Architecture's layered structure already separates
@@ -29,7 +29,7 @@ This step has three parallel concerns:
29
29
 
30
30
  **Part A — Determine the Ceremony Tier (T1 / T2 / T3)**
31
31
 
32
- Dflow runs three ceremony tiers (full table in SKILL.md § Ceremony Scaling).
32
+ Dflow runs three ceremony tiers (full table in AI-AGENT-GUIDE.md § Ceremony Scaling).
33
33
  For a modification, AI judges which tier fits before deciding what to
34
34
  produce:
35
35
 
@@ -147,7 +147,7 @@ add a row:
147
147
  | {新 SPEC-ID} | {新 slug} | {today} | in-progress |
148
148
  ```
149
149
 
150
- This update is **part of the same change set** (the developer commits
150
+ This update is **part of the same change set** (offer to commit
151
151
  both at once; commit message should mention "Add follow-up reference to
152
152
  `{新 SPEC-ID}`"). The reverse link is a derived index — the new
153
153
  feature's `follow-up-of` field is the authoritative source.
@@ -158,8 +158,6 @@ phase's content).
158
158
 
159
159
  ## Step 2: Check Documentation
160
160
 
161
- ## Step 2: Check Documentation
162
-
163
161
  - Spec in `dflow/specs/features/completed/`?
164
162
  - Domain model in `dflow/specs/domain/{context}/models.md`?
165
163
  - Business rules in `rules.md`?
@@ -265,6 +263,8 @@ If the lightweight checklist looks larger than a short-fix checklist, AI must pa
265
263
  Announce to developer:
266
264
  > "DDD impact analysis done — {Aggregate boundary OK / needs redesign}, {no new events / new events needed}. Ready to implement? `/dflow:next` to proceed, or adjust the design first."
267
265
 
266
+ > Branch gate (policy-aware): a feature branch is mandatory for every tier (T1 / T2 / T3) under both Git policies (`_conventions.md` § Git Policy). If you are already on this work's `feature/{SPEC-ID}-{slug}` (or `bugfix/{BUG-ID}-{slug}`) branch — e.g. the change belongs to the active feature you are already in — the gate is satisfied and nothing new is created. Otherwise (on the base branch the project cuts from, or an unrelated branch) the AI offers to create/switch to the correct branch, switch to an existing matching one, or override and record it in the `_index.md` Checkpoint Log. Dflow does not need to know which branch is your base. See `references/git-integration.md` § Commit Checkpoints, Branch Gate & AI Commits.
267
+
268
268
  Wait for confirmation before entering Step 4.
269
269
 
270
270
  ## Step 4: Implement
@@ -283,6 +283,8 @@ Even for bug fixes, verify:
283
283
  Announce to developer:
284
284
  > "Implementation appears complete. Ready to update documentation (spec, models.md, rules.md, events.md, glossary, tech-debt)? `/dflow:next` to proceed."
285
285
 
286
+ > Commit checkpoint (per `references/git-integration.md` § Commit Checkpoints, Branch Gate & AI Commits): offer to commit, then record the result in the `_index.md` Checkpoint Log. Tier sets the count — T2 commits the merged spec+implementation here (closeout is the second checkpoint); T3 is a single commit.
287
+
286
288
  Wait for confirmation before entering Step 5. This step gate is where the completion checklist is triggered — do not skip.
287
289
 
288
290
  ## Step 5: Update Documentation
@@ -301,7 +303,7 @@ Items marked *(post-5.3)* are re-verified after the documentation merge in 5.3 l
301
303
  - [ ] ORM / persistence mapping is kept outside Domain entities (no persistence attributes/annotations on Domain entities)
302
304
  - [ ] `Implementation Tasks` section (`phase-spec.md` or `lightweight-spec.md`): all tasks checked, or unchecked items explicitly labelled as follow-up
303
305
  - [ ] *(post-5.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`)
304
- - [ ] *(post-5.3)* `dflow/specs/domain/{context}/behavior.md` `last-updated` is later than this spec's `created` date (mechanical drift guard)
306
+ - [ ] *(post-5.3)* every ADDED / MODIFIED / RENAMED BR's `Last updated` in `dflow/specs/domain/{context}/rules.md` is later than this spec's `created` date (mechanical drift guard)
305
307
 
306
308
  If any item fails, report the gap and pause — don't proceed to 5.2.
307
309
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Step-by-step guide for adding a new feature with full DDD and Clean Architecture.
4
4
 
5
- Triggered by `/dflow:new-feature` (or natural language implying a new-feature task — see SKILL.md § Workflow Transparency for the auto-trigger safety net behavior).
5
+ Triggered by `/dflow:new-feature` (or natural language implying a new-feature task — see AI-AGENT-GUIDE.md § Workflow Transparency for the auto-trigger safety net behavior).
6
6
 
7
7
  **Step Gates** in this flow (stop-and-confirm before proceeding):
8
8
  - Step 3 → Step 3.5 (Aggregate / VO / Events identified → confirm slug + directory + branch names)
@@ -10,9 +10,9 @@ Triggered by `/dflow:new-feature` (or natural language implying a new-feature ta
10
10
  - Step 6 → Step 7 (branch ready → start implementation)
11
11
  - Step 7 → Step 8 (implementation done → completion)
12
12
 
13
- 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.
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.
14
14
 
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 SKILL.md § Ceremony Scaling).
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).
16
16
 
17
17
  ## Step 1: Intake — Understand the Request
18
18
 
@@ -42,7 +42,7 @@ Check `dflow/specs/domain/context-map.md`:
42
42
  [Context] bounded context. Does that match your understanding?"
43
43
  ```
44
44
 
45
- If new context needed → use context-definition template.
45
+ If a new context is needed → create `dflow/specs/domain/{new-context}/context.md` using the context-definition template (`templates/context-definition.md`).
46
46
 
47
47
  If it crosses contexts:
48
48
  ```
@@ -201,7 +201,7 @@ Scenario: Submit expense report
201
201
  Announce to developer:
202
202
  > "Spec is drafted — behavior scenarios, Aggregate state transitions, Domain Events, and CQRS split are captured. Ready to plan the layer-by-layer implementation (Domain → Application → Infrastructure → Presentation)? `/dflow:next` or reply 'OK' to continue, or tell me if the spec needs another iteration first."
203
203
 
204
- Wait for confirmation (`/dflow:next`, verbal OK, or implicit — see SKILL.md § Confirmation Signals) before entering Step 5.
204
+ Wait for confirmation (`/dflow:next`, verbal OK, or implicit — see AI-AGENT-GUIDE.md § Confirmation Signals) before entering Step 5.
205
205
 
206
206
  ## Step 5: Plan the Implementation (Layer by Layer)
207
207
 
@@ -278,11 +278,24 @@ The slug **must match the slug agreed in Step 3.5** (which is also the
278
278
  feature directory name). The SPEC-ID + slug links the branch to its
279
279
  feature directory and `_index.md`.
280
280
 
281
+ **Branch gate (policy-aware).** A feature branch is mandatory under both Git
282
+ policies (`gitflow` / `trunk`, per `_conventions.md` § Git Policy). The gate
283
+ checks whether you are already on this feature's `feature/{SPEC-ID}-{slug}`
284
+ branch: if so, it is satisfied. If you are not yet on it (still on the base
285
+ branch the project cuts from, or an unrelated branch), the AI offers to create
286
+ and switch to `feature/{SPEC-ID}-{slug}`, switch to an existing matching branch,
287
+ or override and stay (recorded in the `_index.md` Checkpoint Log; three
288
+ consecutive overrides → the AI suggests re-running `dflow init`). Dflow does not
289
+ need to know which branch is your base. See `references/git-integration.md`
290
+ § Commit Checkpoints, Branch Gate & AI Commits.
291
+
281
292
  **→ Step Gate: Step 6 → Step 7**
282
293
 
283
294
  Announce to developer:
284
295
  > "Branch `feature/{SPEC-ID}-{description}` is created. Ready to start layer-by-layer implementation (Domain first)? `/dflow:next` to proceed, or discuss layer order / scope first."
285
296
 
297
+ > Commit checkpoint (T1 milestone 1 of 3 — see `references/git-integration.md` § Commit Checkpoints, Branch Gate & AI Commits): now that the feature branch exists (the branch gate above ran first, so this commit lands on the feature branch — never on a base branch), offer to commit the spec baseline, then record the result (committed / skipped) in the `_index.md` Checkpoint Log. Milestone 2 = implementation (Step 7→8); milestone 3 = closeout (`/dflow:finish-feature`).
298
+
286
299
  Wait for confirmation before entering Step 7.
287
300
 
288
301
  ## Step 7: Implementation Checklist
@@ -318,6 +331,8 @@ During implementation, continuously verify:
318
331
  Announce to developer:
319
332
  > "Implementation appears complete across all four layers. Ready to run the completion checklist (verify against spec, update domain docs + context-map, ensure test coverage, archive the spec)? `/dflow:next` to proceed."
320
333
 
334
+ > Commit checkpoint (T1 milestone 2 of 3): offer to commit the implementation, then record the result in the `_index.md` Checkpoint Log. Milestone 3 (closeout) is the `/dflow:finish-feature` checkpoint.
335
+
321
336
  Wait for confirmation before entering Step 8. This step gate is where the completion checklist is triggered — do not skip.
322
337
 
323
338
  ## Step 8: Completion
@@ -337,7 +352,7 @@ AI reports `✓` / `✗` for every item before touching docs. Items marked *(pos
337
352
  - [ ] Aggregate invariants still hold after the change (all state changes go through methods, no public setters)
338
353
  - [ ] ORM / persistence mapping is kept outside Domain entities (no persistence attributes/annotations on Domain entities)
339
354
  - [ ] *(post-8.3)* `dflow/specs/domain/{context}/behavior.md` contains a section anchor for every `BR-*` introduced by this spec (mechanical input for `/dflow:verify`)
340
- - [ ] *(post-8.3)* `dflow/specs/domain/{context}/behavior.md` `last-updated` is later than this spec's `created` date (mechanical drift guard)
355
+ - [ ] *(post-8.3)* `dflow/specs/domain/{context}/rules.md` `last-updated` is later than this spec's `created` date (mechanical drift guard)
341
356
 
342
357
  If any item fails, report the gap and pause — don't proceed to 8.2.
343
358
 
@@ -369,12 +384,14 @@ Ask these one-by-one; do not dump all six at once.
369
384
 
370
385
  ### 8.4 Archival
371
386
 
372
- For a single-phase feature, this is the closeout point. For a multi-phase
373
- feature, the developer typically reaches this point at the end of the
374
- final phase — at which time `/dflow:finish-feature` is the recommended
375
- trigger (it bundles steps 8.1 / 8.2 verification, BC sync, and archival
376
- into one explicit ceremony). Either path is acceptable; pick the one
377
- that matches the developer's habit.
387
+ For a single-phase feature, this is the closeout point. If the feature has
388
+ later phases still ahead, this phase is complete but the feature is not —
389
+ don't archive yet; run `/dflow:new-phase` to start the next phase, not
390
+ `/dflow:finish-feature` yet. For a multi-phase feature, the developer
391
+ typically reaches this point at the end of the final phase — at which time
392
+ `/dflow:finish-feature` is the recommended trigger (it bundles steps 8.1 /
393
+ 8.2 verification, BC sync, and archival into one explicit ceremony). Either
394
+ path is acceptable; pick the one that matches the developer's habit.
378
395
 
379
396
  - [ ] `_index.md` `status` field changed to `completed`
380
397
  - [ ] All `phase-spec-*.md` files in the feature directory have `status:
@@ -20,7 +20,7 @@ adds a new phase to an in-progress feature only.
20
20
  - Step 6 → Step 7 (implementation done → complete the phase)
21
21
 
22
22
  All other step transitions are **step-internal**: announce "Step N complete,
23
- entering Step N+1" and proceed without waiting. See SKILL.md § Workflow
23
+ entering Step N+1" and proceed without waiting. See AI-AGENT-GUIDE.md § Workflow
24
24
  Transparency for the full transparency protocol and confirmation signals.
25
25
 
26
26
  ## Step 1: Read Active Feature Context
@@ -67,6 +67,17 @@ AI must locate the target feature and load its current state:
67
67
  and `behavior.md` if the new phase is likely to touch system-level
68
68
  state (BC-level current state lives there, not in `_index.md`)
69
69
 
70
+ 4. **Branch gate — ensure you are on this feature's branch (before any commit)**
71
+
72
+ This phase's commits must land on the active feature's
73
+ `feature/{SPEC-ID}-{slug}` branch. If you are not already on it (you
74
+ identified the feature by name, or are on a base / unrelated branch),
75
+ switch to the existing branch — or override and record it in the
76
+ `_index.md` Checkpoint Log. **Never create a new feature branch here:**
77
+ `new-phase` extends an existing active feature, it does not start one. See
78
+ `references/git-integration.md` § Commit Checkpoints, Branch Gate & AI
79
+ Commits.
80
+
70
81
  Share what you found:
71
82
 
72
83
  > "OK — `{SPEC-ID}-{slug}` has {N} prior phases in BC `{context}`. The
@@ -167,6 +178,8 @@ Announce to developer:
167
178
  > Ready to refresh `_index.md` (add Phase Specs row, regenerate Current BR
168
179
  > Snapshot from the Delta)? `/dflow:next` to proceed."
169
180
 
181
+ > Commit checkpoint (per `references/git-integration.md` § Commit Checkpoints, Branch Gate & AI Commits): with the Step 1 branch gate satisfied (you are on the feature's branch), offer to commit the phase-spec baseline and record the result in the `_index.md` Checkpoint Log.
182
+
170
183
  Wait for confirmation before entering Step 5.
171
184
 
172
185
  ## Step 5: Refresh `_index.md`
@@ -240,6 +253,8 @@ Announce to developer:
240
253
  > Ready to mark this phase completed and update `_index.md`? `/dflow:next`
241
254
  > to proceed."
242
255
 
256
+ > Commit checkpoint (per `references/git-integration.md` § Commit Checkpoints, Branch Gate & AI Commits): offer to commit the phase implementation, then record the result in the `_index.md` Checkpoint Log.
257
+
243
258
  Wait for confirmation before entering Step 7.
244
259
 
245
260
  ## Step 7: Complete the Phase