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
@@ -49,8 +49,8 @@ Report findings plainly:
49
49
  > - `dflow/specs/`: not yet present → greenfield Dflow setup
50
50
  > - `specs/`: present → legacy / other-tool directory; Dflow V1 will not
51
51
  > migrate or modify it
52
- > - `CLAUDE.md`: present → will not overwrite; I'll offer a snippet
53
- > to merge into it"
52
+ > - `CLAUDE.md`: present → I'll append a marked Dflow block (shown in
53
+ > the preview); a merge snippet only if there's a marker conflict"
54
54
 
55
55
  Or:
56
56
 
@@ -117,25 +117,42 @@ blank input, or prose descriptions such as "Traditional Chinese". Dflow
117
117
  templates keep canonical English structural language; this setting controls
118
118
  free prose inside generated spec sections.
119
119
 
120
- ### Q5. Optional starter files (multi-select)
120
+ ### Q5. Git policy (mandatory — pick one)
121
121
 
122
- > "Besides the mandatory baseline, which optional starter files do
123
- > you want me to seed? You can check as many as apply:
122
+ > "Which Git policy does the team follow? This drives the runtime branch gate
123
+ > and the finish-stage merge guidance, so it is required:
124
124
  >
125
- > - [ ] `dflow/specs/shared/_overview.md` — system overview template
126
- > - [ ] Git principles — **pick one** if your project has opinions
127
- > about Git conventions (decision hint: **if you're not sure,
128
- > pick trunk-based** — that's the default for GitHub / GitLab.
129
- > Pick Git Flow only if you have a formal release cycle with
130
- > dedicated release / hotfix branches):
131
- > - [ ] `dflow/specs/shared/Git-principles-gitflow.md`
132
- > - [ ] `dflow/specs/shared/Git-principles-trunk.md`"
125
+ > 1. GitFlow — long-lived develop / release branches
126
+ > 2. Trunk / GitHub Flow — short-lived feature branches (lightest; the
127
+ > default for most GitHub / GitLab teams)"
133
128
 
134
- Wait for answers. If the developer picks both Git-principles flavours,
135
- confirm once more that they really want both (usually a project picks
136
- one).
129
+ Required — do not accept a skip. Both policies use feature branches; the choice
130
+ only changes finish-stage merge guidance. The selected policy seeds exactly one
131
+ `dflow/specs/shared/Git-principles-{gitflow|trunk}.md` (**mandatory, not
132
+ optional**) and is recorded in `_conventions.md` under `## Git Policy`.
137
133
 
138
- ### Q6. AI coding agents (multi-select)
134
+ ### Q6. AI commit marker (mandatory — default None)
135
+
136
+ > "How should AI-made commits be marked? The AI offers to commit at lifecycle
137
+ > checkpoints (you can always decline); this sets how those commits are tagged:
138
+ >
139
+ > 1. None (default) — AI commits look like any other commit
140
+ > 2. Co-Authored-By trailer (`dflow-ai <noreply@dflow.local>`) — filterable
141
+ > 3. `[ai-assisted]` commit-subject prefix — visible at a glance"
142
+
143
+ Recorded in `_conventions.md` under `## AI Commit Policy`; the runtime does not
144
+ re-ask.
145
+
146
+ ### Q7. Optional starter files (multi-select)
147
+
148
+ > "Besides the mandatory baseline, which optional starter files do you want me
149
+ > to seed?
150
+ >
151
+ > - [ ] `dflow/specs/shared/_overview.md` — system overview template"
152
+
153
+ Wait for answers.
154
+
155
+ ### Q8. AI coding agents (multi-select)
139
156
 
140
157
  > "Which AI coding agents should Dflow configure?
141
158
  >
@@ -145,9 +162,10 @@ one).
145
162
  >
146
163
  > If you select any agent, Dflow will create
147
164
  > `dflow/specs/shared/AI-AGENT-GUIDE.md` as the canonical guide. Root-level
148
- > tool files stay thin and point back to that guide. Existing tool files are
149
- > never overwritten; Dflow writes merge snippets under `dflow/specs/shared/`
150
- > instead."
165
+ > tool files stay thin and point back to that guide. Existing user content is
166
+ > never overwritten; Dflow appends a marked Dflow block (shown in the preview)
167
+ > and refreshes it in place on re-run. Merge snippets under
168
+ > `dflow/specs/shared/` are used only if Dflow markers conflict."
151
169
 
152
170
  **→ Transition (step-internal)**: Step 2 complete. Announce
153
171
  > "Step 2 complete (project information captured). Entering Step 3:
@@ -197,7 +215,7 @@ Key Brownfield-track notes:
197
215
  track makes this file mandatory because BCs are usually planned
198
216
  up-front).
199
217
 
200
- ### 3.2 Optional files (from Step 2 Q5)
218
+ ### 3.2 Optional files (from Step 2 Q7)
201
219
 
202
220
  Use the packaged scaffolding templates listed below; their project-local
203
221
  outputs are under `dflow/specs/shared/` (the scaffolding root, not the
@@ -211,16 +229,17 @@ vendored workflow bundle). Compute the destination path:
211
229
  | `scaffolding/Git-principles-trunk.md` | `dflow/specs/shared/Git-principles-trunk.md` |
212
230
  | `scaffolding/AI-AGENT-GUIDE.md` | `dflow/specs/shared/AI-AGENT-GUIDE.md` when at least one AI agent is selected |
213
231
  | generated tool shim | `AGENTS.md`, `CLAUDE.md`, or `.github/copilot-instructions.md` when selected and missing |
214
- | generated merge snippet | `dflow/specs/shared/*-snippet.md` when the selected tool file already exists |
232
+ | 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 |
233
+ | fallback merge snippet | `dflow/specs/shared/*-snippet.md` only when the selected tool file has conflicting or malformed Dflow markers |
215
234
 
216
235
  ### 3.3 Present the preview
217
236
 
218
- Present the complete file list as two tables, separating create vs
237
+ Present the complete file list as two tables, separating create / update vs
219
238
  skip, and wait for developer confirmation:
220
239
 
221
240
  > "Based on Step 1 inventory + Step 2 answers, here is what I'll do:
222
241
  >
223
- > **Will create ({N} files):**
242
+ > **Will create / update ({N} files):**
224
243
  >
225
244
  > | Path | Source |
226
245
  > |---|---|
@@ -231,9 +250,9 @@ skip, and wait for developer confirmation:
231
250
  > | `dflow/specs/shared/_conventions.md` | `scaffolding/_conventions.md` (mandatory baseline) |
232
251
  > | `dflow/specs/migration/tech-debt.md` | `templates/tech-debt.md` (mandatory baseline) |
233
252
  > | `dflow/specs/shared/_overview.md` | optional (you picked it) |
234
- > | `dflow/specs/shared/Git-principles-trunk.md` | optional (you picked it) |
253
+ > | `dflow/specs/shared/Git-principles-trunk.md` | mandatory (selected Git policy) |
235
254
  > | `dflow/specs/shared/AI-AGENT-GUIDE.md` | selected AI agent guide |
236
- > | `CLAUDE.md` | selected tool shim because repo has no CLAUDE.md |
255
+ > | `CLAUDE.md` | marked Dflow block appended to existing CLAUDE.md (shown in preview) |
237
256
  >
238
257
  > **Will skip ({M} files — already present):**
239
258
  >
@@ -255,7 +274,7 @@ skip, and wait for developer confirmation:
255
274
  **→ Step Gate: Step 3 → Step 4**
256
275
 
257
276
  Wait for explicit confirmation. If the developer asks to change the
258
- selection, go back to Step 2 Q5 or Q6 and re-run Step 3.
277
+ selection, go back to the relevant Step 2 question (Q5–Q8) and re-run Step 3.
259
278
 
260
279
  ---
261
280
 
@@ -301,18 +320,31 @@ notice:
301
320
 
302
321
  ### 4.3 Special case — AI agent instruction files
303
322
 
304
- If the developer selected any AI coding agent in Q6, create
323
+ If the developer selected any AI coding agent in Q8, create
305
324
  `dflow/specs/shared/AI-AGENT-GUIDE.md` as the canonical Dflow project
306
325
  guide.
307
326
 
308
327
  For each selected tool-specific file (`AGENTS.md`, `CLAUDE.md`,
309
328
  `.github/copilot-instructions.md`):
310
329
 
330
+ (checked in this order — the first matching rule wins):
331
+
311
332
  - if the target file does not exist, create a small shim at the target
312
333
  path that points to `dflow/specs/shared/AI-AGENT-GUIDE.md`
313
- - if the target file already exists, do not overwrite it; write a merge
314
- snippet under `dflow/specs/shared/` and report that the developer
315
- should merge it manually
334
+ - if the target file contains conflicting or malformed Dflow markers, do not
335
+ edit it; write a fallback merge snippet under `dflow/specs/shared/` and
336
+ report that the developer should merge it manually
337
+ - if the target file already contains a single well-formed Dflow marked block,
338
+ replace that block in place (idempotent refresh) and keep the rest of the
339
+ file unchanged
340
+ - if the target file is an existing whole-file Dflow-generated shim, refresh it
341
+ in place
342
+ - if the target file already points to the guide through the developer's own
343
+ pointer (and has no Dflow marked block), leave it untouched
344
+ - otherwise preserve the existing content and append a marked Dflow block at
345
+ the end of the file, keeping the file's dominant line ending; show that block
346
+ in the preview, and refresh that same block on re-run. If the developer later
347
+ deletes the block, a later `init` / `configure-agents` run appends it again
316
348
 
317
349
  ### 4.4 Directory-only entries
318
350
 
@@ -337,7 +369,7 @@ Summarise what actually happened and point at the next command.
337
369
  ```
338
370
  Init complete. Summary:
339
371
 
340
- Created ({N} files):
372
+ Created / Updated ({N} files):
341
373
  ✓ dflow/specs/features/active/.gitkeep
342
374
  ✓ dflow/specs/features/completed/.gitkeep
343
375
  ✓ dflow/specs/features/backlog/.gitkeep
@@ -346,7 +378,7 @@ Init complete. Summary:
346
378
  ✓ dflow/specs/migration/tech-debt.md
347
379
  ✓ dflow/specs/shared/_overview.md
348
380
  ✓ dflow/specs/shared/Git-principles-trunk.md
349
- ✓ CLAUDE.md (seeded from scaffolding snippet)
381
+ ✓ CLAUDE.md (marked Dflow block appended)
350
382
 
351
383
  Skipped ({M} files already present):
352
384
  - (none this run)
@@ -395,9 +427,8 @@ Remind the developer to review files that have `{placeholder}` tokens
395
427
  still in them:
396
428
 
397
429
  > "A few files still have `{placeholder}` tokens that need your input:
398
- > - `dflow/specs/shared/_overview.md`: `{業務領域}`, `{團隊}`,
399
- > `{使用者規模}`
400
- > - `CLAUDE.md`: `{業務領域}`
430
+ > - `dflow/specs/shared/_overview.md`: the Business Domain and Technical
431
+ > Architecture fields (e.g. primary domain, stakeholders, user scale, stack)
401
432
  >
402
433
  > These are fine to leave for now; fill them in during your next
403
434
  > review pass."
@@ -1,15 +1,15 @@
1
1
  # Modify Existing Feature Workflow
2
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).
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 AI-AGENT-GUIDE.md § Workflow Transparency for the auto-trigger safety net).
4
4
 
5
5
  **Step Gates** in this flow (stop-and-confirm before proceeding):
6
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
7
  - Step 4 → Step 5 (extraction decision → start implementation)
8
8
  - Step 5 → Step 6 (implementation done → update artifacts)
9
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.
10
+ 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
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).
12
+ **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).
13
13
 
14
14
  ## Mindset
15
15
 
@@ -31,7 +31,7 @@ This step has two parallel concerns:
31
31
 
32
32
  **Part A — Determine the Ceremony Tier (T1 / T2 / T3)**
33
33
 
34
- Dflow runs three ceremony tiers (full table in SKILL.md § Ceremony Scaling).
34
+ Dflow runs three ceremony tiers (full table in AI-AGENT-GUIDE.md § Ceremony Scaling).
35
35
  For a modification, AI judges which tier fits before deciding what to
36
36
  produce:
37
37
 
@@ -141,7 +141,7 @@ add a row:
141
141
  | {新 SPEC-ID} | {新 slug} | {today} | in-progress |
142
142
  ```
143
143
 
144
- This update is **part of the same change set** (the developer commits
144
+ This update is **part of the same change set** (offer to commit
145
145
  both at once; commit message should mention "Add follow-up reference to
146
146
  `{新 SPEC-ID}`"). The reverse link is a derived index — the new
147
147
  feature's `follow-up-of` field is the authoritative source.
@@ -152,8 +152,6 @@ phase's content).
152
152
 
153
153
  ## Step 2: Document Current Behavior (if no spec exists)
154
154
 
155
- ## Step 2: Document Current Behavior (if no spec exists)
156
-
157
155
  This is critical. Before changing anything, capture what currently exists:
158
156
 
159
157
  ```
@@ -299,6 +297,8 @@ If the lightweight checklist looks larger than a short-fix checklist, AI must pa
299
297
  Announce to developer:
300
298
  > "Extraction decision made — {extract now / defer and record}. Ready to start implementation? `/dflow:next` to proceed, or adjust the extraction scope first."
301
299
 
300
+ > 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.
301
+
302
302
  Wait for confirmation before entering Step 5.
303
303
 
304
304
  ## Step 5: Implement the Change
@@ -341,6 +341,8 @@ protected void Calculate()
341
341
  Announce to developer:
342
342
  > "Implementation appears complete. Ready to update artifacts (spec, rules.md, models.md, glossary, tech-debt)? `/dflow:next` to proceed."
343
343
 
344
+ > 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.
345
+
344
346
  Wait for confirmation before entering Step 6. This step gate is where the completion checklist is triggered — do not skip.
345
347
 
346
348
  ## Step 6: Update Artifacts
@@ -356,7 +358,7 @@ Items marked *(post-6.3)* are re-verified after the documentation merge in 6.3 l
356
358
  - [ ] Extracted logic (if Step 4 decided "extract now") lives under `src/Domain/` as framework-pure code
357
359
  - [ ] `Implementation Tasks` section (`phase-spec.md` or `lightweight-spec.md`): all tasks checked, or unchecked items explicitly labelled as follow-up
358
360
  - [ ] *(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)
361
+ - [ ] *(post-6.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)
360
362
 
361
363
  If any item fails, report the gap and pause — don't proceed to 6.2.
362
364
 
@@ -412,33 +414,3 @@ new follow-up directory; that happens at `/dflow:finish-feature` time.
412
414
 
413
415
  Only announce "change complete" after the appropriate archival step
414
416
  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
- ```
@@ -1,6 +1,6 @@
1
1
  # New Feature Workflow
2
2
 
3
- Step-by-step guide for when a developer triggers `/dflow:new-feature` (or natural language implying a new-feature task — see SKILL.md § Workflow Transparency for the auto-trigger safety net behavior).
3
+ Step-by-step guide for when a developer triggers `/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).
4
4
 
5
5
  **Step Gates** in this flow (stop-and-confirm before proceeding):
6
6
  - Step 3 → Step 3.5 (domain concepts captured → confirm slug + directory + branch names)
@@ -8,9 +8,9 @@ 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
- 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
+ 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
12
 
13
- **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).
13
+ **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).
14
14
 
15
15
  ## Step 1: Intake — Understand the Request
16
16
 
@@ -188,7 +188,7 @@ Specifically ask about:
188
188
  Announce to developer:
189
189
  > "Spec is drafted — behavior scenarios, business rules, and edge cases are captured. Ready to plan the implementation (Domain layer design, interfaces, thin delivery/entrypoint code — presentation/UI layer, controllers, handlers, jobs, message consumers, data pipelines, or stored procedures)? `/dflow:next` or reply 'OK' to continue, or tell me if the spec needs another iteration first."
190
190
 
191
- Wait for confirmation (`/dflow:next`, verbal OK, or implicit — see SKILL.md § Confirmation Signals) before entering Step 5.
191
+ Wait for confirmation (`/dflow:next`, verbal OK, or implicit — see AI-AGENT-GUIDE.md § Confirmation Signals) before entering Step 5.
192
192
 
193
193
  ## Step 5: Plan the Implementation
194
194
 
@@ -273,11 +273,24 @@ The slug **must match the slug agreed in Step 3.5** (which is also the
273
273
  feature directory name). The SPEC-ID + slug links the branch to its
274
274
  feature directory and `_index.md`.
275
275
 
276
+ **Branch gate (policy-aware).** A feature branch is mandatory under both Git
277
+ policies (`gitflow` / `trunk`, per `_conventions.md` § Git Policy). The gate
278
+ checks whether you are already on this feature's `feature/{SPEC-ID}-{slug}`
279
+ branch: if so, it is satisfied. If you are not yet on it (still on the base
280
+ branch the project cuts from, or an unrelated branch), the AI offers to create
281
+ and switch to `feature/{SPEC-ID}-{slug}`, switch to an existing matching branch,
282
+ or override and stay (recorded in the `_index.md` Checkpoint Log; three
283
+ consecutive overrides → the AI suggests re-running `dflow init`). Dflow does not
284
+ need to know which branch is your base. See `references/git-integration.md`
285
+ § Commit Checkpoints, Branch Gate & AI Commits.
286
+
276
287
  **→ Step Gate: Step 6 → Step 7**
277
288
 
278
289
  Announce to developer:
279
290
  > "Branch `feature/{SPEC-ID}-{description}` is created. Ready to start implementation? `/dflow:next` to proceed, or discuss implementation order / scope first."
280
291
 
292
+ > 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`).
293
+
281
294
  Wait for confirmation before entering Step 7.
282
295
 
283
296
  ## Step 7: Implementation
@@ -294,6 +307,8 @@ During implementation, continuously check:
294
307
  Announce to developer:
295
308
  > "Implementation appears complete. Ready to run the completion checklist (verify against spec, update domain docs, archive the spec)? `/dflow:next` to proceed."
296
309
 
310
+ > 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.
311
+
297
312
  Wait for confirmation before entering Step 8. This step gate is where the completion checklist is triggered — do not skip.
298
313
 
299
314
  ## Step 8: Completion
@@ -310,7 +325,7 @@ AI reports `✓` / `✗` for every item before touching docs. Items marked *(pos
310
325
  - [ ] Every `EC-*` edge case is handled
311
326
  - [ ] Domain layer has **no** delivery-framework references (grep `src/Domain/`)
312
327
  - [ ] *(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`)
313
- - [ ] *(post-8.3)* `dflow/specs/domain/{context}/behavior.md` `last-updated` is later than this spec's `created` date (mechanical drift guard)
328
+ - [ ] *(post-8.3)* `dflow/specs/domain/{context}/rules.md` `last-updated` is later than this spec's `created` date (mechanical drift guard)
314
329
 
315
330
  If any item fails, report the gap and pause — don't proceed to 8.2.
316
331
 
@@ -339,12 +354,14 @@ Ask these one-by-one; do not dump all five at once.
339
354
 
340
355
  ### 8.4 Archival
341
356
 
342
- For a single-phase feature, this is the closeout point. For a multi-phase
343
- feature, the developer typically reaches this point at the end of the
344
- final phase — at which time `/dflow:finish-feature` is the recommended
345
- trigger (it bundles steps 8.1 / 8.2 verification, BC sync, and archival
346
- into one explicit ceremony). Either path is acceptable; pick the one
347
- that matches the developer's habit.
357
+ For a single-phase feature, this is the closeout point. If the feature has
358
+ later phases still ahead, this phase is complete but the feature is not —
359
+ don't archive yet; run `/dflow:new-phase` to start the next phase, not
360
+ `/dflow:finish-feature` yet. For a multi-phase feature, the developer
361
+ typically reaches this point at the end of the final phase — at which time
362
+ `/dflow:finish-feature` is the recommended trigger (it bundles steps 8.1 /
363
+ 8.2 verification, BC sync, and archival into one explicit ceremony). Either
364
+ path is acceptable; pick the one that matches the developer's habit.
348
365
 
349
366
  - [ ] `_index.md` `status` field changed to `completed`
350
367
  - [ ] 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
@@ -64,6 +64,17 @@ AI must locate the target feature and load its current state:
64
64
  left off (its Business Rules and Delta-from-prior-phases sections in
65
65
  particular)
66
66
 
67
+ 4. **Branch gate — ensure you are on this feature's branch (before any commit)**
68
+
69
+ This phase's commits must land on the active feature's
70
+ `feature/{SPEC-ID}-{slug}` branch. If you are not already on it (you
71
+ identified the feature by name, or are on a base / unrelated branch),
72
+ switch to the existing branch — or override and record it in the
73
+ `_index.md` Checkpoint Log. **Never create a new feature branch here:**
74
+ `new-phase` extends an existing active feature, it does not start one. See
75
+ `references/git-integration.md` § Commit Checkpoints, Branch Gate & AI
76
+ Commits.
77
+
67
78
  Share what you found:
68
79
 
69
80
  > "OK — `{SPEC-ID}-{slug}` has {N} prior phases. The most recent
@@ -158,6 +169,8 @@ Announce to developer:
158
169
  > Ready to refresh `_index.md` (add Phase Specs row, regenerate Current BR
159
170
  > Snapshot from the Delta)? `/dflow:next` to proceed."
160
171
 
172
+ > 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.
173
+
161
174
  Wait for confirmation before entering Step 5.
162
175
 
163
176
  ## Step 5: Refresh `_index.md`
@@ -227,6 +240,8 @@ Announce to developer:
227
240
  > Ready to mark this phase completed and update `_index.md`? `/dflow:next`
228
241
  > to proceed."
229
242
 
243
+ > 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.
244
+
230
245
  Wait for confirmation before entering Step 7.
231
246
 
232
247
  ## Step 7: Complete the Phase