dflow-sdd-ddd 0.1.1 → 0.3.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 (34) hide show
  1. package/CHANGELOG.md +2055 -0
  2. package/CONTRIBUTING.md +123 -0
  3. package/README.en.md +345 -0
  4. package/README.md +222 -102
  5. package/TEMPLATE-COVERAGE.md +46 -0
  6. package/TEMPLATE-LANGUAGE-GLOSSARY.md +52 -0
  7. package/bin/dflow.js +37 -1
  8. package/docs/evaluating-dflow.en.md +238 -0
  9. package/docs/evaluating-dflow.md +169 -0
  10. package/docs/migrating-to-dflow-v1.md +230 -0
  11. package/docs/npm-publish-checklist.md +93 -0
  12. package/docs/release-versioning-policy.md +99 -0
  13. package/docs/using-with-claude-code.en.md +210 -0
  14. package/docs/using-with-claude-code.md +191 -0
  15. package/docs/using-with-codex.en.md +248 -0
  16. package/docs/using-with-codex.md +224 -0
  17. package/docs/using-with-gemini-cli.en.md +200 -0
  18. package/docs/using-with-gemini-cli.md +184 -0
  19. package/docs/using-with-github-copilot.en.md +136 -0
  20. package/docs/using-with-github-copilot.md +177 -0
  21. package/docs/why-ddd-for-ai.en.md +37 -0
  22. package/docs/why-ddd-for-ai.md +19 -17
  23. package/lib/init.js +97 -1
  24. package/package.json +5 -1
  25. package/templates/brownfield/scaffolding/AI-AGENT-GUIDE.md +29 -0
  26. package/templates/brownfield/scaffolding/CLAUDE-md-snippet.md +8 -7
  27. package/templates/brownfield/scaffolding/_conventions.md +1 -0
  28. package/templates/brownfield/templates/CLAUDE.md +1 -1
  29. package/templates/brownfield/templates/phase-spec.md +23 -20
  30. package/templates/greenfield/scaffolding/AI-AGENT-GUIDE.md +29 -0
  31. package/templates/greenfield/scaffolding/CLAUDE-md-snippet.md +9 -7
  32. package/templates/greenfield/scaffolding/_conventions.md +2 -1
  33. package/templates/greenfield/templates/CLAUDE.md +1 -1
  34. package/templates/greenfield/templates/phase-spec.md +24 -21
@@ -0,0 +1,248 @@
1
+ # Using Dflow with Codex CLI
2
+
3
+ > [繁體中文](using-with-codex.md) | **English**
4
+
5
+ A walk-through of what Dflow looks like when your AI coding agent is
6
+ [Codex CLI](https://developers.openai.com/codex/cli). About 10 minutes to
7
+ read.
8
+
9
+ This guide focuses on the Codex CLI experience specifically. For the
10
+ tool-neutral evaluation flow, see
11
+ [`docs/evaluating-dflow.en.md`](evaluating-dflow.en.md). For the full Get Started
12
+ and feature list, see [`README.md`](../README.en.md).
13
+
14
+ ## Who This Guide Is For
15
+
16
+ You are using or evaluating Dflow with Codex CLI as your AI coding agent.
17
+ This guide covers what Codex sees after `init`, how the `AGENTS.md` shim
18
+ points to the canonical Dflow guide, and the Codex-specific command and
19
+ permission patterns worth knowing.
20
+
21
+ You do not need to read this before running `init`. It is most useful after
22
+ you have run `init` once and want to understand what Codex CLI is actually
23
+ loading.
24
+
25
+ ## Prerequisites
26
+
27
+ - Codex CLI installed and authenticated (see
28
+ [developers.openai.com/codex/cli](https://developers.openai.com/codex/cli)).
29
+ - Node.js / npm available (Dflow ships through npm). Install globally with
30
+ `npm install -g dflow-sdd-ddd`, or use `npx dflow-sdd-ddd` for the no-install path.
31
+ - A project directory you are comfortable initializing in. A branch or a
32
+ disposable sample project is recommended for first contact; see the
33
+ [evaluator guide playbook](evaluating-dflow.en.md#a-30-minute-evaluation-playbook).
34
+ - Codex started from the initialized project root, or with `codex --cd` set
35
+ to that root, so Codex's `AGENTS.md` discovery includes the Dflow shim.
36
+
37
+ Running Dflow workflows does not require a separate Dflow service or API key.
38
+ The workflows are Markdown-based instructions and project files.
39
+
40
+ ## What Codex CLI Sees After `init`
41
+
42
+ Running `dflow init` (or `npx dflow-sdd-ddd init` on the no-install path) and
43
+ selecting `AGENTS.md - Codex / Copilot coding agent` as a target tool creates
44
+ a thin shim at the project root:
45
+
46
+ ```markdown
47
+ # AGENTS.md - Dflow Project Instructions
48
+
49
+ This project uses Dflow for spec-first AI-assisted development.
50
+
51
+ Before planning or editing code, read and follow:
52
+
53
+ - `dflow/specs/shared/AI-AGENT-GUIDE.md`
54
+
55
+ Keep tool-specific instruction files small. The Dflow guide above is the
56
+ single source of truth for project workflow rules, slash-command behavior,
57
+ spec locations, and SDD/DDD constraints.
58
+ ```
59
+
60
+ Two things matter when Codex starts in this project:
61
+
62
+ 1. Codex CLI reads `AGENTS.md` as project instructions. This is Codex's
63
+ standard repository-instruction mechanism.
64
+ 2. The Dflow shim does not include a Markdown import line. Unlike the
65
+ Claude Code and Gemini shims, generated `AGENTS.md` does not contain
66
+ `@dflow/specs/shared/AI-AGENT-GUIDE.md`.
67
+
68
+ That means Codex sees the pointer immediately, but the canonical Dflow guide
69
+ is not auto-inlined by the shim. Before planning or editing, Codex should
70
+ follow the pointer and read `dflow/specs/shared/AI-AGENT-GUIDE.md`. If Codex
71
+ starts answering a Dflow request without mentioning that file, steer it
72
+ explicitly: "Before continuing, read and follow
73
+ `dflow/specs/shared/AI-AGENT-GUIDE.md`."
74
+
75
+ The canonical guide is where the real workflow rules live: project context
76
+ (track, tech stack, prose language), the Dflow workflow table,
77
+ source-of-truth file paths, and core SDD/DDD rules. The `AGENTS.md` shim
78
+ stays small so the same canonical guide can serve Codex CLI, Claude Code,
79
+ Gemini CLI, GitHub Copilot, and other tools.
80
+
81
+ If an `AGENTS.md` already existed in the project, `init` does not overwrite
82
+ it. If the existing file does not already point to
83
+ `dflow/specs/shared/AI-AGENT-GUIDE.md`, `init` writes a merge snippet under
84
+ `dflow/specs/shared/AGENTS-md-snippet.md` that you can merge manually. This
85
+ avoids destroying custom project instructions you already had.
86
+
87
+ ## Using Dflow Workflow Commands in Codex CLI
88
+
89
+ Codex CLI has its own built-in slash command layer for controlling the CLI
90
+ session. Commands such as `/permissions`, `/model`, `/status`, `/diff`,
91
+ `/review`, and `/init` are Codex CLI controls, not Dflow workflows.
92
+
93
+ Dflow's `/dflow:*` entries are workflow names recognized by the AI through
94
+ `AI-AGENT-GUIDE.md`, not registered Codex CLI commands. Raw
95
+ `/dflow:new-feature` passthrough behavior in Codex CLI should be verified
96
+ with the maintainer for the supported Codex version. The reliable form is to
97
+ name the workflow as a plain chat instruction:
98
+
99
+ ```text
100
+ Run the Dflow /dflow:new-feature workflow.
101
+ ```
102
+
103
+ If your Codex CLI version passes unknown slash-prefixed input through to the
104
+ model, this shorter form may also work (verify with maintainer):
105
+
106
+ ```text
107
+ /dflow:new-feature
108
+ ```
109
+
110
+ If Codex reports an unknown slash command, re-send the request in prose:
111
+
112
+ ```text
113
+ Treat /dflow:new-feature as a Dflow workflow name, not as a Codex CLI
114
+ command. Read dflow/specs/shared/AI-AGENT-GUIDE.md and start that workflow.
115
+ ```
116
+
117
+ A typical conversation looks like:
118
+
119
+ ```text
120
+ You: Run the Dflow /dflow:new-feature workflow.
121
+
122
+ Codex CLI: I'll read dflow/specs/shared/AI-AGENT-GUIDE.md first, then use the
123
+ new-feature workflow. Please describe the user-visible capability or business
124
+ behavior you want to add.
125
+
126
+ You: Allow expense submitters to attach a receipt image when filing an
127
+ expense.
128
+
129
+ Codex CLI: I'll start by drafting a feature spec under
130
+ dflow/specs/features/active/. Before I do, I have a few clarifying questions.
131
+ ```
132
+
133
+ The workflow then walks you through spec drafting, behavior examples,
134
+ implementation planning, and finish-feature drift checks. The exact
135
+ sequence depends on which workflow you entered (`/dflow:new-feature`,
136
+ `/dflow:modify-existing`, `/dflow:bug-fix`, etc.).
137
+
138
+ Available workflow entry points:
139
+
140
+ | Workflow | Use when |
141
+ |---|---|
142
+ | `/dflow:new-feature` | A new user-visible capability or business behavior is requested. |
143
+ | `/dflow:modify-existing` | Existing behavior needs to change. |
144
+ | `/dflow:bug-fix` | A defect can be described with expected vs actual behavior. |
145
+ | `/dflow:new-phase` | An active feature needs another implementation slice. |
146
+ | `/dflow:finish-feature` | Implementation is complete and needs drift closure. |
147
+ | `/dflow:verify` | Specs, domain docs, implementation, and tests need consistency checks. |
148
+ | `/dflow:pr-review` | A change is ready for SDD/DDD review. |
149
+ | `/dflow:report-dflow-feedback` | You found a Dflow issue or improvement and want a sanitized upstream feedback draft. |
150
+
151
+ If you forget a workflow name, ask Codex to read
152
+ `dflow/specs/shared/AI-AGENT-GUIDE.md` and list the available Dflow
153
+ workflows.
154
+
155
+ ## Differences vs Other AI Tools
156
+
157
+ The canonical guide (`dflow/specs/shared/AI-AGENT-GUIDE.md`) is identical
158
+ across tools. Only the root-level shim differs:
159
+
160
+ | Tool | Generated shim | Loads canonical guide via |
161
+ |---|---|---|
162
+ | Claude Code | `CLAUDE.md` | `@dflow/specs/shared/AI-AGENT-GUIDE.md` Markdown import |
163
+ | Codex / Copilot coding agent | `AGENTS.md` | Project instructions load the shim; Codex must follow the pointer and read the guide |
164
+ | Gemini CLI | `GEMINI.md` | `@dflow/specs/shared/AI-AGENT-GUIDE.md` Markdown import |
165
+ | GitHub Copilot | `.github/copilot-instructions.md` | Reads repository instructions directly |
166
+
167
+ You can run `dflow configure-agents` later to add another tool's shim
168
+ without re-running `init`. Multiple tools can be active in the same project
169
+ and stay synchronized via the canonical guide.
170
+
171
+ Codex also has its own project-instruction layering. It can read global
172
+ instructions from Codex home and project instructions from `AGENTS.md` files
173
+ between the project root and the current working directory. For Dflow, the
174
+ important practical rule is simple: start Codex at the initialized project
175
+ root, and keep the Dflow pointer in the nearest relevant `AGENTS.md`.
176
+
177
+ If your team uses both Claude Code and Codex CLI on the same project, no
178
+ extra Dflow coordination is needed. Both tools use the same canonical guide;
179
+ only the shim file and loading mechanism differ.
180
+
181
+ ## Common Patterns and Gotchas
182
+
183
+ **Keep `AGENTS.md` thin.** If you find yourself adding workflow rules, spec
184
+ locations, or SDD constraints to `AGENTS.md`, those belong in
185
+ `dflow/specs/shared/AI-AGENT-GUIDE.md` instead. The shim stays small so that
186
+ other tools' shims do not drift away from it.
187
+
188
+ **Codex does not inline the Dflow guide from `AGENTS.md`.** The generated
189
+ Codex shim has a normal Markdown bullet pointing to the canonical guide, not
190
+ an `@...` import. Ask Codex to read `AI-AGENT-GUIDE.md` if it appears to be
191
+ working from the shim alone.
192
+
193
+ **`/dflow:*` is not a Codex CLI built-in slash command.** Codex slash
194
+ commands control the Codex session itself. Use Dflow workflow names as plain
195
+ chat instructions when raw slash input is intercepted or rejected. Raw
196
+ `/dflow:*` passthrough behavior should be verified with the maintainer for
197
+ the supported Codex version.
198
+
199
+ **Do not confuse Codex `/init` with Dflow `init`.** Codex `/init` creates a
200
+ generic `AGENTS.md` scaffold for Codex. Dflow setup is `dflow init` (or
201
+ `npx dflow-sdd-ddd init` on the no-install path), and adding later tool shims
202
+ is `dflow configure-agents`.
203
+
204
+ **Permission gates and Dflow workflow gates are separate.** Codex may ask
205
+ permission to run a command, edit outside the workspace, or access network
206
+ depending on its sandbox and approval settings. Dflow workflows have their
207
+ own approval gates, such as confirming a spec before implementation. Both
208
+ can appear in the same session; this is expected.
209
+
210
+ **The common Codex local-work preset is workspace write plus on-request
211
+ approvals.** In current Codex CLI terminology this is
212
+ `--sandbox workspace-write --ask-for-approval on-request`. In that mode,
213
+ Codex can work inside the project and asks before going beyond the sandbox,
214
+ such as writing outside the workspace or accessing network.
215
+
216
+ **Existing `AGENTS.md` files are preserved.** If Dflow cannot safely write
217
+ the root shim because the file already exists, look under
218
+ `dflow/specs/shared/` for the merge snippet and merge the Dflow pointer into
219
+ your existing project instructions manually.
220
+
221
+ **Nested `AGENTS.md` files can change what Codex sees.** Codex layers project
222
+ instructions along the path to the current working directory. If a subfolder
223
+ has its own `AGENTS.md` or `AGENTS.override.md`, make sure it does not hide
224
+ or contradict the Dflow pointer you expect Codex to follow.
225
+
226
+ ## Where to Go Next
227
+
228
+ If you have not run `init` yet:
229
+
230
+ - Follow the [evaluator guide playbook](evaluating-dflow.en.md#a-30-minute-evaluation-playbook)
231
+ to try it on a disposable sample project.
232
+
233
+ If you have run `init` and want to see end-to-end workflow examples:
234
+
235
+ - Read [`tutorial/01-greenfield/`](../tutorial/01-greenfield/walkthrough-00-setup.md) or
236
+ [`tutorial/02-brownfield/`](../tutorial/02-brownfield/walkthrough-00-setup.md). The
237
+ tutorial walk-throughs show conversation flows and the resulting
238
+ `dflow/specs/` outputs.
239
+
240
+ If you want to understand the design rationale:
241
+
242
+ - Read [`docs/why-ddd-for-ai.en.md`](why-ddd-for-ai.en.md).
243
+
244
+ If something does not work as described:
245
+
246
+ - File a docs feedback issue (see [`CONTRIBUTING.md`](../CONTRIBUTING.md)).
247
+ Per-tool documentation is new and feedback specifically about Codex CLI
248
+ behavior is valuable.
@@ -0,0 +1,224 @@
1
+ # 在 Codex CLI 中使用 Dflow
2
+
3
+ > **繁體中文** | [English](using-with-codex.en.md)
4
+
5
+ 當你的 AI 程式設計助理是 [Codex CLI](https://developers.openai.com/codex/cli) 時,Dflow 的使用體驗 walk-through。閱讀約需 10 分鐘。
6
+
7
+ 本指南專注於 Codex CLI 的具體使用體驗。工具中立的評估流程請見
8
+ [`docs/evaluating-dflow.md`](evaluating-dflow.md)。完整的 Get Started
9
+ 與功能列表請見 [`README.md`](../README.md)。
10
+
11
+ ## 本指南的適用對象
12
+
13
+ 你正在使用或評估以 Codex CLI 作為 AI 程式設計助理的 Dflow。
14
+ 本指南說明 `init` 之後 Codex 看到了什麼、`AGENTS.md` 薄 shim 是如何指向
15
+ canonical Dflow 指南的,以及幾個值得了解的 Codex 專屬指令與權限模式。
16
+
17
+ 你不需要在執行 `init` 之前先讀本指南。它最適合在你執行過一次 `init` 之後、
18
+ 想了解 Codex CLI 實際載入什麼內容時閱讀。
19
+
20
+ ## 前置條件
21
+
22
+ - 已安裝並完成認證的 Codex CLI(見
23
+ [developers.openai.com/codex/cli](https://developers.openai.com/codex/cli))。
24
+ - 已具備 Node.js / npm 環境(Dflow 透過 npm 發佈)。以
25
+ `npm install -g dflow-sdd-ddd` 全域安裝,或用 `npx dflow-sdd-ddd` 走免安裝路徑。
26
+ - 有一個你願意在其中執行 init 的專案目錄。首次嘗試建議先用 branch 或
27
+ 可拋棄的範例專案;見
28
+ [評估者指南 Playbook](evaluating-dflow.md#30-分鐘評估-playbook)。
29
+ - Codex 從已初始化的專案根目錄啟動,或以 `codex --cd` 指向該根目錄,
30
+ 確保 Codex 的 `AGENTS.md` 探索範圍包含 Dflow shim。
31
+
32
+ 執行 Dflow workflow 不需要獨立的 Dflow 服務或 API 金鑰。
33
+ 這些 workflow 是 Markdown-based 的指示與專案檔案。
34
+
35
+ ## `init` 之後 Codex CLI 看到了什麼
36
+
37
+ 執行 `dflow init`(或免安裝路徑的 `npx dflow-sdd-ddd init`)並選擇
38
+ `AGENTS.md - Codex / Copilot coding agent` 作為目標工具後,會在專案根目錄
39
+ 建立一個薄 shim:
40
+
41
+ ```markdown
42
+ # AGENTS.md - Dflow Project Instructions
43
+
44
+ This project uses Dflow for spec-first AI-assisted development.
45
+
46
+ Before planning or editing code, read and follow:
47
+
48
+ - `dflow/specs/shared/AI-AGENT-GUIDE.md`
49
+
50
+ Keep tool-specific instruction files small. The Dflow guide above is the
51
+ single source of truth for project workflow rules, slash-command behavior,
52
+ spec locations, and SDD/DDD constraints.
53
+ ```
54
+
55
+ Codex 在這個專案中啟動時,有兩件事值得注意:
56
+
57
+ 1. Codex CLI 將 `AGENTS.md` 作為專案指示讀取。這是 Codex 的
58
+ 標準 repository 指示機制。
59
+ 2. Dflow shim 不含 Markdown import 那一行。與 Claude Code 和 Gemini 的
60
+ shim 不同,產生的 `AGENTS.md` 不含 `@dflow/specs/shared/AI-AGENT-GUIDE.md`。
61
+
62
+ 這意味著 Codex 能立即看到指標,但 canonical Dflow 指南不會由 shim 自動 inline 嵌入。
63
+ 在規劃或編輯之前,Codex 應跟著指標讀取 `dflow/specs/shared/AI-AGENT-GUIDE.md`。
64
+ 若 Codex 在回應 Dflow 請求時沒有提到該檔案,請明確引導它:「Before continuing,
65
+ read and follow `dflow/specs/shared/AI-AGENT-GUIDE.md`.」
66
+
67
+ canonical 指南是實際 workflow 規則的所在:專案上下文(track、技術棧、
68
+ 文章語言)、Dflow workflow 表、source-of-truth 檔案路徑,以及核心 SDD/DDD 規則。
69
+ `AGENTS.md` shim 刻意保持精簡,這樣 canonical 指南就能同時服務 Codex CLI、
70
+ Claude Code、Gemini CLI、GitHub Copilot 與其他工具。
71
+
72
+ 如果專案中已有 `AGENTS.md`,`init` 不會覆蓋它。若既有檔案尚未指向
73
+ `dflow/specs/shared/AI-AGENT-GUIDE.md`,`init` 會在
74
+ `dflow/specs/shared/AGENTS-md-snippet.md` 下寫入 merge snippet,
75
+ 讓你手動合併。這樣可以避免破壞你已有的自訂專案指示。
76
+
77
+ ## 在 Codex CLI 中使用 Dflow Workflow 指令
78
+
79
+ Codex CLI 有自己的內建 slash command 層,用來控制 CLI session。
80
+ `/permissions`、`/model`、`/status`、`/diff`、`/review`、`/init` 等指令
81
+ 都是 Codex CLI 控制項,不是 Dflow workflow。
82
+
83
+ Dflow 的 `/dflow:*` 項目是 AI 透過 `AI-AGENT-GUIDE.md` 識別的 workflow
84
+ 名稱,不是已註冊的 Codex CLI 指令。`/dflow:new-feature` 在 Codex CLI 中
85
+ 能否直接傳遞到模型,需依所用的 Codex 版本向 maintainer 確認。
86
+ 最可靠的方式是以普通對話指示輸入 workflow 名稱:
87
+
88
+ ```text
89
+ Run the Dflow /dflow:new-feature workflow.
90
+ ```
91
+
92
+ 若你的 Codex CLI 版本會將未知的 slash 前綴輸入傳遞到模型,也可嘗試以下
93
+ 較短形式(請先向 maintainer 確認):
94
+
95
+ ```text
96
+ /dflow:new-feature
97
+ ```
98
+
99
+ 若 Codex 回報未知 slash command,改以純文字重新送出:
100
+
101
+ ```text
102
+ Treat /dflow:new-feature as a Dflow workflow name, not as a Codex CLI
103
+ command. Read dflow/specs/shared/AI-AGENT-GUIDE.md and start that workflow.
104
+ ```
105
+
106
+ 典型的對話如下:
107
+
108
+ ```text
109
+ You: Run the Dflow /dflow:new-feature workflow.
110
+
111
+ Codex CLI: I'll read dflow/specs/shared/AI-AGENT-GUIDE.md first, then use the
112
+ new-feature workflow. Please describe the user-visible capability or business
113
+ behavior you want to add.
114
+
115
+ You: Allow expense submitters to attach a receipt image when filing an
116
+ expense.
117
+
118
+ Codex CLI: I'll start by drafting a feature spec under
119
+ dflow/specs/features/active/. Before I do, I have a few clarifying questions.
120
+ ```
121
+
122
+ 接著這個 workflow 會引導你完成 spec 起草、行為範例、實作計畫,以及
123
+ finish-feature 漂移(drift)檢查。確切的流程取決於你進入的是哪個 workflow
124
+ (`/dflow:new-feature`、`/dflow:modify-existing`、`/dflow:bug-fix` 等)。
125
+
126
+ 可用的 workflow 入口:
127
+
128
+ | 指令 | 適用情境 |
129
+ |---|---|
130
+ | `/dflow:new-feature` | 需要新增一個使用者可見的功能或業務行為。 |
131
+ | `/dflow:modify-existing` | 需要修改現有行為。 |
132
+ | `/dflow:bug-fix` | 可以用預期行為 vs 實際行為描述的缺陷。 |
133
+ | `/dflow:new-phase` | 進行中的 feature 需要另一個實作 slice。 |
134
+ | `/dflow:finish-feature` | 實作完成後需要進行漂移(drift)收尾。 |
135
+ | `/dflow:verify` | 需要對 spec、領域文件、實作與測試進行一致性檢查。 |
136
+ | `/dflow:pr-review` | 變更已準備好進行 SDD/DDD review。 |
137
+ | `/dflow:report-dflow-feedback` | 你發現了 Dflow 的問題或改進點,想要一份清理過的上游回饋草稿。 |
138
+
139
+ 如果你忘了 workflow 名稱,請 Codex 讀取 `dflow/specs/shared/AI-AGENT-GUIDE.md`
140
+ 並列出可用的 Dflow workflow 即可。
141
+
142
+ ## 與其他 AI 工具的差異
143
+
144
+ canonical 指南(`dflow/specs/shared/AI-AGENT-GUIDE.md`)在各工具之間是相同的。
145
+ 只有根目錄層的 shim 有所不同:
146
+
147
+ | 工具 | 產生的 shim | 載入 canonical 指南的方式 |
148
+ |---|---|---|
149
+ | Claude Code | `CLAUDE.md` | `@dflow/specs/shared/AI-AGENT-GUIDE.md` Markdown import |
150
+ | Codex / Copilot coding agent | `AGENTS.md` | 專案指示載入 shim;Codex 須跟著指標讀取指南 |
151
+ | Gemini CLI | `GEMINI.md` | `@dflow/specs/shared/AI-AGENT-GUIDE.md` Markdown import |
152
+ | GitHub Copilot | `.github/copilot-instructions.md` | 直接讀取 repository 指示 |
153
+
154
+ 你可以之後執行 `dflow configure-agents` 來新增另一個工具的 shim,而不需要重跑
155
+ `init`。同一個專案可以同時啟用多個工具,並透過 canonical 指南保持同步。
156
+
157
+ Codex 也有自己的專案指示分層機制。它可以從 Codex home 讀取全域指示、
158
+ 從專案根目錄到當前工作目錄之間的 `AGENTS.md` 檔案讀取專案指示。
159
+ 對 Dflow 而言,關鍵的實務規則很簡單:從已初始化的專案根目錄啟動 Codex,
160
+ 並將 Dflow 指標保留在最近一層相關的 `AGENTS.md` 中。
161
+
162
+ 如果你的團隊在同一個專案中同時使用 Claude Code 和 Codex CLI,
163
+ 不需要額外的 Dflow 協調。兩個工具都讀取相同的 canonical 指南;
164
+ 只有 shim 檔案與載入機制不同。
165
+
166
+ ## 常見模式與注意事項
167
+
168
+ **保持 `AGENTS.md` 精簡。** 如果你發現自己在把 workflow 規則、spec 路徑或
169
+ SDD 約束加入 `AGENTS.md`,這些內容應該放到
170
+ `dflow/specs/shared/AI-AGENT-GUIDE.md`。shim 保持精簡,其他工具的 shim 才不會
171
+ 與它產生漂移(drift)。
172
+
173
+ **Codex 不會從 `AGENTS.md` inline 嵌入 Dflow 指南。** 產生的 Codex shim
174
+ 是以普通的 Markdown bullet 指向 canonical 指南,而非 `@...` import。
175
+ 若 Codex 看起來只從 shim 工作,請要求它讀取 `AI-AGENT-GUIDE.md`。
176
+
177
+ **`/dflow:*` 不是 Codex CLI 的內建 slash command。** Codex slash command 控制
178
+ 的是 Codex session 本身。當 slash 輸入被攔截或拒絕時,改用普通對話指示
179
+ 輸入 Dflow workflow 名稱。`/dflow:*` 的直通行為需依所用的 Codex 版本向
180
+ maintainer 確認。
181
+
182
+ **不要混淆 Codex `/init` 與 Dflow `init`。** Codex `/init` 為 Codex 建立
183
+ 通用的 `AGENTS.md` scaffold。Dflow 的設定是 `dflow init`(或免安裝路徑的
184
+ `npx dflow-sdd-ddd init`),之後新增工具 shim 則是 `dflow configure-agents`。
185
+
186
+ **Permission gates 與 Dflow workflow gates 是分開的。** Codex 可能會依其
187
+ sandbox 與 approvals 設定,詢問執行指令、workspace 外編輯或存取網路的權限。
188
+ Dflow workflow 有自己的審核關卡,例如在實作前確認 spec。兩者可能在同一個
189
+ session 中同時出現;這是預期行為。
190
+
191
+ **Codex 本機工作的常見預設是 workspace write 加上 on-request approvals。**
192
+ 以目前 Codex CLI 的術語為 `--sandbox workspace-write --ask-for-approval on-request`。
193
+ 在這個模式下,Codex 可在專案內工作,並在超出 sandbox 範圍(例如 workspace
194
+ 外寫入或存取網路)前先詢問。
195
+
196
+ **既有的 `AGENTS.md` 會被保留。** 若 Dflow 因檔案已存在而無法安全寫入
197
+ 根目錄 shim,請到 `dflow/specs/shared/` 下找 merge snippet,
198
+ 手動將 Dflow 指標合併進你現有的專案指示。
199
+
200
+ **巢狀 `AGENTS.md` 可能改變 Codex 看到的內容。** Codex 沿著到當前工作目錄
201
+ 的路徑分層讀取專案指示。若某個子目錄有自己的 `AGENTS.md` 或
202
+ `AGENTS.override.md`,請確認它不會遮蓋或矛盾你預期 Codex 遵循的 Dflow 指標。
203
+
204
+ ## 下一步
205
+
206
+ 如果你還沒有執行 `init`:
207
+
208
+ - 按照[評估者指南 Playbook](evaluating-dflow.md#30-分鐘評估-playbook)
209
+ 在可拋棄的範例專案中試用。
210
+
211
+ 如果你已執行 `init` 且想查看端到端的 workflow 範例:
212
+
213
+ - 閱讀 [`tutorial/01-greenfield/`](../tutorial/01-greenfield/walkthrough-00-setup.md) 或
214
+ [`tutorial/02-brownfield/`](../tutorial/02-brownfield/walkthrough-00-setup.md)。
215
+ tutorial walk-through 展示了對話流程與產生的 `dflow/specs/` 輸出。
216
+
217
+ 如果你想了解設計理念:
218
+
219
+ - 閱讀[為什麼 AI 時代 DDD 更重要](why-ddd-for-ai.md)。
220
+
221
+ 如果有任何行為與描述不符:
222
+
223
+ - 開一個 docs feedback issue(見 [`CONTRIBUTING.md`](../CONTRIBUTING.md))。
224
+ Per-tool 文件是新內容,有關 Codex CLI 行為的具體回饋非常有價值。
@@ -0,0 +1,200 @@
1
+ # Using Dflow with Gemini CLI
2
+
3
+ > [繁體中文](using-with-gemini-cli.md) | **English**
4
+
5
+ A walk-through of what Dflow looks like when your AI coding agent is
6
+ [Gemini CLI](https://github.com/google/gemini-cli). About 10 minutes to read.
7
+
8
+ This guide focuses on the Gemini CLI experience specifically. For the
9
+ tool-neutral evaluation flow, see
10
+ [`docs/evaluating-dflow.en.md`](evaluating-dflow.en.md). For the full Get Started
11
+ and feature list, see [`README.md`](../README.en.md).
12
+
13
+ ## Who This Guide Is For
14
+
15
+ You are using or evaluating Dflow with Gemini CLI as your AI coding agent.
16
+ This guide covers what Gemini CLI sees after `init`, how Dflow's slash
17
+ commands are recognized, and the Gemini-CLI-specific patterns worth knowing.
18
+
19
+ You do not need to read this before running `init`. It is most useful after
20
+ you have run `init` once and want to understand what Gemini CLI is actually
21
+ loading.
22
+
23
+ ## Prerequisites
24
+
25
+ - Gemini CLI installed (see [github.com/google/gemini-cli](https://github.com/google/gemini-cli)).
26
+ - Node.js / npm available (Dflow ships through npm). Install globally with
27
+ `npm install -g dflow-sdd-ddd`, or use `npx dflow-sdd-ddd` for the no-install path.
28
+ - A project directory you are comfortable initializing in. A branch or a
29
+ disposable sample project is recommended for first contact; see the
30
+ [evaluator guide playbook](evaluating-dflow.en.md#a-30-minute-evaluation-playbook).
31
+
32
+ You do not need a separate Dflow service or API key. The workflows are
33
+ text-based and use Gemini CLI's existing capabilities.
34
+
35
+ ## What Gemini CLI Sees After `init`
36
+
37
+ Running `dflow init` (or `npx dflow-sdd-ddd init` on the no-install path) and
38
+ selecting Gemini CLI as a target tool creates a thin shim at the project root:
39
+
40
+ ```markdown
41
+ # GEMINI.md - Dflow Project Instructions
42
+
43
+ This project uses Dflow for spec-first AI-assisted development.
44
+
45
+ Before planning or editing code, read and follow:
46
+
47
+ - `dflow/specs/shared/AI-AGENT-GUIDE.md`
48
+
49
+ Keep tool-specific instruction files small. The Dflow guide above is the
50
+ single source of truth for project workflow rules, slash-command behavior,
51
+ spec locations, and SDD/DDD constraints.
52
+
53
+ If your tool supports Markdown imports, the canonical guide is imported below:
54
+
55
+ @dflow/specs/shared/AI-AGENT-GUIDE.md
56
+ ```
57
+
58
+ Two things happen when Gemini CLI starts in this project:
59
+
60
+ 1. Gemini CLI automatically loads `GEMINI.md` from the project root into
61
+ its context. This is Gemini CLI's standard project instructions
62
+ mechanism.
63
+ 2. The trailing `@dflow/specs/shared/AI-AGENT-GUIDE.md` line uses Gemini
64
+ CLI's Markdown import syntax to inline the canonical Dflow guide. So
65
+ Gemini CLI effectively reads both files as one set of instructions.
66
+
67
+ The canonical guide (`dflow/specs/shared/AI-AGENT-GUIDE.md`) is where the
68
+ real workflow rules live: project context (track, tech stack, prose
69
+ language), the `/dflow:*` workflow table, source-of-truth file paths, and
70
+ core SDD/DDD rules. The `GEMINI.md` shim stays small precisely so the
71
+ canonical guide can evolve without Gemini-CLI-specific edits.
72
+
73
+ If a `GEMINI.md` already existed in the project, `init` does not overwrite
74
+ it. Instead it writes a merge snippet under `dflow/specs/shared/` that you
75
+ can paste into your existing `GEMINI.md` manually.
76
+
77
+ ## Using Dflow Workflow Commands in Gemini CLI
78
+
79
+ Dflow's `/dflow:*` slash commands are workflow names recognized by the AI
80
+ through the workflow table in `AI-AGENT-GUIDE.md`, not Gemini CLI's
81
+ built-in tool commands. You type them as plain chat:
82
+
83
+ ```text
84
+ /dflow:new-feature
85
+ ```
86
+
87
+ Gemini CLI treats this as input. Because it has the workflow table loaded
88
+ via `GEMINI.md` import, it recognizes the prefix and enters the matching
89
+ workflow. A typical conversation looks like:
90
+
91
+ ```text
92
+ User: /dflow:new-feature
93
+
94
+ Gemini CLI: Entering new-feature workflow. Please describe the user-facing
95
+ capability or business behavior you want to add.
96
+
97
+ User: Allow expense submitters to attach a receipt image when filing an
98
+ expense.
99
+
100
+ Gemini CLI: I'll start by drafting a feature spec under
101
+ dflow/specs/features/active/. Before I do, I need a short answer on:
102
+ [clarifying questions about scope, owner, priority]
103
+ ```
104
+
105
+ The workflow then walks you through spec drafting, behavior examples,
106
+ implementation planning, and finish-feature drift checks. The exact
107
+ sequence depends on which workflow you entered (`/dflow:new-feature`,
108
+ `/dflow:modify-existing`, `/dflow:bug-fix`, etc.). All workflow definitions
109
+ live under the Dflow skill source; Gemini CLI follows them by reading the
110
+ skill files when needed.
111
+
112
+ Available workflow entry points:
113
+
114
+ | Command | Use when |
115
+ |---|---|
116
+ | `/dflow:new-feature` | A new user-visible capability or business behavior is requested. |
117
+ | `/dflow:modify-existing` | Existing behavior needs to change. |
118
+ | `/dflow:bug-fix` | A defect can be described with expected vs actual behavior. |
119
+ | `/dflow:new-phase` | An active feature needs another implementation slice. |
120
+ | `/dflow:finish-feature` | Implementation is complete and needs drift closure. |
121
+ | `/dflow:verify` | Specs, domain docs, implementation, and tests need consistency checks. |
122
+ | `/dflow:pr-review` | A change is ready for SDD/DDD review. |
123
+ | `/dflow:report-dflow-feedback` | You found a Dflow issue or improvement and want a sanitized upstream feedback draft. |
124
+
125
+ If you forget a command name, ask Gemini CLI "what dflow workflows are
126
+ available?" — the answer comes from the workflow table it already has
127
+ loaded.
128
+
129
+ ## Differences vs Other AI Tools
130
+
131
+ The canonical guide (`dflow/specs/shared/AI-AGENT-GUIDE.md`) is identical
132
+ across tools. Only the root-level shim differs:
133
+
134
+ | Tool | Generated shim | Loads canonical guide via |
135
+ |---|---|---|
136
+ | Gemini CLI | `GEMINI.md` | `@dflow/specs/shared/AI-AGENT-GUIDE.md` Markdown import |
137
+ | Claude Code | `CLAUDE.md` | `@dflow/specs/shared/AI-AGENT-GUIDE.md` Markdown import |
138
+ | Codex / Copilot coding agent | `AGENTS.md` | Reads file content directly when starting |
139
+ | GitHub Copilot | `.github/copilot-instructions.md` | Reads file content directly |
140
+
141
+ You can run `dflow configure-agents` later to add another tool's shim
142
+ without re-running `init`. Multiple tools can be active in the same project
143
+ and stay synchronized via the canonical guide.
144
+
145
+ ## Common Patterns and Gotchas
146
+
147
+ **Keep `GEMINI.md` thin.** If you find yourself adding workflow rules,
148
+ spec locations, or SDD constraints to `GEMINI.md`, those belong in
149
+ `dflow/specs/shared/AI-AGENT-GUIDE.md` instead. The shim stays small so
150
+ that other tools' shims don't drift away from it.
151
+
152
+ **`/dflow:*` is not a Gemini CLI tool.** The slash commands are plain text
153
+ patterns the AI recognizes from the workflow table. You can use them
154
+ immediately after `init` without any Gemini CLI configuration.
155
+
156
+ **Permission gates and Dflow workflow gates are separate.** Gemini CLI may
157
+ ask for confirmation before executing a shell command or modifying a file.
158
+ Dflow's workflows have their own approval gates (e.g., "I drafted the spec —
159
+ do you want me to proceed to implementation?"). Both can fire on the same
160
+ action; this is expected and not a sign of misconfiguration.
161
+
162
+ **The `@` import is not recursive.** `GEMINI.md` imports
163
+ `AI-AGENT-GUIDE.md`, but if `AI-AGENT-GUIDE.md` references other files
164
+ (e.g., feature specs), those are not auto-loaded — Gemini CLI reads them
165
+ on demand when entering the relevant workflow. This keeps context usage
166
+ proportional to active work.
167
+
168
+ **A pre-existing `GEMINI.md` is preserved.** `init` will not overwrite your
169
+ existing project instructions. Look under `dflow/specs/shared/` for the
170
+ merge snippet `init` wrote and paste the relevant sections into your
171
+ existing `GEMINI.md` manually.
172
+
173
+ **Cross-machine projects work.** `dflow/specs/` is plain Markdown checked
174
+ into your repo. Anyone cloning the repo and using Gemini CLI in it will
175
+ see the same Dflow setup automatically through the committed `GEMINI.md`
176
+ shim and the canonical guide.
177
+
178
+ ## Where to Go Next
179
+
180
+ If you have not run `init` yet:
181
+
182
+ - Follow the [evaluator guide playbook](evaluating-dflow.en.md#a-30-minute-evaluation-playbook)
183
+ to try it on a disposable sample project.
184
+
185
+ If you have run `init` and want to see end-to-end workflow examples:
186
+
187
+ - Read [`tutorial/01-greenfield/`](../tutorial/01-greenfield/walkthrough-00-setup.md) or
188
+ [`tutorial/02-brownfield/`](../tutorial/02-brownfield/walkthrough-00-setup.md). The
189
+ tutorial walk-throughs show conversation flows and the resulting
190
+ `dflow/specs/` outputs.
191
+
192
+ If you want to understand the design rationale:
193
+
194
+ - Read [`docs/why-ddd-for-ai.en.md`](why-ddd-for-ai.en.md).
195
+
196
+ If something does not work as described:
197
+
198
+ - File a docs feedback issue (see [`CONTRIBUTING.md`](../CONTRIBUTING.md)).
199
+ Per-tool documentation is new and feedback specifically about Gemini CLI
200
+ behavior is valuable.