dflow-sdd-ddd 0.8.0 → 0.9.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 (29) hide show
  1. package/CHANGELOG.md +47 -0
  2. package/LICENSE +679 -21
  3. package/README.en.md +5 -4
  4. package/README.md +3 -3
  5. package/bin/dflow.js +3 -2
  6. package/docs/using-with-codex.en.md +12 -8
  7. package/docs/using-with-codex.md +8 -6
  8. package/lib/init.js +217 -35
  9. package/package.json +2 -2
  10. package/templates/brownfield/references/dflow-feedback-flow.md +135 -63
  11. package/templates/brownfield/references/finish-feature-flow.md +56 -21
  12. package/templates/brownfield/references/git-integration.md +65 -6
  13. package/templates/brownfield/references/init-project-flow.md +36 -19
  14. package/templates/brownfield/references/modify-existing-flow.md +4 -0
  15. package/templates/brownfield/references/new-feature-flow.md +15 -0
  16. package/templates/brownfield/references/new-phase-flow.md +15 -0
  17. package/templates/brownfield/scaffolding/Git-principles-gitflow.md +13 -12
  18. package/templates/brownfield/scaffolding/Git-principles-trunk.md +13 -16
  19. package/templates/brownfield/templates/_index.md +20 -2
  20. package/templates/greenfield/references/dflow-feedback-flow.md +135 -63
  21. package/templates/greenfield/references/finish-feature-flow.md +55 -21
  22. package/templates/greenfield/references/git-integration.md +65 -6
  23. package/templates/greenfield/references/init-project-flow.md +36 -19
  24. package/templates/greenfield/references/modify-existing-flow.md +4 -0
  25. package/templates/greenfield/references/new-feature-flow.md +15 -0
  26. package/templates/greenfield/references/new-phase-flow.md +15 -0
  27. package/templates/greenfield/scaffolding/Git-principles-gitflow.md +13 -12
  28. package/templates/greenfield/scaffolding/Git-principles-trunk.md +13 -17
  29. package/templates/greenfield/templates/_index.md +20 -2
@@ -2,7 +2,8 @@
2
2
 
3
3
  `/dflow:report-dflow-feedback` helps the developer turn a Dflow problem or
4
4
  improvement observed during real project work into a high-quality upstream
5
- feedback draft.
5
+ feedback draft. The draft is rendered **field by field to match the upstream
6
+ GitHub issue form**, so the developer pastes each field with no reformatting.
6
7
 
7
8
  This flow is **not** a project feature workflow and does not change the
8
9
  application being built. It is a standalone governance/support flow for Dflow
@@ -48,13 +49,16 @@ turn it into a PR, or discard it.
48
49
 
49
50
  ## Step 1: Classify the Feedback
50
51
 
51
- Classify the feedback as one of:
52
+ Classify the feedback as one of the following. Each maps to one upstream issue
53
+ form (see "Upstream Issue Forms" below):
52
54
 
53
- - Bug report
54
- - Workflow change request
55
- - Documentation feedback
56
- - Question / unclear usage
57
- - Maintainer release/process feedback
55
+ | Classification | Upstream issue form | Title prefix |
56
+ |---|---|---|
57
+ | Bug report | Bug report | `[Bug]: ` |
58
+ | Workflow change request | Workflow change request | `[Workflow]: ` |
59
+ | Documentation feedback | Documentation feedback | `[Docs]: ` |
60
+ | Question / unclear usage | Question | `[Question]: ` |
61
+ | Maintainer release/process feedback | Workflow change request (closest form; the upstream repo disables blank issues) | `[Workflow]: ` |
58
62
 
59
63
  Capture:
60
64
 
@@ -88,92 +92,160 @@ Avoid:
88
92
 
89
93
  ## Step 3: Redaction Pass
90
94
 
91
- Before writing the issue body section, perform a redaction check and include it
92
- in the draft:
95
+ Before writing any field content, run a redaction check and use it as your own
96
+ gate. Confirm there are:
93
97
 
94
- ```markdown
95
- ## Redaction Checklist
98
+ - No secrets, tokens, credentials, or auth headers
99
+ - No customer, tenant, or private organization names
100
+ - No proprietary business rules beyond a sanitized paraphrase
101
+ - No private repository URLs or internal hostnames
102
+ - No long proprietary source snippets
96
103
 
97
- - [ ] No secrets, tokens, credentials, or auth headers
98
- - [ ] No customer, tenant, or private organization names
99
- - [ ] No proprietary business rules beyond sanitized paraphrase
100
- - [ ] No private repository URLs or internal hostnames
101
- - [ ] No long proprietary source snippets
102
- - [ ] Developer reviewed before submission
103
- ```
104
+ The draft ends with a short submitter self-check (Step 5); leave its items
105
+ unchecked unless the developer explicitly confirms them.
106
+
107
+ ## Step 4: Resolve the Target Issue Form
104
108
 
105
- Leave the final "Developer reviewed before submission" unchecked unless the
106
- developer explicitly confirms it.
109
+ Submit upstream at: **https://github.com/weilung/dflow-sdd-ddd/issues/new/choose**
107
110
 
108
- ## Step 4: Write the Feedback Draft
111
+ Resolve the field schema for the chosen form using this priority chain (it
112
+ avoids any network dependency at draft time):
109
113
 
110
- Use this structure:
114
+ 1. **Live upstream schema** — if you can read the target repo's
115
+ `.github/ISSUE_TEMPLATE/*.yml` (for example you are working inside a
116
+ `dflow-sdd-ddd` checkout), use that file; it is authoritative.
117
+ 2. **Bundled field map** — otherwise use the field map in "Upstream Issue
118
+ Forms" below. It is a snapshot of the upstream forms shipped with Dflow.
119
+ 3. **Generic fallback** — only if the feedback matches none of the forms, use
120
+ Step 6.
111
121
 
112
- ```markdown
113
- # Dflow Feedback Draft: {short-title}
122
+ ## Step 5: Render the Draft Field by Field
114
123
 
115
- ## Summary
124
+ Write the draft as one block per upstream field, in the form's field order, so
125
+ the developer copies each block straight into the matching field.
116
126
 
117
- {One or two sentences.}
127
+ Per field-type rules:
118
128
 
119
- ## Type
129
+ | Field type | How to render |
130
+ |---|---|
131
+ | `input` | One short line inside a fenced block. |
132
+ | `textarea` | Multi-line content inside a fenced block. If the field sets a non-empty `render:` attribute, do **not** add an extra fence (the form already code-blocks it). |
133
+ | `dropdown` | State the **recommended option** plus a one-line reason. If `multiple: true`, list the chosen options. |
134
+ | `checkboxes` | List every option as `- [x]` / `- [ ]`; mark any option whose schema sets `required: true`. |
135
+ | `markdown` | Display-only text in the form — produce **no** field block for it. |
136
+ | upload / attachment | Emit a manual step ("drag the relevant screenshot / log into the issue editor"); do not try to handle the file. |
120
137
 
121
- {Bug report | Workflow change request | Documentation feedback | Question | Maintainer process feedback}
138
+ Always start with a **Title** block: the form's title prefix plus a concise
139
+ one-line summary. GitHub pre-fills the prefix in the title box; the developer
140
+ can paste the full line over it.
122
141
 
123
- ## Observed While Using
142
+ Attribute handling: bring `value` / `default` in as starting content; surface
143
+ `placeholder` as a hint; append "(required)" to the block heading when the
144
+ field sets `required: true`.
124
145
 
125
- - Dflow version: {version-or-unknown}
126
- - Command / flow: {command-or-flow}
127
- - Track: {Greenfield | Brownfield | both | unknown}
128
- - Project context: {sanitized generic context}
146
+ **Fence escaping (dynamic).** Wrap each field's content in a backtick fence
147
+ whose length is *(longest backtick run in the content) + 1*, minimum 3. The
148
+ fence is only a local wrapper so the content survives in the draft file — when
149
+ pasting into the issue form, the developer copies the **inner** content, not
150
+ the fence. State this in the draft.
129
151
 
130
- ## Affected Dflow Area
152
+ Draft skeleton:
131
153
 
132
- - {CLI | template | scaffolding | skill reference | tutorial | docs | governance}
133
- - Files or concepts: {sanitized list}
154
+ ````markdown
155
+ # {Issue form name} — {short title}
134
156
 
135
- ## Problem
157
+ ## Where to submit
136
158
 
137
- {What happened, why it is confusing or harmful, and who is affected.}
159
+ https://github.com/weilung/dflow-sdd-ddd/issues/new/choose → choose
160
+ **"{Issue form name}"**. (A GitHub account is all you need; the title is
161
+ auto-prefixed with `{prefix}`.)
138
162
 
139
- ## Expected Behavior or Improvement
163
+ ## Title
164
+
165
+ ```
166
+ {prefix}{concise one-line summary}
167
+ ```
140
168
 
141
- {What Dflow should do or explain instead.}
169
+ ## {Field label} (required)
142
170
 
143
- ## Evidence
171
+ ```
172
+ {field content; copy the inner text only, not this fence}
173
+ ```
144
174
 
145
- {Minimal sanitized observations.}
175
+ ... one block per field, in form order ...
146
176
 
147
- ## Compatibility / Breaking-Change Risk
177
+ ## Before you submit (submitter self-check)
148
178
 
149
- {None | low | medium | high}, with reasoning.
179
+ - [ ] Any real file names / customer names / internal project code names to redact?
180
+ - [ ] If you attach screenshots, do they show sensitive content (internal systems, tokens, passwords)?
181
+ - [ ] Is opening a public issue within what your organization allows?
182
+ ````
150
183
 
151
- ## Suggested GitHub Issue Body
184
+ Keep the draft **submitter-facing only**: no maintainer tracking notes, no
185
+ internal references, no "for your friend / for yourself" audience switches.
152
186
 
153
- {Copy-ready issue body matching the closest issue template.}
187
+ ## Upstream Issue Forms (bundled field map)
154
188
 
155
- ## Optional PR Plan
189
+ > Snapshot of the `weilung/dflow-sdd-ddd` issue forms. If the live `.yml` is
190
+ > reachable (Step 4 priority 1), prefer it. Resync this map when the upstream
191
+ > forms change.
156
192
 
157
- {Only include if the change is small and concrete. Otherwise write "Not recommended yet; start with an issue."}
193
+ ### Bug report — title `[Bug]: `
158
194
 
159
- ## Redaction Checklist
195
+ | Field | Type | Required | Notes |
196
+ |---|---|---|---|
197
+ | Dflow version | input | yes | placeholder `0.2.0` |
198
+ | Node.js version | input | yes | from `node --version` |
199
+ | Project track | dropdown | yes | Greenfield / Brownfield / Not sure |
200
+ | Command or workflow | textarea | yes | the command or `/dflow:*` workflow used |
201
+ | Expected behavior | textarea | yes | |
202
+ | Actual behavior | textarea | yes | include relevant output |
203
+ | Reproduction steps | textarea | yes | smallest steps that reproduce |
204
+ | Additional context | textarea | no | screenshots / snippets / environment |
160
205
 
161
- - [ ] No secrets, tokens, credentials, or auth headers
162
- - [ ] No customer, tenant, or private organization names
163
- - [ ] No proprietary business rules beyond sanitized paraphrase
164
- - [ ] No private repository URLs or internal hostnames
165
- - [ ] No long proprietary source snippets
166
- - [ ] Developer reviewed before submission
167
- ```
206
+ ### Workflow change request — title `[Workflow]: `
207
+
208
+ | Field | Type | Required | Notes |
209
+ |---|---|---|---|
210
+ | Problem | textarea | yes | |
211
+ | Proposed change | textarea | yes | |
212
+ | Affected track | dropdown | yes | Greenfield / Brownfield / Both / Not sure |
213
+ | Affected area | checkboxes | no | CLI command / Generated template / Generated scaffolding / Skill workflow guidance / Tutorial or examples / Documentation only |
214
+ | Compatibility risk | textarea | yes | |
215
+ | Alternatives considered | textarea | no | |
216
+
217
+ ### Documentation feedback — title `[Docs]: `
218
+
219
+ | Field | Type | Required | Notes |
220
+ |---|---|---|---|
221
+ | Affected page or file | input | yes | placeholder `README.md` |
222
+ | Reader goal | textarea | yes | what you were trying to understand or do |
223
+ | What was confusing? | textarea | yes | the missing, unclear, or misleading part |
224
+ | Suggested improvement | textarea | no | optional wording or structure |
225
+
226
+ ### Question — title `[Question]: `
227
+
228
+ | Field | Type | Required | Notes |
229
+ |---|---|---|---|
230
+ | Project type | dropdown | yes | New project / Existing project / Not sure |
231
+ | Dflow track you are considering | dropdown | yes | Greenfield / Brownfield / Not sure |
232
+ | What are you trying to do? | textarea | yes | the workflow or decision you need help with |
233
+ | Project context | textarea | no | framework, team workflow, AI agent, constraints |
234
+
235
+ ## Step 6: Generic Fallback
236
+
237
+ Use this only when the feedback matches none of the forms above. The upstream
238
+ repo disables blank issues, so direct the developer to pick the closest form at
239
+ `https://github.com/weilung/dflow-sdd-ddd/issues/new/choose` and adapt. Emit
240
+ two paste-ready blocks — a `Title` and a `Body` — plus the URL. Do **not** fall
241
+ back to a generic `## Problem` / `## Evidence` Markdown draft.
168
242
 
169
- ## Step 5: Present Submission Options
243
+ ## Step 7: Present Submission Options
170
244
 
171
- After writing the draft, summarize the options:
245
+ After writing the draft, name the draft file path and whether any submitter
246
+ self-check items remain unchecked, then summarize the options:
172
247
 
173
- - Copy the suggested issue body manually into GitHub.
174
- - Use the optional PR plan as implementation guidance in a Dflow source
175
- checkout.
248
+ - Open the chosen issue form and paste each field block.
176
249
  - Discard the draft if it was only a local observation.
177
250
 
178
- Do not submit anything automatically. End by naming the draft file path and
179
- whether any redaction checklist items remain unchecked.
251
+ Do not submit anything automatically.
@@ -11,10 +11,18 @@ state, archives the feature directory, and emits a Git-strategy-neutral
11
11
  **Integration Summary** for the developer's PR / merge / push step.
12
12
 
13
13
  **Important boundaries**:
14
- - This command **does not auto-merge**. It does not push, does not open a
15
- PR, does not run the project's merge strategy. Those decisions stay
16
- with the developer / project's Git principles — Dflow keeps merge
17
- strategy project-owned.
14
+ - This command **does not auto-merge** and never pushes or opens a PR on its
15
+ own. Merge strategy follows the team's selected Git policy (`gitflow` /
16
+ `trunk`, recorded in `dflow/specs/shared/_conventions.md` § Git Policy).
17
+ - Closeout is split into two gates so it works offline: a **Local-closeout
18
+ gate** (Steps 1–4: validation, status flip, BC sync, archive + an optional
19
+ commit checkpoint — all doable with no network) and an **Integration / PR
20
+ gate** (Step 5: push / merge / PR — needs network; the AI only runs
21
+ `git push` / `gh pr create` when you explicitly ask).
22
+ - At the archive checkpoint the AI may offer to commit using your Git identity;
23
+ you can always decline. The commit marker mode is read from `_conventions.md`
24
+ § AI Commit Policy. This replaces Dflow's earlier "the AI never commits"
25
+ stance — the AI helps at natural checkpoints, you keep the final say.
18
26
  - The BC-layer sync in Step 3 **reuses the existing Step 8.3 mechanism**
19
27
  from `new-feature-flow` — it does not introduce a new sync flow. Treat
20
28
  it as "lift Step 8.3 out of the per-phase checklist and run it once at
@@ -41,8 +49,8 @@ AI runs mechanical checks first. Report `✓` / `✗` for every item; if any
41
49
  proceeding (do not flip status, do not archive, do not emit summary).
42
50
 
43
51
  - [ ] Locate the feature directory at `dflow/specs/features/active/{SPEC-ID}-{slug}/`
44
- - [ ] `_index.md` exists and parses (YAML front matter intact, six required
45
- sections present)
52
+ - [ ] `_index.md` exists and parses (YAML front matter intact, seven required
53
+ sections present, including the Checkpoint Log)
46
54
  - [ ] Every row in `_index.md` Phase Specs table has Status = `completed`
47
55
  - [ ] Every phase-spec file referenced in the Phase Specs table exists at
48
56
  the path the table claims
@@ -88,7 +96,7 @@ Also update the **Resume Pointer** to reflect closeout:
88
96
 
89
97
  ```
90
98
  **Current Progress**: feature completed ({date}); all phase-specs status = completed.
91
- **Next Action**: merge / push (per project Git-principles).
99
+ **Next Action**: integration — push / merge / PR per the selected Git policy.
92
100
  ```
93
101
 
94
102
  **→ Transition (step-internal)**: Step 2 complete. Announce "Step 2 complete (status flipped). Entering Step 3: Sync BR Snapshot to BC layer." and continue.
@@ -172,11 +180,35 @@ the full rule set.
172
180
 
173
181
  After the move, also `git add` any modified files from Step 3 (the
174
182
  updated `rules.md`, `behavior.md`, `glossary.md`, `tech-debt.md`, etc.)
175
- into the same stage. AI **does not commit** — the developer commits in
176
- their own preferred manner (and the project's Git-principles decide
177
- whether one commit or several).
183
+ into the same stage.
178
184
 
179
- **→ Transition (step-internal)**: Step 4 complete. Announce "Step 4 complete (feature archived to completed/). Entering Step 5: Emit Integration Summary." and continue.
185
+ **Closeout commit checkpoint** (completes the offline Local-closeout gate):
186
+
187
+ ```
188
+ ✓ Feature archived to completed/ and closeout files staged
189
+ Commit this closeout now?
190
+ [Y] Yes — the AI commits with your Git identity (marker per _conventions.md § AI Commit Policy)
191
+ [N] No — skip; you commit yourself
192
+ ```
193
+
194
+ Whether you choose Y or N, record one row in the feature `_index.md`
195
+ Checkpoint Log (`closeout | committed ({hash})` or `closeout | skipped`). Only
196
+ write a hash after the commit actually succeeds; if a pre-commit hook rejects it
197
+ or the commit fails, record `failed` and surface the error — never write a fake
198
+ hash.
199
+
200
+ The Local-closeout gate is satisfied **only when the closeout is committed**:
201
+ closeout complete, Checkpoint Log updated, and the working tree clean (no
202
+ uncommitted changes). If you declined the commit (chose N) or it failed,
203
+ Local-closeout is **not** satisfied yet — commit the staged closeout yourself
204
+ before continuing; do not enter the Integration / PR gate with uncommitted
205
+ changes. Once committed, the gate stands on its own offline; integration happens
206
+ in Step 5 when you have network.
207
+
208
+ **→ Transition (step-internal)**: Step 4 complete. Branch on whether the closeout commit landed:
209
+
210
+ - **Closeout commit landed (working tree clean)** → announce "Step 4 complete (feature archived; Local-closeout gate satisfied). Entering Step 5: Integration / PR gate." and continue.
211
+ - **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.
180
212
 
181
213
  ## Step 5: Emit Integration Summary (Git-strategy-neutral)
182
214
 
@@ -185,10 +217,10 @@ Produce a plain-text summary of what this feature did. The summary is
185
217
  developer adapts to whichever merge strategy their project uses
186
218
  (merge commit, squash, rebase, fast-forward — Dflow stays neutral).
187
219
 
188
- For projects that adopted the optional Dflow Git-principles scaffolding, the
189
- applicable `scaffolding/Git-principles-{gitflow|trunk}.md` "Integration
190
- Commit Message Conventions" section explains how to format the actual commit
191
- message from this summary.
220
+ The selected Git policy's `Git-principles-{gitflow|trunk}.md` (seeded at init
221
+ under `dflow/specs/shared/`) explains, in its "Integration Commit Message
222
+ Conventions" section, how to format the actual commit / merge message from this
223
+ summary.
192
224
 
193
225
  Format:
194
226
 
@@ -212,10 +244,11 @@ Phase List:
212
244
  - phase-2 ({date}): {phase-slug} — {1 line}
213
245
  - ...
214
246
 
215
- Next Steps (developer):
216
- - Per the project's Git-principles, choose a merge strategy (merge commit /
217
- squash / rebase / fast-forward) and execute
218
- - Push to remote / open a PR
247
+ Next Steps (developer) — Integration / PR gate (needs network):
248
+ - Per the selected Git policy (`gitflow` / `trunk` in `_conventions.md`), choose
249
+ a merge strategy (merge commit / squash / rebase / fast-forward) and execute
250
+ - Push to remote / open a PR — the AI can run `git push` / `gh pr create` for
251
+ you, but only when you explicitly ask; it never pushes on its own
219
252
  ```
220
253
 
221
254
  Print the summary to the conversation; do not write it to a file (it is
@@ -233,7 +266,9 @@ the developer:
233
266
  If no `follow-up-of` field, skip Step 6 and announce closeout complete:
234
267
  > "`/dflow:finish-feature` complete for `{SPEC-ID}-{slug}`. Feature
235
268
  > directory is now at `dflow/specs/features/completed/{SPEC-ID}-{slug}/`.
236
- > Stage is set; commit / merge / push at your discretion."
269
+ > If you skipped the closeout commit, commit the staged changes first to
270
+ > finish the Local-closeout gate. Then integration — merge / push / PR —
271
+ > follows the selected Git policy, at your discretion."
237
272
 
238
273
  ## Step 6: Reverse-Update Follow-up Tracking (only if follow-up)
239
274
 
@@ -246,7 +281,7 @@ Follow-up Tracking table.
246
281
  3. Flip Status → `completed`
247
282
 
248
283
  ```bash
249
- # AI does the edit; commits stay with the developer
284
+ # The AI makes the edit and may offer to commit it (Y / N), per the AI commit policy
250
285
  ```
251
286
 
252
287
  After the update:
@@ -6,9 +6,10 @@ agnostic about which Git *branching strategy* your project adopts (Git Flow,
6
6
  GitHub Flow, trunk-based, single-`main`, etc.) — it only prescribes the
7
7
  feature-branch-per-feature convention that SDD traceability depends on.
8
8
 
9
- > If your project adopts Git Flow specifically, see the optional
10
- > optional `scaffolding/Git-principles-gitflow.md` template
11
- > for Git-Flow-specific conventions.
9
+ > Dflow does not pick `gitflow` vs `trunk` for you, but it now requires you to
10
+ > record one at `dflow init` so the runtime branch gate and finish-stage merge
11
+ > guidance can adapt. The selected policy's `Git-principles-{gitflow|trunk}.md`
12
+ > is seeded under `dflow/specs/shared/`.
12
13
 
13
14
  ## Branch-to-Workflow Mapping
14
15
 
@@ -103,6 +104,64 @@ This requirement is independent of the branching strategy — whether you
103
104
  branch off `develop`, `main`, or something else, the feature-per-branch
104
105
  convention stays.
105
106
 
107
+ ## Commit Checkpoints, Branch Gate & AI Commits
108
+
109
+ Dflow actively helps keep the Git trace aligned with the workflow — the AI
110
+ reminds, can do the work, and leaves policy to the team.
111
+
112
+ ### Branch gate
113
+
114
+ Before implementation starts (and before the first commit), the AI checks
115
+ whether the current branch is the feature / bugfix branch this work belongs to.
116
+ Both Git policies (`gitflow` / `trunk`, per `dflow/specs/shared/_conventions.md`
117
+ § Git Policy) use a feature branch, so:
118
+
119
+ - **Already on the matching `feature/{SPEC-ID}-{slug}` (or
120
+ `bugfix/{BUG-ID}-{slug}`) branch** — e.g. continuing an active feature with
121
+ `new-phase`, `modify-existing`, or `bug-fix` — the gate is satisfied; nothing
122
+ is created or switched.
123
+ - **Not on this work's feature / bugfix branch** (you are on the base branch the
124
+ project cuts features from — `main` / `develop` / `trunk`, or whatever your
125
+ policy uses — or on an unrelated branch) — the AI offers to create and switch
126
+ to the correct branch, switch to an existing matching one, or override and
127
+ stay (recorded in the feature `_index.md` Checkpoint Log; three consecutive
128
+ overrides → the AI suggests re-running `dflow init`, never changing the
129
+ setting on its own).
130
+
131
+ Dflow does not need to identify your base branch to evaluate the gate — it only
132
+ checks whether you are on the right feature branch. The base branch matters only
133
+ when a new branch is actually created, and which base to cut from is your
134
+ project's decision (GitFlow → `develop`, Trunk / GitHub Flow → `main`).
135
+
136
+ ### Commit checkpoints
137
+
138
+ At lifecycle milestones the AI offers a commit checkpoint, folded into the
139
+ existing Step Gate prompt (it does not add a separate question):
140
+
141
+ ```
142
+ ✓ {milestone} complete
143
+ Commit here?
144
+ [Y] Yes — the AI commits with your Git identity (marker per _conventions.md § AI Commit Policy)
145
+ [N] No — skip this checkpoint
146
+ ```
147
+
148
+ Tier sets how many checkpoints a change has: T1 three (spec / implementation /
149
+ closeout), T2 two (spec+implementation merged / closeout), T3 a single commit.
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.
155
+
156
+ ### AI commits
157
+
158
+ The AI may commit at these checkpoints using your Git identity; you can always
159
+ decline. How AI commits are marked is the `## AI Commit Policy` setting in
160
+ `_conventions.md` (`none` / `co-authored-by` / `prefix`), chosen once at init.
161
+ This is a deliberate reversal of Dflow's earlier "the AI never commits" stance:
162
+ the AI helps at natural break points, while merge / push / PR still follow the
163
+ team's policy and your explicit go-ahead.
164
+
106
165
  ## Directory Moves Must Use `git mv`
107
166
 
108
167
  When you rename or move a directory or file that is tracked in Dflow
@@ -255,9 +314,9 @@ AI should verify:
255
314
  - [ ] If business logic was touched, evaluate Domain extraction
256
315
 
257
316
  > The exact merge strategy (merge commit, squash, rebase, fast-forward)
258
- > is a project-level decision and sits outside Dflow's scope. See your
259
- > project's Git-principles document (e.g. the optional
260
- > Git-principles scaffolding) for integration commit conventions.
317
+ > follows the team's selected Git policy. See the seeded
318
+ > `Git-principles-{gitflow|trunk}.md` under `dflow/specs/shared/` for that
319
+ > policy's integration commit conventions.
261
320
 
262
321
  ## Commit Message Convention
263
322
 
@@ -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
  >
@@ -197,7 +214,7 @@ Key Brownfield-track notes:
197
214
  track makes this file mandatory because BCs are usually planned
198
215
  up-front).
199
216
 
200
- ### 3.2 Optional files (from Step 2 Q5)
217
+ ### 3.2 Optional files (from Step 2 Q7)
201
218
 
202
219
  Use the packaged scaffolding templates listed below; their project-local
203
220
  outputs are under `dflow/specs/shared/` (the scaffolding root, not the
@@ -231,7 +248,7 @@ skip, and wait for developer confirmation:
231
248
  > | `dflow/specs/shared/_conventions.md` | `scaffolding/_conventions.md` (mandatory baseline) |
232
249
  > | `dflow/specs/migration/tech-debt.md` | `templates/tech-debt.md` (mandatory baseline) |
233
250
  > | `dflow/specs/shared/_overview.md` | optional (you picked it) |
234
- > | `dflow/specs/shared/Git-principles-trunk.md` | optional (you picked it) |
251
+ > | `dflow/specs/shared/Git-principles-trunk.md` | mandatory (selected Git policy) |
235
252
  > | `dflow/specs/shared/AI-AGENT-GUIDE.md` | selected AI agent guide |
236
253
  > | `CLAUDE.md` | selected tool shim because repo has no CLAUDE.md |
237
254
  >
@@ -255,7 +272,7 @@ skip, and wait for developer confirmation:
255
272
  **→ Step Gate: Step 3 → Step 4**
256
273
 
257
274
  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.
275
+ selection, go back to the relevant Step 2 question (Q5–Q8) and re-run Step 3.
259
276
 
260
277
  ---
261
278
 
@@ -301,7 +318,7 @@ notice:
301
318
 
302
319
  ### 4.3 Special case — AI agent instruction files
303
320
 
304
- If the developer selected any AI coding agent in Q6, create
321
+ If the developer selected any AI coding agent in Q8, create
305
322
  `dflow/specs/shared/AI-AGENT-GUIDE.md` as the canonical Dflow project
306
323
  guide.
307
324
 
@@ -299,6 +299,8 @@ If the lightweight checklist looks larger than a short-fix checklist, AI must pa
299
299
  Announce to developer:
300
300
  > "Extraction decision made — {extract now / defer and record}. Ready to start implementation? `/dflow:next` to proceed, or adjust the extraction scope first."
301
301
 
302
+ > 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.
303
+
302
304
  Wait for confirmation before entering Step 5.
303
305
 
304
306
  ## Step 5: Implement the Change
@@ -341,6 +343,8 @@ protected void Calculate()
341
343
  Announce to developer:
342
344
  > "Implementation appears complete. Ready to update artifacts (spec, rules.md, models.md, glossary, tech-debt)? `/dflow:next` to proceed."
343
345
 
346
+ > 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.
347
+
344
348
  Wait for confirmation before entering Step 6. This step gate is where the completion checklist is triggered — do not skip.
345
349
 
346
350
  ## Step 6: Update Artifacts
@@ -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