forge-workflow 0.0.2 → 0.0.4

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 (175) hide show
  1. package/.claude/commands/dev.md +26 -0
  2. package/.claude/commands/plan.md +141 -9
  3. package/.claude/commands/premerge.md +0 -3
  4. package/.claude/commands/rollback.md +4 -4
  5. package/.claude/commands/ship.md +71 -41
  6. package/.claude/commands/status.md +9 -38
  7. package/.claude/commands/validate.md +47 -2
  8. package/.cline/workflows/dev.md +337 -0
  9. package/.cline/workflows/plan.md +518 -0
  10. package/.cline/workflows/premerge.md +173 -0
  11. package/.cline/workflows/research.md +39 -0
  12. package/.cline/workflows/review.md +439 -0
  13. package/.cline/workflows/rollback.md +718 -0
  14. package/.cline/workflows/ship.md +161 -0
  15. package/.cline/workflows/sonarcloud.md +146 -0
  16. package/.cline/workflows/status.md +45 -0
  17. package/.cline/workflows/validate.md +279 -0
  18. package/.cline/workflows/verify.md +218 -0
  19. package/.codex/config.toml +11 -0
  20. package/.codex/skills/dev/SKILL.md +340 -0
  21. package/.codex/skills/plan/SKILL.md +521 -0
  22. package/.codex/skills/premerge/SKILL.md +176 -0
  23. package/.codex/skills/research/SKILL.md +42 -0
  24. package/.codex/skills/review/SKILL.md +442 -0
  25. package/.codex/skills/rollback/SKILL.md +721 -0
  26. package/.codex/skills/ship/SKILL.md +164 -0
  27. package/.codex/skills/sonarcloud/SKILL.md +149 -0
  28. package/.codex/skills/status/SKILL.md +48 -0
  29. package/.codex/skills/validate/SKILL.md +282 -0
  30. package/.codex/skills/verify/SKILL.md +221 -0
  31. package/.cursor/commands/dev.md +337 -0
  32. package/.cursor/commands/plan.md +518 -0
  33. package/.cursor/commands/premerge.md +173 -0
  34. package/.cursor/commands/research.md +39 -0
  35. package/.cursor/commands/review.md +439 -0
  36. package/.cursor/commands/rollback.md +718 -0
  37. package/.cursor/commands/ship.md +161 -0
  38. package/.cursor/commands/sonarcloud.md +146 -0
  39. package/.cursor/commands/status.md +45 -0
  40. package/.cursor/commands/validate.md +279 -0
  41. package/.cursor/commands/verify.md +218 -0
  42. package/.cursor/hooks/state/continual-learning-index.json +19 -0
  43. package/.cursor/hooks/state/continual-learning.json +8 -0
  44. package/.cursor/rules/permissions-guidance.mdc +37 -0
  45. package/.github/prompts/dev.prompt.md +342 -0
  46. package/.github/prompts/plan.prompt.md +523 -0
  47. package/.github/prompts/premerge.prompt.md +178 -0
  48. package/.github/prompts/research.prompt.md +44 -0
  49. package/.github/prompts/review.prompt.md +444 -0
  50. package/.github/prompts/rollback.prompt.md +723 -0
  51. package/.github/prompts/ship.prompt.md +166 -0
  52. package/.github/prompts/sonarcloud.prompt.md +151 -0
  53. package/.github/prompts/status.prompt.md +50 -0
  54. package/.github/prompts/validate.prompt.md +284 -0
  55. package/.github/prompts/verify.prompt.md +223 -0
  56. package/.kilocode/workflows/dev.md +341 -0
  57. package/.kilocode/workflows/plan.md +522 -0
  58. package/.kilocode/workflows/premerge.md +177 -0
  59. package/.kilocode/workflows/research.md +43 -0
  60. package/.kilocode/workflows/review.md +443 -0
  61. package/.kilocode/workflows/rollback.md +722 -0
  62. package/.kilocode/workflows/ship.md +165 -0
  63. package/.kilocode/workflows/sonarcloud.md +150 -0
  64. package/.kilocode/workflows/status.md +49 -0
  65. package/.kilocode/workflows/validate.md +283 -0
  66. package/.kilocode/workflows/verify.md +222 -0
  67. package/.opencode/commands/dev.md +340 -0
  68. package/.opencode/commands/plan.md +521 -0
  69. package/.opencode/commands/premerge.md +176 -0
  70. package/.opencode/commands/research.md +42 -0
  71. package/.opencode/commands/review.md +442 -0
  72. package/.opencode/commands/rollback.md +721 -0
  73. package/.opencode/commands/ship.md +164 -0
  74. package/.opencode/commands/sonarcloud.md +149 -0
  75. package/.opencode/commands/status.md +48 -0
  76. package/.opencode/commands/validate.md +282 -0
  77. package/.opencode/commands/verify.md +221 -0
  78. package/.roo/commands/dev.md +341 -0
  79. package/.roo/commands/plan.md +522 -0
  80. package/.roo/commands/premerge.md +177 -0
  81. package/.roo/commands/research.md +43 -0
  82. package/.roo/commands/review.md +443 -0
  83. package/.roo/commands/rollback.md +722 -0
  84. package/.roo/commands/ship.md +165 -0
  85. package/.roo/commands/sonarcloud.md +150 -0
  86. package/.roo/commands/status.md +49 -0
  87. package/.roo/commands/validate.md +283 -0
  88. package/.roo/commands/verify.md +222 -0
  89. package/AGENTS.md +7 -1
  90. package/CLAUDE.md +5 -4
  91. package/README.md +21 -19
  92. package/bin/{forge-validate.js → forge-preflight.js} +21 -15
  93. package/bin/forge.js +209 -138
  94. package/docs/AGENT_INSTALL_PROMPT.md +1 -1
  95. package/docs/BEADS_GITHUB_SYNC.md +251 -0
  96. package/docs/ENHANCED_ONBOARDING.md +8 -8
  97. package/docs/EXAMPLES.md +4 -4
  98. package/docs/GREPTILE_SETUP.md +1 -1
  99. package/docs/MANUAL_REVIEW_GUIDE.md +1 -1
  100. package/docs/ROADMAP.md +6 -6
  101. package/docs/SETUP.md +1 -2
  102. package/docs/TOOLCHAIN.md +15 -234
  103. package/docs/VALIDATION.md +11 -11
  104. package/install.sh +33 -39
  105. package/lib/agents-config.js +3 -3
  106. package/lib/commands/plan.js +11 -15
  107. package/lib/commands/recommend.js +2 -2
  108. package/lib/dep-guard/analyzer.js +294 -0
  109. package/lib/dep-guard/behavior-detector.js +98 -0
  110. package/lib/dep-guard/contract-detector.js +162 -0
  111. package/lib/dep-guard/import-detector.js +498 -0
  112. package/lib/dep-guard/path-utils.js +13 -0
  113. package/lib/dep-guard/rubric.js +120 -0
  114. package/lib/dep-guard/task-parser.js +318 -0
  115. package/lib/detect-agent.js +191 -0
  116. package/lib/detect-worktree.js +47 -0
  117. package/lib/file-hash.js +26 -0
  118. package/lib/plugin-catalog.js +18 -28
  119. package/lib/setup-action-log.js +139 -0
  120. package/lib/setup-summary-renderer.js +106 -0
  121. package/lib/setup.js +75 -1
  122. package/lib/workflow-profiles.js +5 -11
  123. package/package.json +17 -7
  124. package/skills/parallel-deep-research/SKILL.md +108 -0
  125. package/skills/parallel-deep-research/evals/README.md +27 -0
  126. package/skills/parallel-deep-research/evals/evals.json +62 -0
  127. package/skills/sonarcloud-analysis/SKILL.md +171 -0
  128. package/skills/sonarcloud-analysis/evals/README.md +27 -0
  129. package/skills/sonarcloud-analysis/evals/evals.json +50 -0
  130. package/skills/sonarcloud-analysis/references/api-reference.md +466 -0
  131. package/docs/WORKFLOW.md +0 -400
  132. package/docs/planning/PROGRESS.md +0 -396
  133. package/docs/plans/.gitkeep +0 -0
  134. package/docs/plans/2026-02-27-forge-test-suite-v2-decisions.md +0 -21
  135. package/docs/plans/2026-02-27-forge-test-suite-v2-design.md +0 -362
  136. package/docs/plans/2026-02-27-forge-test-suite-v2-tasks.md +0 -343
  137. package/docs/plans/2026-03-02-superpowers-gaps-decisions.md +0 -26
  138. package/docs/plans/2026-03-02-superpowers-gaps-design.md +0 -239
  139. package/docs/plans/2026-03-02-superpowers-gaps-tasks.md +0 -260
  140. package/docs/plans/2026-03-04-agent-command-parity-design.md +0 -163
  141. package/docs/plans/2026-03-04-verify-worktree-cleanup-decisions.md +0 -7
  142. package/docs/plans/2026-03-04-verify-worktree-cleanup-design.md +0 -165
  143. package/docs/plans/2026-03-05-forge-uto-decisions.md +0 -6
  144. package/docs/plans/2026-03-05-forge-uto-design.md +0 -116
  145. package/docs/plans/2026-03-05-forge-uto-tasks.md +0 -244
  146. package/docs/plans/2026-03-10-command-creator-and-eval-decisions.md +0 -52
  147. package/docs/plans/2026-03-10-command-creator-and-eval-design.md +0 -350
  148. package/docs/plans/2026-03-10-command-creator-and-eval-tasks.md +0 -426
  149. package/docs/plans/2026-03-10-stale-workflow-refs-decisions.md +0 -8
  150. package/docs/plans/2026-03-10-stale-workflow-refs-design.md +0 -80
  151. package/docs/plans/2026-03-10-stale-workflow-refs-tasks.md +0 -90
  152. package/docs/plans/2026-03-14-beads-plan-context-decisions.md +0 -9
  153. package/docs/plans/2026-03-14-beads-plan-context-design.md +0 -171
  154. package/docs/plans/2026-03-14-beads-plan-context-tasks.md +0 -160
  155. package/docs/plans/2026-03-14-skill-eval-loop-decisions.md +0 -33
  156. package/docs/plans/2026-03-14-skill-eval-loop-design.md +0 -118
  157. package/docs/plans/2026-03-14-skill-eval-loop-results.md +0 -78
  158. package/docs/plans/2026-03-14-skill-eval-loop-tasks.md +0 -160
  159. package/docs/plans/2026-03-15-agent-command-parity-v2-decisions.md +0 -11
  160. package/docs/plans/2026-03-15-agent-command-parity-v2-design.md +0 -145
  161. package/docs/plans/2026-03-15-agent-command-parity-v2-tasks.md +0 -211
  162. package/docs/research/TEMPLATE.md +0 -292
  163. package/docs/research/advanced-testing.md +0 -297
  164. package/docs/research/agent-permissions.md +0 -167
  165. package/docs/research/dependency-chain.md +0 -328
  166. package/docs/research/forge-workflow-v2.md +0 -550
  167. package/docs/research/plugin-architecture.md +0 -772
  168. package/docs/research/pr4-cli-automation.md +0 -326
  169. package/docs/research/premerge-verify-restructure.md +0 -205
  170. package/docs/research/skills-restructure.md +0 -508
  171. package/docs/research/sonarcloud-perfection-plan.md +0 -166
  172. package/docs/research/sonarcloud-quality-gate.md +0 -184
  173. package/docs/research/superpowers-integration.md +0 -403
  174. package/docs/research/superpowers.md +0 -319
  175. package/docs/research/test-environment.md +0 -519
@@ -63,6 +63,32 @@ Do NOT write any code until ALL confirmed:
63
63
 
64
64
  ---
65
65
 
66
+
67
+ ### Multi-developer conflict check (soft block)
68
+
69
+ Before starting the per-task loop, check for cross-developer conflicts:
70
+
71
+ ```bash
72
+ # Auto-sync to get latest team state
73
+ bash scripts/sync-utils.sh auto-sync
74
+
75
+ # Check for conflicts with the current beads issue
76
+ bash scripts/conflict-detect.sh --issue <beads-id>
77
+ ```
78
+
79
+ If exit code 2 (validation error): show error message, abort — do not show conflict prompt.
80
+
81
+ If exit code 1 (conflicts found):
82
+ - Display the conflict output to the developer
83
+ - Ask: "Other developers are working in overlapping areas. Proceed anyway? (y/n)"
84
+ - If `n`: exit cleanly, no side effects
85
+ - If `y`: log override via `bd comments add <id> "Conflict override: proceeding despite overlap with <conflicting-issues>"`, then continue to Per-Task Loop
86
+ - Audit: record conflict override per OWASP A09
87
+
88
+ If exit code 0: proceed silently to Per-Task Loop.
89
+
90
+ ---
91
+
66
92
  ## Per-Task Loop
67
93
 
68
94
  Repeat for each task in the task list, in order:
@@ -20,10 +20,16 @@ Before ANY planning work begins:
20
20
  - Tell the user: "You are on '<branch>'. Planning must start from a clean worktree on master.
21
21
  Run: git checkout master — then re-run /plan."
22
22
  3. If on master, create the worktree NOW before asking any questions:
23
- a. git worktree add -b feat/<slug> .worktrees/<slug>
23
+ a. bd worktree create .worktrees/<slug> --branch feat/<slug>
24
24
  b. cd .worktrees/<slug>
25
25
  4. Confirm: "Working in isolated worktree: .worktrees/<slug> (branch: feat/<slug>)"
26
- 5. ONLY THEN begin Phase 1.
26
+ 5. Create the epic issue and record the stage transition:
27
+ ```bash
28
+ bd create --title="<feature-name>" --type=epic
29
+ bd update <id> --status=in_progress
30
+ bash scripts/beads-context.sh stage-transition <id> none plan
31
+ ```
32
+ 6. ONLY THEN begin Phase 1.
27
33
 
28
34
  Rationale: Planning commits (design docs, task lists) belong only to this feature's branch.
29
35
  If planning runs in the main directory on a non-master branch, those commits contaminate
@@ -44,10 +50,92 @@ between parallel features or sessions.
44
50
 
45
51
  ---
46
52
 
53
+
54
+ ### Multi-developer conflict check (soft block)
55
+
56
+ Before proceeding to Phase 1, check for cross-developer conflicts:
57
+
58
+ ```bash
59
+ # Auto-sync to get latest team state
60
+ bash scripts/sync-utils.sh auto-sync
61
+
62
+ # Check for conflicts with this issue's planned work area
63
+ bash scripts/conflict-detect.sh --issue <beads-id>
64
+ ```
65
+
66
+ If exit code 2 (validation error): show error message, abort — do not show conflict prompt.
67
+
68
+ If exit code 1 (conflicts found):
69
+ - Display the conflict output to the developer
70
+ - Ask: "Other developers are working in overlapping areas. Proceed anyway? (y/n)"
71
+ - If `n`: exit cleanly, no side effects
72
+ - If `y`: log override via `bd comments add <id> "Conflict override: proceeding despite overlap with <conflicting-issues>"`, then continue to Phase 1
73
+ - Audit: record conflict override per OWASP A09
74
+
75
+ If exit code 0: proceed silently to Phase 1.
76
+
77
+ ---
78
+
47
79
  ## Phase 1: Design Intent (Brainstorming)
48
80
 
49
81
  **Goal**: Capture WHAT to build — purpose, constraints, success criteria, edge cases, approach.
50
82
 
83
+ ### Step 0: Dependency ripple check (advisory)
84
+
85
+ Before exploring context or asking questions, check for potential conflicts with in-flight work:
86
+
87
+ ```bash
88
+ # If a Beads issue ID is known (e.g., from /status or bd ready):
89
+ bash scripts/dep-guard.sh check-ripple <beads-issue-id>
90
+
91
+ # If no issue exists yet (first-time plan):
92
+ bd list --status=open,in_progress
93
+ ```
94
+
95
+ Review the output. If overlaps are detected:
96
+ - Consider whether the overlapping issue should be a dependency
97
+ - Note any shared areas for the design Q&A
98
+ - This check is **advisory only** — always proceed to Step 1 regardless of findings
99
+
100
+ #### Ripple Analyst Agent (spawned when contract overlaps found)
101
+
102
+ When `check-ripple` detects overlapping issues AND contract metadata is available, spawn a Ripple Analyst subagent with this prompt:
103
+
104
+ **Input to agent**:
105
+ - Current issue's contract changes (from `extract-contracts` output)
106
+ - Consumer code snippets (from `find-consumers` output for each changed contract)
107
+ - Overlapping issue's title, description, and contract metadata
108
+
109
+ **Agent instructions**:
110
+ 1. For each overlapping contract, imagine 2-3 concrete break scenarios:
111
+ - "If [contract X] changes [specific behavior], then [consumer Y] will [specific failure]"
112
+ 2. Rate overall impact as one of:
113
+ - **NONE**: No real conflict despite keyword overlap
114
+ - **LOW**: Consumers need trivial adjustment (add parameter, rename call)
115
+ - **HIGH**: Consumer needs significant rework (parsing logic, data handling changes)
116
+ - **CRITICAL**: Consumer is in an active in_progress issue's task list
117
+ 3. **When uncertain, default to HIGH** — conservative over permissive
118
+ 4. Recommend one action:
119
+ - Add dependency (`bd dep add <source> <target>`)
120
+ - Coordinate with other issue's developer
121
+ - Scope down current feature to avoid overlap
122
+ - Proceed as-is (no real conflict)
123
+
124
+ **Output format**:
125
+ ```
126
+ Impact: [NONE|LOW|HIGH|CRITICAL]
127
+ Confidence: [high|medium|low]
128
+
129
+ Break scenarios:
130
+ 1. [scenario description]
131
+ 2. [scenario description]
132
+
133
+ Recommendation: [action]
134
+ Reason: [why this action]
135
+ ```
136
+
137
+ This agent is advisory only. The developer always makes the final decision.
138
+
51
139
  ### Step 1: Explore project context
52
140
 
53
141
  Before asking any questions, read relevant files:
@@ -125,6 +213,11 @@ Do NOT begin Phase 2 (web research) until:
125
213
 
126
214
  **Goal**: Find HOW to build it — best practices, known issues, security risks, TDD scenarios.
127
215
 
216
+ Record the phase transition before starting research:
217
+ ```bash
218
+ bash scripts/beads-context.sh stage-transition <id> plan research
219
+ ```
220
+
128
221
  Run these in parallel:
129
222
 
130
223
  ### Web research (parallel-deep-research skill)
@@ -215,13 +308,19 @@ Do NOT begin Phase 3 (setup) until:
215
308
 
216
309
  ## Phase 3: Setup + Task List
217
310
 
218
- **Goal**: Create branch, worktree, Beads issue, and a complete task list ready for /dev.
311
+ **Goal**: Create branch, worktree, and a complete task list ready for /dev.
312
+
313
+ Record the phase transition before starting setup:
314
+ ```bash
315
+ bash scripts/beads-context.sh stage-transition <id> research setup
316
+ ```
317
+
318
+ ### Step 1: Link child issues to the epic
219
319
 
220
- ### Step 1: Beads issue
320
+ The epic was created in the Entry HARD-GATE (Phase 1 entry). If this feature requires child issues (sub-tasks tracked separately), create them now and link to the epic:
221
321
 
222
322
  ```bash
223
- bd create --title="<feature-name>" --type=feature
224
- bd update <id> --status=in_progress
323
+ bd create --title="<sub-task-name>" --type=feature --parent=<epic-id>
225
324
  ```
226
325
 
227
326
  ### Step 2: Branch + worktree
@@ -239,10 +338,9 @@ else
239
338
  # Step 2b: Verify .worktrees/ is gitignored — add if missing
240
339
  git check-ignore -v .worktrees/ || echo ".worktrees/" >> .gitignore
241
340
 
242
- # Step 2c: Create branch + worktree in one command (from master)
243
- # Using -b with worktree add avoids "branch already checked out" error
341
+ # Step 2c: Create a Beads-aware worktree rooted on master
244
342
  git checkout master
245
- git worktree add -b feat/<slug> .worktrees/<slug>
343
+ bd worktree create .worktrees/<slug> --branch feat/<slug>
246
344
  cd .worktrees/<slug>
247
345
  fi
248
346
  ```
@@ -315,6 +413,38 @@ bash scripts/beads-context.sh set-acceptance <id> "<success-criteria from design
315
413
 
316
414
  Both commands must exit with code 0. If either fails, investigate (wrong issue ID? missing script?) before continuing.
317
415
 
416
+ ### Step 5c: Contract extraction and logic-level dependency review
417
+
418
+ After saving the task list and Beads context, extract and store contract metadata, then run the logic-level Phase 3 dependency review:
419
+
420
+ ```bash
421
+ # Extract contracts — only call store-contracts if extract succeeds (exit 0)
422
+ if bash scripts/dep-guard.sh extract-contracts docs/plans/YYYY-MM-DD-<slug>-tasks.md > /tmp/contracts.txt; then
423
+ bash scripts/dep-guard.sh store-contracts <id> "$(cat /tmp/contracts.txt)"
424
+ else
425
+ echo "No contracts found — skipping store-contracts"
426
+ fi
427
+
428
+ # Re-run ripple check using Beads JSON + logic-level analysis
429
+ bash scripts/dep-guard.sh check-ripple <id>
430
+ ```
431
+
432
+ `extract-contracts` exits 1 when no contracts are found (not an error — just nothing to store). `store-contracts` must exit 0 if called.
433
+
434
+ `check-ripple` is now advisory but logic-aware. It should:
435
+ - read Beads issue data via JSON
436
+ - analyze import/call-chain, contract, and behavioral dependency signals
437
+ - show rubric score, confidence, issue pairs, and proposed dependency updates with pros/cons
438
+ - stop for user approval whenever a dependency mutation is proposed
439
+
440
+ If the user approves a dependency mutation, apply it explicitly:
441
+
442
+ ```bash
443
+ bash scripts/dep-guard.sh apply-decision <id> <dependent-id> <depends-on-id> "<approval rationale>"
444
+ ```
445
+
446
+ 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.
447
+
318
448
  ### Step 6: User review
319
449
 
320
450
  Present the full task list. Allow the user to reorder, split, or remove tasks.
@@ -332,6 +462,8 @@ Do NOT proceed to /dev until ALL are confirmed:
332
462
  6. User has confirmed task list is correct
333
463
  7. `beads-context.sh set-design` ran successfully (exit code 0)
334
464
  8. `beads-context.sh set-acceptance` ran successfully (exit code 0)
465
+ 9. `dep-guard.sh store-contracts` ran successfully (exit code 0) — or skipped if no contracts found
466
+ 10. `dep-guard.sh check-ripple` ran successfully and any proposed dependency mutation was reviewed with the user before calling `apply-decision`
335
467
  </HARD-GATE>
336
468
  ```
337
469
 
@@ -82,9 +82,6 @@ Check each of the following and update if the feature affects it. Be selective
82
82
  **F. `AGENTS.md`** (if agent config, skills, or cross-agent workflow changed):
83
83
  - Update relevant sections describing agent capabilities or workflow
84
84
 
85
- **G. `docs/WORKFLOW.md`** (if the workflow itself changed):
86
- - Update stage descriptions or workflow tables
87
-
88
85
  **Commit doc updates to feature branch**:
89
86
 
90
87
  ```bash
@@ -186,18 +186,18 @@ git commit -m "Rollback: <files>"
186
186
  ```bash
187
187
  bunx forge rollback
188
188
  # Select: 4. Rollback specific files
189
- # Enter: AGENTS.md,docs/WORKFLOW.md
189
+ # Enter: AGENTS.md,CLAUDE.md
190
190
 
191
191
  ✓ Validating file paths...
192
192
  ✓ Working directory is clean
193
193
  ✓ Extracting USER sections...
194
- ✓ Executing: git checkout HEAD~1 -- AGENTS.md docs/WORKFLOW.md
194
+ ✓ Executing: git checkout HEAD~1 -- AGENTS.md CLAUDE.md
195
195
  ✓ Committing changes...
196
196
  ✓ Restoring USER sections...
197
197
  ✓ Amended commit to preserve USER content
198
198
 
199
199
  Rollback complete!
200
- Commit: q4r5s6t "Rollback: AGENTS.md, docs/WORKFLOW.md"
200
+ Commit: q4r5s6t "Rollback: AGENTS.md, CLAUDE.md"
201
201
  Files affected: 2
202
202
  ```
203
203
 
@@ -717,5 +717,5 @@ bunx forge rollback
717
717
 
718
718
  - [/dev](.claude/commands/dev.md) - TDD development workflow
719
719
  - [/validate](.claude/commands/validate.md) - Validation before shipping
720
- - [docs/WORKFLOW.md](../../docs/WORKFLOW.md) - Complete workflow guide
720
+ - [AGENTS.md](../../AGENTS.md) - Complete workflow guide
721
721
  - [Beads](https://github.com/beadshq/beads) - Issue tracking integration
@@ -29,60 +29,97 @@ Do NOT create PR until:
29
29
  ### Step 1: Verify /validate Passed
30
30
  Ensure all four validation checks completed successfully with fresh output in this session.
31
31
 
32
- ### Step 2: Update Beads
32
+ ### Step 2: Freshness Check — Is Branch Still Current?
33
+
34
+ Even though /validate rebased onto the base branch, time may have passed since then (user reviewed design doc, took a break, etc.). This lightweight check catches staleness before pushing.
35
+
36
+ ```bash
37
+ BASE=$(git remote show origin 2>/dev/null | grep 'HEAD branch' | awk '{print $NF}')
38
+ if [ -z "$BASE" ] || [ "$BASE" = "(unknown)" ]; then BASE="master"; fi
39
+ git fetch origin "$BASE" || { echo "✗ Fetch failed — cannot verify freshness"; exit 1; }
40
+ BEHIND=$(git rev-list --count HEAD..origin/"$BASE")
41
+ ```
42
+
43
+ - If `BEHIND > 0`: **STOP**. Print: "$BASE has advanced since /validate ($BEHIND new commits). Run /validate again to rebase and re-check."
44
+ - If `BEHIND = 0`: Continue to push.
45
+ - If fetch fails: the `|| { ...; exit 1; }` guard catches this — **STOP**. Do NOT push without confirming freshness.
46
+
47
+ This is NOT a full rebase — just a check. The rebase happens in /validate where the full test suite runs afterward.
48
+
49
+ ### Step 3: Update Beads
33
50
  ```bash
34
51
  bd update <id> --status done
35
52
  bd sync
36
53
  ```
37
54
 
38
- ### Step 3: Push Branch
55
+ ### Step 4: Push Branch
56
+
57
+ Use `--force-with-lease` because `/validate` may have rebased the branch, rewriting history. This is safe: it only forces the push if the remote branch hasn't been updated by someone else since the last fetch.
58
+
39
59
  ```bash
40
- git push -u origin <branch-name>
60
+ git push --force-with-lease -u origin <branch-name>
41
61
  ```
42
62
 
43
- ### Step 4: Create PR
63
+ ### Step 5: Create PR
64
+
65
+ Use the narrative PR template below. Lead with WHY (Problem/Root Cause/Fix/Value) — this is what reviewers need to understand first. Keep implementation details (test coverage, security review, design doc) in a collapsible section so they're available but don't clutter the summary.
66
+
67
+ If no Beads issue exists (hotfix, external contribution), skip the "Closes" line.
44
68
 
45
69
  ```bash
46
- gh pr create --title "feat: <feature-name>" --body "$(cat <<'EOF'
47
- ## Summary
48
- [Auto-generated from commits and design doc]
70
+ gh pr create --title "<type>: <concise description>" --body "$(cat <<'EOF'
71
+ ## Problem
72
+ [What was broken, what need existed, or what user pain this addresses]
49
73
 
50
- ## Design Doc
51
- See: docs/plans/YYYY-MM-DD-<slug>-design.md
74
+ ## Root Cause
75
+ [Why it happened, why it was missing, or what gap existed]
52
76
 
53
- ## Decisions Log
54
- See: docs/plans/YYYY-MM-DD-<slug>-decisions.md (if any undocumented decisions arose during /dev)
77
+ ## Fix
78
+ [What this PR does to solve it approach, not implementation details]
79
+
80
+ ## Value
81
+ [Who benefits, what improves, what risk is removed]
55
82
 
56
- ## Beads Issue
83
+ ## Beads
57
84
  Closes: <issue-id>
58
85
 
59
- ## Key Decisions
60
- [From design doc - 3-5 key decisions with reasoning]
86
+ <details>
87
+ <summary>Implementation Details</summary>
61
88
 
62
- ## TDD Test Coverage
63
- - Unit tests: [count] tests, [X] scenarios
64
- - Integration tests: [count] tests
65
- - E2E tests: [count] tests
66
- - All tests passing ✓
89
+ ### Test Coverage
90
+ - Tests: [count] passing
91
+ - Scenarios covered: [list key scenarios]
67
92
 
68
- ## Security Review
69
- - OWASP Top 10: All mitigations implemented
70
- - Security tests: [count] scenarios passing
71
- - Automated scan: No vulnerabilities
93
+ ### Security Review
94
+ - OWASP Top 10: [summary — applicable risks and mitigations]
95
+ - Automated scan: [result]
72
96
 
73
- ## Test Plan
97
+ ### Design Doc
98
+ See: docs/plans/YYYY-MM-DD-<slug>-design.md
99
+
100
+ ### Decisions Log
101
+ See: docs/plans/YYYY-MM-DD-<slug>-decisions.md (if any undocumented decisions arose during /dev)
102
+
103
+ ### Key Decisions
104
+ [From design doc — 3-5 key decisions with reasoning]
105
+
106
+ ### Documentation Updated
107
+ [List docs updated in this PR, or "None — no doc-facing changes"]
108
+
109
+ ### Validation
74
110
  - [x] Type check passing
75
- - [x] Lint passing
76
- - [x] Code review passing
77
- - [x] E2E tests passing
111
+ - [x] Lint passing (0 errors, 0 warnings)
112
+ - [x] All tests passing
78
113
  - [x] Security review completed
79
114
 
115
+ </details>
116
+
80
117
  🤖 Generated with [Claude Code](https://claude.com/claude-code)
81
118
  EOF
82
119
  )"
83
120
  ```
84
121
 
85
- ### Step 5: Record Stage Transition
122
+ ### Step 6: Record Stage Transition
86
123
  ```bash
87
124
  bash scripts/beads-context.sh stage-transition <id> ship review
88
125
  ```
@@ -91,20 +128,13 @@ bash scripts/beads-context.sh stage-transition <id> ship review
91
128
 
92
129
  ```
93
130
  ✓ Validation: /validate passed (all 4 checks — fresh output confirmed)
131
+ ✓ Freshness: Branch is up-to-date with master
94
132
  ✓ Beads: Marked done & synced (forge-xyz)
95
133
  ✓ Pushed: feat/stripe-billing
96
134
  ✓ PR created: https://github.com/.../pull/123
135
+ - PR body: Problem → Root Cause → Fix → Value (narrative format)
97
136
  - Beads linked: forge-xyz
98
- - Design doc linked: docs/plans/2026-02-26-stripe-billing-design.md
99
- - Decisions log linked: docs/plans/2026-02-26-stripe-billing-decisions.md
100
- - Test coverage documented
101
- - Security review documented
102
-
103
- PR Summary:
104
- - 12 commits
105
- - 18 test cases, all passing
106
- - OWASP Top 10 security review completed
107
- - 3 key architectural decisions documented
137
+ - Implementation details in collapsible section
108
138
 
109
139
  ⏸️ PR created, awaiting automated checks (Greptile, SonarCloud, GitHub Actions)
110
140
 
@@ -126,9 +156,9 @@ Stage 7: /verify → Post-merge CI check on main
126
156
 
127
157
  ## Tips
128
158
 
129
- - **Complete PR body**: Include design doc, decisions log, and test coverage
130
- - **Link everything**: Design doc, decisions log, Beads issue
131
- - **Document security**: OWASP Top 10 review in PR body
159
+ - **Lead with why**: Problem Root Cause Fix Value is what reviewers need first
160
+ - **Collapsible details**: Design doc, decisions log, test coverage go in `<details>` — available but not in the way
161
+ - **Document security**: OWASP Top 10 review in collapsible section
132
162
  - **Test coverage**: Show all test scenarios passing
133
163
  - **Wait for checks**: Let GitHub Actions, Greptile, SonarCloud run
134
164
  - **NO auto-merge**: Always wait for /review phase
@@ -16,60 +16,31 @@ This command helps you understand the current state of the project before starti
16
16
 
17
17
  ## What This Command Does
18
18
 
19
- ### Step 1: Check Project Health
20
- ```bash
21
- bd stats
22
- ```
23
- - How many open / in-progress / completed issues?
24
- - Any blocked issues?
19
+ ## Step 0: Sync team state
25
20
 
26
- ### Step 2: Check Active Work
27
21
  ```bash
28
- # Active Beads issues
29
- bd list --status in_progress
22
+ # Sync team state before showing status
23
+ bash scripts/sync-utils.sh auto-sync
30
24
  ```
31
25
 
32
- For each in-progress issue, show compact progress:
26
+ ### Step 1: Smart Status (ranked issues with conflict detection)
33
27
  ```bash
34
- bash scripts/beads-context.sh parse-progress <issue-id>
28
+ bash scripts/smart-status.sh
35
29
  ```
36
- Display the compact output (e.g., "3/7 tasks done | Last: Validation logic (def5678)")
30
+ This script dynamically computes and displays all issues ranked by composite score (priority, dependency impact, type, staleness, epic proximity). Output includes active sessions, conflict risk annotations, and grouped categories. No manual querying needed — the script handles everything.
37
31
 
38
- Hint: `bd show <id>` for full context on any issue.
32
+ For full context on any issue: `bd show <id>`
39
33
 
40
- ### Step 3: Review Recent Work
34
+ ### Step 2: Review Recent Commits
41
35
  ```bash
42
- # Recent commits
43
36
  git log --oneline -10
44
-
45
- # Recently completed Beads
46
- bd list --status completed --limit 5
47
37
  ```
48
38
 
49
- ### Step 4: Determine Context
39
+ ### Step 3: Determine Context
50
40
  - **New feature**: No active work, ready to start fresh
51
41
  - **Continuing work**: In-progress issues found, resume where left off
52
42
  - **Review needed**: Work marked complete, needs review/merge
53
43
 
54
- ## Example Output
55
-
56
- ```
57
- ✓ Project Health: 3 open, 1 in-progress, 12 completed
58
-
59
- Active Work:
60
- - forge-ctc: Clean up stale workflow refs (in_progress)
61
- 3/7 tasks done | Last: Validation logic (def5678)
62
- → bd show forge-ctc for full context
63
-
64
- Recent Completions:
65
- - forge-uto: Sync AGENTS.md with agent cleanup (closed 2 days ago)
66
- - forge-abc: Auth refresh tokens (closed 5 days ago)
67
-
68
- Context: Continuing work
69
-
70
- Next: Resume with /dev or /validate (check issue status)
71
- ```
72
-
73
44
  ## Next Steps
74
45
 
75
46
  - **If starting new work**: Run `/plan <feature-name>`
@@ -2,6 +2,11 @@
2
2
  description: Complete validation (type/lint/tests/security)
3
3
  ---
4
4
 
5
+ > **Note:** Three things share the "validate" name in Forge:
6
+ > - `/validate` (this command): Workflow Stage 3 — rebases onto the base branch, then runs type/lint/test/security checks
7
+ > - `forge-preflight` (formerly forge-validate): CLI tool — checks prerequisites before a stage
8
+ > - `bun run check` (scripts/validate.sh): Local quality gate — runs type/lint/test/security checks only (does NOT rebase; assumes branch is already current with the base branch)
9
+
5
10
  Run comprehensive validation including type checking, linting, code review, security review, and tests.
6
11
 
7
12
  # Validate
@@ -14,10 +19,50 @@ This command validates all code before creating a pull request.
14
19
  /validate
15
20
  ```
16
21
 
17
- Or use the unified validation script:
22
+ Or use the validation script (checks only — no rebase):
18
23
 
19
24
  ```bash
20
- bun run check # Runs all validation steps automatically (check is the npm script name; /validate is the workflow command)
25
+ bun run check # Runs lint/test/security checks only. Does NOT rebase onto the base branch.
26
+ # Use /validate for the full workflow (rebase + checks).
27
+ ```
28
+
29
+ ```
30
+ <HARD-GATE: /validate entry — rebase onto latest base branch>
31
+ Before running ANY validation checks:
32
+
33
+ 0. Resolve the base branch dynamically (do NOT hardcode master or main):
34
+ BASE=$(git remote show origin 2>/dev/null | grep 'HEAD branch' | awk '{print $NF}')
35
+ if [ -z "$BASE" ] || [ "$BASE" = "(unknown)" ]; then BASE="master"; fi
36
+
37
+ This handles repos using main, master, or any other default branch.
38
+ Falls back to "master" when HEAD is unresolved (detached remote, empty repo).
39
+
40
+ 1. Fetch latest base branch:
41
+ git fetch origin "$BASE" || { echo "✗ Fetch failed — cannot verify branch freshness"; exit 1; }
42
+
43
+ The `|| { ...; exit 1; }` guard ensures fetch failures are never silently skipped.
44
+
45
+ 2. Check if branch is behind:
46
+ BEHIND=$(git rev-list --count HEAD..origin/"$BASE")
47
+
48
+ 3. If BEHIND > 0:
49
+ a. Run: git rebase origin/"$BASE" || REBASE_FAILED=1
50
+ b. If rebase succeeds (REBASE_FAILED unset): print "✓ Rebased onto latest $BASE ($BEHIND commits integrated)"
51
+ c. If rebase fails (REBASE_FAILED=1 — conflicts or any other error):
52
+ - Capture conflicting files BEFORE aborting: git diff --name-only --diff-filter=U
53
+ - Run: git rebase --abort
54
+ - Print the captured conflicting file list
55
+ - Print: "✗ Rebase conflict — resolve manually, then re-run /validate"
56
+ - STOP. Do NOT proceed to any validation checks.
57
+
58
+ 4. If BEHIND = 0:
59
+ Print "✓ Branch is up-to-date with $BASE" and continue.
60
+
61
+ Rationale: Without this step, validation checks run against stale code that doesn't
62
+ include recent base branch changes. Integration issues are only caught after the PR is
63
+ created, wasting CI cycles and review time. Rebasing here ensures /validate results
64
+ reflect the true state of what will be merged.
65
+ </HARD-GATE>
21
66
  ```
22
67
 
23
68
  ## What This Command Does