dflow-sdd-ddd 0.6.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/CHANGELOG.md +65 -0
  2. package/README.en.md +30 -0
  3. package/README.md +14 -0
  4. package/bin/dflow.js +7 -3
  5. package/docs/evaluating-dflow.en.md +14 -5
  6. package/docs/evaluating-dflow.md +14 -5
  7. package/docs/npm-publish-checklist.md +8 -0
  8. package/docs/using-with-claude-code.en.md +118 -11
  9. package/docs/using-with-claude-code.md +94 -9
  10. package/docs/using-with-codex.en.md +14 -0
  11. package/docs/using-with-codex.md +10 -0
  12. package/docs/using-with-github-copilot.en.md +36 -0
  13. package/docs/using-with-github-copilot.md +26 -0
  14. package/lib/init.js +461 -24
  15. package/package.json +1 -1
  16. package/templates/brownfield/references/dflow-feedback-flow.md +179 -0
  17. package/templates/brownfield/references/drift-verification.md +183 -0
  18. package/templates/brownfield/references/finish-feature-flow.md +259 -0
  19. package/templates/brownfield/references/git-integration.md +312 -0
  20. package/templates/brownfield/references/init-project-flow.md +413 -0
  21. package/templates/brownfield/references/modify-existing-flow.md +444 -0
  22. package/templates/brownfield/references/new-feature-flow.md +367 -0
  23. package/templates/brownfield/references/new-phase-flow.md +259 -0
  24. package/templates/brownfield/references/pr-review-checklist.md +179 -0
  25. package/templates/brownfield/scaffolding/AI-AGENT-GUIDE.md +31 -4
  26. package/templates/brownfield/scaffolding/CLAUDE-md-snippet.md +12 -8
  27. package/templates/brownfield/scaffolding/Git-principles-gitflow.md +1 -1
  28. package/templates/brownfield/scaffolding/Git-principles-trunk.md +1 -1
  29. package/templates/brownfield/scaffolding/_conventions.md +1 -1
  30. package/templates/brownfield/scaffolding/_overview.md +3 -3
  31. package/templates/brownfield/templates/context-map.md +1 -1
  32. package/templates/brownfield/templates/glossary.md +1 -1
  33. package/templates/brownfield/templates/models.md +1 -1
  34. package/templates/brownfield/templates/rules.md +1 -1
  35. package/templates/brownfield/templates/tech-debt.md +1 -1
  36. package/templates/common/skill/SKILL.md +35 -0
  37. package/templates/greenfield/references/ddd-modeling-guide.md +351 -0
  38. package/templates/greenfield/references/dflow-feedback-flow.md +179 -0
  39. package/templates/greenfield/references/drift-verification.md +195 -0
  40. package/templates/greenfield/references/finish-feature-flow.md +280 -0
  41. package/templates/greenfield/references/git-integration.md +285 -0
  42. package/templates/greenfield/references/init-project-flow.md +447 -0
  43. package/templates/greenfield/references/modify-existing-flow.md +362 -0
  44. package/templates/greenfield/references/new-feature-flow.md +397 -0
  45. package/templates/greenfield/references/new-phase-flow.md +273 -0
  46. package/templates/greenfield/references/pr-review-checklist.md +130 -0
  47. package/templates/greenfield/scaffolding/AI-AGENT-GUIDE.md +31 -4
  48. package/templates/greenfield/scaffolding/CLAUDE-md-snippet.md +15 -13
  49. package/templates/greenfield/scaffolding/Git-principles-gitflow.md +1 -1
  50. package/templates/greenfield/scaffolding/Git-principles-trunk.md +1 -1
  51. package/templates/greenfield/scaffolding/_conventions.md +1 -1
  52. package/templates/greenfield/scaffolding/_overview.md +5 -3
  53. package/templates/greenfield/scaffolding/architecture-decisions-README.md +1 -1
  54. package/templates/greenfield/templates/context-map.md +1 -1
  55. package/templates/greenfield/templates/events.md +1 -1
  56. package/templates/greenfield/templates/glossary.md +1 -1
  57. package/templates/greenfield/templates/models.md +1 -1
  58. package/templates/greenfield/templates/rules.md +1 -1
  59. package/templates/greenfield/templates/tech-debt.md +1 -1
@@ -0,0 +1,179 @@
1
+ # Dflow Feedback Draft Flow
2
+
3
+ `/dflow:report-dflow-feedback` helps the developer turn a Dflow problem or
4
+ improvement observed during real project work into a high-quality upstream
5
+ feedback draft.
6
+
7
+ This flow is **not** a project feature workflow and does not change the
8
+ application being built. It is a standalone governance/support flow for Dflow
9
+ itself.
10
+
11
+ ## Hard Boundaries
12
+
13
+ - Do not submit anything to GitHub automatically.
14
+ - Do not run `gh issue create`, `gh pr create`, `git push`, or any networked
15
+ submission command from this flow.
16
+ - Do not expose private project details, business rules, customer data,
17
+ secrets, tokens, internal URLs, or proprietary source snippets.
18
+ - Always show the draft to the developer before anything leaves the local
19
+ machine.
20
+ - If the developer later asks to submit through GitHub CLI, stop and treat that
21
+ as a separate explicit task with fresh permission and environment checks.
22
+
23
+ ## Trigger Conditions
24
+
25
+ Enter this flow when:
26
+
27
+ - The developer explicitly runs `/dflow:report-dflow-feedback`.
28
+ - The developer says the Dflow process, template, generated file, or docs seem
29
+ wrong or improvable.
30
+ - The AI notices a clear contradiction or gap in Dflow guidance and asks:
31
+ "This looks like a possible Dflow upstream issue. Should I draft feedback for
32
+ you to review?"
33
+
34
+ Do not interrupt normal development for minor preference differences. If the
35
+ observation is speculative, ask before drafting.
36
+
37
+ ## Output Location
38
+
39
+ Write the draft to:
40
+
41
+ ```text
42
+ dflow/feedback/dflow-feedback-YYYY-MM-DD-{slug}.md
43
+ ```
44
+
45
+ Create `dflow/feedback/` if it does not exist. The file is local project
46
+ working material; the developer decides whether to copy it into a GitHub issue,
47
+ turn it into a PR, or discard it.
48
+
49
+ ## Step 1: Classify the Feedback
50
+
51
+ Classify the feedback as one of:
52
+
53
+ - Bug report
54
+ - Workflow change request
55
+ - Documentation feedback
56
+ - Question / unclear usage
57
+ - Maintainer release/process feedback
58
+
59
+ Capture:
60
+
61
+ - Observed during which flow or command
62
+ - Affected Dflow track: Greenfield, Brownfield, both, or unknown
63
+ - Affected area: CLI, generated template, scaffolding, skill reference,
64
+ tutorial, README/docs, release/governance
65
+ - Whether the issue blocks current project work
66
+
67
+ ## Step 2: Capture Evidence Safely
68
+
69
+ Collect only the evidence needed to explain the Dflow issue.
70
+
71
+ Allowed evidence:
72
+
73
+ - Dflow command name
74
+ - Dflow version if known
75
+ - Template or reference file name
76
+ - Generic project type, such as "existing brownfield app" or "legacy batch-processing system"
77
+ - Minimal paraphrased symptom
78
+ - Short sanitized snippets from Dflow-owned files
79
+
80
+ Avoid:
81
+
82
+ - Internal business rules
83
+ - Customer or tenant names
84
+ - Private repository names or URLs
85
+ - Secrets, tokens, credentials, or auth headers
86
+ - Long proprietary code snippets
87
+ - Full logs containing private paths or environment data
88
+
89
+ ## Step 3: Redaction Pass
90
+
91
+ Before writing the issue body section, perform a redaction check and include it
92
+ in the draft:
93
+
94
+ ```markdown
95
+ ## Redaction Checklist
96
+
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
+
105
+ Leave the final "Developer reviewed before submission" unchecked unless the
106
+ developer explicitly confirms it.
107
+
108
+ ## Step 4: Write the Feedback Draft
109
+
110
+ Use this structure:
111
+
112
+ ```markdown
113
+ # Dflow Feedback Draft: {short-title}
114
+
115
+ ## Summary
116
+
117
+ {One or two sentences.}
118
+
119
+ ## Type
120
+
121
+ {Bug report | Workflow change request | Documentation feedback | Question | Maintainer process feedback}
122
+
123
+ ## Observed While Using
124
+
125
+ - Dflow version: {version-or-unknown}
126
+ - Command / flow: {command-or-flow}
127
+ - Track: {Greenfield | Brownfield | both | unknown}
128
+ - Project context: {sanitized generic context}
129
+
130
+ ## Affected Dflow Area
131
+
132
+ - {CLI | template | scaffolding | skill reference | tutorial | docs | governance}
133
+ - Files or concepts: {sanitized list}
134
+
135
+ ## Problem
136
+
137
+ {What happened, why it is confusing or harmful, and who is affected.}
138
+
139
+ ## Expected Behavior or Improvement
140
+
141
+ {What Dflow should do or explain instead.}
142
+
143
+ ## Evidence
144
+
145
+ {Minimal sanitized observations.}
146
+
147
+ ## Compatibility / Breaking-Change Risk
148
+
149
+ {None | low | medium | high}, with reasoning.
150
+
151
+ ## Suggested GitHub Issue Body
152
+
153
+ {Copy-ready issue body matching the closest issue template.}
154
+
155
+ ## Optional PR Plan
156
+
157
+ {Only include if the change is small and concrete. Otherwise write "Not recommended yet; start with an issue."}
158
+
159
+ ## Redaction Checklist
160
+
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
+ ```
168
+
169
+ ## Step 5: Present Submission Options
170
+
171
+ After writing the draft, summarize the options:
172
+
173
+ - Copy the suggested issue body manually into GitHub.
174
+ - Use the optional PR plan as implementation guidance in a Dflow source
175
+ checkout.
176
+ - Discard the draft if it was only a local observation.
177
+
178
+ Do not submit anything automatically. End by naming the draft file path and
179
+ whether any redaction checklist items remain unchecked.
@@ -0,0 +1,183 @@
1
+ # Drift Verification — rules.md ↔ behavior.md Consistency Check
2
+
3
+ Triggered by `/dflow:verify` or `/dflow:verify <bounded-context>`.
4
+
5
+ ## Purpose
6
+
7
+ The A+C structure (`rules.md` as index + `behavior.md` as scenario content) introduces a drift risk — the two files can fall out of sync. This command provides a mechanical verification safety net that developers can run at key moments: before a PR, after a refactor, or when onboarding to an unfamiliar Bounded Context.
8
+
9
+ ## Scope
10
+
11
+ ### This command does (mechanical layer)
12
+
13
+ Three string-matching checks that AI can perform deterministically:
14
+
15
+ 1. **BR-ID forward check**: Every `BR-*` declared in `rules.md` has a corresponding section in `behavior.md`
16
+ 2. **Anchor validity**: If `rules.md` links to `behavior.md#section`, that anchor exists
17
+ 3. **BR-ID reverse check**: Every `BR-*` referenced in `behavior.md` is declared in `rules.md`
18
+
19
+ ### This command does NOT do (semantic layer — explicitly excluded)
20
+
21
+ Semantic verification (LLM reads the one-line summary in `rules.md` vs the Given/When/Then in `behavior.md` and judges whether they contradict) is **out of scope**. Reasons:
22
+ - Mechanical checks already catch most drift (missing IDs, broken links)
23
+ - Semantic judgment costs tokens and requires human review of LLM conclusions
24
+ - Deferred to Wave D — revisit after 10+ verify runs show the type distribution of actual drift
25
+
26
+ ### This command does NOT do (feature-directory aggregation — explicitly excluded)
27
+
28
+ Given the feature directory layout
29
+ (`dflow/specs/features/active/{SPEC-ID}-{slug}/` containing `_index.md` plus
30
+ 0..N `phase-spec-*.md` and 0..N `lightweight-*.md`), a tempting but
31
+ **out-of-scope** extension would be: "make `/dflow:verify` aggregate BR
32
+ state across all phase-spec files in a feature, then cross-check against
33
+ `rules.md`." Don't do that here.
34
+
35
+ Reasons:
36
+ - Feature-level BR aggregation is already maintained by `_index.md`
37
+ Current BR Snapshot, refreshed by `/dflow:new-phase` Step 5, reconciled
38
+ by `/dflow:new-phase` Step 7, and promoted by `/dflow:finish-feature`
39
+ Step 3
40
+ - BC-level current state is already maintained by `rules.md` /
41
+ `behavior.md`, written by the same `/dflow:finish-feature` Step 3
42
+ - `/dflow:verify` keeps a small, mechanical scope: just the
43
+ `rules.md` ↔ `behavior.md` correspondence inside one BC
44
+ - Cross-feature / cross-phase aggregation would mix `/dflow:verify`'s
45
+ job with `/dflow:finish-feature`'s job and produce false positives
46
+ during in-progress features
47
+
48
+ If a future need arises to add an `_index.md` Current BR Snapshot ↔
49
+ `rules.md` cross-check, that belongs in a future extension,
50
+ not in this command's current scope.
51
+
52
+ ### Anchor coexistence with `dflow:section`
53
+
54
+ `dflow:section` HTML comment anchors and markdown heading anchors serve different purposes:
55
+
56
+ - Markdown heading anchors (e.g., `behavior.md#br-001-rule-name`) remain the primary link target for BR-ID verification.
57
+ - `<!-- dflow:section ... -->` anchors are helper markers for AI/tool section positioning only.
58
+ - `dflow:section` does **not** replace BR-ID markdown anchors, and does **not** change the drift-verification algorithm.
59
+
60
+ So this command still uses BR-ID + markdown auto-id anchors as its primary index; `dflow:section` is auxiliary metadata.
61
+
62
+ ## Usage
63
+
64
+ ```
65
+ /dflow:verify # Verify all Bounded Contexts
66
+ /dflow:verify Expense # Verify a single BC (recommended default)
67
+ ```
68
+
69
+ When verifying all BCs, run each context independently and report per-context results.
70
+
71
+ ## Verification Steps
72
+
73
+ For each Bounded Context:
74
+
75
+ ### Step 1: Locate files
76
+
77
+ - Find `dflow/specs/domain/{context}/rules.md`
78
+ - Find `dflow/specs/domain/{context}/behavior.md`
79
+ - If either is missing, report and stop for that context:
80
+ ```
81
+ ✗ Expense: rules.md exists but behavior.md is missing
82
+ → Create the missing file using the matching template:
83
+ - rules.md → templates/rules.md
84
+ - behavior.md → templates/behavior.md
85
+ Or run the completion flow to populate it from existing completed specs
86
+ ```
87
+
88
+ ### Step 2: Extract BR-IDs from rules.md
89
+
90
+ Scan `rules.md` for all `BR-*` identifiers. Record each ID and any anchor link to `behavior.md`.
91
+
92
+ ### Step 3: Extract BR-IDs from behavior.md
93
+
94
+ Build two sets:
95
+
96
+ - **Primary set (scenario-bound)**: BR-IDs that appear in section headings
97
+ (e.g. `## Amount Validation (BR-001)`) or in the formal `(BR-NNN)` marker
98
+ inside a Given/When/Then scenario block. These represent BR-IDs that have
99
+ a dedicated scenario section.
100
+ - **Supplementary set (body-text mentions)**: BR-IDs that appear only in
101
+ prose / discussion text, outside any Given/When/Then block. These are
102
+ informational references, not equivalent to a scenario section.
103
+
104
+ ### Step 4: Cross-reference
105
+
106
+ Run the three checks using the primary set from Step 3 as the main comparison basis:
107
+
108
+ | Check | Pass condition | Fail message |
109
+ |---|---|---|
110
+ | Forward | Every BR-ID in rules.md has a corresponding scenario section in behavior.md (primary set) | `✗ BR-NNN declared in rules.md but has no scenario section in behavior.md` |
111
+ | Anchor | Every `behavior.md#anchor` in rules.md resolves to an existing heading | `✗ BR-NNN links to behavior.md#section but anchor not found` |
112
+ | Reverse | Every BR-ID formally referenced in behavior.md (primary set) is declared in rules.md | `✗ BR-NNN referenced in behavior.md scenario but not declared in rules.md` |
113
+
114
+ Body-text mentions (supplementary set) do **not** satisfy forward / reverse
115
+ pass conditions on their own. They are reported separately as informational
116
+ signals (see Step 5).
117
+
118
+ ### Step 5: Report
119
+
120
+ Output format:
121
+
122
+ ```
123
+ Verifying {Context} — rules.md ↔ behavior.md consistency
124
+
125
+ ✓ BR-001 → scenario section exists and references BR-001
126
+ ✓ BR-002 → scenario section exists and references BR-002
127
+ ✗ BR-003 → behavior.md has no scenario section for BR-003
128
+ (note: BR-003 appears in body text of another section,
129
+ but that does not satisfy the forward check)
130
+ ℹ BR-005 → body text reference only — no dedicated scenario section;
131
+ confirm this is intentional (e.g. cross-reference to another BR)
132
+
133
+ ✗ BR-010 → formally referenced in a behavior.md scenario but not
134
+ declared in rules.md
135
+
136
+ Summary: 3 passed, 2 issues, 1 informational
137
+
138
+ Issues:
139
+ 1. rules.md declares BR-003, but behavior.md has no corresponding
140
+ scenario section
141
+ → Possible cause: rule was implemented but behavior.md wasn't
142
+ updated in the completion flow; or a body-text mention was
143
+ mistaken for a scenario
144
+ → Action: check the implementation, then either add the scenario
145
+ to behavior.md (preferred) or remove BR-003 from rules.md if
146
+ deprecated
147
+
148
+ 2. behavior.md's {scenario section name} formally references BR-010,
149
+ but rules.md doesn't declare it
150
+ → Possible cause: scenario was added directly to behavior.md
151
+ without updating rules.md
152
+ → Action: add BR-010 to rules.md with a one-line summary, or
153
+ remove the stale scenario reference from behavior.md
154
+ ```
155
+
156
+ ## When to Run
157
+
158
+ Recommended trigger points (not enforced — developer's judgment):
159
+ - Before creating a PR (`/dflow:verify` as a pre-PR sanity check)
160
+ - After a refactor that touched multiple specs or domain docs
161
+ - When onboarding to an unfamiliar Bounded Context (verify before trusting the docs)
162
+ - After running `/dflow:finish-feature` — that command writes BC layer
163
+ updates from the feature's `_index.md` Current BR Snapshot; verify
164
+ catches any anchor / link drift introduced by the merge
165
+
166
+ ## Path Assumptions
167
+
168
+ This command operates entirely within `dflow/specs/domain/{context}/` files
169
+ (`rules.md` and `behavior.md`). It does **not** read from
170
+ `dflow/specs/features/active/{SPEC-ID}-{slug}/` directories — the feature
171
+ directory layout is not part of verify's input. The only effect of feature directory layout on this command is
172
+ ensuring `last-updated` dates in `behavior.md` are bumped at
173
+ `/dflow:finish-feature` time (so verify's mechanical drift guard stays
174
+ useful).
175
+
176
+ ## Interaction with Other Commands
177
+
178
+ - `/dflow:verify` is a **standalone command** — it does not require an active workflow
179
+ - It can be run mid-workflow (e.g., during Step 7 implementation to check you haven't drifted)
180
+ - It can be run after `/dflow:finish-feature` lands — that's the moment
181
+ BC-layer files get rewritten; verify catches mechanical issues from
182
+ the merge
183
+ - If issues are found, the developer decides whether to fix now or defer — the command does not block other workflows
@@ -0,0 +1,259 @@
1
+ # Finish Feature Workflow
2
+
3
+ Step-by-step guide for when a developer triggers `/dflow:finish-feature` —
4
+ the feature closeout ceremony.
5
+
6
+ This command makes the previously-implicit closeout step (originally a
7
+ sub-step of `new-feature-flow` / `modify-existing-flow`) explicit and
8
+ directly callable. It validates that all phase-specs are completed,
9
+ syncs the feature-level BR Snapshot to the bounded context's system-level
10
+ state, archives the feature directory, and emits a Git-strategy-neutral
11
+ **Integration Summary** for the developer's PR / merge / push step.
12
+
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.
18
+ - The BC-layer sync in Step 3 **reuses the existing Step 8.3 mechanism**
19
+ from `new-feature-flow` — it does not introduce a new sync flow. Treat
20
+ it as "lift Step 8.3 out of the per-phase checklist and run it once at
21
+ feature closeout, with the `_index.md` Current BR Snapshot as input."
22
+
23
+ **Step Gates** in this flow (stop-and-confirm before proceeding):
24
+ - Step 1 → Step 2 (validation passed → flip status)
25
+ - Step 3 → Step 4 (BC sync done → archive)
26
+ - Step 5 → Step 6 (Integration Summary emitted → optional follow-up reverse-link)
27
+
28
+ All other step transitions are **step-internal**: announce "Step N complete,
29
+ entering Step N+1" and proceed without waiting. See SKILL.md § Workflow
30
+ Transparency for the full transparency protocol and confirmation signals.
31
+
32
+ ## Step 1: Validate Phase Specs and `_index.md`
33
+
34
+ Before producing any closeout prose or Integration Summary text, read
35
+ `dflow/specs/shared/_conventions.md` and apply the `## Prose Language`
36
+ setting. If the setting is missing or not an explicit language tag, ask the
37
+ developer to update `_conventions.md` before continuing.
38
+
39
+ AI runs mechanical checks first. Report `✓` / `✗` for every item; if any
40
+ `✗` appears, **stop here** and ask the developer to address them before
41
+ proceeding (do not flip status, do not archive, do not emit summary).
42
+
43
+ - [ ] 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)
46
+ - [ ] Every row in `_index.md` Phase Specs table has Status = `completed`
47
+ - [ ] Every phase-spec file referenced in the Phase Specs table exists at
48
+ the path the table claims
49
+ - [ ] Every phase-spec file's frontmatter has `status: completed`
50
+ - [ ] `_index.md` has no obvious open items in Resume Pointer (e.g. "phase-N
51
+ drafting" / "implementation pending" / "TODO" markers)
52
+ - [ ] Current BR Snapshot table is non-empty (or feature is intentionally
53
+ a no-BR feature — confirm with developer if uncertain)
54
+
55
+ If any check fails:
56
+ > "Cannot finish feature `{SPEC-ID}-{slug}` yet — {N} validation issues
57
+ > found:
58
+ > ✗ phase-spec-2026-04-15-foo.md status is still `in-progress`
59
+ > ✗ Phase Specs table row 3 references missing file phase-spec-...
60
+ >
61
+ > Address these (run `/dflow:new-phase` to add missing work, or fix the
62
+ > stale status manually), then re-run `/dflow:finish-feature`."
63
+
64
+ **→ Step Gate: Step 1 → Step 2**
65
+
66
+ If all checks pass:
67
+ > "All {N} phase-specs are completed and `_index.md` is internally
68
+ > consistent. Ready to flip the feature status to `completed`?
69
+ > `/dflow:next` to proceed."
70
+
71
+ Wait for confirmation before entering Step 2.
72
+
73
+ ## Step 2: Flip `_index.md` Status to `completed`
74
+
75
+ Update the feature's `_index.md` Metadata block:
76
+
77
+ ```yaml
78
+ ---
79
+ spec-id: SPEC-{YYYYMMDD}-{NNN}
80
+ slug: {slug}
81
+ status: completed # ← flipped from in-progress
82
+ created: {YYYY-MM-DD}
83
+ branch: feature/{SPEC-ID}-{slug}
84
+ ---
85
+ ```
86
+
87
+ Also update the **Resume Pointer** to reflect closeout:
88
+
89
+ ```
90
+ **Current Progress**: feature completed ({date}); all phase-specs status = completed.
91
+ **Next Action**: merge / push (per project Git-principles).
92
+ ```
93
+
94
+ **→ Transition (step-internal)**: Step 2 complete. Announce "Step 2 complete (status flipped). Entering Step 3: Sync BR Snapshot to BC layer." and continue.
95
+
96
+ ## Step 3: Sync `_index.md` Current BR Snapshot to BC Layer
97
+
98
+ This step **reuses the existing sync mechanism** from `new-feature-flow`
99
+ Step 8.3 (`dflow/specs/domain/{context}/rules.md` + `behavior.md` updates). The
100
+ input is the feature's `_index.md` Current BR Snapshot table; the output
101
+ is the BC's `rules.md` and `behavior.md` updated to reflect the
102
+ feature's net effect.
103
+
104
+ Before syncing, ensure required BC files exist. If missing, create from templates:
105
+ - `dflow/specs/domain/{context}/rules.md` → `templates/rules.md`
106
+ - `dflow/specs/domain/{context}/behavior.md` → `templates/behavior.md`
107
+
108
+ For each row in Current BR Snapshot where Status = `active`:
109
+
110
+ - If the BR-ID is **not yet in `rules.md`** → add it (new ADDED rule
111
+ introduced by this feature)
112
+ - If the BR-ID is **already in `rules.md`** but the rule text differs →
113
+ update it (MODIFIED rule, reflect the new text)
114
+ - If the BR-ID was previously in `rules.md` and is now in Current BR
115
+ Snapshot with Status = `removed` → remove the corresponding section in
116
+ `rules.md` (REMOVED rule)
117
+ - For any RENAMED BR-ID → rename the BR-ID in `rules.md` and update
118
+ `glossary.md` if the term itself changed
119
+
120
+ For `behavior.md`:
121
+
122
+ - For every BR-ID still active after this feature, ensure
123
+ `dflow/specs/domain/{context}/behavior.md` has a scenario section (anchor)
124
+ matching the BR-ID
125
+ - For REMOVED BR-IDs, delete the corresponding scenario section from
126
+ `behavior.md`
127
+ - Update the BR-ID anchor's `last-updated` date in `behavior.md` to today
128
+
129
+ This is the **mechanical input that `/dflow:verify` later uses** for the
130
+ rules.md ↔ behavior.md drift check (see `references/drift-verification.md`).
131
+
132
+ Cross-reference each phase-spec's Delta-from-prior-phases section to
133
+ double-check the net result; the Snapshot is the SSOT but the per-phase
134
+ Deltas are the audit trail.
135
+
136
+ > Note: this step does NOT read individual phase-specs to re-derive the BR
137
+ > set — that work was already reconciled by `/dflow:new-phase` Step 7 each
138
+ > time a phase completed. We trust `_index.md` Current BR Snapshot as the
139
+ > feature-level truth here. If the developer finds drift between Snapshot
140
+ > and the phase-specs, fix `_index.md` first, then re-run
141
+ > `/dflow:finish-feature`.
142
+
143
+ Also update `migration/tech-debt.md` / `models.md` / `glossary.md` as
144
+ discovered during the feature (the same items listed in
145
+ `new-feature-flow.md` Step 8.3) — these may have been touched per phase
146
+ already; this is the closeout sweep.
147
+
148
+ **→ Step Gate: Step 3 → Step 4**
149
+
150
+ > "BC `{context}` synced — `rules.md` updated ({n_added} added,
151
+ > {n_modified} modified, {n_removed} removed), `behavior.md` anchors
152
+ > updated, `last-updated` set to {date}. Ready to archive the feature
153
+ > directory? `/dflow:next` to proceed."
154
+
155
+ Wait for confirmation before entering Step 4.
156
+
157
+ ## Step 4: Archive — `git mv` the Feature Directory
158
+
159
+ AI runs:
160
+
161
+ ```bash
162
+ git mv dflow/specs/features/active/{SPEC-ID}-{slug} \
163
+ dflow/specs/features/completed/{SPEC-ID}-{slug}
164
+ git status # confirm rename detection
165
+ ```
166
+
167
+ `git mv` is mandatory — never use plain `mv` + `git add`. This preserves
168
+ git's directory rename detection so `git log --follow` / `git blame` /
169
+ PR diff quality stays intact across the move. See
170
+ `references/git-integration.md` § "Directory Moves Must Use git mv" for
171
+ the full rule set.
172
+
173
+ After the move, also `git add` any modified files from Step 3 (the
174
+ 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).
178
+
179
+ **→ Transition (step-internal)**: Step 4 complete. Announce "Step 4 complete (feature archived to completed/). Entering Step 5: Emit Integration Summary." and continue.
180
+
181
+ ## Step 5: Emit Integration Summary (Git-strategy-neutral)
182
+
183
+ Produce a plain-text summary of what this feature did. The summary is
184
+ **not** a commit message template — it is reference material the
185
+ developer adapts to whichever merge strategy their project uses
186
+ (merge commit, squash, rebase, fast-forward — Dflow stays neutral).
187
+
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.
192
+
193
+ Format:
194
+
195
+ ```
196
+ == Integration Summary: {SPEC-ID}-{slug} ==
197
+
198
+ Feature Goal: {1-2 sentences from _index.md Goals & Scope}
199
+
200
+ Change Scope:
201
+ - BC: {context-name}
202
+ - Phase Count: {N} (phase-spec-{date1}-{slug1} ... phase-spec-{dateN}-{slugN})
203
+ - Lightweight Changes: {n_t2} T2 lightweight specs + {n_t3} T3 inline rows
204
+
205
+ Related BR-IDs (post-closeout state):
206
+ - ADDED: BR-NN, BR-NN, ...
207
+ - MODIFIED: BR-NN, BR-NN, ...
208
+ - REMOVED: BR-NN, BR-NN, ...
209
+
210
+ Phase List:
211
+ - phase-1 ({date}): {phase-slug} — {1 line}
212
+ - phase-2 ({date}): {phase-slug} — {1 line}
213
+ - ...
214
+
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
219
+ ```
220
+
221
+ Print the summary to the conversation; do not write it to a file (it is
222
+ ephemeral closeout output).
223
+
224
+ **→ Step Gate: Step 5 → Step 6**
225
+
226
+ If the feature has `follow-up-of: {原 SPEC-ID}` in its Metadata, prompt
227
+ the developer:
228
+ > "This feature is a follow-up of `{原 SPEC-ID}`. Ready to update the
229
+ > original feature's `_index.md` Follow-up Tracking row to mark this
230
+ > follow-up as `completed`? `/dflow:next` to proceed (or skip if you
231
+ > prefer to do it manually)."
232
+
233
+ If no `follow-up-of` field, skip Step 6 and announce closeout complete:
234
+ > "`/dflow:finish-feature` complete for `{SPEC-ID}-{slug}`. Feature
235
+ > directory is now at `dflow/specs/features/completed/{SPEC-ID}-{slug}/`.
236
+ > Stage is set; commit / merge / push at your discretion."
237
+
238
+ ## Step 6: Reverse-Update Follow-up Tracking (only if follow-up)
239
+
240
+ For features that were created as follow-ups of an earlier completed
241
+ feature, update the original feature's
242
+ Follow-up Tracking table.
243
+
244
+ 1. Locate `dflow/specs/features/completed/{原 SPEC-ID}-{原 slug}/_index.md`
245
+ 2. Find the Follow-up Tracking section's row for this feature's SPEC-ID
246
+ 3. Flip Status → `completed`
247
+
248
+ ```bash
249
+ # AI does the edit; commits stay with the developer
250
+ ```
251
+
252
+ After the update:
253
+ > "Follow-up Tracking row in `{原 SPEC-ID}-{原 slug}/_index.md` updated
254
+ > to Status = `completed`. Closeout complete."
255
+
256
+ The connection is bidirectional and weakly redundant: the new feature's
257
+ `follow-up-of` field is the authoritative source; the old feature's
258
+ Follow-up Tracking row is a derived index. If they ever disagree, trust
259
+ `follow-up-of`.