@pknx/waterfall-cli 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 (106) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +62 -0
  3. package/bin/waterfall.mjs +14 -0
  4. package/lib/cli/agent/agent-message.ts +71 -0
  5. package/lib/cli/agent/agent-translators.ts +145 -0
  6. package/lib/cli/agent/backend-invoke.ts +133 -0
  7. package/lib/cli/agent/backends.ts +100 -0
  8. package/lib/cli/agent/global-prompts.ts +55 -0
  9. package/lib/cli/commands/bug-start.ts +115 -0
  10. package/lib/cli/commands/comment-add.ts +47 -0
  11. package/lib/cli/commands/cr-all.ts +18 -0
  12. package/lib/cli/commands/cr-finish.ts +176 -0
  13. package/lib/cli/commands/cr-start.ts +105 -0
  14. package/lib/cli/commands/cr-to-rq.ts +18 -0
  15. package/lib/cli/commands/export-pdf.ts +193 -0
  16. package/lib/cli/commands/horizontal/horizontal.ts +232 -0
  17. package/lib/cli/commands/horizontal-create.ts +34 -0
  18. package/lib/cli/commands/horizontal-update.ts +32 -0
  19. package/lib/cli/commands/join-hint.ts +4 -0
  20. package/lib/cli/commands/registry.ts +59 -0
  21. package/lib/cli/commands/resolve-operator-hint.ts +120 -0
  22. package/lib/cli/commands/rq-all.ts +18 -0
  23. package/lib/cli/commands/rq-to-uc.ts +18 -0
  24. package/lib/cli/commands/story-close.ts +124 -0
  25. package/lib/cli/commands/sync-work-items.ts +59 -0
  26. package/lib/cli/commands/sys-start.ts +96 -0
  27. package/lib/cli/commands/test-all.ts +18 -0
  28. package/lib/cli/commands/test-to-story.ts +18 -0
  29. package/lib/cli/commands/types.ts +33 -0
  30. package/lib/cli/commands/uc-all.ts +18 -0
  31. package/lib/cli/commands/uc-to-story.ts +18 -0
  32. package/lib/cli/commands/uc-to-test.ts +18 -0
  33. package/lib/cli/comments/item-comments.ts +285 -0
  34. package/lib/cli/config/dot-waterfall.ts +404 -0
  35. package/lib/cli/config/global-cli.ts +21 -0
  36. package/lib/cli/config/sync-work-item-config.ts +34 -0
  37. package/lib/cli/core/cli-help-spec.ts +833 -0
  38. package/lib/cli/core/cli-log.ts +124 -0
  39. package/lib/cli/core/exec-file.ts +8 -0
  40. package/lib/cli/core/prompt-map.ts +64 -0
  41. package/lib/cli/core/slug.ts +44 -0
  42. package/lib/cli/entry.ts +4 -0
  43. package/lib/cli/export/collect-md.ts +41 -0
  44. package/lib/cli/export/export-items.ts +104 -0
  45. package/lib/cli/export/export-pdf-path.ts +88 -0
  46. package/lib/cli/export/merge-md.ts +37 -0
  47. package/lib/cli/export/mermaid-run.ts +104 -0
  48. package/lib/cli/export/pandoc-pdf.ts +90 -0
  49. package/lib/cli/export/pdf-bundled-worker.mjs +73 -0
  50. package/lib/cli/export/pdf-bundled.ts +36 -0
  51. package/lib/cli/git/cr-agent-context.ts +62 -0
  52. package/lib/cli/git/git-branch-guards.ts +60 -0
  53. package/lib/cli/git/git-cli-mock.ts +191 -0
  54. package/lib/cli/git/git-cli.ts +24 -0
  55. package/lib/cli/main.ts +434 -0
  56. package/lib/cli/paths.ts +9 -0
  57. package/lib/cli/project/pom-json.ts +55 -0
  58. package/lib/cli/spec/spec-init.ts +216 -0
  59. package/lib/cli/spec/spec-root.ts +93 -0
  60. package/lib/cli/sync/apply-remote-comments.ts +87 -0
  61. package/lib/cli/sync/attachment-category.ts +43 -0
  62. package/lib/cli/sync/diff-work-items.ts +113 -0
  63. package/lib/cli/sync/materialize-remote-bugs.ts +66 -0
  64. package/lib/cli/sync/provider-types.ts +43 -0
  65. package/lib/cli/sync/providers/direct-provider.ts +27 -0
  66. package/lib/cli/sync/providers/jira-provider.ts +34 -0
  67. package/lib/cli/sync/providers/registry.ts +26 -0
  68. package/lib/cli/sync/run-sync-work-items.ts +202 -0
  69. package/lib/cli/sync/spec-work-items.ts +226 -0
  70. package/lib/cli/sync/sync-hint-json.ts +163 -0
  71. package/lib/cli/sync/work-item-meta.ts +117 -0
  72. package/lib/cli/work-items/infer-bug-sys.ts +147 -0
  73. package/lib/cli/work-items/remote-bug-import-scaffold.ts +32 -0
  74. package/lib/cli/work-items/write-bug-to-spec.ts +158 -0
  75. package/package.json +54 -0
  76. package/prompts/commands/bug-start.md +46 -0
  77. package/prompts/commands/cr-finish.md +44 -0
  78. package/prompts/commands/cr-start.md +65 -0
  79. package/prompts/commands/cr-to-rq.md +62 -0
  80. package/prompts/commands/horizontal-create.md +27 -0
  81. package/prompts/commands/horizontal-update.md +39 -0
  82. package/prompts/commands/rq-to-uc.md +62 -0
  83. package/prompts/commands/story-close-all.md +34 -0
  84. package/prompts/commands/story-close.md +44 -0
  85. package/prompts/commands/sync-bugs-refine-imports.md +33 -0
  86. package/prompts/commands/sys-start.md +63 -0
  87. package/prompts/commands/test-to-story.md +64 -0
  88. package/prompts/commands/uc-to-story.md +85 -0
  89. package/prompts/commands/uc-to-test.md +58 -0
  90. package/prompts/global/before-changing-spec.md +62 -0
  91. package/prompts/global/content-requirements-vs-use-cases.md +116 -0
  92. package/prompts/global/cursor-overview.md +31 -0
  93. package/prompts/global/git-usage.md +46 -0
  94. package/prompts/global/horizontal-structure.md +75 -0
  95. package/prompts/global/workflows-index.md +59 -0
  96. package/prompts/items/bug-document-structure.md +23 -0
  97. package/prompts/items/cr-document-structure.md +45 -0
  98. package/prompts/items/rq-theme-document-structure.md +36 -0
  99. package/prompts/items/story-document-structure.md +49 -0
  100. package/prompts/items/sys-document-structure.md +36 -0
  101. package/prompts/items/tst-document-structure.md +55 -0
  102. package/prompts/items/uc-document-structure.md +38 -0
  103. package/spec-template/README.md +11 -0
  104. package/spec-template/full/doc/spec-structure.md +16 -0
  105. package/spec-template/full/prompts/before-changing-spec.md +7 -0
  106. package/spec-template/full/prompts/workflows.md +25 -0
@@ -0,0 +1,62 @@
1
+ # Process: CR → RQ
2
+
3
+ ## Purpose
4
+
5
+ Promote **raw intent** in a **`CR-*`** into a structured **requirement theme** **`RQ-*`** so use cases can hang under a coherent scope.
6
+
7
+ ## Scope of edits (strict)
8
+
9
+ **Only** touch artifacts of these types in this action (plus **`number.json`** counter updates this workflow requires):
10
+
11
+ | In scope | Typical paths |
12
+ |----------|----------------|
13
+ | **`CR-*`** | `changerequests/CR-<NNN>-<slug>/CR-<NNN>.md` — append the new RQ id under `### Downstream references`. |
14
+ | **`RQ-*`** | `requirements/RQ-*-…/RQ-<NNN>.md` (create or update). |
15
+
16
+ **Out of scope (do not edit here):** **`UC-*`**, **`SYS-*`**, **`STORY-*`**, **`BUG-*`**, **`TST-*`**, and **`RQ`** content that belongs under **use cases** (flows, testcase tables). Use **RQ → UC** and later prompts instead.
17
+
18
+ If you discover missing **UC** / **STORY** / **test** work, **stop** after **`CR → RQ`** and run the matching prompt in a **separate** change.
19
+
20
+ ## Preconditions
21
+
22
+ - **`changerequests/CR-<NNN>-<slug>/CR-<NNN>.md`** exists.
23
+ - Scope is clear enough to name at least one RQ theme; when the CR bundles **several separable themes**, plan **multiple RQs** in this pass (or explicit deferrals on the CR), not one kitchen-sink RQ.
24
+
25
+ ## Granular RQ breakdown (required mindset)
26
+
27
+ - **One RQ = one coherent requirement theme** at the “what area / what constraints” level. If the CR mixes **catalog**, **cart/checkout**, **account**, **admin**, etc., create **multiple** **`RQ-*`** folders — do **not** fold the whole CR into a single mega-RQ whose scope is every path in the diff.
28
+ - **Split by customer- or policy-visible boundaries** when themes have different non-goals, actors, or quality bars; keep each **`RQ-<NNN>.md`** readable on its own.
29
+ - **Phrase scope** so **RQ → UC** can later produce **several granular UCs** per theme — see **[`content-requirements-vs-use-cases.md`](../global/content-requirements-vs-use-cases.md)** (sections **Granularity: multiple RQ themes from one CR** and **Granularity: breaking an RQ into multiple UCs**).
30
+
31
+ ## Rules
32
+
33
+ 1. **Every new `RQ-*` must be added to the source CR markdown** under `### Downstream references` (one-way linking).
34
+ 2. **`RQ-*`** gets **`RQ-<NNN>.md`** (summary + links) inside **`requirements/RQ-<NNN>-<slug>/`**.
35
+ 3. Do **not** skip **`CR`** for net-new product intent — record or extend a **`CR-*`** first unless **`CURSOR.md`** allows a different entry (e.g. **BUG**).
36
+
37
+ ## Content (RQ `RQ-<NNN>.md`)
38
+
39
+ Follow **[`content-requirements-vs-use-cases.md`](../global/content-requirements-vs-use-cases.md)** — the RQ theme file carries **general** purpose, **scope**, **constraints**, **in/out of scope**, and links. Avoid step-by-step user flows here (those belong in **UCs**). Where the theme covers multiple separable capabilities, phrase **scope** so **RQ → UC** can produce **several granular UCs** (not one kitchen-sink UC) — see the same doc, *Granularity: breaking an RQ into multiple UCs*. If the **CR** already mixes unrelated themes, **split RQs first** (see **Granularity: multiple RQ themes from one CR** in the same doc).
40
+
41
+ When editing the source **CR**, follow **[`cr-document-structure.md`](../items/cr-document-structure.md)**. When authoring **`RQ-<NNN>.md`**, follow **[`rq-theme-document-structure.md`](../items/rq-theme-document-structure.md)**.
42
+
43
+ ## Steps
44
+
45
+ 1. Allocate **`next.RQ`** from **`number.json`** → e.g. **`RQ-002`**.
46
+ 2. Create **`requirements/RQ-002-<slug>/`** with **`RQ-002.md`** (per content rules above).
47
+ 3. In the source **`CR-<NNN>.md`**, append the produced RQ under `### Downstream references`.
48
+ 4. Increment **`next.RQ`** in **`number.json`** in the **same** commit.
49
+ 5. If **`CR`** proposed multiple themes, create **multiple RQs** or explicitly defer follow-on RQs in **`CR`** revision notes.
50
+
51
+ ## Done when
52
+
53
+ - `CR -> RQ` traceability is visible in markdown via `### Downstream references` in the source CR.
54
+
55
+ ## CLI orchestration
56
+
57
+ When this prompt is executed as part of a batch command (for example `waterfall cr all`), the CLI will run multiple prompts in separate agent invocations.
58
+
59
+ 1. Treat the operator-provided `hint` as global steering for the batch, but do not widen this step beyond its **Scope of edits (strict)**.
60
+ 2. If this step has **nothing to do** for the current artifact(s), make no changes and let the CLI proceed.
61
+ 3. Commit boundary: stop after this step's artifacts are internally consistent (`CR`/`RQ`/`number.json` for this step). The next lifecycle step prompt will be invoked separately.
62
+
@@ -0,0 +1,27 @@
1
+ # Process: refine horizontal scaffold (`waterfall horizontal create` — phase 2)
2
+
3
+ ## Purpose
4
+
5
+ After the CLI **mechanically** creates **`technical/horizontals/HOR-<NNN>-<slug>/HOR-<NNN>.md`** (identity block, italic **Purpose** placeholder, empty **`## Aggregated definitions`**, **`## Draft steering (CLI)`**), this prompt runs with **`--execute-agent`** (or dry-run) so **Purpose** becomes **meaningful synthesized prose** aligned with **[`horizontal-structure.md`](../global/horizontal-structure.md)** — not a verbatim copy of steering.
6
+
7
+ ## When this prompt runs (agent refinement)
8
+
9
+ The scaffold file **already exists** and is **committed**. **Git diff vs `develop`** shows recent paths.
10
+
11
+ **Your task:** edit **only** that **`HOR-<NNN>.md`**:
12
+
13
+ - Replace the **Purpose** placeholder with a short, product-readable paragraph on what this horizontal reconciles (schemas, APIs, stack, …) — **synthesize** from **Draft steering** and the operator hint (`[horizontal create · anchor=… · name=…]` prefix in the wire payload). **Do not** name **CR-***, **SYS-***, **STORY-***, **RQ-***, **UC-***, **HOR-*** (other), or **TST-*** in **Purpose** — describe the concern in plain language; **typed ids** belong in **`## Aggregated definitions`** only when traceability is needed (sparingly, per **[`before-changing-spec.md`](../global/before-changing-spec.md)**), not in the Purpose paragraph.
14
+ - **Remove** **`## Draft steering (CLI)`** when **Purpose** is satisfactory.
15
+ - **`## Aggregated definitions`:** usually stays **empty** until **`waterfall horizontal update`** fills it from **STORY** substance; you may add a **one-line** intent bullet only if it helps the next update pass — **no** path dumps.
16
+
17
+ **Out of scope for this pass:** **`number.json`**, other files, lifecycle edges (**UC → STORY**, etc.).
18
+
19
+ ## Mechanical phase (CLI only — before this prompt)
20
+
21
+ The CLI creates the folder, file, bumps **`next.HOR`**, commits. See **[`horizontal-structure.md`](../global/horizontal-structure.md)** for folder shape.
22
+
23
+ ## Rules (content)
24
+
25
+ 1. **Purpose** must be **synthesized**, not a 1:1 paste of **Draft steering**.
26
+ 2. **Purpose** must stay **id-free** (no **CR-001**, **SYS-002**, **STORY-014**, …). **`## Aggregated definitions`** may use **typed ids** sparingly for traceability when you add substance later — see **[`before-changing-spec.md`](../global/before-changing-spec.md)**.
27
+ 3. Full **Aggregated definitions** content is the job of **`horizontal update`** + **`horizontal-update.md`**, not this pass.
@@ -0,0 +1,39 @@
1
+ # Process: refresh a horizontal after **`waterfall horizontal update`**
2
+
3
+ ## Purpose
4
+
5
+ **`waterfall horizontal update HOR-<NNN>`** computes **`git diff develop...HEAD --name-only`**, filters paths for this horizontal’s **anchor** (e.g. **story**), and injects the result into the **operator hint** for this run — **not** into **`HOR-<NNN>.md`**. The spec file stays a **model document**; raw path lists live only in chat / CI logs (and may overlap with the CLI’s **CR branch — changed paths** block).
6
+
7
+ Your job is to **turn that hint into real content** in **`## Aggregated definitions`**: definitions, tables, and rules — **never** a dump of repository paths.
8
+
9
+ ## Scope of edits (strict)
10
+
11
+ | In scope | Action |
12
+ |----------|--------|
13
+ | **`HOR-<NNN>.md`** | Rewrite or extend **## Aggregated definitions** with **substantive** consolidated model/contract text. |
14
+
15
+ **Out of scope:** creating new **STORY**/**UC**/**RQ** files, changing **CR** scope, editing **`CURSOR.md`** / **`schemas/`** unless this CR explicitly owns that.
16
+
17
+ ## Reference rule (critical)
18
+
19
+ - In **`## Aggregated definitions`**, **never** cite other artifacts by **file path**.
20
+ - Use **typed ids** only (**`STORY-004`**, **`UC-002`**) when traceability is unavoidable — **not more than one** id reference per logical subsection; prefer **none** if the text stands alone.
21
+
22
+ See **[`horizontal-structure.md`](../global/horizontal-structure.md)** and **[`before-changing-spec.md`](../global/before-changing-spec.md)**.
23
+
24
+ ## Steps
25
+
26
+ 1. Read **`prompts/global/horizontal-structure.md`** for the horizontal **kind** (e.g. `database-model`, `api-model`, `technical-stack`).
27
+ 2. Use the **operator hint** (matching paths + full diff list) to choose which **stories** (or other anchors) to open; extract **facts** (fields, endpoints, constraints).
28
+ 3. Update **## Aggregated definitions** with deduplicated **content**; resolve conflicts explicitly in prose.
29
+ 4. If this artifact is a **`database-model`** horizontal (**`Horizontal name:`** / slug **`database-model`** in the file): satisfy **Database model — required shape** in **`horizontal-structure.md`** — **Mermaid `erDiagram`** covering **all** tables and relationships, plus **one markdown table per table** listing **every field** and **datatype** (and optional Null/Default/Notes).
30
+ 5. If this artifact is a **`technical-stack`** horizontal (**`Horizontal name:`** / slug **`technical-stack`**): satisfy **Technical stack — required shape** in **`horizontal-structure.md`** — grouped **`###`** sections with **markdown tables** listing **all** in-use technologies (component, role; version and notes when known).
31
+ 6. Optionally add **one** compact traceability line per subsection (**`STORY-<NNN>`** only) if required — never path dumps.
32
+ 7. Save and commit your **content** edits if the horizontal document changed.
33
+
34
+ ## Done when
35
+
36
+ - **## Aggregated definitions** reads like a **real** consolidated spec for that concern, not an index of paths.
37
+ - For **`database-model`**: ER diagram + per-table field/type tables are **complete** for every table in scope.
38
+ - For **`technical-stack`**: every technology committed by in-scope stories appears in the grouped inventory tables **once**, with no silent contradictions across stories.
39
+ - No stale **aggregated** text that contradicts the current stories on the branch.
@@ -0,0 +1,62 @@
1
+ # Process: RQ → UC
2
+
3
+ ## Purpose
4
+
5
+ Break an **`RQ-*`** into **use cases** **`UC-*`** with **actionable** behavior and **acceptance tests** in **one** markdown file (**`UC-<NNN>.md`**).
6
+
7
+ ## Scope of edits (strict)
8
+
9
+ **Only** touch artifacts of these types in this action (plus **`number.json`** counter updates this workflow requires):
10
+
11
+ | In scope | Typical paths |
12
+ |----------|----------------|
13
+ | **`RQ-*`** | `requirements/RQ-*-…/RQ-<NNN>.md` — append new UC id under `### Downstream references`; keep **`RQ`** general. |
14
+ | **`UC-*`** | New or updated `requirements/RQ-*-…/UC-<NNN>-<slug>/UC-<NNN>.md` (behaviour + **`## TC-…`** sections). |
15
+
16
+ **Out of scope (do not edit here):** **`CR-*`** (except read-only context), **`SYS-*`**, **`STORY-*`**, **`BUG-*`**, **`TST-*`**. Do **not** promote **`CR`** into **`STORY`** or **tests** in this pass.
17
+
18
+ If scope needs a **new** **`CR`** or **another** **`RQ`**, finish this **`RQ → UC`** slice first, then run **CR → RQ** / another edge prompt **separately**.
19
+
20
+ ## Preconditions
21
+
22
+ - **`RQ-*`** folder exists with **`RQ-<NNN>.md`**.
23
+ - You can name actors, goal, and boundaries for at least one UC.
24
+ - You have read **[`before-changing-spec.md`](../global/before-changing-spec.md)** and reviewed **`git diff`** for the RQ/UC paths you will touch.
25
+
26
+ ## Granular UC breakdown (required mindset)
27
+
28
+ - **One UC = one coherent capability slice** a tester could exercise end-to-end (or a clear system behaviour with bounded pre/postconditions). If the RQ theme covers multiple such slices, create **multiple** **`UC-*`** folders — do **not** fold the whole theme into a single mega-UC.
29
+ - **Split by feature boundaries:** e.g. browse/search, cart mutation, checkout submission, order history — each gets its own UC when they are independently describable and testable.
30
+ - **Each new UC** gets its own **`## TC-<NNN>-<seq>`** set sized for that slice — avoid one UC carrying dozens of unrelated testcases.
31
+ - Link all produced UCs from **`RQ-<NNN>.md`** `### Downstream references`; cross-link UCs with **ids only** (`UC-003`), never file paths — **[`before-changing-spec.md`](../global/before-changing-spec.md)**.
32
+
33
+ See **[`content-requirements-vs-use-cases.md`](../global/content-requirements-vs-use-cases.md)** → **Granularity: breaking an RQ into multiple UCs** (and, when the **RQ** still bundles unrelated themes, **Granularity: multiple RQ themes from one CR** upstream on the **CR**).
34
+
35
+ ## Rules
36
+
37
+ 1. **Separation of concerns:** **`RQ`** stays **general** (theme, scope, constraints); each **`UC`** is **specific** and **testable** — see **[`content-requirements-vs-use-cases.md`](../global/content-requirements-vs-use-cases.md)**.
38
+ 2. **RQ theme shape:** preserve the theme required header + section structure described in **[`rq-theme-document-structure.md`](../items/rq-theme-document-structure.md)** when updating **`RQ-<NNN>.md`**.
39
+ 3. **UC document model:** follow **[`uc-document-structure.md`](../items/uc-document-structure.md)** — **no separate “description” file**; all narrative sections live in **`UC-<NNN>.md`**.
40
+ 4. In **`UC-<NNN>.md`**, add **`## TC-<NNN>-<seq> — …`** acceptance sections — **`TC-*`** must be sufficient to judge **UC completion**.
41
+ 5. Keep one-way linking lightweight: append the new UC in the source **`RQ-<NNN>.md`** under `### Downstream references`.
42
+ 6. Use **`number.json` `next.UC`**, create artifacts, increment in the **same** commit.
43
+
44
+ ## Steps
45
+
46
+ 1. Allocate **`next.UC`** → **`UC-<NNN>`** with kebab **`UC-<NNN>-<slug>/`** under the owning **`RQ`**.
47
+ 2. Write **`UC-<NNN>.md`** with **actionable** main flow, pre/postconditions, exceptions, any **context** sections, **and** stable **`## TC-<NNN>-<seq> — …`** acceptance blocks that **prove** the UC’s goal and critical paths.
48
+ 3. Create **`UC-<NNN>.md`** and update **`RQ-<NNN>.md`** by appending this UC under `### Downstream references`.
49
+ 4. Increment **`next.UC`**.
50
+
51
+ ## Done when
52
+
53
+ - **`UC`** folder is linked from **`RQ`** and ready for **`SYS` / `STORY` / `TST`** work.
54
+
55
+ ## CLI orchestration
56
+
57
+ When this prompt is executed as part of a batch command (for example `waterfall cr all`, `waterfall rq all`, or `waterfall uc all`), the CLI will run multiple prompts in separate agent invocations.
58
+
59
+ 1. Treat the operator-provided `hint` as global steering for the batch, but do not widen this step beyond its **Scope of edits (strict)**.
60
+ 2. If this step has **nothing to do** for the current artifact(s), make no changes and let the CLI proceed.
61
+ 3. Commit boundary: stop after this step's artifacts are internally consistent (`RQ`/`UC`/`number.json` for this step). The next lifecycle step prompt will be invoked separately.
62
+
@@ -0,0 +1,34 @@
1
+ # Orchestration: close all eligible STORIES (`waterfall story close all`)
2
+
3
+ ## Purpose
4
+
5
+ Run **[`story-close.md`](story-close.md)** once per **eligible** **STORY**, in a batch, without closing stories that are not ready.
6
+
7
+ ## Scope of edits (strict)
8
+
9
+ This file does **not** widen **`story-close.md`** scope. Each closure is one application of **`story-close.md`** (prefer one commit per STORY for auditability).
10
+
11
+ ## Preconditions
12
+
13
+ - Human-approved **ordered list** of **STORY-<NNN>** ids to close.
14
+ - Branch **`feature/…`** from **`develop`**; **[`before-changing-spec.md`](../global/before-changing-spec.md)** reviewed.
15
+
16
+ ## Eligibility (all must hold for each id)
17
+
18
+ 1. Implementation for that STORY is merged to **`waterfall-app`** **`develop`** (or agreed integration branch).
19
+ 2. Verification (tests per STORY/TST policy) is green.
20
+ 3. Folder is still **`STORY-*`**, not already **`_STORY-*`**.
21
+ 4. No remaining open work tracked under the same STORY id (otherwise split to a new STORY first).
22
+
23
+ If any item is unclear, stop and run **`story close STORY-<NNN>`** only after confirmation.
24
+
25
+ ## Invocation order
26
+
27
+ 1. For each approved id in order, execute **[`story-close.md`](story-close.md)** for that STORY only.
28
+ 2. Commit after each STORY (recommended) or one reviewed batch per team policy.
29
+ 3. Do not use this pass to change UC **`TC-*`** or RQ prose beyond link fixes allowed inside **`story-close.md`**.
30
+
31
+ ## Done when
32
+
33
+ - Every approved STORY on the list is **`_STORY-*`** with a consistent graph; no ineligible STORY was closed.
34
+
@@ -0,0 +1,44 @@
1
+ # Process: close one STORY (`waterfall story close STORY-NNN`)
2
+
3
+ ## Purpose
4
+
5
+ Close a **delivered** **STORY** per **[`CURSOR.md`](CURSOR.md)** (Closed STORY): rename folder to **`_STORY-NNN-slug/`**, set **Status: closed** in **`STORY-NNN.md`**, and fix markdown links/references. **Convention:** **NNN** is the **three-digit zero-padded** story number (e.g. `014`); **slug** matches the existing folder slug. Usually **implementation** is merged on **`waterfall-app`** **`develop`** first; then spec closure (see companion app `prompts/spec-lock-and-merge.md` §0.5).
6
+
7
+ ## Scope of edits (strict)
8
+
9
+ Only what this **one** story needs for closure and path consistency:
10
+
11
+ | Area | Action |
12
+ |------|--------|
13
+ | Story folder | Rename `technical/SYS-…/module/STORY-NNN-slug/` → `_STORY-NNN-slug/` (underscore on **folder** only). |
14
+ | Story markdown | **`STORY-NNN.md`:** **Status:** `closed`, **Closed:** date + note. |
15
+ | Story markdown | Ensure `## Links and dependencies` / `### Downstream references` stay valid after rename. |
16
+ | Peers | Fix markdown links/references that still point at the old **`STORY-…`** path (module, UC, TST, other STORY links). |
17
+
18
+ **Out of scope:** CR, RQ, UC behaviour or **`TC-*`** sections (except link-only path fixes), new STORY ids, **`next.STORY`** bumps for new work. **Never** add new scope inside **`_STORY-*`** after close — use a new **STORY** per **`CURSOR.md`**.
19
+
20
+ ## Preconditions
21
+
22
+ - Implementation merged per team rules.
23
+ - Work on **`feature/…`**, not direct **`develop`** commits for spec tree edits.
24
+ - **[`before-changing-spec.md`](../global/before-changing-spec.md)** — diff vs **`develop`**.
25
+
26
+ ## Rules
27
+
28
+ 1. Inner filename stays **`STORY-NNN.md`** (not `_STORY-NNN.md`).
29
+ 2. Preserve numeric id.
30
+ 3. Search for stale path references after rename.
31
+
32
+ ## Steps
33
+
34
+ 1. Locate **`technical/SYS-*-…/<module>/STORY-NNN-slug/`**.
35
+ 2. Rename to **`_STORY-NNN-slug/`**.
36
+ 3. Update **`STORY-NNN.md`** (status, **Closed:**).
37
+ 4. Fix links/references in the story markdown.
38
+ 5. Fix all markdown links/references in peers.
39
+ 6. Commit on **`feature/…`**; merge per **`CURSOR.md`**.
40
+
41
+ ## Done when
42
+
43
+ - Folder is **`_STORY-…`**, story is closed, graph and links are consistent.
44
+
@@ -0,0 +1,33 @@
1
+ # Process: refine BUG(s) imported from remote sync (`waterfall sync bugs`)
2
+
3
+ ## Purpose
4
+
5
+ After **remote-leading** sync materializes new `BUG-NNN.md` files, the CLI invokes this prompt (dry-run logs the plan; **`--execute-agent`** runs your backend) so imported scaffolds get the same treatment as **`waterfall bug start`**: real **Summary** prose per **[`bug-document-structure.md`](../items/bug-document-structure.md)**, not placeholders.
6
+
7
+ ## When this prompt runs
8
+
9
+ The CLI has **already**:
10
+
11
+ - Created `technical/SYS-…/BUG-NNN-…/BUG-NNN.md` with **Id / SYS / Status** and a **Summary** section containing **Draft steering (remote import)** (remote title + quoted tracker comments).
12
+ - Applied remote comments to **`BUG-NNN.comments.json`** where applicable.
13
+ - Listed spec-relative paths in the operator hint.
14
+
15
+ ## Your task
16
+
17
+ For **each** path in the hint:
18
+
19
+ 1. Open that `BUG-NNN.md`.
20
+ 2. **Synthesize** a proper **Summary** from **Draft steering (remote import)** — same quality bar as **[`bug-start.md`](bug-start.md)** (repro, expected vs actual, links to related items by **typed id** only).
21
+ 3. **Remove** the entire **Draft steering (remote import)** section when done.
22
+ 4. Keep **Id**, **SYS**, **Status** unchanged unless you find a clear error (e.g. wrong subsystem — rare if sync inferred SYS correctly).
23
+
24
+ **Out of scope:** `number.json`, inventing tracker comments, moving folders unless the steering clearly implies the wrong SYS and you can fix it safely.
25
+
26
+ ## Rules
27
+
28
+ - **SYS** on the file should match the folder under `technical/SYS-…/`; do not retarget bugs casually.
29
+ - Typed references only (**STORY-***, **UC-***, …); no file paths in finished prose — **[`before-changing-spec.md`](../global/before-changing-spec.md)**.
30
+
31
+ ## Done when
32
+
33
+ Every listed `BUG-NNN.md` reads like a real defect note and **Draft steering (remote import)** is gone.
@@ -0,0 +1,63 @@
1
+ # Process: start a new SYS (`waterfall sys start`)
2
+
3
+ ## Purpose
4
+
5
+ Create a new technical subsystem folder under `technical/` with a minimal **`SYS-<NNN>.md`** scaffold, and advance `number.json` `next.SYS`.
6
+
7
+ The **Waterfall CLI** runs **mechanical** scaffold + commit first, then invokes this prompt with **`--execute-agent`** (or dry-run) so **Purpose** is **synthesized** prose per **`sys-document-structure`**, not an italic placeholder.
8
+
9
+ ## When this prompt runs (agent refinement — phase 2)
10
+
11
+ The CLI has **already** created **`technical/SYS-<NNN>-<slug>/SYS-<NNN>.md`** (placeholder **Purpose** + **`## Draft steering (CLI)`**), bumped **`number.json`**, and **committed**.
12
+
13
+ **Your task:** edit **only** that **`SYS-<NNN>.md`**:
14
+
15
+ - Replace the **Purpose** placeholder with subsystem **purpose and boundaries** per **[`sys-document-structure.md`](../items/sys-document-structure.md)** — **synthesize** from **Draft steering**; **no verbatim paste** as the only Purpose.
16
+ - In **`## Purpose`**, **do not** mention **CR-***, **RQ-***, **UC-***, other **SYS-***, **STORY-***, **HOR-***, or **TST-*** — write scope in ordinary language (what this boundary owns and what is out of scope). Put **typed ids** only under **`### Downstream references`** (or notes), not in the Purpose paragraph.
17
+ - **Remove** **`## Draft steering (CLI)`** when done.
18
+ - Keep **Id**, **Status**, **`## Links and dependencies`** unchanged except as needed for prose consistency.
19
+
20
+ **Out of scope for this agent pass:** **`number.json`**, other artifacts, story folders.
21
+
22
+ ## Scope of edits — mechanical phase only (CLI / human)
23
+
24
+ Only touch:
25
+
26
+ - New folder: `technical/SYS-<NNN>-<slug>/`
27
+ - New file: `technical/SYS-<NNN>-<slug>/SYS-<NNN>.md`
28
+ - `number.json` (`next.SYS` increment in same change)
29
+
30
+ Out of scope: CR/RQ/UC/STORY/TST content edits, story creation, and restructuring existing SYS folders.
31
+
32
+ ## Rules
33
+
34
+ 1. Use `next.SYS` as the numeric source of truth (three-digit, zero-padded).
35
+ 2. Keep slug kebab-case and short.
36
+ 3. `SYS-<NNN>.md` must include:
37
+ - identity fields (`Id`, `Status`)
38
+ - `## Links and dependencies` with **`### Downstream references`** only (no **`### Upstream`** — see **[`sys-document-structure.md`](../items/sys-document-structure.md)**)
39
+ - `## Purpose`
40
+ 4. SYS creation is manual structure setup, not lifecycle chain execution.
41
+
42
+ ### Operator steering vs canonical SYS prose
43
+
44
+ The CLI **`waterfall sys start`** scaffold may include **`## Draft steering (CLI)`** and an italic placeholder under **Purpose**.
45
+
46
+ - **Synthesize** subsystem purpose and boundaries from that steering into real **Purpose** prose per **[`sys-document-structure.md`](../items/sys-document-structure.md)** — **not** a 1:1 paste of the steering block.
47
+ - **Purpose** stays **free of typed ids** (**CR-***, **SYS-***, **STORY-***, …); traceability uses **`### Downstream references`**.
48
+ - **Remove** **`## Draft steering (CLI)`** when **Purpose** is complete.
49
+
50
+ ## Steps
51
+
52
+ 1. Read `number.json` `next.SYS`.
53
+ 2. Create `technical/SYS-<NNN>-<slug>/`.
54
+ 3. Create `SYS-<NNN>.md` using `items/sys-document-structure.md`.
55
+ 4. Increment `next.SYS` in `number.json`.
56
+ 5. Commit scaffold change on the current feature branch.
57
+
58
+ ## Done when
59
+
60
+ - New SYS folder exists with `SYS-<NNN>.md`.
61
+ - `number.json` `next.SYS` is incremented.
62
+ - No unrelated artifact types were edited.
63
+
@@ -0,0 +1,64 @@
1
+ # Process: TEST → STORY
2
+
3
+ ## Purpose
4
+
5
+ When a **`TST-*`** or **`TC-*`** requires **implementation work** (harness, fixtures, automation, app changes to make a test runnable), capture that work as **`STORY-*`** items — **stories implement what the test needs**, not only product features.
6
+
7
+ Examples: add integration test target, mock server, CI job, **`local-environment`** change, Playwright setup, API endpoint needed **only** for verification.
8
+
9
+ ## Scope of edits (strict)
10
+
11
+ **Only** touch artifacts of these types in this action (plus **`number.json`** counter updates this workflow requires):
12
+
13
+ | In scope | Typical paths |
14
+ |----------|----------------|
15
+ | **`TST-*`** | **`TST-<NNN>.md`** — append new **`STORY-*`** / **`BUG-*`** under `### Downstream references` plus status notes if needed. |
16
+ | **`STORY-*`** | Under **`technical/SYS-*-…/<module>/`** when new work is **test-driven**. |
17
+ | **`BUG-*`** | Under **`technical/SYS-*-…/<module>/`** when the gap is a **defect / regression** (per **`CURSOR.md`**) rather than greenfield test enablement. |
18
+ | **`UC-*`** | Optional markdown links update only when needed; do not change **`UC-<NNN>.md`** behaviour or `TC-*` sections here. |
19
+
20
+ **Out of scope (do not edit here):** **`CR-*`**, **`RQ-*`** / **`RQ` `RQ-<NNN>.md`**, wholesale rewrites of **`UC-<NNN>.md`** **`TC-*`** sections (that is **UC → TEST**). Do **not** use this pass to “also” implement product **STORY** scope unrelated to the cited **`TST`** / **`TC`**.
21
+
22
+ ## Preconditions
23
+
24
+ - A **`TST-*`** and/or **`UC-<NNN>.md`** (**`TC-*`** sections) defines expected results.
25
+ - You have identified **engineering work** that is **driven by the test** (not already covered by an existing **STORY**).
26
+
27
+ ## Content rules (STORY from tests)
28
+
29
+ Each **STORY** created from **TEST** should:
30
+
31
+ - **Respect `HOR-*`** horizontals the same way as **UC → STORY** — **`## Data and validation`** / API / **`## Technology`** notes must **align** with **`## Aggregated definitions`** in relevant **`database-model`**, **`api-model`**, and **`technical-stack`** files; **extend** only when the test or harness **requires** something not modeled there, and say so explicitly (**[`horizontal-structure.md`](../global/horizontal-structure.md)**).
32
+
33
+ - State clearly that it **implements or enables** a **test** or **test level** (cite **`TST-*`** and **`TC-*`** ids).
34
+ - Split **test infrastructure** from **product behaviour** when both are needed — separate STORIES if separable (e.g. “add health endpoint for probe” vs “add E2E suite wiring”).
35
+ - **Acceptance criteria** should be observable: e.g. “`npm run test:integration` covers TC-002-01–03”, “CI runs TST-001 on PR”.
36
+ - Ensure any new/updated `STORY-<NNN>.md` matches the required shape in **[`story-document-structure.md`](../items/story-document-structure.md)**.
37
+
38
+ ## Rules (graph + BUG)
39
+
40
+ 1. **Regressions / wrong behaviour** in product code → prefer **`BUG-*`** linking **`TST`**, **`STORY`**, **`UC`** as **`CURSOR.md`** describes.
41
+ 2. **New work** (automation, tooling, test-only endpoints with guardrails) -> **new `STORY-*`**; do not expand closed **`_STORY-*`**.
42
+ 3. One-way linking model: append produced **`STORY`** / **`BUG`** links under source **`TST-<NNN>.md`** -> `### Downstream references`.
43
+ 4. Trivial doc-only tweaks to **TST** may skip a STORY; anything touching **implementation repos** or **CI** should usually have a **STORY**.
44
+
45
+ ## Steps
46
+
47
+ 1. **Diff** **`TST-*`** / **`UC-<NNN>.md`** — see **[`before-changing-spec.md`](../global/before-changing-spec.md)** — and list **what must be built** to execute or automate the tests.
48
+ 2. For each **non-trivial** work item, create **`STORY-*`** (or **`BUG-*`**) with test-driven goal and acceptance criteria.
49
+ 3. Update or create the produced **`STORY-*`** / **`BUG-*`** markdown.
50
+ 4. In source **`TST-<NNN>.md`**, append new entries under `### Downstream references`; update status notes if tracked.
51
+ 5. Allocate ids from **`number.json`** in the same commit.
52
+
53
+ ## Done when
54
+
55
+ - Every **test-execution gap** that needs code or infra has a **traceable STORY or BUG**, and **`TST → STORY|BUG`** edges are consistent.
56
+
57
+ ## CLI orchestration
58
+
59
+ When this prompt is executed as part of a batch command (for example `waterfall cr all`, `waterfall rq all`, `waterfall uc all`, or `waterfall test all`), the CLI will run multiple prompts in separate agent invocations.
60
+
61
+ 1. Treat the operator-provided `hint` as global steering for the batch, but do not widen this step beyond its **Scope of edits (strict)**.
62
+ 2. If this step has **nothing to do** for the current artifact(s), make no changes and let the CLI proceed.
63
+ 3. Commit boundary: stop after this step's artifacts are internally consistent (`TST`/`STORY`/`BUG`/`number.json` for this step). The batch will not continue in this same invocation.
64
+
@@ -0,0 +1,85 @@
1
+ # Process: UC → STORY
2
+
3
+ ## Purpose
4
+
5
+ Turn **`UC-*`** intent into implementable **`STORY-*`** items under one or more existing **`technical/SYS-*`** subsystems. A single UC should be split into small, actionable stories, and those stories may land in different SYS areas.
6
+
7
+ ## Scope of edits (strict)
8
+
9
+ **Only** touch artifacts of these types in this action (plus **`number.json`** counter updates this workflow requires):
10
+
11
+ | In scope | Typical paths |
12
+ |----------|----------------|
13
+ | **`UC-*`** | In **`UC-<NNN>.md`**, append produced stories under `### Downstream references`. Do not rewrite behaviour/testcase content here. |
14
+ | **`STORY-*`** | New or updated `technical/SYS-*-…/STORY-<NNN>-<slug>/STORY-<NNN>.md` (or equivalent folder pattern already used in the target SYS). |
15
+
16
+ **Out of scope (do not edit here):** **`CR-*`**, **`RQ-*`** (theme / **`RQ-<NNN>.md`**), **`UC-<NNN>.md`** **acceptance (`TC-*`) sections** or wholesale rewrites of behaviour/testcases, **`TST-*`**, **`BUG-*`** (unless **`CURSOR.md`** mandates a parallel **BUG** for a defect — still prefer a **separate** BUG prompt). If the **UC prose** or **acceptance** is wrong, fix it under **RQ → UC** or **UC → TEST** in another change, **not** inside **UC → STORY**.
17
+
18
+ ## Preconditions
19
+
20
+ - **`UC-<NNN>.md`** (behaviour + **`TC-*`** acceptance) exists and is stable enough to scope engineering work.
21
+ - Target **`SYS-*`** areas are identified.
22
+ - You have reviewed **[`before-changing-spec.md`](../global/before-changing-spec.md)** (e.g. **`git diff`** on the UC) so new stories align with **current** wording.
23
+ - Applicable **`HOR-*`** horizontals for this change (e.g. **`database-model`**, **`api-model`**, **`technical-stack`**) are **read**; see **[`horizontal-structure.md`](../global/horizontal-structure.md)**. Stories **must respect** their **`## Aggregated definitions`** — names, types, tables, API contracts, and **named stack choices** stay **consistent** with the horizontal. **Extend** those concepts **only** when the **UC** truly needs something not yet modeled; then state the extension **explicitly** in the STORY and treat a **horizontal** refresh as the normal follow-up when the extension is durable.
24
+ - SYS creation is manual and out of lifecycle orchestration: this prompt selects from existing SYS only.
25
+
26
+ ## Granular STORY breakdown (required mindset)
27
+
28
+ - **One STORY = one shippable engineering slice** (clear goal, bounded acceptance, explicit **out of scope** for the rest of the UC). If the UC implies **search**, **cart**, **checkout**, **persistence**, **API**, **UI** work, create **multiple** **`STORY-*`** items — do **not** collapse the whole UC into a single vague story.
29
+ - **Split by vertical slice or layer** when each part has different **TC-*** coverage, different **SYS** homes, or different sequencing (e.g. schema + API before storefront flow).
30
+ - **Each STORY** must still satisfy **[`story-document-structure.md`](../items/story-document-structure.md)** (**`## Data and validation`**, **`## Technology`**, etc.) for **its** slice only; do not use one story as a dump of every open question for the UC.
31
+ - Link every produced story from **`UC-<NNN>.md`** `### Downstream references`; cite **UC** / **TC-*** by **id only** — **[`before-changing-spec.md`](../global/before-changing-spec.md)**.
32
+
33
+ See **[`content-requirements-vs-use-cases.md`](../global/content-requirements-vs-use-cases.md)** → **Granularity: multiple STORY items from one UC**.
34
+
35
+ ## Content rules (STORY body)
36
+
37
+ Each **STORY** should:
38
+
39
+ - **Honor horizontals:** **`## Data and validation`** and **`## Technology`** (and any API/persistence prose) must **not** contradict relevant **`HOR-*`** definitions — including **`technical-stack`** (frameworks, libraries, runtimes). Prefer **reusing** consolidated model, contract, and stack text **by meaning** (cite **`HOR-<NNN>`** by id if you need a single traceability line). Only **add** new fields, resources, types, or **stack components** when the UC slice **requires** them and the horizontal does not yet cover them — then document the delta clearly.
40
+ - Map to **part of the UC** you can deliver independently (API slice, UI slice, infra, docs in implementation repo, etc.) — **not** one giant “do everything” unless the UC is truly atomic.
41
+ - State **goal** and **acceptance criteria** that **trace** to **UC** sections and/or **`TC-*`** ids where helpful — cite **`UC-<NNN>`** and **`TC-*`** by **id only**, never by file path (**[`before-changing-spec.md`](../global/before-changing-spec.md)**).
42
+ - List **out of scope** so the next STORY can pick up the remainder without overlap.
43
+ - Prefer **several small STORIES** over one vague one when the UC change is large (phasing, vertical slices).
44
+ - Split by subsystem ownership when needed: one UC may produce stories in multiple SYS folders.
45
+ - Ensure `STORY-<NNN>.md` matches the required shape in **[`story-document-structure.md`](../items/story-document-structure.md)**.
46
+
47
+ ### Concrete engineering detail (required depth)
48
+
49
+ Stories must be **implementation-ready**, not vague intent:
50
+
51
+ - **`## Data and validation` (required):** name **entities / fields / types** (or equivalent schema shapes), **validity rules** (ranges, required fields, uniqueness, state transitions), and what “invalid” means for this slice.
52
+ - **`## Technology` (required):** name **concrete** stack choices for this slice — languages, frameworks, protocols, storage type (e.g. relational table vs document vs cache), integration style (REST/gRPC/events) — at the level the team needs to start work without guessing.
53
+ - Tie those sections to **UC** / **`TC-*`** by **id** so traceability stays compact.
54
+
55
+ If information is still unknown, state **explicit assumptions** or **open decisions** in the STORY rather than leaving generic placeholders.
56
+
57
+ ## Rules (graph + process)
58
+
59
+ 1. One-way linking model: when a story is created, append it in source **`UC-<NNN>.md`** under `### Downstream references`.
60
+ 2. Keep traceability in markdown only through `### Downstream references` in the source UC.
61
+ 3. Use **`number.json` `next.STORY`**; **closed** stories get **`_STORY-*`** folder prefix only — never edit closed stories for new scope (**`CURSOR.md`**).
62
+ 4. **Implementation** happens outside **`waterfall-spec`**; the STORY describes what lands in which SYS-owned technical area.
63
+ 5. SYS entities are not created by this lifecycle edge; if a new SYS is needed, create it manually first.
64
+
65
+ ## Steps
66
+
67
+ 1. **Diff / read** the UC — see **[`before-changing-spec.md`](../global/before-changing-spec.md)** — and list **concrete deltas** (new flows, changed preconditions, new exceptions).
68
+ 2. **Decompose** those deltas into **ordered or parallel** STORIES (each shippable, each with clear acceptance), grouped by target SYS ownership.
69
+ 3. Allocate each **`STORY-<NNN>`** under the appropriate existing **`technical/SYS-…/`** path.
70
+ 4. Write **`STORY-<NNN>.md`**: goal, acceptance criteria (linked to UC / TC where useful), out-of-scope, and links section.
71
+ 5. In source **`UC-<NNN>.md`**, append each produced story under `### Downstream references`.
72
+ 6. Increment **`next.STORY`** per new STORY in the **same** commit batch as appropriate.
73
+
74
+ ## Done when
75
+
76
+ - Every planned UC change has at least one STORY (or explicit deferral), stories are split into actionable chunks, and `UC -> STORY` traceability is present under `### Downstream references` in the UC.
77
+
78
+ ## CLI orchestration
79
+
80
+ When this prompt is executed as part of a batch command (for example `waterfall cr all`, `waterfall rq all`, or `waterfall uc all`), the CLI will run multiple prompts in separate agent invocations.
81
+
82
+ 1. Treat the operator-provided `hint` as global steering for the batch, but do not widen this step beyond its **Scope of edits (strict)**.
83
+ 2. If this step has **nothing to do** for the current artifact(s), make no changes and let the CLI proceed.
84
+ 3. Commit boundary: stop after this step's artifacts are internally consistent (`UC`/`STORY`/`number.json` for this step). The next lifecycle step prompt will be invoked separately.
85
+
@@ -0,0 +1,58 @@
1
+ # Process: UC → TEST
2
+
3
+ ## Purpose
4
+
5
+ **Create or adapt** verification so that **all changes** to a **`UC-*`** are **covered** by **`TC-*`** acceptance sections in **`UC-<NNN>.md`** and, where used, **`TST-*`** (manual and/or automated).
6
+
7
+ ## Scope of edits (strict)
8
+
9
+ **Only** touch artifacts of these types in this action (plus **`number.json`** counter updates this workflow requires):
10
+
11
+ | In scope | Typical paths |
12
+ |----------|----------------|
13
+ | **`UC-*`** | **`UC-<NNN>.md`** — update `## TC-...` acceptance blocks and append produced tests under `### Downstream references`. |
14
+ | **`TST-*`** | `tests/TST-<NNN>-<slug>/TST-<NNN>.md`. |
15
+
16
+ **Out of scope (do not edit here):** **`UC-<NNN>.md`** behaviour narrative (**actors** through **main flow**, **exceptions**, **non-functional** sections, etc.) unless a **separate** **RQ → UC** (or explicit UC authoring pass) already changed it — **UC → TEST** does not redefine product behaviour. **`CR-*`**, **`RQ-*`**, **`SYS-*`**, **`STORY-*`**, **`BUG-*`**.
17
+
18
+ ## Preconditions
19
+
20
+ - **`UC-<NNN>.md`** contains (or will contain) **`TC-*`** sections aligned to the use case.
21
+ - You know whether verification is **manual-only**, **automated in an implementation repo**, or both.
22
+ - You have run **`git diff`** (or equivalent) on **`UC-<NNN>.md`** — see **[`before-changing-spec.md`](../global/before-changing-spec.md)** — so you see **every** delta that needs test coverage.
23
+
24
+ ## Content rules
25
+
26
+ 1. **Every new or changed** main-flow step, precondition, postcondition, or **exception** in the **behaviour** part of **`UC-<NNN>.md`** should map to **at least one** **`TC-*`** (new or updated steps/expected outcome), unless explicitly marked non-testable (rare — then document why next to the **`TC-*`** or in a short note in the same file).
27
+ 2. **Regressions:** if behaviour is **removed** or **replaced**, **retire or rewrite** the affected **`TC-*`** blocks so no stale acceptance remains.
28
+ 3. **`TST-*`** (if present) must **mirror** the **`TC-*`** set you intend to run as a **formal spec** — add or adjust **TST** sections when **TCs** change; cite testcase ids in **TST** tables.
29
+ 4. **Automation** (implementation repo) should still trace to **`TC-*`** / **TST** in prose or CI docs — no “mystery tests” with no UC id.
30
+
31
+ ## Rules (graph + ids)
32
+
33
+ 1. **Source of testcase ids:** **`UC-<NNN>.md`** (`**## TC-…**` headings) — **`TST-*`** cites those ids; do not invent parallel numbering in **`TST-*`** without mapping.
34
+ 2. One-way linking model: append new `TST-*` links in the source **`UC-<NNN>.md`** under `### Downstream references`.
35
+ 3. **`number.json` `next.TST`** for new **`TST-*`** folders under **`tests/`**.
36
+
37
+ ## Steps
38
+
39
+ When creating/updating **`TST-<NNN>.md`**, follow **[`tst-document-structure.md`](../items/tst-document-structure.md)** so identity, `Links and dependencies`, `Objective`, `Environment and data`, and `TC-*` table sections remain consistent.
40
+
41
+ 1. From the **UC diff**, list **coverage gaps** (missing **TC-**, outdated expected outcomes, new branches).
42
+ 2. **Update `UC-<NNN>.md`** — edit **`TC-*`** sections first until the delta is fully covered.
43
+ 3. **Update or create `TST-*`** so it reflects the same scope (new sections, environment notes, manual vs automated).
44
+ 4. In **`UC-<NNN>.md`**, append each produced test spec under `### Downstream references`.
45
+ 5. Increment **`next.TST`** when adding a new **`TST-*`**.
46
+
47
+ ## Done when
48
+
49
+ - **No UC change** is left without a matching **`TC-*`** update (or explicit documented exception), and every **`TST-*`** row traces to a **`TC-*`** where applicable.
50
+
51
+ ## CLI orchestration
52
+
53
+ When this prompt is executed as part of a batch command (for example `waterfall cr all`, `waterfall rq all`, or `waterfall uc all`), the CLI will run multiple prompts in separate agent invocations.
54
+
55
+ 1. Treat the operator-provided `hint` as global steering for the batch, but do not widen this step beyond its **Scope of edits (strict)**.
56
+ 2. If this step has **nothing to do** for the current artifact(s), make no changes and let the CLI proceed.
57
+ 3. Commit boundary: stop after this step's artifacts are internally consistent (`UC`/`TST`/`number.json` for this step). The next lifecycle step prompt will be invoked separately.
58
+