dflow-sdd-ddd 0.1.0 → 0.1.1
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.
- package/README.md +136 -160
- package/bin/dflow.js +37 -8
- package/docs/why-ddd-for-ai.md +35 -0
- package/lib/init.js +347 -65
- package/package.json +9 -7
- package/templates/brownfield/scaffolding/AI-AGENT-GUIDE.md +64 -0
- package/templates/{webforms → brownfield}/scaffolding/CLAUDE-md-snippet.md +7 -9
- package/templates/{webforms → brownfield}/scaffolding/Git-principles-gitflow.md +1 -1
- package/templates/{webforms → brownfield}/scaffolding/Git-principles-trunk.md +1 -1
- package/templates/{webforms → brownfield}/scaffolding/_conventions.md +1 -1
- package/templates/{webforms → brownfield}/scaffolding/_overview.md +2 -2
- package/templates/{webforms → brownfield}/templates/context-map.md +1 -1
- package/templates/{webforms → brownfield}/templates/glossary.md +1 -1
- package/templates/{webforms → brownfield}/templates/models.md +1 -1
- package/templates/{webforms → brownfield}/templates/phase-spec.md +1 -1
- package/templates/{webforms → brownfield}/templates/rules.md +1 -1
- package/templates/{webforms → brownfield}/templates/tech-debt.md +1 -1
- package/templates/greenfield/scaffolding/AI-AGENT-GUIDE.md +64 -0
- package/templates/{core → greenfield}/scaffolding/CLAUDE-md-snippet.md +14 -14
- package/templates/{core → greenfield}/scaffolding/Git-principles-gitflow.md +1 -1
- package/templates/{core → greenfield}/scaffolding/Git-principles-trunk.md +1 -1
- package/templates/{core → greenfield}/scaffolding/_conventions.md +1 -1
- package/templates/{core → greenfield}/scaffolding/_overview.md +2 -2
- package/templates/{core → greenfield}/scaffolding/architecture-decisions-README.md +1 -1
- package/templates/{core → greenfield}/templates/context-map.md +1 -1
- package/templates/{core → greenfield}/templates/events.md +1 -1
- package/templates/{core → greenfield}/templates/glossary.md +1 -1
- package/templates/{core → greenfield}/templates/models.md +1 -1
- package/templates/{core → greenfield}/templates/phase-spec.md +1 -1
- package/templates/{core → greenfield}/templates/rules.md +1 -1
- package/templates/{core → greenfield}/templates/tech-debt.md +1 -1
- /package/templates/{webforms → brownfield}/templates/CLAUDE.md +0 -0
- /package/templates/{webforms → brownfield}/templates/_index.md +0 -0
- /package/templates/{webforms → brownfield}/templates/behavior.md +0 -0
- /package/templates/{webforms → brownfield}/templates/context-definition.md +0 -0
- /package/templates/{webforms → brownfield}/templates/lightweight-spec.md +0 -0
- /package/templates/{core → greenfield}/templates/CLAUDE.md +0 -0
- /package/templates/{core → greenfield}/templates/_index.md +0 -0
- /package/templates/{core → greenfield}/templates/aggregate-design.md +0 -0
- /package/templates/{core → greenfield}/templates/behavior.md +0 -0
- /package/templates/{core → greenfield}/templates/context-definition.md +0 -0
- /package/templates/{core → greenfield}/templates/lightweight-spec.md +0 -0
package/README.md
CHANGED
|
@@ -1,209 +1,185 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Dflow
|
|
2
2
|
|
|
3
|
-
AI
|
|
3
|
+
Dflow is a spec-first workflow kit for AI-assisted software development. It gives your AI coding agent a concrete process for turning change requests into structured specs, domain language, implementation plans, drift checks, and reviewable code instead of jumping straight from prompt to code.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
AI makes delivery faster, but it also makes ambiguous domain knowledge more dangerous. Dflow uses DDD ideas such as ubiquitous language, bounded contexts, domain rules, and model ownership as the semantic backbone of SDD, so the AI has constraints before it generates code. The goal is not ceremony for its own sake; the goal is repeatable software change with clearer meaning, fewer scattered rules, and less prompt-dependent behavior.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## Key Features
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
-
|
|
12
|
-
|
|
13
|
-
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
| Feature | What it gives engineering teams |
|
|
10
|
+
|---|---|
|
|
11
|
+
| **Spec-first development** | Every meaningful change starts from an explicit spec, acceptance behavior, and implementation plan before code changes begin. |
|
|
12
|
+
| **Greenfield and Brownfield tracks** | Start clean in a new project, or introduce Dflow into an existing codebase through progressive domain extraction and safer incremental change. |
|
|
13
|
+
| **Hybrid workflow control** | Command-first entry points for intentional work, auto-trigger checks as a safety net, and transparent phase gates so developers stay in control. |
|
|
14
|
+
| **DDD semantic backbone** | Captures domain language, context boundaries, business rules, and model decisions so AI output is constrained by project meaning. |
|
|
15
|
+
| **Three-layer documentation model** | Keeps short-lived phase deltas, feature snapshots, and system-level state separate, so specs stay useful instead of becoming one large document dump. |
|
|
16
|
+
| **Drift verification** | Checks whether specs, domain documents, implementation, tests, and technical debt records still describe the same system. |
|
|
16
17
|
|
|
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
|
-
```
|
|
18
|
+
## Get Started
|
|
29
19
|
|
|
30
|
-
|
|
20
|
+
Run Dflow from the root of the project you want to adopt it in:
|
|
31
21
|
|
|
32
|
-
|
|
22
|
+
```bash
|
|
23
|
+
npx dflow-sdd-ddd init
|
|
24
|
+
```
|
|
33
25
|
|
|
34
|
-
|
|
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 設計工作表、模擬練習計畫 |
|
|
26
|
+
The init flow asks whether the project is greenfield or brownfield, then previews the files it will create. Existing files are not overwritten.
|
|
42
27
|
|
|
43
|
-
|
|
28
|
+
For a fixed global CLI:
|
|
44
29
|
|
|
45
|
-
|
|
30
|
+
```bash
|
|
31
|
+
npm install -g dflow-sdd-ddd
|
|
32
|
+
dflow init
|
|
33
|
+
```
|
|
46
34
|
|
|
47
|
-
|
|
48
|
-
|
|
35
|
+
If the project is already initialized and you later add another AI coding
|
|
36
|
+
tool, run:
|
|
49
37
|
|
|
50
|
-
|
|
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 原則模板 |
|
|
38
|
+
```bash
|
|
39
|
+
dflow configure-agents
|
|
40
|
+
```
|
|
68
41
|
|
|
69
|
-
|
|
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 文件模板 |
|
|
42
|
+
This command only configures AI instruction files. It does not rerun project
|
|
43
|
+
initialization or touch existing specs.
|
|
79
44
|
|
|
80
|
-
|
|
45
|
+
After init, start work through the Dflow workflow in your AI coding agent:
|
|
81
46
|
|
|
82
|
-
|
|
47
|
+
```text
|
|
48
|
+
/dflow:new-feature
|
|
49
|
+
/dflow:modify-existing
|
|
50
|
+
/dflow:bug-fix
|
|
51
|
+
/dflow:new-phase
|
|
52
|
+
/dflow:finish-feature
|
|
53
|
+
/dflow:verify
|
|
54
|
+
/dflow:pr-review
|
|
55
|
+
```
|
|
83
56
|
|
|
84
|
-
|
|
85
|
-
在 WebForms 版基礎上新增:Clean Architecture 四層架構圖、各層不可妥協的規範、DDD 戰術模式的引導問題。
|
|
57
|
+
If your tool does not support custom slash commands, use the same command names as plain instructions in chat. Dflow is Markdown-based workflow material plus a scaffolding CLI, so it can be used with AI coding agents that can read project instructions and repository context.
|
|
86
58
|
|
|
87
|
-
|
|
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 原則模板 |
|
|
59
|
+
## Project Tracks
|
|
107
60
|
|
|
108
|
-
|
|
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 概念 |
|
|
61
|
+
| Track | Use it when | Main outcome |
|
|
124
62
|
|---|---|---|
|
|
125
|
-
|
|
|
126
|
-
|
|
|
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 檢視 | 流程改善 |
|
|
63
|
+
| **Greenfield** | You are starting a new system or a new bounded area with room to shape architecture and domain model early. | Clean spec baseline, domain model ownership, feature-by-feature implementation through SDD. |
|
|
64
|
+
| **Brownfield** | You are adding or changing behavior in an existing codebase where business rules may already be scattered. | Progressive domain extraction, safer change planning, and migration-ready domain knowledge. |
|
|
132
65
|
|
|
133
|
-
|
|
66
|
+
These tracks describe adoption style, not framework branding. Dflow should be read as a workflow system for software teams that want AI assistance without giving up domain clarity.
|
|
134
67
|
|
|
135
|
-
##
|
|
68
|
+
## Workflow Model
|
|
136
69
|
|
|
137
|
-
Dflow
|
|
70
|
+
Dflow uses a hybrid design:
|
|
138
71
|
|
|
139
|
-
|
|
72
|
+
| Layer | Purpose |
|
|
73
|
+
|---|---|
|
|
74
|
+
| **Command-first entry** | Developers intentionally start work with commands such as `/dflow:new-feature` or `/dflow:modify-existing`. |
|
|
75
|
+
| **Auto-trigger safety net** | When the conversation clearly implies a feature, phase, bug fix, verification, or review, the AI should suggest the matching Dflow flow. |
|
|
76
|
+
| **Transparency gates** | The AI announces flow entry, phase transitions, and important internal steps so the developer can approve direction before work expands. |
|
|
140
77
|
|
|
141
|
-
|
|
78
|
+
Dflow also scales ceremony by change risk:
|
|
142
79
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
80
|
+
| Tier | Typical use | Expected weight |
|
|
81
|
+
|---|---|---|
|
|
82
|
+
| **T1 Lightweight** | Small bug fixes or narrow edits. | Minimal spec, focused verification. |
|
|
83
|
+
| **T2 Standard** | Normal feature work. | Feature spec, behavior examples, implementation plan, finish checks. |
|
|
84
|
+
| **T3 Full** | Cross-cutting changes, new bounded contexts, risky architecture work. | Full domain modeling, phase planning, broader drift verification, stronger review gates. |
|
|
147
85
|
|
|
148
|
-
The
|
|
86
|
+
The transparency gates and T1/T2/T3 tiers are related but separate: transparency controls how the AI communicates the workflow; tiers control how much specification and verification the change needs.
|
|
149
87
|
|
|
150
|
-
|
|
88
|
+
## Documentation Model
|
|
151
89
|
|
|
152
|
-
|
|
90
|
+
Dflow separates documents by lifecycle:
|
|
153
91
|
|
|
154
|
-
|
|
92
|
+
| Layer | Shape | Purpose |
|
|
93
|
+
|---|---|---|
|
|
94
|
+
| **Phase Delta** | Short-lived phase spec. | Captures what this phase changes, why, and how it will be verified. |
|
|
95
|
+
| **Feature Snapshot** | Feature-level summary and behavior. | Preserves the accepted behavior and implementation decisions after phases complete. |
|
|
96
|
+
| **System State** | Shared domain and architecture documents. | Maintains durable knowledge such as glossary, context map, rules, models, conventions, and technical debt. |
|
|
97
|
+
|
|
98
|
+
This keeps AI collaboration grounded. The phase layer gives the agent immediate execution context, the feature layer records what was delivered, and the system layer becomes the long-term source of truth for future prompts and reviews.
|
|
99
|
+
|
|
100
|
+
## Files Created by Init
|
|
101
|
+
|
|
102
|
+
A typical initialized project receives a `dflow/` workspace:
|
|
103
|
+
|
|
104
|
+
```text
|
|
105
|
+
dflow/
|
|
106
|
+
specs/
|
|
107
|
+
shared/
|
|
108
|
+
_overview.md
|
|
109
|
+
_conventions.md
|
|
110
|
+
Git-principles-*.md
|
|
111
|
+
domain/
|
|
112
|
+
glossary.md
|
|
113
|
+
context-map.md
|
|
114
|
+
architecture/
|
|
115
|
+
tech-debt.md
|
|
116
|
+
features/
|
|
117
|
+
active/
|
|
118
|
+
completed/
|
|
119
|
+
```
|
|
155
120
|
|
|
156
|
-
|
|
121
|
+
Dflow also creates or provides a mergeable project instruction file for your AI coding agent. The exact file depends on the target tool and existing project setup; Dflow avoids overwriting existing project instructions.
|
|
157
122
|
|
|
158
|
-
|
|
123
|
+
When you select AI agent setup during init, Dflow writes
|
|
124
|
+
`dflow/specs/shared/AI-AGENT-GUIDE.md` as the canonical project guide, then
|
|
125
|
+
creates small tool-specific shims that point back to it:
|
|
159
126
|
|
|
160
|
-
|
|
|
161
|
-
|
|
162
|
-
|
|
|
163
|
-
|
|
|
164
|
-
|
|
|
165
|
-
|
|
|
127
|
+
| Tool target | Generated file |
|
|
128
|
+
|---|---|
|
|
129
|
+
| Codex / Copilot coding agent | `AGENTS.md` |
|
|
130
|
+
| Claude Code | `CLAUDE.md` |
|
|
131
|
+
| Gemini CLI | `GEMINI.md` |
|
|
132
|
+
| GitHub Copilot | `.github/copilot-instructions.md` |
|
|
166
133
|
|
|
167
|
-
|
|
134
|
+
If one of those files already exists, Dflow leaves it unchanged and writes a
|
|
135
|
+
merge snippet under `dflow/specs/shared/` instead. The project guide stays the
|
|
136
|
+
single source of truth, so teams can use multiple AI tools without maintaining
|
|
137
|
+
multiple copies of the workflow rules.
|
|
168
138
|
|
|
169
|
-
|
|
139
|
+
You can run `dflow configure-agents` later to add more tool shims as the team
|
|
140
|
+
adopts additional AI coding agents.
|
|
170
141
|
|
|
171
|
-
##
|
|
142
|
+
## Main Flows
|
|
172
143
|
|
|
173
|
-
|
|
144
|
+
| Flow | When to use it | Typical outputs |
|
|
145
|
+
|---|---|---|
|
|
146
|
+
| `/dflow:new-feature` | A new user-visible capability or business behavior. | Feature spec, behavior examples, phase plan, domain updates. |
|
|
147
|
+
| `/dflow:modify-existing` | A change to behavior already present in the system. | Impact analysis, updated specs, adjusted domain rules, migration notes when needed. |
|
|
148
|
+
| `/dflow:bug-fix` | A defect where expected behavior can be stated narrowly. | Lightweight spec, reproduction, fix plan, regression check. |
|
|
149
|
+
| `/dflow:new-phase` | A feature needs another implementation slice. | Phase delta, acceptance checks, focused implementation plan. |
|
|
150
|
+
| `/dflow:finish-feature` | The implementation is done and needs closure. | Drift verification, feature snapshot, technical debt update, review checklist. |
|
|
151
|
+
| `/dflow:verify` | You need confidence that docs and code still match. | Drift report across spec, domain docs, implementation, tests, and debt records. |
|
|
152
|
+
| `/dflow:pr-review` | A change is ready for review. | SDD/DDD compliance review with risks, gaps, and follow-up items. |
|
|
174
153
|
|
|
175
|
-
|
|
176
|
-
2. 依提示選擇 edition、starter files、project prose language
|
|
177
|
-
3. 預覽並確認寫入清單;Dflow 不會覆寫既有檔案
|
|
178
|
-
4. 啟動 AI coding agent,從 `/dflow:new-feature` 或 `/dflow:modify-existing` 開始
|
|
154
|
+
## Why DDD Matters More with AI
|
|
179
155
|
|
|
180
|
-
|
|
156
|
+
AI agents are strong at filling gaps. That is useful when the missing detail is mechanical, but risky when the missing detail is business meaning. If a prompt does not define the language, boundaries, and allowed behavior, the model may invent plausible rules that are hard to notice in review.
|
|
181
157
|
|
|
182
|
-
|
|
183
|
-
2. 啟動 Claude Code,輸入:
|
|
184
|
-
```
|
|
185
|
-
我要開始一個 DDD 模擬練習專案:員工費用報銷系統(ExpenseTracker)。
|
|
186
|
-
請依照 Skill 中定義的流程引導我,從 Phase 1 開始。
|
|
187
|
-
```
|
|
158
|
+
Dflow treats DDD as the semantic structure behind the spec. Ubiquitous language keeps names consistent. Bounded contexts keep meanings from leaking across areas. Domain rules define what is correct, allowed, or forbidden before implementation starts.
|
|
188
159
|
|
|
189
|
-
|
|
160
|
+
In a code-first workflow, design often appears after the fact in classes, handlers, and tests. In an AI-assisted workflow, the spec must become the precondition for generation. The practical flow becomes:
|
|
190
161
|
|
|
191
|
-
|
|
162
|
+
```text
|
|
163
|
+
Domain meaning -> Structured spec -> AI implementation -> Code as output
|
|
164
|
+
```
|
|
192
165
|
|
|
193
|
-
|
|
194
|
-
每一次程式碼變更都應該有對應的規格文件。規格不是額外的負擔,而是思考的工具——在寫程式之前先想清楚要做什麼。
|
|
166
|
+
For a longer explanation, see [Why DDD Matters More with AI](docs/why-ddd-for-ai.md).
|
|
195
167
|
|
|
196
|
-
|
|
197
|
-
AI 不只是回答問題的工具,它主動引導開發流程:在你開分支前確認規格存在、在你寫 Code-Behind 時提醒業務邏輯應該在 Domain 層、在 PR 時檢查架構合規性。
|
|
168
|
+
## Repository Layout
|
|
198
169
|
|
|
199
|
-
|
|
200
|
-
|
|
170
|
+
| Path | Purpose |
|
|
171
|
+
|---|---|
|
|
172
|
+
| `bin/` | CLI entrypoint. |
|
|
173
|
+
| `lib/` | Init runtime implementation. |
|
|
174
|
+
| `templates/` | Files copied by the init command. |
|
|
175
|
+
| `test/` | Smoke tests for generated output. |
|
|
176
|
+
| `tutorial/` | Guided learning scenarios and expected outputs. |
|
|
177
|
+
| `sdd-ddd-*-skill/` | Source workflow material consumed by AI coding agents. |
|
|
201
178
|
|
|
202
|
-
|
|
203
|
-
每次開發循環都產出:**規格文件**(未來的需求文件)、**Domain 層程式碼**(可直接遷移)、**技術債記錄**(遷移指南)。
|
|
179
|
+
## Status
|
|
204
180
|
|
|
205
|
-
|
|
181
|
+
Dflow is currently published as `dflow-sdd-ddd` on npm. Version `0.1.0` focuses on project initialization, workflow documentation, and AI-agent-readable SDD/DDD guidance. Additional packaging for specific AI tools can be layered on top without changing the core workflow model.
|
|
206
182
|
|
|
207
|
-
##
|
|
183
|
+
## License
|
|
208
184
|
|
|
209
185
|
MIT License. See [LICENSE](LICENSE).
|
package/bin/dflow.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
const { runInit } = require('../lib/init');
|
|
3
|
+
const { runConfigureAgents, runInit } = require('../lib/init');
|
|
4
4
|
const pkg = require('../package.json');
|
|
5
5
|
|
|
6
6
|
const args = process.argv.slice(2);
|
|
@@ -9,11 +9,10 @@ function printHelp() {
|
|
|
9
9
|
process.stdout.write(`Dflow CLI ${pkg.version}
|
|
10
10
|
|
|
11
11
|
Usage:
|
|
12
|
-
dflow init
|
|
13
|
-
dflow
|
|
14
|
-
dflow --
|
|
15
|
-
|
|
16
|
-
Only the init subcommand is implemented in this version.
|
|
12
|
+
dflow init Initialize Dflow specs in the current project
|
|
13
|
+
dflow configure-agents Add or update AI agent instruction shims
|
|
14
|
+
dflow --help Show this help
|
|
15
|
+
dflow --version Show the CLI version
|
|
17
16
|
`);
|
|
18
17
|
}
|
|
19
18
|
|
|
@@ -22,8 +21,19 @@ function printInitHelp() {
|
|
|
22
21
|
dflow init
|
|
23
22
|
|
|
24
23
|
Initializes Dflow project specs under dflow/specs/.
|
|
25
|
-
The command prompts for project type,
|
|
26
|
-
|
|
24
|
+
The command prompts for project type, tech stack, prose language,
|
|
25
|
+
optional starter files, and AI coding agents before showing a full file preview.
|
|
26
|
+
`);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function printConfigureAgentsHelp() {
|
|
30
|
+
process.stdout.write(`Usage:
|
|
31
|
+
dflow configure-agents
|
|
32
|
+
|
|
33
|
+
Adds AI agent instruction files to an existing Dflow project.
|
|
34
|
+
The command can create AGENTS.md, CLAUDE.md, GEMINI.md, and
|
|
35
|
+
.github/copilot-instructions.md shims that point to the canonical
|
|
36
|
+
dflow/specs/shared/AI-AGENT-GUIDE.md file.
|
|
27
37
|
`);
|
|
28
38
|
}
|
|
29
39
|
|
|
@@ -57,6 +67,25 @@ async function main() {
|
|
|
57
67
|
});
|
|
58
68
|
}
|
|
59
69
|
|
|
70
|
+
if (args[0] === 'configure-agents') {
|
|
71
|
+
if (args.length > 1 && (args[1] === '--help' || args[1] === '-h')) {
|
|
72
|
+
printConfigureAgentsHelp();
|
|
73
|
+
return 0;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (args.length > 1) {
|
|
77
|
+
process.stderr.write(`Unsupported configure-agents option: ${args.slice(1).join(' ')}\n`);
|
|
78
|
+
return 1;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return await runConfigureAgents({
|
|
82
|
+
cwd: process.cwd(),
|
|
83
|
+
stdin: process.stdin,
|
|
84
|
+
stdout: process.stdout,
|
|
85
|
+
stderr: process.stderr
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
60
89
|
process.stderr.write(`Unsupported subcommand: ${args[0]}\n\n`);
|
|
61
90
|
printHelp();
|
|
62
91
|
return 1;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Why DDD Matters More with AI
|
|
2
|
+
|
|
3
|
+
AI-assisted development changes the failure mode of software design. The team can produce more code faster, but unclear domain meaning is also amplified faster.
|
|
4
|
+
|
|
5
|
+
When a project lacks shared language and explicit boundaries, small inconsistencies spread:
|
|
6
|
+
|
|
7
|
+
- the same concept appears as `Order`, `Booking`, and `Transaction`
|
|
8
|
+
- APIs encode different meanings for similar actions
|
|
9
|
+
- business rules live in handlers, UI code, scripts, and tests
|
|
10
|
+
- nobody can confidently say which behavior is authoritative
|
|
11
|
+
|
|
12
|
+
An AI coding agent does not know the business domain by default. When the prompt is incomplete, it fills the missing parts with plausible logic. That logic may compile, pass superficial tests, and still be wrong. The most dangerous AI mistakes are often not syntax errors; they are reasonable-looking domain mistakes.
|
|
13
|
+
|
|
14
|
+
DDD gives the spec a semantic backbone:
|
|
15
|
+
|
|
16
|
+
| DDD idea | AI-era value |
|
|
17
|
+
|---|---|
|
|
18
|
+
| **Ubiquitous Language** | Keeps names and meanings stable across prompts, specs, code, and reviews. |
|
|
19
|
+
| **Bounded Context** | Defines where a term or rule is valid, and prevents accidental meaning leaks. |
|
|
20
|
+
| **Domain Model** | Gives behavior a clear owner instead of scattering rules across technical layers. |
|
|
21
|
+
| **Domain Rules** | States what is correct, allowed, forbidden, and exceptional before code generation. |
|
|
22
|
+
|
|
23
|
+
The important shift is where design lives. In older workflows, much of the real design could remain implicit in code. With AI, that is too late. The model needs constraints before it generates code.
|
|
24
|
+
|
|
25
|
+
```text
|
|
26
|
+
Without DDD:
|
|
27
|
+
Prompt -> AI fills gaps -> Code -> Hidden domain drift
|
|
28
|
+
|
|
29
|
+
With DDD:
|
|
30
|
+
Domain meaning -> Structured spec -> AI implementation -> Reviewable code
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Code still matters, but it is no longer the first place where meaning should be discovered. For AI collaboration, specs become the pre-generation contract, and DDD supplies the language, boundaries, and rules that make the contract precise.
|
|
34
|
+
|
|
35
|
+
Dflow is built around that idea: spec first, domain meaning explicit, AI constrained before implementation, and drift checked before the work is considered done.
|