dflow-sdd-ddd 0.1.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 (40) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +209 -0
  3. package/bin/dflow.js +72 -0
  4. package/lib/init.js +1206 -0
  5. package/package.json +42 -0
  6. package/templates/core/scaffolding/CLAUDE-md-snippet.md +168 -0
  7. package/templates/core/scaffolding/Git-principles-gitflow.md +350 -0
  8. package/templates/core/scaffolding/Git-principles-trunk.md +375 -0
  9. package/templates/core/scaffolding/_conventions.md +175 -0
  10. package/templates/core/scaffolding/_overview.md +165 -0
  11. package/templates/core/scaffolding/architecture-decisions-README.md +34 -0
  12. package/templates/core/templates/CLAUDE.md +172 -0
  13. package/templates/core/templates/_index.md +118 -0
  14. package/templates/core/templates/aggregate-design.md +58 -0
  15. package/templates/core/templates/behavior.md +62 -0
  16. package/templates/core/templates/context-definition.md +64 -0
  17. package/templates/core/templates/context-map.md +25 -0
  18. package/templates/core/templates/events.md +19 -0
  19. package/templates/core/templates/glossary.md +15 -0
  20. package/templates/core/templates/lightweight-spec.md +82 -0
  21. package/templates/core/templates/models.md +47 -0
  22. package/templates/core/templates/phase-spec.md +195 -0
  23. package/templates/core/templates/rules.md +24 -0
  24. package/templates/core/templates/tech-debt.md +15 -0
  25. package/templates/webforms/scaffolding/CLAUDE-md-snippet.md +167 -0
  26. package/templates/webforms/scaffolding/Git-principles-gitflow.md +333 -0
  27. package/templates/webforms/scaffolding/Git-principles-trunk.md +316 -0
  28. package/templates/webforms/scaffolding/_conventions.md +139 -0
  29. package/templates/webforms/scaffolding/_overview.md +109 -0
  30. package/templates/webforms/templates/CLAUDE.md +157 -0
  31. package/templates/webforms/templates/_index.md +110 -0
  32. package/templates/webforms/templates/behavior.md +58 -0
  33. package/templates/webforms/templates/context-definition.md +57 -0
  34. package/templates/webforms/templates/context-map.md +25 -0
  35. package/templates/webforms/templates/glossary.md +15 -0
  36. package/templates/webforms/templates/lightweight-spec.md +82 -0
  37. package/templates/webforms/templates/models.md +39 -0
  38. package/templates/webforms/templates/phase-spec.md +187 -0
  39. package/templates/webforms/templates/rules.md +24 -0
  40. package/templates/webforms/templates/tech-debt.md +15 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Dflow contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,209 @@
1
+ # AI-Guided SDD/DDD Development Skills
2
+
3
+ AI 引導的規格驅動開發(SDD)與領域驅動設計(DDD)工作流程規範,設計用於 Claude Code 協作開發。
4
+
5
+ ## 這是什麼
6
+
7
+ 這套 Skill 讓 AI 在開發過程中擔任**流程守衛(Workflow Guardian)**的角色。開發者不需要熟悉 SDD 或 DDD 的所有細節——AI 會在對的時機問對的問題,引導開發者自然地產出規格文件、領域模型、和技術債記錄。
8
+
9
+ 適用場景:
10
+ - 團隊導入 SDD/DDD 但成員經驗不一
11
+ - 希望在開發過程中保持架構紀律
12
+ - ASP.NET WebForms 專案準備遷移到 ASP.NET Core
13
+ - 學習 DDD 並透過模擬專案練習
14
+
15
+ ## 目錄結構
16
+
17
+ ```
18
+ ├── bin/ # dflow CLI entrypoint
19
+ ├── lib/ # init runtime implementation
20
+ ├── templates/ # npm package template source
21
+ ├── test/ # smoke tests
22
+ ├── tutorial/ # 人讀教學劇本與範例 outputs
23
+ ├── planning/ # handoff / contract / planning notes
24
+ ├── proposals/ # Proposal 管理目錄
25
+ ├── reviews/ # cross-round review reports and prompts
26
+ ├── sdd-ddd-webforms-skill/ # WebForms 版 Skill(英文,供 AI 使用)
27
+ └── sdd-ddd-core-skill/ # ASP.NET Core 版 Skill(英文,供 AI 使用)
28
+ ```
29
+
30
+ ---
31
+
32
+ ## 兩套 Skill 的差異
33
+
34
+ | | WebForms Skill | Core Skill |
35
+ |---|---|---|
36
+ | **適用階段** | 目前:在運行中的 WebForms 專案開發 | 未來:ASP.NET Core 新專案 / 模擬練習 |
37
+ | **架構** | Domain 層 + Code-Behind(兩層) | Clean Architecture 四層 |
38
+ | **DDD 深度** | 準備性——術語表、Context 識別、基本抽離 | 完整戰術模式——Aggregate、Domain Events、CQRS |
39
+ | **核心引導** | 「Code-Behind 盡量薄」 | 「每一層各司其職,業務邏輯只在 Domain」 |
40
+ | **遷移意識** | 每次開發都產出可遷移的資產 | 從頭設計乾淨架構 |
41
+ | **附加內容** | — | DDD 建模指南、Aggregate 設計工作表、模擬練習計畫 |
42
+
43
+ ---
44
+
45
+ ## WebForms Skill 檔案說明
46
+
47
+ ### SKILL.md — 主文件
48
+ AI 的決策樹和核心規範。定義了五個核心原則、流程嚴謹度對照表、專案目錄結構、各階段引導問題、Domain 層規範。
49
+
50
+ ### references/ — 流程參考
51
+ | 檔案 | 內容 |
52
+ |---|---|
53
+ | `init-project-flow.md` | `npx dflow-sdd-ddd init` 的 internal flow / manual fallback,定義 project bootstrap 問答和 scaffolding 行為 |
54
+ | `new-feature-flow.md` | 新功能 8 步驟流程:需求理解 → Context 識別 → 概念發掘 → 撰寫規格 → 實作規劃 → 分支 → 實作 → 完成 |
55
+ | `modify-existing-flow.md` | 修改既有功能流程,重點在趁機從 Code-Behind 抽離業務邏輯到 Domain 層 |
56
+ | `new-phase-flow.md` | 在既有 feature 下新增 phase 的規格與實作流程 |
57
+ | `finish-feature-flow.md` | 完成功能時的 drift 檢查、文件收斂與 tech-debt 收尾 |
58
+ | `drift-verification.md` | 規格、模型、實作與文件間的 drift verification 檢查 |
59
+ | `git-integration.md` | Git principles 與 SDD 階段對齊,每個 gate 有具體檢查項目 |
60
+ | `pr-review-checklist.md` | PR 審查時的合規檢查和遷移準備度 A~F 評分 |
61
+
62
+ ### scaffolding/ — init 建立的基線文件
63
+ | 檔案 | 用途 |
64
+ |---|---|
65
+ | `_overview.md` | Dflow-owned spec tree 的總覽 |
66
+ | `_conventions.md` | 專案 convention,包含 `Prose Language` |
67
+ | `Git-principles-*.md` | Git Flow / Trunk-Based Development 原則模板 |
68
+
69
+ ### templates/ — 模板
70
+ | 檔案 | 用途 |
71
+ |---|---|
72
+ | `_index.md` | feature / phase 索引與 integration summary |
73
+ | `phase-spec.md` | phase 級規格模板 |
74
+ | `behavior.md` | Given/When/Then 行為規格模板 |
75
+ | `lightweight-spec.md` | Bug 修復用的輕量規格模板 |
76
+ | `context-definition.md` | 新 Bounded Context 定義模板 |
77
+ | `CLAUDE.md` | init 用的 AI 協作規範模板來源;採用時由 `npx dflow-sdd-ddd init` 處理 |
78
+ | `context-map.md`、`glossary.md`、`models.md`、`rules.md`、`tech-debt.md` | domain / migration 文件模板 |
79
+
80
+ ---
81
+
82
+ ## Core Skill 檔案說明
83
+
84
+ ### SKILL.md — 主文件
85
+ 在 WebForms 版基礎上新增:Clean Architecture 四層架構圖、各層不可妥協的規範、DDD 戰術模式的引導問題。
86
+
87
+ ### references/ — 流程參考
88
+ | 檔案 | 內容 |
89
+ |---|---|
90
+ | `init-project-flow.md` | `npx dflow-sdd-ddd init` 的 internal flow / manual fallback,定義 project bootstrap 問答和 scaffolding 行為 |
91
+ | `new-feature-flow.md` | 新功能流程,新增逐層實作順序(Domain → Application → Infrastructure → Presentation) |
92
+ | `modify-existing-flow.md` | 修改流程,新增 Aggregate 設計重新評估 |
93
+ | `new-phase-flow.md` | 在既有 feature 下新增 phase 的規格與實作流程 |
94
+ | `finish-feature-flow.md` | 完成功能時的 drift 檢查、文件收斂與 tech-debt 收尾 |
95
+ | `drift-verification.md` | 規格、模型、實作與文件間的 drift verification 檢查 |
96
+ | `ddd-modeling-guide.md` | **核心新增**:DDD 建模完整指南,涵蓋 Aggregate 設計規則、Value Object、Domain Events、Specification、Domain Service、Bounded Context 關係、常見錯誤 |
97
+ | `git-integration.md` | Git principles 與 SDD 階段對齊,閘門檢查新增 Aggregate 設計和 Domain Events |
98
+ | `pr-review-checklist.md` | PR 審查,四層各自的檢查項目 |
99
+
100
+ ### scaffolding/ — init 建立的基線文件
101
+ | 檔案 | 用途 |
102
+ |---|---|
103
+ | `_overview.md` | Dflow-owned spec tree 的總覽 |
104
+ | `_conventions.md` | 專案 convention,包含 `Prose Language` |
105
+ | `architecture-decisions-README.md` | architecture decisions 目錄說明 |
106
+ | `Git-principles-*.md` | Git Flow / Trunk-Based Development 原則模板 |
107
+
108
+ ### templates/ — 模板
109
+ | 檔案 | 用途 |
110
+ |---|---|
111
+ | `_index.md` | feature / phase 索引與 integration summary |
112
+ | `phase-spec.md` | phase 級規格模板,支援 Domain Events 和逐層實作計畫 |
113
+ | `behavior.md` | Given/When/Then 行為規格模板 |
114
+ | `lightweight-spec.md` | 輕量規格模板 |
115
+ | `context-definition.md` | Bounded Context 定義模板 |
116
+ | `aggregate-design.md` | **核心新增**:Aggregate 設計工作表(不變條件、狀態變更方法、Events、引用關係) |
117
+ | `CLAUDE.md` | init 用的 AI 協作規範模板來源;採用時由 `npx dflow-sdd-ddd init` 處理 |
118
+ | `events.md`、`context-map.md`、`glossary.md`、`models.md`、`rules.md`、`tech-debt.md` | domain / architecture 文件模板 |
119
+
120
+ ### PRACTICE_PLAN_tw.md — 模擬練習計畫
121
+ 7 個 Phase 的 DDD 學習路線,使用費用報銷系統作為模擬專案,預估 15-22 小時:
122
+
123
+ | Phase | 內容 | 學到的 DDD 概念 |
124
+ |---|---|---|
125
+ | 1 | 建立基礎、識別 Bounded Context | Context Map、Ubiquitous Language |
126
+ | 2 | 第一個 Aggregate + Value Objects | Aggregate Root、不變條件、Private Setter |
127
+ | 3 | Domain Events | 事件驅動、最終一致性 |
128
+ | 4 | 第二個 Aggregate + 跨 Aggregate 溝通 | Reference by ID、狀態機 |
129
+ | 5 | CQRS + Application 層 | Command/Query 分離 |
130
+ | 6 | Infrastructure 整合 | EF Core 設定、Repository、Event Dispatching |
131
+ | 7 | 回顧 + Skill 檢視 | 流程改善 |
132
+
133
+ ---
134
+
135
+ ## How to adopt Dflow in your project
136
+
137
+ Dflow is the AI-guided SDD/DDD workflow contained in this repo (see `sdd-ddd-webforms-skill/` and `sdd-ddd-core-skill/`). In V1, project bootstrap is npm CLI first: the default entry is `npx dflow-sdd-ddd init`, which seeds `dflow/specs/` and keeps Dflow-owned documents under the `dflow/` namespace.
138
+
139
+ The npm package is published as `dflow-sdd-ddd` because the unscoped `dflow` package name is already occupied on npm. The installed CLI still exposes the `dflow` binary for global installs.
140
+
141
+ Adopting Dflow in a project takes 4 steps:
142
+
143
+ 1. In your project root, run `npx dflow-sdd-ddd init`.
144
+ 2. Answer the intake questions. Dflow will ask for the edition, project context, optional starter files, and the required project prose language for generated spec content.
145
+ 3. Review the file-list preview and confirm the writes. Existing files are never overwritten.
146
+ 4. Start your first feature with `/dflow:new-feature`, or for an existing codebase, `/dflow:modify-existing` to work from an incoming change request.
147
+
148
+ The generated baseline lives under `dflow/specs/`, for example `dflow/specs/shared/_conventions.md`, `dflow/specs/domain/glossary.md`, and `dflow/specs/features/active/`. The project AI guide is the one special root-level exception: `CLAUDE.md` stays at the project root so AI tools can discover it normally. If a root `CLAUDE.md` already exists, Dflow writes a mergeable snippet instead of overwriting it.
149
+
150
+ Dflow keeps template structure stable in English: headings, table headers, labels, anchors, IDs, placeholders, file paths, and code-facing terms remain canonical English. Free prose inside those sections follows the project's `Prose Language` setting in `dflow/specs/shared/_conventions.md`.
151
+
152
+ Advanced usage: `npm install -g dflow-sdd-ddd` may be useful for users who want a fixed global CLI, then run `dflow init`. This is not the V1 default. `npm create dflow-sdd-ddd` is not implemented in V1 and remains a V2 evaluation item.
153
+
154
+ For what gets created at init time, how scaffolding templates are chosen, and how to re-run safely, see `sdd-ddd-webforms-skill/references/init-project-flow.md` (or the Core equivalent).
155
+
156
+ ### V2 Starter Kit and Dflow — division of labour
157
+
158
+ Dflow is distributed alongside a sister project, **V2 Starter Kit** (`SDD-Starter-Kit`), which plays a complementary role:
159
+
160
+ | | V2 Starter Kit | Dflow (this repo) |
161
+ |---|---|---|
162
+ | **Format** | Complete distributable starter kit (flat files + tutorial docs) | AI-guided skill (read and executed by Claude Code at runtime) |
163
+ | **Onboarding documents** | Ships full onboarding pack (e.g. `SDD-AI協作開發模式介紹.md`, `使用說明.md`) | Ships minimal scaffolding templates only (`scaffolding/`) |
164
+ | **Primary audience** | Humans reading + copying files manually | AI running slash commands in a live project |
165
+ | **Typical use** | Teams evaluating SDD/DDD or wanting a human-readable reference | Teams who want the workflow enforced at development time |
166
+
167
+ The two are designed to coexist: you can start with V2's onboarding docs for reading/training, then adopt Dflow in the project itself for enforcement. Dflow's `scaffolding/` is intentionally a **minimal** template set; if you want the full V2 onboarding documents, copy them from V2 separately (V2's Tutorial rebuild is tracked as Closeout C2 of this repo's work plan).
168
+
169
+ ---
170
+
171
+ ## 如何使用
172
+
173
+ ### 在專案中採用 Dflow
174
+
175
+ 1. 在專案根目錄執行 `npx dflow-sdd-ddd init`
176
+ 2. 依提示選擇 edition、starter files、project prose language
177
+ 3. 預覽並確認寫入清單;Dflow 不會覆寫既有檔案
178
+ 4. 啟動 AI coding agent,從 `/dflow:new-feature` 或 `/dflow:modify-existing` 開始
179
+
180
+ ### 在 Claude Code 中進行 DDD 模擬練習
181
+
182
+ 1. 在練習專案根目錄執行 `npx dflow-sdd-ddd init`,選擇 Core edition
183
+ 2. 啟動 Claude Code,輸入:
184
+ ```
185
+ 我要開始一個 DDD 模擬練習專案:員工費用報銷系統(ExpenseTracker)。
186
+ 請依照 Skill 中定義的流程引導我,從 Phase 1 開始。
187
+ ```
188
+
189
+ ---
190
+
191
+ ## 設計理念
192
+
193
+ ### Spec Before Code(先規格、後程式碼)
194
+ 每一次程式碼變更都應該有對應的規格文件。規格不是額外的負擔,而是思考的工具——在寫程式之前先想清楚要做什麼。
195
+
196
+ ### AI 作為流程守衛
197
+ AI 不只是回答問題的工具,它主動引導開發流程:在你開分支前確認規格存在、在你寫 Code-Behind 時提醒業務邏輯應該在 Domain 層、在 PR 時檢查架構合規性。
198
+
199
+ ### 漸進式 DDD
200
+ 不需要一次到位。WebForms 階段先累積術語表和領域知識,ASP.NET Core 階段再完整落地 DDD 戰術模式。現在寫的每一份規格和每一段 Domain 層程式碼,都是未來遷移的資產。
201
+
202
+ ### 三份資產
203
+ 每次開發循環都產出:**規格文件**(未來的需求文件)、**Domain 層程式碼**(可直接遷移)、**技術債記錄**(遷移指南)。
204
+
205
+ ---
206
+
207
+ ## 授權
208
+
209
+ MIT License. See [LICENSE](LICENSE).
package/bin/dflow.js ADDED
@@ -0,0 +1,72 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { runInit } = require('../lib/init');
4
+ const pkg = require('../package.json');
5
+
6
+ const args = process.argv.slice(2);
7
+
8
+ function printHelp() {
9
+ process.stdout.write(`Dflow CLI ${pkg.version}
10
+
11
+ Usage:
12
+ dflow init Initialize Dflow specs in the current project
13
+ dflow --help Show this help
14
+ dflow --version Show the CLI version
15
+
16
+ Only the init subcommand is implemented in this version.
17
+ `);
18
+ }
19
+
20
+ function printInitHelp() {
21
+ process.stdout.write(`Usage:
22
+ dflow init
23
+
24
+ Initializes Dflow project specs under dflow/specs/.
25
+ The command prompts for project type, edition, tech stack, prose language,
26
+ and optional starter files before showing a full file preview.
27
+ `);
28
+ }
29
+
30
+ async function main() {
31
+ if (args.length === 0 || args[0] === '--help' || args[0] === '-h') {
32
+ printHelp();
33
+ return 0;
34
+ }
35
+
36
+ if (args[0] === '--version' || args[0] === '-v') {
37
+ process.stdout.write(`${pkg.version}\n`);
38
+ return 0;
39
+ }
40
+
41
+ if (args[0] === 'init') {
42
+ if (args.length > 1 && (args[1] === '--help' || args[1] === '-h')) {
43
+ printInitHelp();
44
+ return 0;
45
+ }
46
+
47
+ if (args.length > 1) {
48
+ process.stderr.write(`Unsupported init option: ${args.slice(1).join(' ')}\n`);
49
+ return 1;
50
+ }
51
+
52
+ return await runInit({
53
+ cwd: process.cwd(),
54
+ stdin: process.stdin,
55
+ stdout: process.stdout,
56
+ stderr: process.stderr
57
+ });
58
+ }
59
+
60
+ process.stderr.write(`Unsupported subcommand: ${args[0]}\n\n`);
61
+ printHelp();
62
+ return 1;
63
+ }
64
+
65
+ main()
66
+ .then((code) => {
67
+ process.exitCode = code;
68
+ })
69
+ .catch((error) => {
70
+ process.stderr.write(`${error && error.message ? error.message : error}\n`);
71
+ process.exitCode = 1;
72
+ });