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
package/CHANGELOG.md CHANGED
@@ -6,6 +6,71 @@
6
6
 
7
7
  ---
8
8
 
9
+ ## 0.8.0 — 2026-05-24 — DDD set-based invariant 引導擴充、雙軌 skill 殼合一、user-projected bundle 內容 polish
10
+
11
+ **Proposals**:PROPOSAL-040(CLI papercuts + 文件補洞)、PROPOSAL-041(C0+C1:configure-agents idempotent bundle re-projection + 雙軌 skill 殼合一)、PROPOSAL-042(ddd-modeling-guide 補 set-based invariants 與 Phase-1 event dispatch 段)、PROPOSAL-044(user-projected bundle 內 maintainer-source path 清除)、PROPOSAL-045(user-projected bundle 內 maintainer-only provenance refs 清除)
12
+
13
+ **新功能 / 新引導內容**:
14
+
15
+ - **ddd-modeling-guide 補「Set-Based / Uniqueness Invariants」段**(PROPOSAL-042):明確說明 set-based invariants(「同 X 只能一筆 active」「email 跨 User 唯一」這類)**無論選哪種 aggregate 邊界**,in-memory check 在並發下都不夠保護,需 DB unique / partial index 或 optimistic concurrency token 配合。涵蓋兩種常見 aggregate 切法(拆獨立 + folded 為 child entity)的對策;指出 child entity 寫入需 bump root version;建議將並發衝突 translate 為業務語意 conflict(HTTP 409)。同 update 補 Common Mistakes #6 與 Phase-1 event dispatch lifecycle 段落。
16
+
17
+ **行為改善**:
18
+
19
+ - **`configure-agents` 自動補回 bundle**(PROPOSAL-041 C0):對 pre-039 既有專案再次跑 `configure-agents` 時,自動 re-project 缺失的 `dflow/specs/shared/dflow-workflows/` bundle(idempotent;第二次跑為 no-op)。順手關閉 PROPOSAL-039 follow-up (i)。
20
+ - **雙軌 skill 殼合一**(PROPOSAL-041 C1):兩份 `sdd-ddd-{green,brown}field-skill/SKILL.md` 統一為 `templates/common/skill/SKILL.md` thin shell;`lib/init.js` 從該檔讀。對 npm 使用者只是裝起來行為一致,無破壞性變更;對 maintainer 是 source-of-truth 收斂。
21
+ - **CLI papercuts 批次修**(PROPOSAL-040 group A):`init` / `configure-agents` 數個 CLI 摩擦點修補(issues #2/#11/#12)。
22
+ - **`init` 後續 step 文件補洞**(PROPOSAL-040 group B):slug 命名加 CI 相容性 caveat、`behavior.md` skeleton 註解明確(避免 user 以為 finish-feature 前就該填)、`configure-agents` 自動偵測既有 agent 配置(#13/#7)、`aggregate-design.md` 在 feature 目錄內的存放位置明文釘住。
23
+
24
+ **文件 / user-facing 內容 polish**:
25
+
26
+ - **user-projected bundle 內 `sdd-ddd-*-skill/` maintainer-source path 清除**(PROPOSAL-044):原本 `npm install` 後 user project 內的 flow / template 文件含 `sdd-ddd-greenfield-skill/scaffolding/...` 這類在 user 端不存在的路徑引用——user 讀到會誤判「我裝錯了?」。本 release 把該類引用全部清為 user 端可解析路徑或自足語句。涵蓋 12 個 source + 12 個 mirror。
27
+ - **user-projected bundle 內 maintainer-only provenance refs 清除**(PROPOSAL-045):原本 user 端會看到的 `<!-- ... PROPOSAL-013 ... -->` HTML 註解、`init-project-flow.md` 末段 `archive/reviews/...` 引用、references body 內 bare `PROPOSAL-NNN` 引用、brownfield `CLAUDE-md-snippet.md` 內 `(established in PROPOSAL-007c)` 標註等——這些是 maintainer-only 歷史佔位、user 看到只會困惑。本 release 全部清除或改寫為自足語句;HTML 註解保留為 `<!-- Seeded by Dflow. -->`(語意精準:user 取到檔後可自行客製化、dflow 並不持續維護該副本)。涵蓋 66 個 unique files。
28
+
29
+ **維護者工具**(不影響套件使用者):
30
+
31
+ - **`scripts/check-repo-consistency.sh` 新增 045 guard**:scoped git grep 對 `sdd-ddd-*-skill/{templates,scaffolding,references}/*.md` + `templates/{green,brown}field/**/*.md` 偵測 `(archive/|planning/|reviews/|proposals/|PROPOSAL-[0-9]{3})` 任一命中即 fail——防未來再引入 maintainer-only provenance refs。Pre-commit hook 不加。
32
+
33
+ ---
34
+
35
+ ## 0.7.0 — 2026-05-22 — Opt-in Claude skill adapter、自動清理舊 command adapter、發布前 lifecycle 機檢
36
+
37
+ **Proposals**:PROPOSAL-037(generated adapter commit 政策與升級流程)、PROPOSAL-038(選配 skill adapter)、PROPOSAL-035(lifecycle drift forcing-functions)
38
+
39
+ **新功能**:
40
+
41
+ - **`dflow configure-agents --skills`**(PROPOSAL-038):在已初始化的專案投影一個
42
+ edition-neutral 的「thin」skill 到 `.claude/skills/dflow/SKILL.md`,指向專案內既有
43
+ guide(不打包 SKILL.md 模板)。auto-trigger 描述刻意收窄,採 suggest-and-wait
44
+ 契約;wrapper 帶 `<!-- dflow-generated: skill-adapter -->` 供覆寫保護。`--skills`
45
+ 在未鎖定 Claude 時 warn 並 no-op。Claude skill 與 command adapter(`dflow:<id>`)
46
+ 名稱不衝突,可共存(已於 real Claude Code 實測)。Codex 維持 AGENTS.md 文字觸發,
47
+ 不提供 user-level skill。
48
+
49
+ **行為改善**:
50
+
51
+ - **`init` 自動移除前一版 stale command adapter**(PROPOSAL-037 Segment B):透過既有
52
+ plan / preview / confirm pipeline,依明確的 `LEGACY_COMMAND_ADAPTERS` 表(目前僅
53
+ v0.5.0)與 CRLF-normalized 精確指紋比對,apply 時再次 re-check;對使用者改過或
54
+ 非 Dflow 產生的檔案 warn-but-keep,絕不使用 glob。**這把 0.6.0 需手動刪除舊
55
+ `.claude/commands/dflow/dflow-*.md` 的遷移步驟自動化了**。新生成的 wrapper 帶
56
+ `<!-- dflow-generated: command-adapter -->`。
57
+
58
+ **文件**:
59
+
60
+ - **generated adapter 的版控政策**(PROPOSAL-037 Segment A):README(zh + en)與各工具
61
+ guide 補上建議預設(gitignore + 重新生成)與「追蹤 adapter」的替代做法、條件式
62
+ `.gitignore` 片段與 glob 注意事項、`git rm --cached` 指引,並區分 adapter-refresh
63
+ 與 canonical-guide-migration、加入 CLI 版本 pinning 說明。
64
+
65
+ **維護者工具**(不影響套件使用者):
66
+
67
+ - **lifecycle drift 機檢**(PROPOSAL-035):新增 `scripts/check-lifecycle.mjs`(dev-only,
68
+ 不隨套件發布),硬斷言「`proposals/` 內無 terminal-status proposal」與「`archive/proposals/`
69
+ 內皆為 terminal status」,並對引用已歸檔 proposal 的 active handoff 發出 warning;
70
+ 接入 CI 與 npm 發布前 checklist。
71
+
72
+ ---
73
+
9
74
  ## 0.6.0 — 2026-05-21 — Command-adapter 命名修正
10
75
 
11
76
  **Proposals**:PROPOSAL-036(修正 command-adapter 命名 + 各工具叫用現實對齊)
package/README.en.md CHANGED
@@ -237,6 +237,36 @@ You can run `dflow configure-agents` later to add more tool shims as the team
237
237
  adopts additional AI coding agents. If you need Claude / Copilot tool-native
238
238
  command entries, use `dflow configure-agents --command-adapters`.
239
239
 
240
+ ### Version-Control Policy for Generated Artifacts (recommended default)
241
+
242
+ The command / prompt wrappers produced by `dflow configure-agents
243
+ --command-adapters` are **generated artifacts** projected from the canonical
244
+ guide. Dflow's **recommended default** is to treat them as regenerable output:
245
+ version-control the source, not the generated artifacts.
246
+
247
+ | File | Role | Recommended default |
248
+ |---|---|---|
249
+ | `dflow/` (canonical guide, specs, merge snippet) | source | **version-control** |
250
+ | Thin shims (`CLAUDE.md` / `AGENTS.md` / `.github/copilot-instructions.md`) | source | **version-control** |
251
+ | `.claude/commands/dflow/`, `.github/prompts/dflow-*.prompt.md` | generated | **recommended: do not version-control (gitignore)**; regenerate after clone with `configure-agents --command-adapters` |
252
+
253
+ This is a **recommendation**, not the only valid policy. If your team wants a
254
+ native `/` menu immediately after clone, or your CI / dev environment does not
255
+ install npm, **version-controlling the adapters** is a reasonable choice — the
256
+ trade-off is that when an upgrade renames commands you must re-project and
257
+ commit the removal of the old files. The key rule: **use one consistent policy
258
+ across all tools in a project**, rather than ignoring adapters for one tool and
259
+ tracking them for another.
260
+
261
+ After upgrading Dflow, re-running `dflow configure-agents --command-adapters`
262
+ re-projects adapters from the **new command registry**, but it does **not**
263
+ overwrite an existing `dflow/specs/shared/AI-AGENT-GUIDE.md` (an existing
264
+ canonical guide is kept). "Re-projecting adapters" and "migrating the canonical
265
+ guide" are two different things; re-project with the **same dflow CLI version**
266
+ to avoid a registry / guide version mismatch. Per-tool `.gitignore` snippets,
267
+ glob side effects, the `git rm --cached` switch-over step, and upgrade details
268
+ are covered in the per-tool guides.
269
+
240
270
  For tool-specific walk-throughs of what `init` writes and how Dflow's
241
271
  workflow commands appear in a given AI tool, see the per-tool guides under
242
272
  `docs/`:
package/README.md CHANGED
@@ -204,6 +204,20 @@ Dflow 也會為你的 AI 程式設計助理建立或提供可合併的專案指
204
204
 
205
205
  之後團隊採用新 AI 程式設計助理時,可隨時跑 `dflow configure-agents` 新增 shim;若需要 Claude / Copilot 的工具原生命令入口,改用 `dflow configure-agents --command-adapters`。
206
206
 
207
+ ### 產生物的版控政策(建議預設)
208
+
209
+ `dflow configure-agents --command-adapters` 產生的命令 / prompt wrapper 是從 canonical guide 投影出來的**衍生物(generated artifact)**。Dflow 的**建議預設**是把它們當成可重生成的產物:版控 source、不版控衍生物。
210
+
211
+ | 檔案 | 角色 | 建議預設 |
212
+ |---|---|---|
213
+ | `dflow/`(canonical guide、規格、merge snippet) | source | **版控** |
214
+ | 薄 shim(`CLAUDE.md` / `AGENTS.md` / `.github/copilot-instructions.md`) | source | **版控** |
215
+ | `.claude/commands/dflow/`、`.github/prompts/dflow-*.prompt.md` | 衍生物 | **建議不版控(gitignore)**,clone 後重跑 `configure-agents --command-adapters` 重生成 |
216
+
217
+ 這是**建議**,不是唯一正解。若團隊希望 clone 後立即有原生 `/` 選單、或 CI / 開發環境不裝 npm,**版控 adapter** 也是合理選擇——代價是升級若改了命名,要重投影並 commit 刪除舊檔。關鍵原則:**同一專案對所有工具採一致策略**,別像常見的踩雷一樣一邊 ignore、一邊版控。
218
+
219
+ 升級 dflow 後重跑 `dflow configure-agents --command-adapters`,adapter 會用**新版的 command registry** 重投影;但**不會**覆寫已存在的 `dflow/specs/shared/AI-AGENT-GUIDE.md`(canonical guide 已存在則保留)。「重投影 adapter」與「升級 canonical guide」是兩件事;升級時請用**相同的 dflow CLI 版本**重投影,避免 registry 與 guide 版本錯位。各工具的 `.gitignore` 片段、glob 副作用、`git rm --cached` 切換步驟與升級細節見 per-tool 指南。
220
+
207
221
  特定工具的 init 寫入內容與 Dflow workflow 命令呈現方式,見 `docs/` 內的 per-tool 指南:
208
222
 
209
223
  - [在 Claude Code 中使用 Dflow](docs/using-with-claude-code.md)
package/bin/dflow.js CHANGED
@@ -29,7 +29,7 @@ optional starter files, and AI coding agents before showing a full file preview.
29
29
 
30
30
  function printConfigureAgentsHelp() {
31
31
  process.stdout.write(`Usage:
32
- dflow configure-agents [--command-adapters]
32
+ dflow configure-agents [--command-adapters] [--skills]
33
33
 
34
34
  Adds AI agent instruction files to an existing Dflow project.
35
35
  The command can create AGENTS.md, CLAUDE.md, and
@@ -38,6 +38,7 @@ dflow/specs/shared/AI-AGENT-GUIDE.md file.
38
38
 
39
39
  Options:
40
40
  --command-adapters Also generate tool-native thin wrappers for supported tools.
41
+ --skills Also generate a supported tool's skill adapter (currently Claude Code project skill, restores natural-language auto-trigger).
41
42
  `);
42
43
  }
43
44
 
@@ -95,7 +96,9 @@ async function main() {
95
96
  }
96
97
 
97
98
  const configureOptions = args.slice(1);
98
- const unsupportedConfigureOptions = configureOptions.filter((arg) => arg !== '--command-adapters');
99
+ const unsupportedConfigureOptions = configureOptions.filter(
100
+ (arg) => arg !== '--command-adapters' && arg !== '--skills'
101
+ );
99
102
  if (unsupportedConfigureOptions.length > 0) {
100
103
  process.stderr.write(`Unsupported configure-agents option: ${unsupportedConfigureOptions.join(' ')}\n`);
101
104
  return 1;
@@ -106,7 +109,8 @@ async function main() {
106
109
  stdin: process.stdin,
107
110
  stdout: process.stdout,
108
111
  stderr: process.stderr,
109
- commandAdapters: configureOptions.includes('--command-adapters')
112
+ commandAdapters: configureOptions.includes('--command-adapters'),
113
+ skills: configureOptions.includes('--skills')
110
114
  });
111
115
  }
112
116
 
@@ -35,10 +35,16 @@ in your project's `dflow/specs/` directory and AI instruction files.
35
35
  map, architecture/tech-debt, features active/completed). See
36
36
  [`README.md` "Files Created by Init"](../README.en.md#files-created-by-init)
37
37
  for the full tree.
38
- - A canonical project guide at `dflow/specs/shared/AI-AGENT-GUIDE.md`.
38
+ - A canonical project guide at `dflow/specs/shared/AI-AGENT-GUIDE.md` —
39
+ the command registry, routing rules, and project context.
40
+ - A vendored workflow bundle at `dflow/specs/shared/dflow-workflows/` —
41
+ the executable step definitions for each `/dflow:*` workflow (step gates,
42
+ completion checklists, templates). This bundle is projected from the npm
43
+ package at init time so workflows are reachable from any clone without
44
+ needing the Dflow source or package installed locally.
39
45
  - Mergeable AI agent instruction files for the tools you select (e.g.,
40
46
  `CLAUDE.md`, `AGENTS.md`, `.github/copilot-instructions.md`). Each is a
41
- thin pointer to the canonical guide.
47
+ thin pointer to the canonical guide and workflow bundle.
42
48
 
43
49
  `init` does **not**:
44
50
 
@@ -60,7 +66,9 @@ or more tools and Dflow writes the corresponding shim:
60
66
  | GitHub Copilot | `.github/copilot-instructions.md` |
61
67
 
62
68
  Each shim points back to the canonical
63
- `dflow/specs/shared/AI-AGENT-GUIDE.md`. Practical implications:
69
+ `dflow/specs/shared/AI-AGENT-GUIDE.md`. The guide acts as the command registry
70
+ and router; executable workflow steps live in the vendored bundle at
71
+ `dflow/specs/shared/dflow-workflows/`. Practical implications:
64
72
 
65
73
  - Multiple tools can be active in the same project without diverging
66
74
  workflow rules.
@@ -68,8 +76,9 @@ Each shim points back to the canonical
68
76
  `dflow configure-agents` to add another shim, or
69
77
  `dflow configure-agents --command-adapters` to opt in to tool-native command
70
78
  entries.
71
- - The project guide stays the single source of truth for Dflow workflow
72
- behavior.
79
+ - The guide and workflow bundle together are the authoritative sources for
80
+ Dflow workflow behavior; both are plain Markdown committed in your repo and
81
+ accessible to any clone.
73
82
 
74
83
  `/dflow:*` is the canonical shared vocabulary, but each tool's `/` parser
75
84
  behaves differently: Claude Code command adapters use `/dflow:<id>`, the
@@ -25,8 +25,14 @@ Dflow 是 Markdown-based 的 workflow 材料加上一個 scaffolding CLI。它
25
25
 
26
26
  - `dflow/specs/` workspace(概覽、慣例、領域詞彙表、context map、架構 / 技術債、功能 active/completed)。完整目錄樹見
27
27
  [`README.md` "Init 產生的檔案"](../README.md#init-產生的檔案)。
28
- - 位於 `dflow/specs/shared/AI-AGENT-GUIDE.md` 的 canonical 專案指南。
29
- - 你所選工具的可合併 AI 指示檔(例如 `CLAUDE.md`、`AGENTS.md`、`.github/copilot-instructions.md`)。每個都是指向 canonical 指南的薄 shim。
28
+ - 位於 `dflow/specs/shared/AI-AGENT-GUIDE.md` 的 canonical 專案指南 ——
29
+ 命令登錄表、路由規則與專案上下文。
30
+ - 位於 `dflow/specs/shared/dflow-workflows/` 的 vendored workflow bundle ——
31
+ 各 `/dflow:*` workflow 的可執行步驟定義(step gates、completion checklists、模板)。
32
+ 這個 bundle 在 init 時從 npm 套件投影進專案,因此 workflow 步驟是 self-contained
33
+ 且可達的,任何 clone 都不需要 Dflow source 或 package 在本機安裝。
34
+ - 你所選工具的可合併 AI 指示檔(例如 `CLAUDE.md`、`AGENTS.md`、`.github/copilot-instructions.md`)。
35
+ 每個都是指向 canonical 指南與 workflow bundle 的薄 shim。
30
36
 
31
37
  `init` **不會**:
32
38
 
@@ -45,11 +51,14 @@ Dflow 支援多種 AI 程式設計助理。跑完 `init` 後,你選取一個
45
51
  | Claude Code | `CLAUDE.md` |
46
52
  | GitHub Copilot | `.github/copilot-instructions.md` |
47
53
 
48
- 每個 shim 都指向 canonical 的 `dflow/specs/shared/AI-AGENT-GUIDE.md`。實際意義:
54
+ 每個 shim 都指向 canonical 的 `dflow/specs/shared/AI-AGENT-GUIDE.md`(命令登錄表)
55
+ 與 `dflow/specs/shared/dflow-workflows/`(可執行步驟定義)。實際意義:
49
56
 
50
57
  - 同一個專案可以同時啟用多個工具,而不會有 workflow 規則分歧。
51
- - 之後切換或新增工具不需要重跑 `init`;執行 `dflow configure-agents` 即可新增 shim,或用 `dflow configure-agents --command-adapters` opt in 工具原生命令入口。
52
- - 專案指南始終保持為 Dflow workflow 行為的單一 source of truth。
58
+ - 之後切換或新增工具不需要重跑 `init`;執行 `dflow configure-agents` 即可新增 shim,
59
+ 或用 `dflow configure-agents --command-adapters` opt in 工具原生命令入口。
60
+ - 指南與 workflow bundle 共同成為 Dflow workflow 行為的權威來源;兩者都是純 Markdown
61
+ 已 commit 進 repo,任何 clone 均可直接讀取。
53
62
 
54
63
  `/dflow:*` 是 canonical 共同詞彙,但各工具的 `/` parser 行為不同:Claude Code
55
64
  command adapters 使用 `/dflow:<id>`,GitHub Copilot prompt 選單使用
@@ -13,6 +13,14 @@ Replace `<version>` with the version being published, for example `0.1.2`.
13
13
  - [ ] Confirm `README.md` installation instructions match the release.
14
14
  - [ ] Confirm Greenfield and Brownfield common flow changes are synchronized.
15
15
  - [ ] Confirm generated templates match skill source where applicable.
16
+ - [ ] Run the lifecycle check in the development repo and confirm it is green,
17
+ so every proposal this release covers is terminal (`implemented` /
18
+ `rejected` / `superseded`) and already archived:
19
+
20
+ ```bash
21
+ node scripts/check-lifecycle.mjs
22
+ ```
23
+
16
24
  - [ ] Run:
17
25
 
18
26
  ```bash
@@ -68,11 +68,15 @@ Two things happen when Claude Code starts in this project:
68
68
  Code's Markdown import syntax to inline the canonical Dflow guide. So
69
69
  Claude Code effectively reads both files as one set of instructions.
70
70
 
71
- The canonical guide (`dflow/specs/shared/AI-AGENT-GUIDE.md`) is where the
72
- real workflow rules live: project context (track, tech stack, prose
71
+ The canonical guide (`dflow/specs/shared/AI-AGENT-GUIDE.md`) is the
72
+ **command registry and router**: project context (track, tech stack, prose
73
73
  language), the `/dflow:*` workflow table, source-of-truth file paths, and
74
- core SDD/DDD rules. The `CLAUDE.md` shim stays small precisely so the
75
- canonical guide can evolve without Claude-Code-specific edits.
74
+ core SDD/DDD rules. The executable workflow steps (Step 1→N, step gates,
75
+ completion checklists) live in the **vendored workflow bundle** that `init`
76
+ projects into `dflow/specs/shared/dflow-workflows/`. Both are plain Markdown
77
+ checked into your repo, so they travel with the project when cloned. The
78
+ `CLAUDE.md` shim stays small precisely so the canonical guide can evolve
79
+ without Claude-Code-specific edits.
76
80
 
77
81
  If a `CLAUDE.md` already existed in the project, `init` does not overwrite
78
82
  it. Instead it writes a merge snippet under `dflow/specs/shared/` that you
@@ -112,9 +116,11 @@ dflow/specs/features/active/. Before I do, I need a short answer on:
112
116
  The workflow then walks you through spec drafting, behavior examples,
113
117
  implementation planning, and finish-feature drift checks. The exact
114
118
  sequence depends on which workflow you entered (`/dflow:new-feature`,
115
- `/dflow:modify-existing`, `/dflow:bug-fix`, etc.). All workflow definitions
116
- live under the Dflow skill source; Claude Code follows them by reading the
117
- skill files when needed.
119
+ `/dflow:modify-existing`, `/dflow:bug-fix`, etc.). The executable step
120
+ definitions (Step 1→N, step gates, completion checklists) are in the
121
+ vendored workflow bundle at `dflow/specs/shared/dflow-workflows/`; `init`
122
+ projects this bundle into every initialized project so the workflow steps
123
+ are self-contained and reachable without any external source dependency.
118
124
 
119
125
  Available workflow entry points:
120
126
 
@@ -156,10 +162,111 @@ These wrappers use Claude Code's directory namespace names, for example
156
162
  `/dflow:new-feature`. Their body only points to the canonical
157
163
  `/dflow:new-feature` workflow and `dflow/specs/shared/AI-AGENT-GUIDE.md`; it
158
164
  does not copy workflow steps. Projects upgraded from Dflow 0.5.0 may still
159
- have old `.claude/commands/dflow/dflow-*.md` files. Dflow does not delete user
160
- files automatically; remove those old wrappers manually so Claude Code does
161
- not show both the old `/dflow:dflow-<id>` names and the new `/dflow:<id>`
162
- names.
165
+ have old `.claude/commands/dflow/dflow-*.md` files, which make Claude Code show
166
+ both the old `/dflow:dflow-<id>` names and the new `/dflow:<id>` names. When you
167
+ re-run `dflow configure-agents --command-adapters`, Dflow **automatically
168
+ detects and removes** these 0.5.0-generated stale wrappers: the files to remove
169
+ are listed in the confirmation preview (marked `remove`) and deleted only after
170
+ you confirm. Dflow removes only files whose content **exactly matches** the
171
+ 0.5.0 generated output; if you have edited the file, or it is one you placed in
172
+ the same namespace yourself, Dflow leaves it in place and prints a warning so
173
+ you can review it manually.
174
+
175
+ ### Version Control and Upgrades for Generated Adapters
176
+
177
+ `.claude/commands/dflow/<id>.md` is a **generated artifact** projected from the
178
+ canonical guide. Dflow's **recommended default** is to not version-control it
179
+ and regenerate it after clone with `dflow configure-agents --command-adapters`;
180
+ teams that want a native command menu immediately after clone may instead
181
+ **version-control** it. Use one consistent policy across all tools in a project
182
+ (see the policy overview and ignore-vs-track trade-off in
183
+ [README "Files Created by Init"](../README.en.md#files-created-by-init)).
184
+
185
+ When using the gitignore default, add this to the project `.gitignore` (**only
186
+ if you reserve the `.claude/commands/dflow/` namespace for Dflow**):
187
+
188
+ ```gitignore
189
+ .claude/commands/dflow/
190
+ ```
191
+
192
+ Note: this rule also ignores any custom commands you place in the same
193
+ directory. If the directory is **already version-controlled**, adding the
194
+ ignore rule does not remove it from version control automatically; first run:
195
+
196
+ ```bash
197
+ git rm --cached -r .claude/commands/dflow/
198
+ ```
199
+
200
+ (`--cached` removes it from version control while keeping the working-tree
201
+ files.)
202
+
203
+ After upgrading Dflow, re-running `dflow configure-agents --command-adapters`
204
+ re-projects adapters from the **new registry**, but an existing
205
+ `dflow/specs/shared/AI-AGENT-GUIDE.md` is **not** overwritten — "re-projecting
206
+ adapters" is not the same as "migrating the canonical guide." Re-project with
207
+ the **same dflow CLI version** to avoid a registry / guide version mismatch.
208
+
209
+ ### Optional Skill Adapter (Restore Natural-Language Auto-Trigger)
210
+
211
+ Command adapters give you a `/` menu entry, but they **do not auto-trigger** —
212
+ you have to invoke the command yourself. If you want to restore the "say 'I want
213
+ to add a feature' and it shows up automatically" experience, run this in an
214
+ initialized project:
215
+
216
+ ```bash
217
+ dflow configure-agents --skills
218
+ ```
219
+
220
+ After you select Claude Code, Dflow generates a thin skill:
221
+
222
+ - `.claude/skills/dflow/SKILL.md`
223
+
224
+ This skill does not copy workflow steps; its body points to the canonical
225
+ `dflow/specs/shared/AI-AGENT-GUIDE.md` (command registry and routing rules) and
226
+ `dflow/specs/shared/dflow-workflows/` (vendored bundle with executable step
227
+ definitions).
228
+ Its behavior:
229
+
230
+ - **Auto-triggers on** feature / bug-fix workflows, product/domain behavior
231
+ changes, new requirements, and spec-impacting architecture / domain-model
232
+ decisions.
233
+ - **Does not trigger on** pure refactors, infrastructure chores, formatting, or
234
+ general code questions.
235
+ - When engaged by natural language it **does not enter a workflow directly**: it
236
+ judges the intent, **suggests the matching `/dflow:` command, and waits for
237
+ your confirmation** before proceeding.
238
+
239
+ **The four combinations** (command adapters and the skill are each independently
240
+ opt-in):
241
+
242
+ | Installed | Entry behavior |
243
+ |---|---|
244
+ | Neither | Root shim only (CLAUDE.md points to the guide); no `/` menu, no auto-trigger |
245
+ | Command adapters only | `/dflow:*` appears in the `/` menu; no natural-language auto-trigger |
246
+ | Skill only | Natural-language auto-trigger (suggest-and-wait); no `/` menu |
247
+ | Both | `/` menu + natural-language safety net **may coexist** |
248
+
249
+ **Both may coexist with no mutex needed** (validated in a real Claude Code
250
+ environment): the skill name `dflow` does not collide with the command adapters'
251
+ `dflow:<id>` names, explicit commands load their own adapter precisely with no
252
+ double-fire; the skill acts as a natural-language safety net while command
253
+ adapters provide the `/` menu.
254
+
255
+ After installing, verify with `/skills` or by asking "What skills are
256
+ available?". Note: adding a new top-level skills directory may require
257
+ **restarting Claude Code** before it is watched. Also, a personal / enterprise
258
+ skill at `~/.claude/skills/dflow` can **override** the project skill (per the
259
+ Claude docs); use `/skills` to check which one is active.
260
+
261
+ **Version-control policy**: `.claude/skills/dflow/SKILL.md` is a **generated
262
+ artifact**, just like the command adapters, and follows the same default — do
263
+ not version-control it and regenerate it after clone with
264
+ `dflow configure-agents --skills` (`.claude/skills/dflow/` is already in the
265
+ recommended gitignore set); clone-ready teams may version-control it instead.
266
+ Re-running `--skills` is idempotent: an existing marker-stamped skill is
267
+ rewritten cleanly. If `.claude/skills/dflow/SKILL.md` is **not** Dflow-generated
268
+ (no `<!-- dflow-generated: skill-adapter -->` marker), Dflow leaves it unchanged
269
+ and prints a warning asking you to remove or rename it.
163
270
 
164
271
  ## Differences vs Other AI Tools
165
272
 
@@ -62,10 +62,14 @@ Claude Code 在這個專案中啟動時,會發生兩件事:
62
62
  Markdown import 語法,將 canonical Dflow 指南 inline 嵌入。因此 Claude Code
63
63
  等效於把兩個檔案當成一組指示來讀取。
64
64
 
65
- canonical 指南(`dflow/specs/shared/AI-AGENT-GUIDE.md`)是實際 workflow
66
- 規則的所在:專案上下文(track、技術棧、文章語言)、`/dflow:*` workflow 表、
67
- source-of-truth 檔案路徑,以及核心 SDD/DDD 規則。`CLAUDE.md` shim 刻意保持精簡,
68
- 這樣 canonical 指南就能在不需要 Claude Code 專屬修改的情況下持續演進。
65
+ canonical 指南(`dflow/specs/shared/AI-AGENT-GUIDE.md`)是**命令登錄表與路由器**:
66
+ 專案上下文(track、技術棧、文章語言)、`/dflow:*` workflow 表、source-of-truth
67
+ 檔案路徑,以及核心 SDD/DDD 規則。可執行的 workflow 步驟(Step 1→N、step gates、
68
+ completion checklists)則放在 `init` 投影進專案的 **vendored workflow bundle**
69
+ (`dflow/specs/shared/dflow-workflows/`)。兩者都是純 Markdown,隨 repo
70
+ 一起 commit,任何 clone 都能直接讀取,不需要 Dflow source 或 package 在本機安裝。
71
+ `CLAUDE.md` shim 刻意保持精簡,這樣 canonical 指南就能在不需要 Claude Code
72
+ 專屬修改的情況下持續演進。
69
73
 
70
74
  如果專案中已有 `CLAUDE.md`,`init` 不會覆蓋它。它改為在
71
75
  `dflow/specs/shared/` 下寫入 merge snippet,讓你手動貼入現有的 `CLAUDE.md`。
@@ -103,8 +107,10 @@ dflow/specs/features/active/. Before I do, I need a short answer on:
103
107
  接著這個 workflow 會引導你完成 spec 起草、行為範例、實作計畫,以及
104
108
  finish-feature 漂移(drift)檢查。確切的流程取決於你進入的是哪個 workflow
105
109
  (`/dflow:new-feature`、`/dflow:modify-existing`、`/dflow:bug-fix` 等)。
106
- 所有 workflow 定義都存放在 Dflow skill source 中;Claude Code 在需要時讀取
107
- skill 檔案來執行它們。
110
+ 可執行的步驟定義(Step 1→N、step gates、completion checklists)存放在
111
+ `dflow/specs/shared/dflow-workflows/` 的 vendored bundle 中;`init` 會把這個
112
+ bundle 投影進每個初始化的專案,因此 workflow 步驟是 self-contained 且可達的,
113
+ 不需要任何外部 source dependency。
108
114
 
109
115
  可用的 workflow 入口:
110
116
 
@@ -143,9 +149,88 @@ dflow configure-agents --command-adapters
143
149
  `/dflow:new-feature`。Wrapper 內容只指向 canonical `/dflow:new-feature`
144
150
  workflow 與 `dflow/specs/shared/AI-AGENT-GUIDE.md`,不複製 workflow 步驟。
145
151
  從 Dflow 0.5.0 升級的專案可能仍保留舊檔
146
- `.claude/commands/dflow/dflow-*.md`;Dflow 不會擅自刪除 user 檔,請手動刪除
147
- 這些舊 wrapper,避免 Claude Code 同時顯示舊的 `/dflow:dflow-<id>` 與新的
148
- `/dflow:<id>`。
152
+ `.claude/commands/dflow/dflow-*.md`,會讓 Claude Code 同時顯示舊的
153
+ `/dflow:dflow-<id>` 與新的 `/dflow:<id>`。重跑
154
+ `dflow configure-agents --command-adapters` 時,Dflow 會**自動偵測並清除**這些
155
+ 0.5.0 產生的 stale wrapper:待刪檔會列在確認 preview 中(標為 `remove`),由你
156
+ 確認後才刪除。Dflow 只會刪除**內容與 0.5.0 產生物完全相符**的檔;若該檔被你改過、
157
+ 或是你自己放在同 namespace 的檔,Dflow 不會刪除,只會印出 warning 提示你自行確認。
158
+
159
+ ### 產生物的版控政策與升級
160
+
161
+ `.claude/commands/dflow/<id>.md` 是從 canonical guide 投影出來的**衍生物**。Dflow 的
162
+ **建議預設**是不版控、由 clone 後重跑 `dflow configure-agents --command-adapters` 重生成;
163
+ 團隊若想 clone 後立即有原生命令選單,也可改為**版控**。重點是同一專案對所有工具採一致策略
164
+ (政策總覽與 ignore-vs-track 取捨見 [README「Init 產生的檔案」](../README.md#init-產生的檔案))。
165
+
166
+ 採 gitignore 預設時,在專案 `.gitignore` 加入(**僅在你保留 `.claude/commands/dflow/`
167
+ namespace 給 Dflow 時**):
168
+
169
+ ```gitignore
170
+ .claude/commands/dflow/
171
+ ```
172
+
173
+ 注意:此規則會一併 ignore 你放在同一目錄下的自訂 command。若該目錄**已被版控**,新增 ignore
174
+ 規則不會自動把它移出版控,需先:
175
+
176
+ ```bash
177
+ git rm --cached -r .claude/commands/dflow/
178
+ ```
179
+
180
+ (`--cached` 只移出版控、保留工作目錄檔案。)
181
+
182
+ 升級 dflow 後重跑 `dflow configure-agents --command-adapters`,adapter 會用**新版 registry**
183
+ 重投影;但既有 `dflow/specs/shared/AI-AGENT-GUIDE.md` **不會**被覆寫——「重投影 adapter」不等於
184
+ 「升級 canonical guide」。請以**相同的 dflow CLI 版本**重投影,避免 registry 與 guide 版本錯位。
185
+
186
+ ### 選配 Skill Adapter(找回自然語言自動觸發)
187
+
188
+ Command adapter 提供 `/` 選單入口,但**不會自動觸發**——你得主動打命令。若想找回
189
+ 「講『我要加一個功能』就自動現身」的體驗,可在已初始化的專案中執行:
190
+
191
+ ```bash
192
+ dflow configure-agents --skills
193
+ ```
194
+
195
+ 選擇 Claude Code 後,Dflow 會產生一份薄 skill:
196
+
197
+ - `.claude/skills/dflow/SKILL.md`
198
+
199
+ 這份 skill 不複製 workflow 步驟,body 指向 canonical
200
+ `dflow/specs/shared/AI-AGENT-GUIDE.md`(命令登錄表與路由規則)以及
201
+ `dflow/specs/shared/dflow-workflows/`(含可執行步驟定義的 vendored bundle)。
202
+ 它的行為:
203
+
204
+ - **自動觸發於** feature / bug-fix workflow、product/domain behavior 變更、新需求、
205
+ spec-impacting 的 architecture / domain-model 決策。
206
+ - **不會觸發於** 純 refactor、infra chore、formatting、一般 code 問題。
207
+ - 由自然語言觸發時,**不會直接進 workflow**:它會判斷意圖、**建議對應的 `/dflow:`
208
+ 命令並等待你確認**,再進入流程。
209
+
210
+ **四種組合**(command adapter 與 skill 各自獨立 opt-in):
211
+
212
+ | 安裝組合 | 入口行為 |
213
+ |---|---|
214
+ | 都不裝 | 只有根目錄 shim(CLAUDE.md 指向 guide);無 `/` 選單、無自動觸發 |
215
+ | 只裝 command adapters | `/dflow:*` 出現在 `/` 選單;無自然語言自動觸發 |
216
+ | 只裝 skill | 自然語言自動觸發(suggest-and-wait);無 `/` 選單 |
217
+ | 兩者都裝 | `/` 選單 + 自然語言 safety net **可共存** |
218
+
219
+ **兩者可共存、無需互斥**(已在真實 Claude Code 環境驗證):skill 名稱 `dflow` 與
220
+ command adapter 的 `dflow:<id>` 不撞名,明確命令各自精準載入、不會雙觸發;skill 當
221
+ 自然語言 safety net,command adapters 當 `/` 選單。
222
+
223
+ 安裝後用 `/skills` 或詢問「What skills are available?」確認 skill 已被探索到。注意:
224
+ 新增頂層 skills 目錄可能需**重啟 Claude Code** 才會被 watch 到。另外,位於
225
+ `~/.claude/skills/dflow` 的 personal / enterprise skill 可能會 **override** 專案層級
226
+ skill(依 Claude 官方文件),用 `/skills` 可檢查目前生效的是哪一份。
227
+
228
+ **版控政策**:`.claude/skills/dflow/SKILL.md` 與 command adapter 一樣是**衍生物**,
229
+ 沿用相同預設——不版控、由 clone 後重跑 `dflow configure-agents --skills` 重生成
230
+ (`.claude/skills/dflow/` 已列入建議的 gitignore 集合);clone-ready 團隊也可選擇版控。
231
+ 重跑 `--skills` 是 idempotent 的:帶 marker 的既有 skill 會被乾淨重寫;若 `.claude/skills/dflow/SKILL.md`
232
+ **不是** Dflow 產生的(無 `<!-- dflow-generated: skill-adapter -->` marker),Dflow 不會覆蓋它,
233
+ 只會印出 warning 提示你移除或改名。
149
234
 
150
235
  ## 與其他 AI 工具的差異
151
236
 
@@ -177,6 +177,20 @@ documentation guidance.
177
177
  In this mode, the Codex-target merge snippet filename is
178
178
  `dflow/specs/shared/AGENTS-md-command-adapters-snippet.md`.
179
179
 
180
+ ### Version-Control Policy for Generated Artifacts (Codex)
181
+
182
+ Codex does not generate command files, so there is **no derived adapter to
183
+ gitignore**. On the Codex side, what you version-control is the `AGENTS.md`
184
+ shim and `dflow/` (the canonical guide and specs); the merge helper
185
+ `dflow/specs/shared/AGENTS-md-command-adapters-snippet.md` is part of `dflow/`
186
+ and is **version-controlled along with `dflow/`**. `--command-adapters` only
187
+ strengthens the text triggers in `AGENTS.md` for Codex; it adds no `.claude/`,
188
+ `.github/`, or `.agents/` command files, so the Claude / Copilot
189
+ "version-control the generated adapter or not" trade-off does not apply on the
190
+ Codex side. The adapter version-control policy for other tools is covered in
191
+ [README "Files Created by Init"](../README.en.md#files-created-by-init) and the
192
+ per-tool guides.
193
+
180
194
  ## Differences vs Other AI Tools
181
195
 
182
196
  The canonical guide (`dflow/specs/shared/AI-AGENT-GUIDE.md`) is identical
@@ -162,6 +162,16 @@ dflow:new-feature
162
162
  在這個模式下,Codex 目標的 merge snippet 檔名是
163
163
  `dflow/specs/shared/AGENTS-md-command-adapters-snippet.md`。
164
164
 
165
+ ### 產生物的版控政策(Codex)
166
+
167
+ Codex 不產生 command 檔,所以**沒有需要 gitignore 的衍生 adapter**。Codex 端要版控的是
168
+ `AGENTS.md` shim 與 `dflow/`(canonical guide + 規格);其中
169
+ `dflow/specs/shared/AGENTS-md-command-adapters-snippet.md` 這個 merge helper 屬 `dflow/` 的一部分,
170
+ **隨 `dflow/` 一起版控**。`--command-adapters` 對 Codex 只強化 `AGENTS.md` 的文字 trigger,
171
+ 不新增任何 `.claude/`、`.github/`、`.agents/` 命令檔,因此 Claude / Copilot 那套「衍生 adapter
172
+ 要不要版控」的取捨在 Codex 端不適用。其他工具的 adapter 版控政策見
173
+ [README「Init 產生的檔案」](../README.md#init-產生的檔案) 與各 per-tool 指南。
174
+
165
175
  ## 與其他 AI 工具的差異
166
176
 
167
177
  canonical 指南(`dflow/specs/shared/AI-AGENT-GUIDE.md`)在各工具之間是相同的。
@@ -83,6 +83,42 @@ does not copy workflow steps. Copilot's `/` parser behavior differs from
83
83
  Claude and Codex: the prompt menu entry is `/dflow-<id>`, while chat text may
84
84
  still name the canonical `/dflow:<id>` workflow.
85
85
 
86
+ ### Version Control and Upgrades for Generated Adapters
87
+
88
+ `.github/prompts/dflow-<id>.prompt.md` is a **generated artifact** projected
89
+ from the canonical guide. Dflow's **recommended default** is to not
90
+ version-control it and regenerate it after clone with `dflow configure-agents
91
+ --command-adapters`; teams that want a native prompt menu immediately after
92
+ clone may instead **version-control** it. Use one consistent policy across all
93
+ tools in a project (policy overview in
94
+ [README "Files Created by Init"](../README.en.md#files-created-by-init)).
95
+
96
+ When using the gitignore default, add this to the project `.gitignore` (**mind
97
+ the glob side effect**):
98
+
99
+ ```gitignore
100
+ .github/prompts/dflow-*.prompt.md
101
+ ```
102
+
103
+ This glob also ignores any of your own prompt files named with a `dflow-`
104
+ prefix. If you have custom prompts with the same prefix, use a more specific
105
+ rule or rename your custom files. If these prompts are **already
106
+ version-controlled**, adding the ignore rule does not remove them
107
+ automatically; first run:
108
+
109
+ ```bash
110
+ git rm --cached .github/prompts/dflow-*.prompt.md
111
+ ```
112
+
113
+ (`--cached` removes them from version control while keeping the working-tree
114
+ files.)
115
+
116
+ After upgrading Dflow, re-running `dflow configure-agents --command-adapters`
117
+ re-projects prompt adapters from the **new registry**, but an existing
118
+ `dflow/specs/shared/AI-AGENT-GUIDE.md` is **not** overwritten — "re-projecting
119
+ adapters" is not the same as "migrating the canonical guide." Re-project with
120
+ the **same dflow CLI version**.
121
+
86
122
  ### Sample Conversation Flow
87
123
 
88
124
  A typical Copilot Chat workflow looks like this: