dflow-sdd-ddd 0.8.0 → 0.10.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 (52) hide show
  1. package/CHANGELOG.md +100 -0
  2. package/LICENSE +679 -21
  3. package/README.en.md +24 -12
  4. package/README.md +15 -8
  5. package/TEMPLATE-COVERAGE.md +0 -1
  6. package/bin/dflow.js +4 -3
  7. package/docs/evaluating-dflow.en.md +11 -7
  8. package/docs/evaluating-dflow.md +9 -4
  9. package/docs/migrating-to-dflow-v1.md +7 -3
  10. package/docs/using-with-claude-code.en.md +40 -23
  11. package/docs/using-with-claude-code.md +34 -23
  12. package/docs/using-with-codex.en.md +135 -48
  13. package/docs/using-with-codex.md +99 -38
  14. package/docs/using-with-github-copilot.en.md +135 -34
  15. package/docs/using-with-github-copilot.md +120 -43
  16. package/lib/init.js +943 -145
  17. package/package.json +3 -3
  18. package/templates/brownfield/references/dflow-feedback-flow.md +135 -63
  19. package/templates/brownfield/references/drift-verification.md +1 -4
  20. package/templates/brownfield/references/finish-feature-flow.md +59 -23
  21. package/templates/brownfield/references/git-integration.md +65 -7
  22. package/templates/brownfield/references/init-project-flow.md +67 -36
  23. package/templates/brownfield/references/modify-existing-flow.md +10 -38
  24. package/templates/brownfield/references/new-feature-flow.md +28 -11
  25. package/templates/brownfield/references/new-phase-flow.md +16 -1
  26. package/templates/brownfield/scaffolding/AI-AGENT-GUIDE.md +253 -2
  27. package/templates/brownfield/scaffolding/CLAUDE-md-snippet.md +5 -8
  28. package/templates/brownfield/scaffolding/Git-principles-gitflow.md +13 -12
  29. package/templates/brownfield/scaffolding/Git-principles-trunk.md +13 -16
  30. package/templates/brownfield/scaffolding/_conventions.md +10 -9
  31. package/templates/brownfield/templates/_index.md +21 -3
  32. package/templates/brownfield/templates/lightweight-spec.md +1 -1
  33. package/templates/brownfield/templates/phase-spec.md +1 -1
  34. package/templates/common/skill/SKILL.md +9 -6
  35. package/templates/greenfield/references/dflow-feedback-flow.md +135 -63
  36. package/templates/greenfield/references/drift-verification.md +1 -4
  37. package/templates/greenfield/references/finish-feature-flow.md +58 -23
  38. package/templates/greenfield/references/git-integration.md +65 -7
  39. package/templates/greenfield/references/init-project-flow.md +67 -36
  40. package/templates/greenfield/references/modify-existing-flow.md +9 -7
  41. package/templates/greenfield/references/new-feature-flow.md +29 -12
  42. package/templates/greenfield/references/new-phase-flow.md +16 -1
  43. package/templates/greenfield/scaffolding/AI-AGENT-GUIDE.md +222 -2
  44. package/templates/greenfield/scaffolding/CLAUDE-md-snippet.md +10 -15
  45. package/templates/greenfield/scaffolding/Git-principles-gitflow.md +13 -12
  46. package/templates/greenfield/scaffolding/Git-principles-trunk.md +14 -18
  47. package/templates/greenfield/scaffolding/_conventions.md +9 -8
  48. package/templates/greenfield/templates/_index.md +21 -3
  49. package/templates/greenfield/templates/lightweight-spec.md +1 -1
  50. package/templates/greenfield/templates/phase-spec.md +1 -1
  51. package/templates/brownfield/templates/CLAUDE.md +0 -165
  52. package/templates/greenfield/templates/CLAUDE.md +0 -172
@@ -48,12 +48,17 @@ a thin shim at the project root:
48
48
 
49
49
  This project uses Dflow for spec-first AI-assisted development.
50
50
 
51
- Before planning or editing code, read and follow:
51
+ For spec-impacting work — a new feature, a change to product, user-facing, or
52
+ domain behavior, a new requirement, or a bug-fix workflow — read and follow:
52
53
 
53
- - `dflow/specs/shared/AI-AGENT-GUIDE.md`
54
+ - `dflow/specs/shared/AI-AGENT-GUIDE.md` — command registry, routing rules, and project context.
55
+ - `dflow/specs/shared/dflow-workflows/` — vendored workflow bundle with executable step definitions.
54
56
 
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
+ For routine work (refactors, renames, chores, formatting, dependency bumps, or
58
+ general code questions), proceed normally; you need not read the guide first.
59
+
60
+ Keep tool-specific instruction files small. The guide and workflow bundle are
61
+ the authoritative sources for Dflow workflow rules, slash-command behavior,
57
62
  spec locations, and SDD/DDD constraints.
58
63
  ```
59
64
 
@@ -61,13 +66,14 @@ Two things matter when Codex starts in this project:
61
66
 
62
67
  1. Codex CLI reads `AGENTS.md` as project instructions. This is Codex's
63
68
  standard repository-instruction mechanism.
64
- 2. The Dflow shim does not include a Markdown import line. Unlike the
65
- Claude Code shim, generated `AGENTS.md` does not contain
66
- `@dflow/specs/shared/AI-AGENT-GUIDE.md`.
69
+ 2. The Dflow shim is a thin pointer and does not inline the guide. Generated
70
+ `AGENTS.md` points to `dflow/specs/shared/AI-AGENT-GUIDE.md` with a plain
71
+ Markdown bullet.
67
72
 
68
73
  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
74
+ is not auto-inlined by the shim. For spec-impacting work (a feature, a
75
+ behavior change, or a bug fix), Codex should follow the pointer and read
76
+ `dflow/specs/shared/AI-AGENT-GUIDE.md`. If Codex
71
77
  starts answering a Dflow request without mentioning that file, steer it
72
78
  explicitly: "Before continuing, read and follow
73
79
  `dflow/specs/shared/AI-AGENT-GUIDE.md`."
@@ -79,13 +85,25 @@ stays small so the same canonical guide can serve Codex CLI, Claude Code,
79
85
  GitHub Copilot, and other tools.
80
86
 
81
87
  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
- In the `dflow configure-agents --command-adapters` case, the corresponding
88
- snippet path is `dflow/specs/shared/AGENTS-md-command-adapters-snippet.md`.
88
+ custom content. A Dflow-generated shim is refreshed in place; another file
89
+ that already points to `dflow/specs/shared/AI-AGENT-GUIDE.md` is skipped
90
+ without adding a second pointer. Otherwise Dflow shows the change in the
91
+ confirmation preview and appends a marked
92
+ `<!-- dflow-generated: agent-shim START/END -->` block at the end of the file;
93
+ re-running refreshes that same block in place. Dflow writes the fallback merge
94
+ snippet
95
+ `dflow/specs/shared/AGENTS-md-snippet.md` only when the file contains
96
+ conflicting or malformed Dflow markers.
97
+
98
+ With `dflow configure-agents --command-adapters`, the marker-conflict fallback
99
+ splits into two files depending on which markers are broken: when only the
100
+ trigger markers are malformed but the file still points to the canonical guide,
101
+ Dflow writes the trigger-only
102
+ `dflow/specs/shared/AGENTS-md-command-adapters-snippet.md`; any other marker
103
+ conflict (the agent-shim markers are malformed, or the two marked regions overlap
104
+ or straddle) takes the full-shim `dflow/specs/shared/AGENTS-md-snippet.md`. Both
105
+ appear only on a marker conflict;
106
+ see *Codex Behavior With Optional Command Adapters* below.
89
107
 
90
108
  ## Using Dflow Workflow Commands in Codex CLI
91
109
 
@@ -157,37 +175,99 @@ workflows.
157
175
  ### Codex Behavior With Optional Command Adapters
158
176
 
159
177
  For Codex, `dflow configure-agents --command-adapters` strengthens text
160
- triggers only. It does not create Codex command files and it does not add
161
- `.agents/skills/dflow/SKILL.md`. Codex v1 has no Dflow command-file adapter
162
- equivalent to Claude `.claude/commands` or Copilot `.github/prompts`.
178
+ triggers only. It does not create Codex command files. Codex v1 has no Dflow
179
+ command-file adapter equivalent to Claude `.claude/commands` or Copilot
180
+ `.github/prompts`.
181
+
182
+ **Auto-trigger skills come from `--skills`, not `--command-adapters`.** See
183
+ "Codex Behavior With Optional Skills" below.
163
184
 
164
185
  When you select `AGENTS.md - Codex / Copilot coding agent` in
165
- `--command-adapters` mode and Dflow can create a new `AGENTS.md` shim, the
166
- shim includes a trigger list generated from the canonical command registry.
167
- Those triggers are still plain text prompts, for example:
186
+ `--command-adapters` mode, Dflow writes a trigger list generated from the
187
+ canonical command registry into `AGENTS.md`. Those triggers are still plain
188
+ text prompts, for example:
168
189
 
169
190
  ```text
170
191
  dflow:new-feature
171
192
  ```
172
193
 
173
- If the project already has a custom `AGENTS.md`, Dflow still preserves that
174
- file; merge the Dflow pointer manually from the generated snippet or the
175
- documentation guidance.
176
-
177
- In this mode, the Codex-target merge snippet filename is
178
- `dflow/specs/shared/AGENTS-md-command-adapters-snippet.md`.
194
+ As long as `AGENTS.md` is an unmodified Dflow-generated shim — which is exactly
195
+ the case after the standard `init` → `configure-agents --command-adapters`
196
+ flow — Dflow **injects** the trigger section directly into `AGENTS.md`, wrapped
197
+ in markers, with zero manual merge. Re-running re-projects that same section in
198
+ place instead of appending a duplicate.
199
+
200
+ If `AGENTS.md` was edited after Dflow generated it, or is your own custom file,
201
+ Dflow still preserves the existing content and appends (or refreshes in place)
202
+ the trigger section as an adjacent marked block in `AGENTS.md` through the same
203
+ mechanism. The confirmation preview shows that block first. Dflow falls back to a
204
+ manual-merge snippet only when existing Dflow markers are too broken to edit in
205
+ place safely, and which snippet it writes depends on which markers are broken:
206
+
207
+ - **Only the trigger markers are malformed, while the agent-shim markers and their
208
+ region are otherwise intact (no overlap or straddle), and the file already points
209
+ to the canonical guide.** The guide pointer is already in place, so the snippet
210
+ carries just the trigger section:
211
+ `dflow/specs/shared/AGENTS-md-command-adapters-snippet.md`.
212
+ - **Any other marker conflict** — for example the agent-shim markers themselves
213
+ are malformed, or the agent-shim and trigger marked regions overlap or straddle
214
+ each other. The snippet then carries the full shim (title, guide pointers, and,
215
+ under `--command-adapters`, the trigger section):
216
+ `dflow/specs/shared/AGENTS-md-snippet.md`.
217
+
218
+ Both snippets appear only on a marker conflict. A clean custom `AGENTS.md` with
219
+ no conflicting markers does not produce a snippet at all — Dflow just appends the
220
+ adjacent marked block in place.
221
+
222
+ ### Codex Behavior With Optional Skills (Auto-Trigger)
223
+
224
+ `dflow configure-agents --skills` projects a thin, tool-neutral skill to
225
+ `.agents/skills/dflow/SKILL.md` — Codex's project-level skill path. This gives
226
+ Codex **natural-language auto-trigger on par with Claude Code**: when you
227
+ describe intent like "help me start a new feature", Codex can judge relevance
228
+ from the skill's `description`, suggest the matching `dflow:<id>` workflow, and
229
+ no longer require you to remember a command every time.
230
+
231
+ The skill body and frontmatter (`name` / `description`) are plain text that
232
+ only point to the canonical guide (`dflow/specs/shared/AI-AGENT-GUIDE.md`) and
233
+ the vendored workflow bundle. It is the **same source** Claude projects
234
+ (`templates/common/skill/SKILL.md`) — no per-tool content fork. When
235
+ auto-triggered, the skill's contract is to judge intent, suggest the matching
236
+ `dflow:<id>`, and wait for your confirmation before entering a workflow rather
237
+ than running one directly.
238
+
239
+ Re-running `--skills` rewrites the same marker-stamped skill in place
240
+ (idempotent). If a **non**-Dflow file already exists at that path (no
241
+ `<!-- dflow-generated: skill-adapter -->` marker), Dflow does not overwrite it —
242
+ it warns and leaves your file untouched.
243
+
244
+ > GitHub Copilot is supported too: selecting Copilot under `--skills` projects
245
+ > `.github/skills/dflow/SKILL.md` (the same thin skill). Copilot also cross-reads
246
+ > the `.claude`/`.agents` paths; Dflow-generated copies are byte-identical, but a
247
+ > pre-existing non-Dflow `dflow` skill at one of those paths is left untouched and
248
+ > could differ — remove or rename it to avoid a same-name duplicate.
179
249
 
180
250
  ### Version-Control Policy for Generated Artifacts (Codex)
181
251
 
182
252
  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
253
+ gitignore** on the `--command-adapters` side. On the Codex side, what you
254
+ version-control is the `AGENTS.md` shim / marked blocks and `dflow/` (the
255
+ canonical guide and specs). The fallback merge helpers
256
+ (`dflow/specs/shared/AGENTS-md-command-adapters-snippet.md` or
257
+ `dflow/specs/shared/AGENTS-md-snippet.md`) are created only on a marker conflict;
258
+ if one appears, it is part of `dflow/` and is **version-controlled along with
259
+ `dflow/`**. `--command-adapters` only strengthens
260
+ the text triggers in `AGENTS.md` for Codex; it adds no `.claude/`, `.github/`,
261
+ or `.agents/` command files.
262
+
263
+ The one Codex derived artifact comes from `--skills`:
264
+ `.agents/skills/dflow/SKILL.md`. Like Claude's `.claude/skills/dflow/SKILL.md`,
265
+ it is regenerable from the canonical guide and follows the same **recommended
266
+ default** (do not version-control; regenerate after clone with
267
+ `configure-agents --skills`; version-controlling it is also reasonable if your
268
+ team wants auto-trigger immediately after clone — the rule is one consistent
269
+ policy across tools in a project). The adapter / skill version-control policy
270
+ for other tools is covered in
191
271
  [README "Files Created by Init"](../README.en.md#files-created-by-init) and the
192
272
  per-tool guides.
193
273
 
@@ -198,7 +278,7 @@ across tools. Only the root-level shim differs:
198
278
 
199
279
  | Tool | Generated shim | Loads canonical guide via |
200
280
  |---|---|---|
201
- | Claude Code | `CLAUDE.md` | `@dflow/specs/shared/AI-AGENT-GUIDE.md` Markdown import |
281
+ | Claude Code | `CLAUDE.md` | Project instructions load the shim; follow the pointer to read the guide |
202
282
  | Codex / Copilot coding agent | `AGENTS.md` | Project instructions load the shim; Codex must follow the pointer and read the guide |
203
283
  | GitHub Copilot | `.github/copilot-instructions.md` | Reads repository instructions directly |
204
284
 
@@ -216,7 +296,7 @@ root, and keep the Dflow pointer in the nearest relevant `AGENTS.md`.
216
296
 
217
297
  If your team uses both Claude Code and Codex CLI on the same project, no
218
298
  extra Dflow coordination is needed. Both tools use the same canonical guide;
219
- only the shim file and loading mechanism differ.
299
+ only the shim file differs.
220
300
 
221
301
  ## Common Patterns and Gotchas
222
302
 
@@ -226,9 +306,9 @@ locations, or SDD constraints to `AGENTS.md`, those belong in
226
306
  other tools' shims do not drift away from it.
227
307
 
228
308
  **Codex does not inline the Dflow guide from `AGENTS.md`.** The generated
229
- Codex shim has a normal Markdown bullet pointing to the canonical guide, not
230
- an `@...` import. Ask Codex to read `AI-AGENT-GUIDE.md` if it appears to be
231
- working from the shim alone.
309
+ Codex shim has a normal Markdown bullet pointing to the canonical guide. Ask
310
+ Codex to read `AI-AGENT-GUIDE.md` if it appears to be working from the shim
311
+ alone.
232
312
 
233
313
  **`/dflow:*` is not a Codex CLI built-in slash command.** Codex slash commands
234
314
  control the Codex session itself. When raw slash input is intercepted or
@@ -237,9 +317,12 @@ rejected, use the no-slash text form `dflow:<id>`, for example
237
317
  workflow by reading `AI-AGENT-GUIDE.md`.
238
318
 
239
319
  **Codex does not generate command files.** Even with `--command-adapters`,
240
- Codex only strengthens text-trigger guidance in `AGENTS.md` / merge
241
- snippets. Do not expect Codex-specific files under `.claude/commands`,
242
- `.github/prompts`, or `.agents/skills/dflow/SKILL.md`.
320
+ Codex only strengthens text-trigger guidance in marked blocks inside
321
+ `AGENTS.md`; fallback merge snippets are created only on marker conflicts. Do
322
+ not expect Codex-specific **command** files under `.claude/commands` or
323
+ `.github/prompts`. (Auto-trigger **skills** are separate: `--skills` projects
324
+ one to `.agents/skills/dflow/SKILL.md`, see "Codex Behavior With Optional
325
+ Skills" above.)
243
326
 
244
327
  **Do not confuse Codex `/init` with Dflow `init`.** Codex `/init` creates a
245
328
  generic `AGENTS.md` scaffold for Codex. Dflow setup is `dflow init` (or
@@ -258,10 +341,14 @@ approvals.** In current Codex CLI terminology this is
258
341
  Codex can work inside the project and asks before going beyond the sandbox,
259
342
  such as writing outside the workspace or accessing network.
260
343
 
261
- **Existing `AGENTS.md` files are preserved.** If Dflow cannot safely write
262
- the root shim because the file already exists, look under
263
- `dflow/specs/shared/` for the merge snippet and merge the Dflow pointer into
264
- your existing project instructions manually.
344
+ **Existing `AGENTS.md` files are preserved.** Dflow does not overwrite your
345
+ custom project instructions. The base pointer is refreshed in place for a
346
+ Dflow-generated shim; other files that already point to `AI-AGENT-GUIDE.md` are
347
+ skipped. Otherwise Dflow shows and appends a marked Dflow block, then refreshes
348
+ that block in place on later runs. `--command-adapters` can still add or refresh
349
+ the adjacent trigger block. If you delete a block, later `init` /
350
+ `configure-agents` runs append it again. Look under `dflow/specs/shared/` for a
351
+ fallback merge snippet only when there is a marker conflict to resolve manually.
265
352
 
266
353
  **Nested `AGENTS.md` files can change what Codex sees.** Codex layers project
267
354
  instructions along the path to the current working directory. If a subfolder
@@ -43,12 +43,17 @@ canonical Dflow 指南的,以及幾個值得了解的 Codex 專屬指令與權
43
43
 
44
44
  This project uses Dflow for spec-first AI-assisted development.
45
45
 
46
- Before planning or editing code, read and follow:
46
+ For spec-impacting work — a new feature, a change to product, user-facing, or
47
+ domain behavior, a new requirement, or a bug-fix workflow — read and follow:
47
48
 
48
- - `dflow/specs/shared/AI-AGENT-GUIDE.md`
49
+ - `dflow/specs/shared/AI-AGENT-GUIDE.md` — command registry, routing rules, and project context.
50
+ - `dflow/specs/shared/dflow-workflows/` — vendored workflow bundle with executable step definitions.
49
51
 
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
+ For routine work (refactors, renames, chores, formatting, dependency bumps, or
53
+ general code questions), proceed normally; you need not read the guide first.
54
+
55
+ Keep tool-specific instruction files small. The guide and workflow bundle are
56
+ the authoritative sources for Dflow workflow rules, slash-command behavior,
52
57
  spec locations, and SDD/DDD constraints.
53
58
  ```
54
59
 
@@ -56,11 +61,11 @@ Codex 在這個專案中啟動時,有兩件事值得注意:
56
61
 
57
62
  1. Codex CLI 將 `AGENTS.md` 作為專案指示讀取。這是 Codex 的
58
63
  標準 repository 指示機制。
59
- 2. Dflow shim 不含 Markdown import 那一行。與 Claude Code 的 shim 不同,
60
- 產生的 `AGENTS.md` 不含 `@dflow/specs/shared/AI-AGENT-GUIDE.md`。
64
+ 2. Dflow shim 是薄指標,不把指南 inline 進來。產生的 `AGENTS.md` 只以
65
+ 普通 Markdown bullet 指向 `dflow/specs/shared/AI-AGENT-GUIDE.md`。
61
66
 
62
67
  這意味著 Codex 能立即看到指標,但 canonical Dflow 指南不會由 shim 自動 inline 嵌入。
63
- 在規劃或編輯之前,Codex 應跟著指標讀取 `dflow/specs/shared/AI-AGENT-GUIDE.md`。
68
+ 做 spec-impacting 工作(新功能、行為變更、bug fix)時,Codex 應跟著指標讀取 `dflow/specs/shared/AI-AGENT-GUIDE.md`。
64
69
  若 Codex 在回應 Dflow 請求時沒有提到該檔案,請明確引導它:「Before continuing,
65
70
  read and follow `dflow/specs/shared/AI-AGENT-GUIDE.md`.」
66
71
 
@@ -69,13 +74,19 @@ canonical 指南是實際 workflow 規則的所在:專案上下文(track、
69
74
  `AGENTS.md` shim 刻意保持精簡,這樣 canonical 指南就能同時服務 Codex CLI、
70
75
  Claude Code、GitHub Copilot 與其他工具。
71
76
 
72
- 如果專案中已有 `AGENTS.md`,`init` 不會覆蓋它。若既有檔案尚未指向
73
- `dflow/specs/shared/AI-AGENT-GUIDE.md`,`init` 會在
74
- `dflow/specs/shared/AGENTS-md-snippet.md` 下寫入 merge snippet,
75
- 讓你手動合併。這樣可以避免破壞你已有的自訂專案指示。
77
+ 如果專案中已有 `AGENTS.md`,`init` 不會覆蓋自訂內容。已是 Dflow-generated shim
78
+ 的檔案會原地刷新;其他已指向 `dflow/specs/shared/AI-AGENT-GUIDE.md` 的檔案會
79
+ 略過,不會新增第二個指標。否則 Dflow 會在確認 preview 顯示並於檔案末尾附加帶有
80
+ `<!-- dflow-generated: agent-shim START/END -->` markers 的 Dflow block,重跑會
81
+ 原地更新同一段。只有遇到衝突或 malformed Dflow markers 時,才會改寫
82
+ `dflow/specs/shared/AGENTS-md-snippet.md` fallback merge snippet 讓你手動合併。
76
83
 
77
- 若是 `dflow configure-agents --command-adapters` 情境,對應檔名為
78
- `dflow/specs/shared/AGENTS-md-command-adapters-snippet.md`。
84
+ 若改用 `dflow configure-agents --command-adapters`,marker conflict 的 fallback 小抄會依
85
+ 「壞掉的是哪一段 marker」分成兩個檔:只有 trigger markers 壞掉、而檔案仍指向 canonical
86
+ 指南時,用 trigger-only 的 `dflow/specs/shared/AGENTS-md-command-adapters-snippet.md`;
87
+ 其他任何 marker conflict(agent-shim markers 壞掉,或兩段 marked block 交疊/跨界)則用
88
+ 完整 shim 的 `dflow/specs/shared/AGENTS-md-snippet.md`。兩者
89
+ 都只在 marker conflict 時出現,詳見下方〈選配 Command Adapters 的 Codex 行為〉。
79
90
 
80
91
  ## 在 Codex CLI 中使用 Dflow Workflow 指令
81
92
 
@@ -144,33 +155,78 @@ guide 中記為 `/dflow:*`)。
144
155
  ### 選配 Command Adapters 的 Codex 行為
145
156
 
146
157
  `dflow configure-agents --command-adapters` 對 Codex 採文字 trigger 強化,不會建立
147
- Codex 命令檔,也不會新增 `.agents/skills/dflow/SKILL.md`。Codex v1 沒有與
148
- Claude `.claude/commands` 或 Copilot `.github/prompts` 對等的 Dflow command-file
149
- adapter。
158
+ Codex 命令檔。Codex v1 沒有與 Claude `.claude/commands` 或 Copilot `.github/prompts`
159
+ 對等的 Dflow command-file adapter。
160
+
161
+ **自動觸發 skill 走的是 `--skills`(非 `--command-adapters`)。** 見下方
162
+ 〈選配 Skill 的 Codex 行為〉。
150
163
 
151
164
  當你在 `--command-adapters` 模式下選擇 `AGENTS.md - Codex / Copilot coding agent`
152
- 且 Dflow 可以建立新的 `AGENTS.md` shim 時,shim 會加入從 canonical command
153
- registry 產生的 trigger 清單。這些 trigger 仍是文字提示,例如:
165
+ 時,Dflow 會把從 canonical command registry 產生的 trigger 清單寫進 `AGENTS.md`。
166
+ 這些 trigger 仍是文字提示,例如:
154
167
 
155
168
  ```text
156
169
  dflow:new-feature
157
170
  ```
158
171
 
159
- 如果專案已有自訂 `AGENTS.md`,Dflow 仍會保留既有檔案;請依產生的 merge snippet
160
- 或文件指引手動合併 Dflow 指標。
161
-
162
- 在這個模式下,Codex 目標的 merge snippet 檔名是
163
- `dflow/specs/shared/AGENTS-md-command-adapters-snippet.md`。
172
+ 只要 `AGENTS.md` 是 Dflow 產生且未經改動的 shim(標準 `init` → `configure-agents
173
+ --command-adapters` 流程就是如此),Dflow 會把帶 marker 的 trigger 段**直接注入**
174
+ `AGENTS.md`,零手動合併;重複執行會就地重投影同一段、不會重複附加。
175
+
176
+ 如果 `AGENTS.md` 在 Dflow 產生後被改過、或本來就是你自訂的檔案,Dflow 仍會保留既有
177
+ 內容,並透過同一套機制把 trigger 段作為相鄰的 marked block 附加(或就地更新)到
178
+ `AGENTS.md`,確認 preview 會先顯示這段。只有當既有的 Dflow markers 壞到無法安全就地
179
+ 改寫時,Dflow 才會改成「不動你的檔、另寫一份手動合併小抄」;而且依「壞掉的是哪一段
180
+ marker」分成兩種小抄:
181
+
182
+ - **只有 trigger markers 壞掉,agent-shim 段與其 region 仍完好(沒有交疊/跨界),且檔案
183
+ 已指向 canonical 指南**:指南指標已就位,小抄只需補 trigger 段,檔名是
184
+ `dflow/specs/shared/AGENTS-md-command-adapters-snippet.md`。
185
+ - **其他任何 marker conflict**——例如 agent-shim markers 本身壞掉,或 agent-shim 與
186
+ trigger 兩段 marked block 交疊/跨界——小抄需要完整 shim(標題、指南指標,以及在
187
+ `--command-adapters` 下的 trigger 段),檔名是 `dflow/specs/shared/AGENTS-md-snippet.md`。
188
+
189
+ 兩種小抄都只在 marker conflict 時出現。乾淨、沒有 marker 衝突的自訂 `AGENTS.md` 不會
190
+ 產生任何小抄——Dflow 會直接把相鄰 marked block append 進去。
191
+
192
+ ### 選配 Skill 的 Codex 行為(自動觸發)
193
+
194
+ `dflow configure-agents --skills` 會把一份精簡、工具中立的 skill 投影到
195
+ `.agents/skills/dflow/SKILL.md`——Codex 的專案層 skill 路徑。這讓 Codex 取得與
196
+ Claude Code **對等的自然語言自動觸發**:你用「help me start a new feature」這類描述
197
+ 時,Codex 可依該 skill 的 `description` 自動判斷是否相關,建議對應的 `dflow:<id>`
198
+ workflow,而不必每次都記得手打命令。
199
+
200
+ skill body 與 frontmatter(`name` / `description`)都是純文字,只指向 canonical 指南
201
+ (`dflow/specs/shared/AI-AGENT-GUIDE.md`)與 vendored workflow bundle,與 Claude 投影
202
+ 的是**同一份 source**(`templates/common/skill/SKILL.md`),沒有 per-tool 內容分岔。
203
+ 被自動觸發時,skill 的約定是:先判斷意圖、建議對應 `dflow:<id>`、等你確認後才進入
204
+ workflow,而不會自行直接執行。
205
+
206
+ 重跑 `--skills` 會就地重寫帶 marker 的同一份 skill(idempotent);若該路徑已存在一份
207
+ **非** Dflow 產生的檔案(沒有 `<!-- dflow-generated: skill-adapter -->` marker),Dflow
208
+ 不會覆寫,只會 warn 並保留你的檔。
209
+
210
+ > GitHub Copilot 也支援:`--skills` 模式下選擇 Copilot 會投影
211
+ > `.github/skills/dflow/SKILL.md`(同一份 thin skill)。Copilot 也會跨讀
212
+ > `.claude`/`.agents`;Dflow 產生的各份逐字相同,但若該路徑已有你自己的非 Dflow
213
+ > `dflow` skill,Dflow 會保留不覆寫、內容可能不同(移除或改名以免同名重複)。
164
214
 
165
215
  ### 產生物的版控政策(Codex)
166
216
 
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 指南。
217
+ Codex 不產生 command 檔,所以 `--command-adapters` 端**沒有需要 gitignore 的衍生 adapter**。
218
+ Codex 端要版控的是 `AGENTS.md` shim / marked blocks 與 `dflow/`(canonical guide +
219
+ 規格);其中兩種 fallback merge helper(`dflow/specs/shared/AGENTS-md-command-adapters-snippet.md`
220
+ 或 `dflow/specs/shared/AGENTS-md-snippet.md`)只在 marker conflict 時產生,若出現也屬
221
+ `dflow/` 的一部分,**隨 `dflow/` 一起版控**。
222
+ `--command-adapters` 對 Codex 只強化 `AGENTS.md` 的文字 trigger,不新增任何
223
+ `.claude/`、`.github/`、`.agents/` 命令檔。
224
+
225
+ 唯一的 Codex 衍生物來自 `--skills`:`.agents/skills/dflow/SKILL.md`。它與 Claude 的
226
+ `.claude/skills/dflow/SKILL.md` 一樣,是可從 canonical 指南重生成的衍生物,沿用相同的
227
+ **建議預設**(不版控、clone 後重跑 `configure-agents --skills` 重生成;若你的團隊偏好 clone
228
+ 即有自動觸發,版控它也是合理選擇,原則是同專案對各工具採一致策略)。其他工具的 adapter /
229
+ skill 版控政策見 [README「Init 產生的檔案」](../README.md#init-產生的檔案) 與各 per-tool 指南。
174
230
 
175
231
  ## 與其他 AI 工具的差異
176
232
 
@@ -179,7 +235,7 @@ canonical 指南(`dflow/specs/shared/AI-AGENT-GUIDE.md`)在各工具之間
179
235
 
180
236
  | 工具 | 產生的 shim | 載入 canonical 指南的方式 |
181
237
  |---|---|---|
182
- | Claude Code | `CLAUDE.md` | `@dflow/specs/shared/AI-AGENT-GUIDE.md` Markdown import |
238
+ | Claude Code | `CLAUDE.md` | 專案指示載入 shim;循指標讀取指南 |
183
239
  | Codex / Copilot coding agent | `AGENTS.md` | 專案指示載入 shim;Codex 須跟著指標讀取指南 |
184
240
  | GitHub Copilot | `.github/copilot-instructions.md` | 直接讀取 repository 指示 |
185
241
 
@@ -195,7 +251,7 @@ Codex 也有自己的專案指示分層機制。它可以從 Codex home 讀取
195
251
 
196
252
  如果你的團隊在同一個專案中同時使用 Claude Code 和 Codex CLI,
197
253
  不需要額外的 Dflow 協調。兩個工具都讀取相同的 canonical 指南;
198
- 只有 shim 檔案與載入機制不同。
254
+ 只有 shim 檔案不同。
199
255
 
200
256
  ## 常見模式與注意事項
201
257
 
@@ -205,7 +261,7 @@ SDD 約束加入 `AGENTS.md`,這些內容應該放到
205
261
  與它產生漂移(drift)。
206
262
 
207
263
  **Codex 不會從 `AGENTS.md` inline 嵌入 Dflow 指南。** 產生的 Codex shim
208
- 是以普通的 Markdown bullet 指向 canonical 指南,而非 `@...` import。
264
+ 是以普通的 Markdown bullet 指向 canonical 指南。
209
265
  若 Codex 看起來只從 shim 工作,請要求它讀取 `AI-AGENT-GUIDE.md`。
210
266
 
211
267
  **`/dflow:*` 不是 Codex CLI 的內建 slash command。** Codex slash command 控制
@@ -214,8 +270,10 @@ SDD 約束加入 `AGENTS.md`,這些內容應該放到
214
270
  canonical `/dflow:<id>` workflow。
215
271
 
216
272
  **Codex 不產生命令檔。** 即使使用 `--command-adapters`,Codex 也只強化
217
- `AGENTS.md` / merge snippet 中的文字 trigger 說明。不要期待 `.claude/commands`、
218
- `.github/prompts` 或 `.agents/skills/dflow/SKILL.md` 形式的 Codex 專屬命令檔。
273
+ `AGENTS.md` 中 marked block 的文字 trigger 說明;只有 marker conflict 才會產生
274
+ fallback merge snippet。不要期待 `.claude/commands` 或 `.github/prompts` 形式的
275
+ Codex 專屬**命令**檔。(自動觸發 **skill** 是另一回事,由 `--skills` 投影到
276
+ `.agents/skills/dflow/SKILL.md`,見上方〈選配 Skill 的 Codex 行為〉。)
219
277
 
220
278
  **不要混淆 Codex `/init` 與 Dflow `init`。** Codex `/init` 為 Codex 建立
221
279
  通用的 `AGENTS.md` scaffold。Dflow 的設定是 `dflow init`(或免安裝路徑的
@@ -231,9 +289,12 @@ session 中同時出現;這是預期行為。
231
289
  在這個模式下,Codex 可在專案內工作,並在超出 sandbox 範圍(例如 workspace
232
290
  外寫入或存取網路)前先詢問。
233
291
 
234
- **既有的 `AGENTS.md` 會被保留。** 若 Dflow 因檔案已存在而無法安全寫入
235
- 根目錄 shim,請到 `dflow/specs/shared/` 下找 merge snippet,
236
- 手動將 Dflow 指標合併進你現有的專案指示。
292
+ **既有的 `AGENTS.md` 會被保留。** Dflow 不會覆蓋你現有的自訂專案指示;base pointer
293
+ 若是 Dflow-generated shim 會原地刷新,其他已指向 `AI-AGENT-GUIDE.md` 的檔案會
294
+ 略過,否則會在確認 preview 顯示並附加 marked Dflow block,重跑原地更新。
295
+ `--command-adapters` 仍可加入 / 更新相鄰的 trigger block;刪除 block 後再跑
296
+ `init` / `configure-agents` 會再附加。只有 marker conflict 時,才需要到
297
+ `dflow/specs/shared/` 找 fallback merge snippet 手動處理。
237
298
 
238
299
  **巢狀 `AGENTS.md` 可能改變 Codex 看到的內容。** Codex 沿著到當前工作目錄
239
300
  的路徑分層讀取專案指示。若某個子目錄有自己的 `AGENTS.md` 或