forge-workflow 0.0.1 → 0.0.3

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 (150) hide show
  1. package/.claude/commands/plan.md +93 -4
  2. package/.cline/workflows/dev.md +311 -0
  3. package/.cline/workflows/plan.md +475 -0
  4. package/.cline/workflows/premerge.md +176 -0
  5. package/.cline/workflows/research.md +39 -0
  6. package/.cline/workflows/review.md +439 -0
  7. package/.cline/workflows/rollback.md +718 -0
  8. package/.cline/workflows/ship.md +131 -0
  9. package/.cline/workflows/sonarcloud.md +146 -0
  10. package/.cline/workflows/status.md +74 -0
  11. package/.cline/workflows/validate.md +234 -0
  12. package/.cline/workflows/verify.md +218 -0
  13. package/.codex/config.toml +11 -0
  14. package/.codex/skills/dev/SKILL.md +314 -0
  15. package/.codex/skills/plan/SKILL.md +478 -0
  16. package/.codex/skills/premerge/SKILL.md +179 -0
  17. package/.codex/skills/research/SKILL.md +42 -0
  18. package/.codex/skills/review/SKILL.md +442 -0
  19. package/.codex/skills/rollback/SKILL.md +721 -0
  20. package/.codex/skills/ship/SKILL.md +134 -0
  21. package/.codex/skills/sonarcloud/SKILL.md +149 -0
  22. package/.codex/skills/status/SKILL.md +77 -0
  23. package/.codex/skills/validate/SKILL.md +237 -0
  24. package/.codex/skills/verify/SKILL.md +221 -0
  25. package/.cursor/commands/dev.md +311 -0
  26. package/.cursor/commands/plan.md +475 -0
  27. package/.cursor/commands/premerge.md +176 -0
  28. package/.cursor/commands/research.md +39 -0
  29. package/.cursor/commands/review.md +439 -0
  30. package/.cursor/commands/rollback.md +718 -0
  31. package/.cursor/commands/ship.md +131 -0
  32. package/.cursor/commands/sonarcloud.md +146 -0
  33. package/.cursor/commands/status.md +74 -0
  34. package/.cursor/commands/validate.md +234 -0
  35. package/.cursor/commands/verify.md +218 -0
  36. package/.cursor/rules/permissions-guidance.mdc +37 -0
  37. package/.github/prompts/dev.prompt.md +316 -0
  38. package/.github/prompts/plan.prompt.md +480 -0
  39. package/.github/prompts/premerge.prompt.md +181 -0
  40. package/.github/prompts/research.prompt.md +44 -0
  41. package/.github/prompts/review.prompt.md +444 -0
  42. package/.github/prompts/rollback.prompt.md +723 -0
  43. package/.github/prompts/ship.prompt.md +136 -0
  44. package/.github/prompts/sonarcloud.prompt.md +151 -0
  45. package/.github/prompts/status.prompt.md +79 -0
  46. package/.github/prompts/validate.prompt.md +239 -0
  47. package/.github/prompts/verify.prompt.md +223 -0
  48. package/.kilocode/workflows/dev.md +315 -0
  49. package/.kilocode/workflows/plan.md +479 -0
  50. package/.kilocode/workflows/premerge.md +180 -0
  51. package/.kilocode/workflows/research.md +43 -0
  52. package/.kilocode/workflows/review.md +443 -0
  53. package/.kilocode/workflows/rollback.md +722 -0
  54. package/.kilocode/workflows/ship.md +135 -0
  55. package/.kilocode/workflows/sonarcloud.md +150 -0
  56. package/.kilocode/workflows/status.md +78 -0
  57. package/.kilocode/workflows/validate.md +238 -0
  58. package/.kilocode/workflows/verify.md +222 -0
  59. package/.opencode/commands/dev.md +314 -0
  60. package/.opencode/commands/plan.md +478 -0
  61. package/.opencode/commands/premerge.md +179 -0
  62. package/.opencode/commands/research.md +42 -0
  63. package/.opencode/commands/review.md +442 -0
  64. package/.opencode/commands/rollback.md +721 -0
  65. package/.opencode/commands/ship.md +134 -0
  66. package/.opencode/commands/sonarcloud.md +149 -0
  67. package/.opencode/commands/status.md +77 -0
  68. package/.opencode/commands/validate.md +237 -0
  69. package/.opencode/commands/verify.md +221 -0
  70. package/.roo/commands/dev.md +315 -0
  71. package/.roo/commands/plan.md +479 -0
  72. package/.roo/commands/premerge.md +180 -0
  73. package/.roo/commands/research.md +43 -0
  74. package/.roo/commands/review.md +443 -0
  75. package/.roo/commands/rollback.md +722 -0
  76. package/.roo/commands/ship.md +135 -0
  77. package/.roo/commands/sonarcloud.md +150 -0
  78. package/.roo/commands/status.md +78 -0
  79. package/.roo/commands/validate.md +238 -0
  80. package/.roo/commands/verify.md +222 -0
  81. package/LICENSE +21 -21
  82. package/bin/forge.js +8 -4
  83. package/docs/ENHANCED_ONBOARDING.md +2 -2
  84. package/docs/TOOLCHAIN.md +15 -234
  85. package/install.sh +35 -39
  86. package/lib/agents/cline.plugin.json +1 -1
  87. package/lib/agents/roo.plugin.json +1 -1
  88. package/lib/commands/plan.js +11 -15
  89. package/lib/commands/recommend.js +2 -2
  90. package/lib/dep-guard/analyzer.js +294 -0
  91. package/lib/dep-guard/behavior-detector.js +98 -0
  92. package/lib/dep-guard/contract-detector.js +162 -0
  93. package/lib/dep-guard/import-detector.js +498 -0
  94. package/lib/dep-guard/path-utils.js +13 -0
  95. package/lib/dep-guard/rubric.js +120 -0
  96. package/lib/dep-guard/task-parser.js +318 -0
  97. package/lib/plugin-catalog.js +18 -28
  98. package/lib/workflow-profiles.js +5 -11
  99. package/package.json +18 -4
  100. package/skills/parallel-deep-research/SKILL.md +108 -0
  101. package/skills/parallel-deep-research/evals/README.md +27 -0
  102. package/skills/parallel-deep-research/evals/evals.json +62 -0
  103. package/skills/sonarcloud-analysis/SKILL.md +171 -0
  104. package/skills/sonarcloud-analysis/evals/README.md +27 -0
  105. package/skills/sonarcloud-analysis/evals/evals.json +50 -0
  106. package/skills/sonarcloud-analysis/references/api-reference.md +466 -0
  107. package/docs/planning/PROGRESS.md +0 -396
  108. package/docs/plans/.gitkeep +0 -0
  109. package/docs/plans/2026-02-27-forge-test-suite-v2-decisions.md +0 -21
  110. package/docs/plans/2026-02-27-forge-test-suite-v2-design.md +0 -362
  111. package/docs/plans/2026-02-27-forge-test-suite-v2-tasks.md +0 -343
  112. package/docs/plans/2026-03-02-superpowers-gaps-decisions.md +0 -26
  113. package/docs/plans/2026-03-02-superpowers-gaps-design.md +0 -239
  114. package/docs/plans/2026-03-02-superpowers-gaps-tasks.md +0 -260
  115. package/docs/plans/2026-03-04-agent-command-parity-design.md +0 -163
  116. package/docs/plans/2026-03-04-verify-worktree-cleanup-decisions.md +0 -7
  117. package/docs/plans/2026-03-04-verify-worktree-cleanup-design.md +0 -165
  118. package/docs/plans/2026-03-05-forge-uto-decisions.md +0 -6
  119. package/docs/plans/2026-03-05-forge-uto-design.md +0 -116
  120. package/docs/plans/2026-03-05-forge-uto-tasks.md +0 -244
  121. package/docs/plans/2026-03-10-command-creator-and-eval-decisions.md +0 -52
  122. package/docs/plans/2026-03-10-command-creator-and-eval-design.md +0 -350
  123. package/docs/plans/2026-03-10-command-creator-and-eval-tasks.md +0 -426
  124. package/docs/plans/2026-03-10-stale-workflow-refs-decisions.md +0 -8
  125. package/docs/plans/2026-03-10-stale-workflow-refs-design.md +0 -80
  126. package/docs/plans/2026-03-10-stale-workflow-refs-tasks.md +0 -90
  127. package/docs/plans/2026-03-14-beads-plan-context-decisions.md +0 -9
  128. package/docs/plans/2026-03-14-beads-plan-context-design.md +0 -171
  129. package/docs/plans/2026-03-14-beads-plan-context-tasks.md +0 -160
  130. package/docs/plans/2026-03-14-skill-eval-loop-decisions.md +0 -33
  131. package/docs/plans/2026-03-14-skill-eval-loop-design.md +0 -118
  132. package/docs/plans/2026-03-14-skill-eval-loop-results.md +0 -78
  133. package/docs/plans/2026-03-14-skill-eval-loop-tasks.md +0 -160
  134. package/docs/plans/2026-03-15-agent-command-parity-v2-decisions.md +0 -11
  135. package/docs/plans/2026-03-15-agent-command-parity-v2-design.md +0 -145
  136. package/docs/plans/2026-03-15-agent-command-parity-v2-tasks.md +0 -211
  137. package/docs/research/TEMPLATE.md +0 -292
  138. package/docs/research/advanced-testing.md +0 -297
  139. package/docs/research/agent-permissions.md +0 -167
  140. package/docs/research/dependency-chain.md +0 -328
  141. package/docs/research/forge-workflow-v2.md +0 -550
  142. package/docs/research/plugin-architecture.md +0 -772
  143. package/docs/research/pr4-cli-automation.md +0 -326
  144. package/docs/research/premerge-verify-restructure.md +0 -205
  145. package/docs/research/skills-restructure.md +0 -508
  146. package/docs/research/sonarcloud-perfection-plan.md +0 -166
  147. package/docs/research/sonarcloud-quality-gate.md +0 -184
  148. package/docs/research/superpowers-integration.md +0 -403
  149. package/docs/research/superpowers.md +0 -319
  150. package/docs/research/test-environment.md +0 -519
@@ -0,0 +1,475 @@
1
+
2
+ Plan a feature from scratch: brainstorm design intent, research technical approach, then set up branch, worktree, and a complete task list ready for /dev.
3
+
4
+ # Plan
5
+
6
+ This command runs in **3 phases**. Each phase ends with a HARD-GATE. Do not skip phases.
7
+
8
+ ---
9
+
10
+ ```
11
+ <HARD-GATE: /plan entry — worktree isolation>
12
+ Before ANY planning work begins:
13
+
14
+ 1. Run: git branch --show-current
15
+ 2. If the current branch is NOT master/main:
16
+ - STOP. Do not begin Phase 1.
17
+ - Tell the user: "You are on '<branch>'. Planning must start from a clean worktree on master.
18
+ Run: git checkout master — then re-run /plan."
19
+ 3. If on master, create the worktree NOW before asking any questions:
20
+ a. bd worktree create .worktrees/<slug> --branch feat/<slug>
21
+ b. cd .worktrees/<slug>
22
+ 4. Confirm: "Working in isolated worktree: .worktrees/<slug> (branch: feat/<slug>)"
23
+ 5. ONLY THEN begin Phase 1.
24
+
25
+ Rationale: Planning commits (design docs, task lists) belong only to this feature's branch.
26
+ If planning runs in the main directory on a non-master branch, those commits contaminate
27
+ whatever branch is currently checked out. The worktree ensures zero cross-contamination
28
+ between parallel features or sessions.
29
+ </HARD-GATE>
30
+ ```
31
+
32
+ ---
33
+
34
+ ## Usage
35
+
36
+ ```bash
37
+ /plan <feature-slug>
38
+ /plan <feature-slug> --strategic # Major architecture change: creates design doc PR before Phase 2
39
+ /plan <feature-slug> --continue # After --strategic PR is merged: run Phase 2 + 3
40
+ ```
41
+
42
+ ---
43
+
44
+ ## Phase 1: Design Intent (Brainstorming)
45
+
46
+ **Goal**: Capture WHAT to build — purpose, constraints, success criteria, edge cases, approach.
47
+
48
+ ### Step 0: Dependency ripple check (advisory)
49
+
50
+ Before exploring context or asking questions, check for potential conflicts with in-flight work:
51
+
52
+ ```bash
53
+ # If a Beads issue ID is known (e.g., from /status or bd ready):
54
+ bash scripts/dep-guard.sh check-ripple <beads-issue-id>
55
+
56
+ # If no issue exists yet (first-time plan):
57
+ bd list --status=open,in_progress
58
+ ```
59
+
60
+ Review the output. If overlaps are detected:
61
+ - Consider whether the overlapping issue should be a dependency
62
+ - Note any shared areas for the design Q&A
63
+ - This check is **advisory only** — always proceed to Step 1 regardless of findings
64
+
65
+ #### Ripple Analyst Agent (spawned when contract overlaps found)
66
+
67
+ When `check-ripple` detects overlapping issues AND contract metadata is available, spawn a Ripple Analyst subagent with this prompt:
68
+
69
+ **Input to agent**:
70
+ - Current issue's contract changes (from `extract-contracts` output)
71
+ - Consumer code snippets (from `find-consumers` output for each changed contract)
72
+ - Overlapping issue's title, description, and contract metadata
73
+
74
+ **Agent instructions**:
75
+ 1. For each overlapping contract, imagine 2-3 concrete break scenarios:
76
+ - "If [contract X] changes [specific behavior], then [consumer Y] will [specific failure]"
77
+ 2. Rate overall impact as one of:
78
+ - **NONE**: No real conflict despite keyword overlap
79
+ - **LOW**: Consumers need trivial adjustment (add parameter, rename call)
80
+ - **HIGH**: Consumer needs significant rework (parsing logic, data handling changes)
81
+ - **CRITICAL**: Consumer is in an active in_progress issue's task list
82
+ 3. **When uncertain, default to HIGH** — conservative over permissive
83
+ 4. Recommend one action:
84
+ - Add dependency (`bd dep add <source> <target>`)
85
+ - Coordinate with other issue's developer
86
+ - Scope down current feature to avoid overlap
87
+ - Proceed as-is (no real conflict)
88
+
89
+ **Output format**:
90
+ ```
91
+ Impact: [NONE|LOW|HIGH|CRITICAL]
92
+ Confidence: [high|medium|low]
93
+
94
+ Break scenarios:
95
+ 1. [scenario description]
96
+ 2. [scenario description]
97
+
98
+ Recommendation: [action]
99
+ Reason: [why this action]
100
+ ```
101
+
102
+ This agent is advisory only. The developer always makes the final decision.
103
+
104
+ ### Step 1: Explore project context
105
+
106
+ Before asking any questions, read relevant files:
107
+ - Recent commits related to this area
108
+ - Existing code in affected modules
109
+ - Any related docs, tests, or prior research
110
+
111
+ ### Step 2: Ask clarifying questions — one at a time
112
+
113
+ Ask each question in sequence. Wait for user response. Use multiple choice where possible.
114
+
115
+ Questions to cover (adapt to feature, don't ask mechanical copies):
116
+ 1. **Purpose** — What problem does this solve? Who benefits?
117
+ 2. **Constraints** — What must this NOT do? What are the hard limits?
118
+ 3. **Success criteria** — How will we know it's done? What is the minimum viable result?
119
+ 4. **Edge cases** — What happens when [key dependency] fails / [input] is missing / [state] is ambiguous?
120
+ 5. **Technical preferences** — Library A or B? Pattern X or Y? (when real options exist)
121
+ 6. **Ambiguity policy** — If a spec gap is found mid-dev, should the agent: (a) make a reasonable choice and document it, or (b) pause and wait for input?
122
+
123
+ ### Step 3: Propose approaches
124
+
125
+ Propose 2-3 concrete approaches with:
126
+ - Trade-offs (speed vs safety, complexity vs flexibility)
127
+ - A clear recommendation with reasoning
128
+ - Get user approval on the chosen approach
129
+
130
+ ### Step 4: Write design doc
131
+
132
+ Save to `docs/plans/YYYY-MM-DD-<slug>-design.md` with these sections:
133
+ - **Feature**: slug, date, status
134
+ - **Purpose**: what problem it solves
135
+ - **Success criteria**: measurable, specific
136
+ - **Out of scope**: explicit boundaries
137
+ - **Approach selected**: which option and why
138
+ - **Constraints**: hard limits
139
+ - **Edge cases**: decisions made during Q&A
140
+ - **Ambiguity policy**: agent's fallback when spec gaps arise mid-dev
141
+
142
+ Commit the design doc:
143
+ ```bash
144
+ git add docs/plans/YYYY-MM-DD-<slug>-design.md
145
+ git commit -m "docs: add design doc for <slug>"
146
+ ```
147
+
148
+ ---
149
+
150
+ **--strategic flag** (for major architecture changes):
151
+
152
+ After committing the design doc, push to a proposal branch and open PR:
153
+ ```bash
154
+ git checkout -b feat/<slug>-proposal
155
+ git push -u origin feat/<slug>-proposal
156
+ gh pr create --title "Design: <feature-name>" \
157
+ --body "Design doc for review. See docs/plans/YYYY-MM-DD-<slug>-design.md"
158
+ ```
159
+
160
+ **STOP here.** Present the PR URL. Wait for the user to merge the proposal PR.
161
+ After merge, run `/plan <slug> --continue` to proceed to Phase 2 + 3.
162
+
163
+ ---
164
+
165
+ ```
166
+ <HARD-GATE: Phase 1 exit>
167
+ Do NOT begin Phase 2 (web research) until:
168
+ 1. User has approved the design in this session
169
+ 2. Design doc exists at docs/plans/YYYY-MM-DD-<slug>-design.md
170
+ 3. Design doc includes: success criteria, edge cases, out-of-scope, ambiguity policy
171
+ 4. Design doc is committed to git
172
+ </HARD-GATE>
173
+ ```
174
+
175
+ ---
176
+
177
+ ## Phase 2: Technical Research
178
+
179
+ **Goal**: Find HOW to build it — best practices, known issues, security risks, TDD scenarios.
180
+
181
+ Run these in parallel:
182
+
183
+ ### Web research (parallel-deep-research skill)
184
+ ```
185
+ Skill("parallel-deep-research")
186
+ ```
187
+ Search for:
188
+ - "[tech stack] [feature] best practices [year]"
189
+ - "[library/framework] [feature] implementation patterns"
190
+ - "Known issues / gotchas with [approach selected]"
191
+
192
+ ### OWASP Top 10 analysis
193
+
194
+ For this feature's risk surface, document each relevant OWASP category:
195
+ - What the risk is
196
+ - Whether it applies to this feature
197
+ - What mitigation will be implemented
198
+
199
+ ### Codebase exploration (Explore agent)
200
+ - Similar existing patterns to reuse
201
+ - Files this feature will affect
202
+ - Existing test infrastructure to leverage
203
+
204
+ ### DRY check (mandatory — use actual search tools)
205
+
206
+ Before finalizing the approach, run Grep/Glob/Read searches for existing implementations of the planned function or pattern. Do not rely on memory or assumptions — execute the searches.
207
+
208
+ ```
209
+ Grep(searchTerm) # e.g., the function or concept name
210
+ Glob("**/*.js") # narrow to affected file types if needed
211
+ Read(matchedFile) # inspect any match in context
212
+ ```
213
+
214
+ If a match is found:
215
+ - Update the design doc's "Approach selected" section to say "extend existing [file/function]" — not "create new".
216
+ - Note the existing file path and line number in the design doc.
217
+
218
+ If no match is found: proceed. The DRY gate is cleared.
219
+
220
+ ### Blast-radius search (mandatory for remove/rename/replace features)
221
+
222
+ If this feature involves **removing**, **renaming**, or **replacing** a concept, tool, or dependency:
223
+
224
+ 1. Grep the ENTIRE codebase for the thing being removed/renamed:
225
+ ```
226
+ Grep("<thing-being-removed>") # exact name
227
+ Grep("<thing-being-removed>", -i) # case-insensitive variant
228
+ Glob("**/*<thing>*") # files named after it
229
+ ```
230
+
231
+ 2. For EVERY match found:
232
+ - Note the file path and line number in the design doc
233
+ - Add a cleanup task to the task list (Phase 3)
234
+ - Flag matches in unexpected packages or config files explicitly
235
+
236
+ 3. Common hiding spots to check:
237
+ - `package.json` (scripts, dependencies, description)
238
+ - `install.sh` / setup scripts
239
+ - CI/CD workflows (`.github/workflows/`)
240
+ - Agent config files (`lib/agents/`, `.cursorrules`, etc.)
241
+ - Documentation (`docs/`, `README.md`, `AGENTS.md`)
242
+ - Import statements and require() calls
243
+
244
+ If no removal/rename is involved, this section is skipped.
245
+
246
+ ### TDD test scenarios
247
+
248
+ Identify at minimum 3 test scenarios:
249
+ - Happy path
250
+ - Error / failure path
251
+ - Edge case from Phase 1
252
+
253
+ Append all research findings to the design doc under a `## Technical Research` section (not a separate file).
254
+
255
+ ---
256
+
257
+ ```
258
+ <HARD-GATE: Phase 2 exit>
259
+ Do NOT begin Phase 3 (setup) until:
260
+ 1. OWASP analysis is documented in design doc
261
+ 2. At least 3 TDD test scenarios are identified
262
+ 3. Approach selection is confirmed (which library/pattern to use)
263
+ 4. If feature involves removal/rename: blast-radius search completed, all references added to task list
264
+ </HARD-GATE>
265
+ ```
266
+
267
+ ---
268
+
269
+ ## Phase 3: Setup + Task List
270
+
271
+ **Goal**: Create branch, worktree, Beads issue, and a complete task list ready for /dev.
272
+
273
+ ### Step 1: Beads issue
274
+
275
+ ```bash
276
+ bd create --title="<feature-name>" --type=feature
277
+ bd update <id> --status=in_progress
278
+ ```
279
+
280
+ ### Step 2: Branch + worktree
281
+
282
+ **ALWAYS branch from master, never from the current branch.** If the working directory is on any branch other than master, the new feature branch would inherit all unmerged changes from that branch — contaminating the new feature's history.
283
+
284
+ **Note**: If the Entry HARD-GATE already created the branch and worktree (and you are already inside `.worktrees/<slug>`), skip Steps 2b–2d — they are already done.
285
+
286
+ ```bash
287
+ # Step 2a: Check if branch and worktree were already created by Entry HARD-GATE
288
+ CURRENT=$(git branch --show-current)
289
+ if [ "$CURRENT" = "feat/<slug>" ]; then
290
+ echo "✓ Branch feat/<slug> already exists (Entry HARD-GATE created it) — skipping 2b–2d"
291
+ else
292
+ # Step 2b: Verify .worktrees/ is gitignored — add if missing
293
+ git check-ignore -v .worktrees/ || echo ".worktrees/" >> .gitignore
294
+
295
+ # Step 2c: Create a Beads-aware worktree rooted on master
296
+ git checkout master
297
+ bd worktree create .worktrees/<slug> --branch feat/<slug>
298
+ cd .worktrees/<slug>
299
+ fi
300
+ ```
301
+
302
+ **Why this matters**: Multiple parallel features or sessions each get their own isolated worktree. Changes to one feature never bleed into another. The main working directory can stay on any branch without affecting new feature branches.
303
+
304
+ ### Step 3: Project setup in worktree
305
+
306
+ Auto-detect and run install:
307
+ ```bash
308
+ # e.g., bun install / npm install / pip install -r requirements.txt
309
+ ```
310
+
311
+ ### Step 4: Baseline test run
312
+
313
+ ```bash
314
+ # Run full test suite in worktree
315
+ bun test # or project test command
316
+ ```
317
+
318
+ If tests fail: report which tests are failing and ask user whether to investigate or proceed anyway. Do not silently proceed past failing baseline tests.
319
+
320
+ ### Step 5: Task list creation
321
+
322
+ Read the design doc. Break implementation into granular tasks.
323
+
324
+ **Task format** (each task MUST have ALL of these):
325
+ ```
326
+ Task N: <descriptive title>
327
+ File(s): <exact file paths>
328
+ What to implement: <complete description — not "add feature X", but what specifically>
329
+ TDD steps:
330
+ 1. Write test: <test file path, what assertion, what input/output>
331
+ 2. Run test: confirm it fails with [specific expected error message]
332
+ 3. Implement: <exact function/class/component to write>
333
+ 4. Run test: confirm it passes
334
+ 5. Commit: `<type>: <message>`
335
+ Expected output: <what running the test/code produces when done>
336
+ ```
337
+
338
+ **Ordering rules**:
339
+ - Foundational/shared modules FIRST (types, utils, constants)
340
+ - Feature logic SECOND
341
+ - Integration/wiring THIRD
342
+ - Uncertain/ambiguous tasks LAST (so they can be deferred if blocked)
343
+
344
+ **YAGNI filter** (after initial task draft, before saving):
345
+
346
+ For each task, confirm it maps to a specific requirement, success criterion, or edge case in the design doc. Run `applyYAGNIFilter({ task, designDoc })` for each task.
347
+
348
+ - Tasks that match → keep as-is.
349
+ - Tasks with no anchor → flagged as "potential scope creep". Present flagged tasks to the user: "These tasks have no anchor in the design doc. Keep (specify which requirement it serves) or remove?"
350
+ - If ALL tasks are flagged → return `allFlagged: true` and tell the user: "Design doc doesn't cover all tasks — needs amendment." Do not save the task list until the design doc is updated or tasks are removed.
351
+
352
+ **Before finalizing**: flag any tasks that touch areas not fully specified in the design doc. Present flagged tasks to user for quick clarification before saving.
353
+
354
+ Save to `docs/plans/YYYY-MM-DD-<slug>-tasks.md`.
355
+
356
+ ### Step 5b: Beads context
357
+
358
+ After saving the task list, attach design context and acceptance criteria to the Beads issue so downstream stages (`/dev`, `/validate`, `/review`) can retrieve it without re-reading the design doc.
359
+
360
+ ```bash
361
+ # Link design metadata (task count + task file path) to the Beads issue
362
+ bash scripts/beads-context.sh set-design <id> <task-count> docs/plans/YYYY-MM-DD-<slug>-tasks.md
363
+
364
+ # Record the success criteria from the design doc on the issue
365
+ bash scripts/beads-context.sh set-acceptance <id> "<success-criteria from design doc>"
366
+ ```
367
+
368
+ Both commands must exit with code 0. If either fails, investigate (wrong issue ID? missing script?) before continuing.
369
+
370
+ ### Step 5c: Contract extraction and logic-level dependency review
371
+
372
+ After saving the task list and Beads context, extract and store contract metadata, then run the logic-level Phase 3 dependency review:
373
+
374
+ ```bash
375
+ # Extract contracts — only call store-contracts if extract succeeds (exit 0)
376
+ if bash scripts/dep-guard.sh extract-contracts docs/plans/YYYY-MM-DD-<slug>-tasks.md > /tmp/contracts.txt; then
377
+ bash scripts/dep-guard.sh store-contracts <id> "$(cat /tmp/contracts.txt)"
378
+ else
379
+ echo "No contracts found — skipping store-contracts"
380
+ fi
381
+
382
+ # Re-run ripple check using Beads JSON + logic-level analysis
383
+ bash scripts/dep-guard.sh check-ripple <id>
384
+ ```
385
+
386
+ `extract-contracts` exits 1 when no contracts are found (not an error — just nothing to store). `store-contracts` must exit 0 if called.
387
+
388
+ `check-ripple` is now advisory but logic-aware. It should:
389
+ - read Beads issue data via JSON
390
+ - analyze import/call-chain, contract, and behavioral dependency signals
391
+ - show rubric score, confidence, issue pairs, and proposed dependency updates with pros/cons
392
+ - stop for user approval whenever a dependency mutation is proposed
393
+
394
+ If the user approves a dependency mutation, apply it explicitly:
395
+
396
+ ```bash
397
+ bash scripts/dep-guard.sh apply-decision <id> <dependent-id> <depends-on-id> "<approval rationale>"
398
+ ```
399
+
400
+ That approval step must validate with `bd dep cycles`, show `bd graph`, summarize `bd ready`, and persist the decision via `bd set-state` plus `bd comments`. Beads remains the canonical machine-readable decision record; the plan docs hold only the concise summary.
401
+
402
+ ### Step 6: User review
403
+
404
+ Present the full task list. Allow the user to reorder, split, or remove tasks.
405
+
406
+ ---
407
+
408
+ ```
409
+ <HARD-GATE: /plan exit>
410
+ Do NOT proceed to /dev until ALL are confirmed:
411
+ 1. git branch --show-current output shows feat/<slug>
412
+ 2. git worktree list shows .worktrees/<slug>
413
+ 3. Baseline tests ran — either passing OR user confirmed to proceed past failures
414
+ 4. Beads issue is created with status=in_progress
415
+ 5. Task list exists at docs/plans/YYYY-MM-DD-<slug>-tasks.md
416
+ 6. User has confirmed task list is correct
417
+ 7. `beads-context.sh set-design` ran successfully (exit code 0)
418
+ 8. `beads-context.sh set-acceptance` ran successfully (exit code 0)
419
+ 9. `dep-guard.sh store-contracts` ran successfully (exit code 0) — or skipped if no contracts found
420
+ 10. `dep-guard.sh check-ripple` ran successfully and any proposed dependency mutation was reviewed with the user before calling `apply-decision`
421
+ </HARD-GATE>
422
+ ```
423
+
424
+ After all HARD-GATE items pass, record the stage transition on the Beads issue:
425
+
426
+ ```bash
427
+ bash scripts/beads-context.sh stage-transition <id> plan dev
428
+ ```
429
+
430
+ ---
431
+
432
+ ## Example Output (Phase 3 complete)
433
+
434
+ ```
435
+ ✓ Phase 1: Design intent captured
436
+ - Design doc: docs/plans/2026-02-26-stripe-billing-design.md
437
+ - Approach: Stripe SDK v4 (selected over v3)
438
+ - Ambiguity policy: Make conservative choice + document in decisions log
439
+
440
+ ✓ Phase 2: Technical research complete
441
+ - OWASP Top 10: 3 risks identified, 3 mitigations planned
442
+ - TDD scenarios: 5 identified
443
+ - Sources: 8 references
444
+
445
+ ✓ Phase 3: Setup complete
446
+ - Beads: forge-xyz (in_progress)
447
+ - Branch: feat/stripe-billing
448
+ - Worktree: .worktrees/stripe-billing (baseline: 24/24 tests passing)
449
+ - Task list: docs/plans/2026-02-26-stripe-billing-tasks.md (8 tasks)
450
+
451
+ ⏸️ Task list ready for review. Confirm to proceed.
452
+
453
+ After confirming, run: /dev
454
+ ```
455
+
456
+ ## Integration with Workflow
457
+
458
+ ```
459
+ Utility: /status → Understand current context before starting
460
+ Stage 1: /plan → Design intent → research → branch + worktree + task list (you are here)
461
+ Stage 2: /dev → Implement each task with subagent-driven TDD
462
+ Stage 3: /validate → Type check, lint, tests, security — all fresh output
463
+ Stage 4: /ship → Push + create PR
464
+ Stage 5: /review → Address GitHub Actions, Greptile, SonarCloud
465
+ Stage 6: /premerge → Update docs, hand off PR to user
466
+ Stage 7: /verify → Post-merge CI check on main
467
+ ```
468
+
469
+ ## Tips
470
+
471
+ - **Phase 1 quality = /dev autonomy**: Every ambiguity resolved in Phase 1 is a decision gate that won't fire during /dev
472
+ - **One question at a time**: Don't dump all questions at once — dialogue produces better design decisions than a questionnaire
473
+ - **Task granularity**: Target 2-5 minutes per task. If a task takes longer, split it
474
+ - **Uncertain tasks go last**: Anything ambiguous at the end of the task list can be deferred if blocked without stopping other work
475
+ - **Baseline failures matter**: Pre-existing test failures hide regressions. Fix or explicitly document them before /dev starts
@@ -0,0 +1,176 @@
1
+
2
+ Prepare the pull request for merge by completing ALL documentation updates on the feature branch, then hand off to the user.
3
+
4
+ # Premerge
5
+
6
+ **The actual merge is always done by the user in the GitHub UI — never by this command.**
7
+
8
+ This command makes the PR 100% complete: code + tests + docs in one unit. After this, the user merges once and there are no follow-up doc PRs needed.
9
+
10
+ ## Usage
11
+
12
+ ```bash
13
+ /premerge <pr-number>
14
+ ```
15
+
16
+ ## What This Command Does
17
+
18
+ ### Step 1: Verify All CI Checks Pass
19
+
20
+ ```bash
21
+ gh pr checks <pr-number>
22
+ ```
23
+
24
+ All checks must be green before proceeding. If any fail, run `/review <pr-number>` first.
25
+
26
+ ### Step 2: Warn If Branch Is Behind Master
27
+
28
+ ```bash
29
+ gh pr view <pr-number> --json baseRefName,headRefName
30
+ git fetch origin master
31
+ git status
32
+ ```
33
+
34
+ If the feature branch is behind `master`, tell the user to rebase first:
35
+
36
+ ```
37
+ ⚠️ Branch is behind master — rebase before updating docs to avoid conflicts:
38
+ git rebase origin/master
39
+ git push --force-with-lease
40
+ ```
41
+
42
+ ### Step 3: Update ALL Relevant Documentation (on feature branch)
43
+
44
+ Check each of the following and update if the feature affects it. Be selective — only update what genuinely changed.
45
+
46
+ **A. `CHANGELOG.md`** (always):
47
+ - Add entry under `## [Unreleased]` heading (create heading if not present)
48
+ - Use [Keep a Changelog](https://keepachangelog.com/) categories:
49
+ - **Added**: New features
50
+ - **Changed**: Changes to existing functionality
51
+ - **Fixed**: Bug fixes
52
+ - **Removed**: Removed features
53
+ - Include: feature name, PR number, Beads ID
54
+ - Example:
55
+ ```markdown
56
+ ## [Unreleased]
57
+
58
+ ### Added
59
+ - Authentication refresh tokens (PR #89, forge-a3f8)
60
+ ```
61
+
62
+ **B. `README.md`** (if user-facing changes):
63
+ - Features list, configuration options, usage examples
64
+
65
+ **C. `docs/reference/API_REFERENCE.md`** (if API changes):
66
+ - New endpoints, request/response schemas, authentication
67
+
68
+ **D. Architecture docs** (if structural changes):
69
+ - `docs/architecture/` diagrams, decision records (ADRs)
70
+
71
+ **E. `CLAUDE.md` — USER section only** (if project conventions changed):
72
+ ```
73
+ <!-- USER:START - Add project-specific learnings here as you work -->
74
+ ...update only between these markers...
75
+ <!-- USER:END -->
76
+ ```
77
+ ⚠️ NEVER touch other managed blocks (e.g., `<!-- AGENT:START/END -->`).
78
+
79
+ **F. `AGENTS.md`** (if agent config, skills, or cross-agent workflow changed):
80
+ - Update relevant sections describing agent capabilities or workflow
81
+
82
+ **G. `docs/WORKFLOW.md`** (if the workflow itself changed):
83
+ - Update stage descriptions or workflow tables
84
+
85
+ **Commit doc updates to feature branch**:
86
+
87
+ ```bash
88
+ git add CHANGELOG.md README.md docs/ AGENTS.md CLAUDE.md
89
+ git commit -m "docs: update documentation for <feature-name>
90
+
91
+ - Updated: [list files changed]
92
+ - Reason: [brief explanation]"
93
+
94
+ git push
95
+ ```
96
+
97
+ ⚠️ **After pushing**: CI will re-trigger (Greptile, SonarCloud, etc.). Wait for checks to pass. If new Greptile comments appear on the doc changes, run `/review <pr-number>` again.
98
+
99
+ ### Step 4: Sync Beads
100
+
101
+ ```bash
102
+ bd sync
103
+ ```
104
+
105
+ ### Step 5: Hand Off — STOP HERE
106
+
107
+ **DO NOT run `gh pr merge`.** Present the PR and wait for the user to merge.
108
+
109
+ Output:
110
+
111
+ ```
112
+ ✅ PR #<number> is ready to merge
113
+
114
+ All checks: ✓ passing
115
+ Documentation: ✓ updated on feature branch
116
+ Beads: ✓ synced
117
+
118
+ 👉 Please merge in the GitHub UI:
119
+ https://github.com/<owner>/<repo>/pull/<number>
120
+
121
+ Recommended: Squash and merge (keeps main history clean)
122
+
123
+ After you merge, run /verify to confirm everything landed correctly.
124
+ ```
125
+
126
+ ```
127
+ <HARD-GATE: /premerge exit>
128
+ Do NOT run gh pr merge.
129
+ Do NOT suggest merging.
130
+ /premerge ends here. Output the PR URL and status. Wait for user.
131
+
132
+ "After you merge, run /verify to confirm everything landed correctly."
133
+ </HARD-GATE>
134
+ ```
135
+
136
+ ## Example Output
137
+
138
+ ```
139
+ ✓ CI checks: All passing
140
+ ✓ Branch: Up to date with master
141
+ ✓ Documentation updated:
142
+ - CHANGELOG.md: Entry added under [Unreleased]
143
+ - README.md: Features list updated
144
+ - CLAUDE.md: USER section updated with new pattern
145
+ - Committed: docs: update documentation for auth-refresh
146
+ ✓ CI re-triggered after doc push — all checks still passing
147
+ ✓ Beads synced
148
+
149
+ ✅ PR #89 is ready to merge
150
+
151
+ 👉 Please merge in the GitHub UI:
152
+ https://github.com/harshanandak/forge/pull/89
153
+
154
+ After you merge, run /verify
155
+ ```
156
+
157
+ ## Rules
158
+
159
+ - **NEVER run `gh pr merge`** — blocked by PreToolUse hook in `.claude/settings.json`
160
+ - **CLAUDE.md USER section only** — never touch other managed blocks
161
+ - **Warn if branch is behind** — tell user to rebase before doc updates
162
+ - **Re-check CI after doc push** — doc commits re-trigger full CI pipeline
163
+ - **One PR, complete** — code + tests + docs merged together, no follow-up doc PRs
164
+
165
+ ## Integration with Workflow
166
+
167
+ ```
168
+ Utility: /status → Understand current context before starting
169
+ Stage 1: /plan → Design intent → research → branch + worktree + task list
170
+ Stage 2: /dev → Implement each task with subagent-driven TDD
171
+ Stage 3: /validate → Type check, lint, tests, security — all fresh output
172
+ Stage 4: /ship → Push + create PR
173
+ Stage 5: /review → Address GitHub Actions, Greptile, SonarCloud
174
+ Stage 6: /premerge → Update docs, hand off PR to user (you are here)
175
+ Stage 7: /verify → Post-merge CI check on main
176
+ ```
@@ -0,0 +1,39 @@
1
+
2
+ > **Note**: `/research` is now Phase 2 of `/plan`.
3
+ >
4
+ > The research phase has been absorbed into the `/plan` command, which runs a full 3-phase workflow:
5
+ > - **Phase 1**: Brainstorming — design intent, constraints, success criteria
6
+ > - **Phase 2**: Technical research — web search, OWASP, codebase exploration, TDD scenarios
7
+ > - **Phase 3**: Setup — branch, worktree, Beads issue, task list
8
+ >
9
+ > Run `/plan <feature-slug>` to start the complete planning workflow.
10
+
11
+ # Research (Legacy Alias)
12
+
13
+ This command previously ran a standalone research phase. It is now embedded in `/plan` as Phase 2.
14
+
15
+ ## If you want to run just the research phase
16
+
17
+ Jump to Phase 2 of `/plan` manually:
18
+
19
+ 1. Read or create the design doc at `docs/plans/YYYY-MM-DD-<slug>-design.md`
20
+ 2. Run parallel web search using the `parallel-deep-research` skill
21
+ 3. Run OWASP Top 10 analysis for the feature
22
+ 4. Use the Explore agent for codebase exploration
23
+ 5. Identify at least 3 TDD test scenarios
24
+ 6. Append findings under `## Technical Research` in the design doc
25
+
26
+ Then continue with `/plan <slug> --continue` to run Phase 3 (setup + task list).
27
+
28
+ ## Integration with Workflow
29
+
30
+ ```
31
+ Utility: /status → Understand current context before starting
32
+ Stage 1: /plan → Design intent → research → branch + worktree + task list
33
+ Stage 2: /dev → Implement each task with subagent-driven TDD
34
+ Stage 3: /validate → Type check, lint, tests, security — all fresh output
35
+ Stage 4: /ship → Push + create PR
36
+ Stage 5: /review → Address GitHub Actions, Greptile, SonarCloud
37
+ Stage 6: /premerge → Update docs, hand off PR to user
38
+ Stage 7: /verify → Post-merge CI check on main
39
+ ```