forge-workflow 0.0.5 → 0.0.7

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 (164) hide show
  1. package/.claude/commands/dev.md +6 -1
  2. package/.claude/commands/plan.md +59 -14
  3. package/.claude/commands/premerge.md +10 -0
  4. package/.claude/commands/review.md +7 -1
  5. package/.claude/commands/ship.md +95 -47
  6. package/.claude/commands/status.md +42 -0
  7. package/.claude/commands/validate.md +7 -1
  8. package/.claude/commands/verify.md +52 -4
  9. package/.claude/rules/workflow.md +16 -0
  10. package/.claude/scripts/greptile-resolve.sh +32 -0
  11. package/.cline/workflows/dev.md +6 -1
  12. package/.cline/workflows/plan.md +59 -14
  13. package/.cline/workflows/premerge.md +10 -0
  14. package/.cline/workflows/review.md +7 -1
  15. package/.cline/workflows/ship.md +95 -47
  16. package/.cline/workflows/status.md +42 -0
  17. package/.cline/workflows/validate.md +7 -1
  18. package/.cline/workflows/verify.md +52 -4
  19. package/.codex/skills/dev/SKILL.md +6 -1
  20. package/.codex/skills/plan/SKILL.md +59 -14
  21. package/.codex/skills/premerge/SKILL.md +10 -0
  22. package/.codex/skills/review/SKILL.md +7 -1
  23. package/.codex/skills/ship/SKILL.md +95 -47
  24. package/.codex/skills/status/SKILL.md +42 -0
  25. package/.codex/skills/validate/SKILL.md +7 -1
  26. package/.codex/skills/verify/SKILL.md +52 -4
  27. package/.cursor/commands/dev.md +6 -1
  28. package/.cursor/commands/plan.md +59 -14
  29. package/.cursor/commands/premerge.md +10 -0
  30. package/.cursor/commands/review.md +7 -1
  31. package/.cursor/commands/ship.md +95 -47
  32. package/.cursor/commands/status.md +42 -0
  33. package/.cursor/commands/validate.md +7 -1
  34. package/.cursor/commands/verify.md +52 -4
  35. package/.cursorrules +149 -0
  36. package/.github/prompts/dev.prompt.md +6 -1
  37. package/.github/prompts/plan.prompt.md +59 -14
  38. package/.github/prompts/premerge.prompt.md +10 -0
  39. package/.github/prompts/review.prompt.md +7 -1
  40. package/.github/prompts/ship.prompt.md +95 -47
  41. package/.github/prompts/status.prompt.md +42 -0
  42. package/.github/prompts/validate.prompt.md +7 -1
  43. package/.github/prompts/verify.prompt.md +52 -4
  44. package/.kilocode/workflows/dev.md +6 -1
  45. package/.kilocode/workflows/plan.md +59 -14
  46. package/.kilocode/workflows/premerge.md +10 -0
  47. package/.kilocode/workflows/review.md +7 -1
  48. package/.kilocode/workflows/ship.md +95 -47
  49. package/.kilocode/workflows/status.md +42 -0
  50. package/.kilocode/workflows/validate.md +7 -1
  51. package/.kilocode/workflows/verify.md +52 -4
  52. package/.opencode/commands/dev.md +6 -1
  53. package/.opencode/commands/plan.md +59 -14
  54. package/.opencode/commands/premerge.md +10 -0
  55. package/.opencode/commands/review.md +7 -1
  56. package/.opencode/commands/ship.md +95 -47
  57. package/.opencode/commands/status.md +42 -0
  58. package/.opencode/commands/validate.md +7 -1
  59. package/.opencode/commands/verify.md +52 -4
  60. package/.roo/commands/dev.md +6 -1
  61. package/.roo/commands/plan.md +59 -14
  62. package/.roo/commands/premerge.md +10 -0
  63. package/.roo/commands/review.md +7 -1
  64. package/.roo/commands/ship.md +95 -47
  65. package/.roo/commands/status.md +42 -0
  66. package/.roo/commands/validate.md +7 -1
  67. package/.roo/commands/verify.md +52 -4
  68. package/AGENTS.md +97 -0
  69. package/CLAUDE.md +10 -0
  70. package/README.md +2 -2
  71. package/bin/forge-cmd.js +5 -1
  72. package/bin/forge-preflight.js +15 -2
  73. package/bin/forge.js +211 -9
  74. package/docs/ENHANCED_ONBOARDING.md +96 -86
  75. package/docs/ROADMAP.md +2 -2
  76. package/docs/TOOLCHAIN.md +23 -0
  77. package/docs/VALIDATION.md +1 -1
  78. package/lefthook.yml +11 -0
  79. package/lib/agents/README.md +46 -1
  80. package/lib/agents/cline.plugin.json +11 -4
  81. package/lib/agents/codex.plugin.json +2 -2
  82. package/lib/agents/copilot.plugin.json +5 -5
  83. package/lib/agents/cursor.plugin.json +1 -1
  84. package/lib/agents/kilocode.plugin.json +1 -1
  85. package/lib/agents/opencode.plugin.json +7 -4
  86. package/lib/agents/roo.plugin.json +10 -3
  87. package/lib/agents-config.js +129 -81
  88. package/lib/codex-skills.js +50 -0
  89. package/lib/commands/_registry.js +173 -0
  90. package/lib/commands/clean.js +181 -0
  91. package/lib/commands/commands-reset.js +147 -0
  92. package/lib/commands/dev.js +84 -0
  93. package/lib/commands/plan.js +18 -0
  94. package/lib/commands/push.js +196 -0
  95. package/lib/commands/recommend.js +1 -1
  96. package/lib/commands/setup.js +4295 -0
  97. package/lib/commands/ship.js +20 -0
  98. package/lib/commands/status.js +210 -44
  99. package/lib/commands/sync.js +71 -0
  100. package/lib/commands/team.js +37 -0
  101. package/lib/commands/test.js +207 -0
  102. package/lib/commands/validate.js +13 -0
  103. package/lib/commands/worktree.js +310 -0
  104. package/lib/detect-agent.js +38 -8
  105. package/lib/detection-utils.js +405 -0
  106. package/lib/docs-command.js +51 -0
  107. package/lib/docs-copy.js +50 -0
  108. package/lib/file-utils.js +260 -0
  109. package/lib/forge-context.js +42 -0
  110. package/lib/freshness-token.js +148 -0
  111. package/lib/frontmatter.js +79 -0
  112. package/lib/greptile-match.js +80 -0
  113. package/lib/husky-migration.js +113 -12
  114. package/lib/lefthook-check.js +27 -6
  115. package/lib/plugin-manager.js +225 -72
  116. package/lib/project-discovery.js +39 -5
  117. package/lib/reset.js +309 -0
  118. package/lib/runtime-health.js +305 -0
  119. package/lib/shell-utils.js +50 -0
  120. package/lib/task-ownership.js +117 -0
  121. package/lib/ui-utils.js +43 -0
  122. package/lib/validation-utils.js +163 -0
  123. package/lib/workflow/enforce-stage.js +179 -0
  124. package/lib/workflow/stages.js +201 -0
  125. package/lib/workflow/state.js +332 -0
  126. package/opencode.json +67 -0
  127. package/package.json +16 -6
  128. package/scripts/beads-context.sh +165 -22
  129. package/scripts/beads-context.test.js +5 -1
  130. package/scripts/check-agents.js +103 -0
  131. package/scripts/check-forge-token.js +98 -0
  132. package/scripts/conflict-detect.sh +2 -2
  133. package/scripts/dep-guard.sh +6 -28
  134. package/scripts/file-index.sh +117 -23
  135. package/scripts/forge-team/index.sh +86 -0
  136. package/scripts/forge-team/lib/agent-prompt.sh +52 -0
  137. package/scripts/forge-team/lib/claim.sh +256 -0
  138. package/scripts/forge-team/lib/dashboard.sh +341 -0
  139. package/scripts/forge-team/lib/epic.sh +332 -0
  140. package/scripts/forge-team/lib/hooks.sh +253 -0
  141. package/scripts/forge-team/lib/identity.sh +235 -0
  142. package/scripts/forge-team/lib/sync-github.sh +317 -0
  143. package/scripts/forge-team/lib/verify.sh +284 -0
  144. package/scripts/forge-team/lib/workload.sh +296 -0
  145. package/scripts/forge-team/tests/agent-prompt.test.sh +72 -0
  146. package/scripts/forge-team/tests/claim.test.sh +179 -0
  147. package/scripts/forge-team/tests/dashboard.test.sh +170 -0
  148. package/scripts/forge-team/tests/dispatcher.test.sh +79 -0
  149. package/scripts/forge-team/tests/epic.test.sh +176 -0
  150. package/scripts/forge-team/tests/hooks.test.sh +239 -0
  151. package/scripts/forge-team/tests/identity.test.sh +176 -0
  152. package/scripts/forge-team/tests/integration.test.sh +371 -0
  153. package/scripts/forge-team/tests/sync-github.test.sh +209 -0
  154. package/scripts/forge-team/tests/verify.test.sh +314 -0
  155. package/scripts/forge-team/tests/workflow-integration.test.sh +43 -0
  156. package/scripts/forge-team/tests/workload.test.sh +209 -0
  157. package/scripts/lib/eval-runner.js +39 -0
  158. package/scripts/lib/jsonl-lock.sh +48 -0
  159. package/scripts/lib/sanitize.sh +116 -0
  160. package/scripts/pr-coordinator.sh +756 -0
  161. package/scripts/smart-status.sh +58 -21
  162. package/scripts/sync-commands.js +49 -20
  163. package/scripts/sync-utils.sh +24 -29
  164. package/scripts/test.js +18 -1
@@ -48,6 +48,36 @@ BEHIND=$(git rev-list --count HEAD..origin/"$BASE")
48
48
 
49
49
  This is NOT a full rebase — just a check. The rebase happens in /validate where the full test suite runs afterward.
50
50
 
51
+ ### Parallel PR coordination (soft block)
52
+
53
+ Before creating the PR, check merge readiness:
54
+
55
+ ```bash
56
+ # Run merge simulation against base branch
57
+ bash scripts/pr-coordinator.sh merge-sim "$(git branch --show-current)" 2>&1
58
+
59
+ # Show recommended merge order
60
+ bash scripts/pr-coordinator.sh merge-order 2>&1 || true
61
+
62
+ # Auto-label the PR after creation (called after gh pr create below)
63
+ # bash scripts/pr-coordinator.sh auto-label <issue-id>
64
+ ```
65
+
66
+ If merge simulation finds conflicts:
67
+ - Display conflicted files
68
+ - Ask: "Merge conflicts detected with base branch. These PRs should merge first: [list]. Proceed with PR creation anyway? (y/n)"
69
+ - If `n`: exit cleanly
70
+ - If `y`: log override via `bd comments add <id> "Ship override: creating PR despite merge conflicts"`, then continue
71
+
72
+ After PR creation completes:
73
+ ```bash
74
+ # Auto-label the newly created PR
75
+ bash scripts/pr-coordinator.sh auto-label <issue-id>
76
+
77
+ # Check for stale worktrees (informational)
78
+ bash scripts/pr-coordinator.sh stale-worktrees 2>&1 || true
79
+ ```
80
+
51
81
  ### Step 3: Update Beads
52
82
  ```bash
53
83
  bd update <id> --status done
@@ -62,68 +92,86 @@ Use `--force-with-lease` because `/validate` may have rebased the branch, rewrit
62
92
  git push --force-with-lease -u origin <branch-name>
63
93
  ```
64
94
 
65
- ### Step 5: Create PR
95
+ ### Step 5: Create PR Using Project's PR Template
66
96
 
67
- 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.
97
+ **CRITICAL**: Always use the project's own PR template. Never use a hardcoded body.
68
98
 
69
- If no Beads issue exists (hotfix, external contribution), skip the "Closes" line.
99
+ **Step 5a: Locate the PR template**
70
100
 
101
+ Check for a PR template in the project (in order of precedence):
71
102
  ```bash
72
- gh pr create --title "<type>: <concise description>" --body "$(cat <<'EOF'
73
- ## Problem
74
- [What was broken, what need existed, or what user pain this addresses]
75
-
76
- ## Root Cause
77
- [Why it happened, why it was missing, or what gap existed]
103
+ # Check standard locations
104
+ PR_TEMPLATE=""
105
+ for path in .github/pull_request_template.md .github/PULL_REQUEST_TEMPLATE.md docs/pull_request_template.md pull_request_template.md; do
106
+ if [ -f "$path" ]; then
107
+ PR_TEMPLATE="$path"
108
+ break
109
+ fi
110
+ done
111
+ ```
78
112
 
79
- ## Fix
80
- [What this PR does to solve it — approach, not implementation details]
113
+ **Step 5b: Read and populate the template**
81
114
 
82
- ## Value
83
- [Who benefits, what improves, what risk is removed]
115
+ If a PR template exists:
116
+ 1. **Read the template file** using the Read tool
117
+ 2. **Fill in every section** with actual data from the current PR context:
118
+ - Replace HTML comments (`<!-- ... -->`) with real content
119
+ - Check applicable checkboxes (`- [x]`)
120
+ - Fill in beads issue IDs (replace `beads-xxx` with actual ID)
121
+ - Fill in test results, validation status, and other concrete data
122
+ - Reference the design doc: `docs/plans/YYYY-MM-DD-<slug>-design.md`
123
+ 3. **Do NOT remove any sections** — fill them all, even if "N/A"
124
+ 4. **Do NOT restructure the template** — keep the project's chosen format
84
125
 
85
- ## Beads
86
- Closes: <issue-id>
126
+ If no PR template exists, use this minimal fallback:
127
+ ```
128
+ ## Summary
129
+ [1-3 sentences: what this PR does and why]
87
130
 
88
- <details>
89
- <summary>Implementation Details</summary>
131
+ ## Changes
132
+ [Bulleted list of key changes]
90
133
 
91
- ### Test Coverage
92
- - Tests: [count] passing
93
- - Scenarios covered: [list key scenarios]
134
+ ## Testing
135
+ [How it was tested, test results]
94
136
 
95
- ### Security Review
96
- - OWASP Top 10: [summary — applicable risks and mitigations]
97
- - Automated scan: [result]
137
+ ## Beads
138
+ Closes beads-xxx
98
139
 
99
- ### Design Doc
100
- See: docs/plans/YYYY-MM-DD-<slug>-design.md
140
+ 🤖 Generated with [Claude Code](https://claude.com/claude-code)
141
+ ```
101
142
 
102
- ### Decisions Log
103
- See: docs/plans/YYYY-MM-DD-<slug>-decisions.md (if any undocumented decisions arose during /dev)
143
+ **Step 5c: Create the PR**
104
144
 
105
- ### Key Decisions
106
- [From design doc 3-5 key decisions with reasoning]
145
+ ```bash
146
+ gh pr create --title "<type>: <concise description>" --body "<populated-template-content>"
147
+ ```
107
148
 
108
- ### Documentation Updated
109
- [List docs updated in this PR, or "None no doc-facing changes"]
149
+ Rules for the PR body:
150
+ - **Use the project's template structure** never substitute your own format
151
+ - **Fill in concrete data** — commit counts, test results, actual file paths, real beads IDs
152
+ - **Check applicable checkboxes** — `[x]` for items that apply, `[ ]` for items that don't
153
+ - **Include "Closes beads-xxx"** in the Beads section (required for auto-close in /verify)
110
154
 
111
- ### Validation
112
- - [x] Type check passing
113
- - [x] Lint passing (0 errors, 0 warnings)
114
- - [x] All tests passing
115
- - [x] Security review completed
155
+ ### Step 6: Validate Context and Record Stage Transition
156
+ ```bash
157
+ bash scripts/beads-context.sh validate <id>
158
+ bash scripts/beads-context.sh stage-transition <id> ship review \
159
+ --summary "<PR created, checks pending>" \
160
+ --decisions "<template sections filled, beads linked>" \
161
+ --artifacts "<PR URL, branch name>" \
162
+ --next "<review focus areas>"
163
+ ```
116
164
 
117
- </details>
165
+ ### Team sync after PR
118
166
 
119
- 🤖 Generated with [Claude Code](https://claude.com/claude-code)
120
- EOF
121
- )"
122
- ```
167
+ After PR is created, sync issue state to GitHub and verify 1:1 mapping:
123
168
 
124
- ### Step 6: Record Stage Transition
125
169
  ```bash
126
- bash scripts/beads-context.sh stage-transition <id> ship review
170
+ # Sync issue state to GitHub
171
+ bash scripts/forge-team/index.sh sync 2>&1 || true
172
+
173
+ # Verify 1:1 mapping
174
+ bash scripts/forge-team/index.sh verify 2>&1 || true
127
175
  ```
128
176
 
129
177
  ## Example Output
@@ -158,9 +206,9 @@ Stage 7: /verify → Post-merge CI check on main
158
206
 
159
207
  ## Tips
160
208
 
161
- - **Lead with why**: Problem Root Cause Fix Value is what reviewers need first
162
- - **Collapsible details**: Design doc, decisions log, test coverage go in `<details>` available but not in the way
163
- - **Document security**: OWASP Top 10 review in collapsible section
164
- - **Test coverage**: Show all test scenarios passing
209
+ - **Use the project's PR template**: Always read `.github/pull_request_template.md` (or equivalent) and populate it never substitute your own format
210
+ - **Fill every section**: Even if "N/A"empty/missing sections cause review friction
211
+ - **Include "Closes beads-xxx"**: Required for auto-close in /verify
212
+ - **Concrete data only**: Test counts, file paths, commit SHAs — not placeholder text
165
213
  - **Wait for checks**: Let GitHub Actions, Greptile, SonarCloud run
166
214
  - **NO auto-merge**: Always wait for /review phase
@@ -26,6 +26,7 @@ bash scripts/sync-utils.sh auto-sync
26
26
  ```
27
27
 
28
28
  ### Step 1: Smart Status (ranked issues with conflict detection)
29
+
29
30
  ```bash
30
31
  bash scripts/smart-status.sh
31
32
  ```
@@ -33,6 +34,35 @@ This script dynamically computes and displays all issues ranked by composite sco
33
34
 
34
35
  For full context on any issue: `bd show <id>`
35
36
 
37
+ ### Step 1b: Reconcile stale in-progress issues
38
+
39
+ Check if any in-progress issues were already merged but not closed (can happen if `/verify` was skipped or backup was restored from stale snapshot):
40
+
41
+ ```bash
42
+ # Detect default branch dynamically (prefer main over master)
43
+ DEFAULT_BRANCH=$(git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's|refs/remotes/origin/||')
44
+ if [ -z "$DEFAULT_BRANCH" ]; then
45
+ if git rev-parse --verify main >/dev/null 2>&1; then DEFAULT_BRANCH="main"
46
+ elif git rev-parse --verify master >/dev/null 2>&1; then DEFAULT_BRANCH="master"
47
+ else echo "ERROR: No main or master branch found — skipping stale reconciliation" >&2; DEFAULT_BRANCH=""; fi
48
+ fi
49
+
50
+ # For each in_progress issue, check if its PR was already merged
51
+ if [ -n "$DEFAULT_BRANCH" ]; then
52
+ bd list --status=in_progress --json 2>/dev/null | jq -r '.[].id' | while read id; do
53
+ # Search git log for the issue ID in commit messages (fixed-strings for literal match)
54
+ if git log --oneline --first-parent "$DEFAULT_BRANCH" --fixed-strings --grep="$id" | grep -q .; then
55
+ echo "STALE: $id — found in git history, likely already merged"
56
+ fi
57
+ done
58
+ fi
59
+ ```
60
+
61
+ If stale issues are found, close them:
62
+ ```bash
63
+ bd close <id> --force --reason="Already merged — detected during status reconciliation"
64
+ ```
65
+
36
66
  ### Step 2: Review Recent Commits
37
67
  ```bash
38
68
  git log --oneline -10
@@ -43,6 +73,18 @@ git log --oneline -10
43
73
  - **Continuing work**: In-progress issues found, resume where left off
44
74
  - **Review needed**: Work marked complete, needs review/merge
45
75
 
76
+ ### Team context
77
+
78
+ Show current developer's active work and team overview:
79
+
80
+ ```bash
81
+ # Show my active issues
82
+ bash scripts/forge-team/index.sh workload --me 2>&1 || true
83
+
84
+ # One-line team summary
85
+ bash scripts/forge-team/index.sh dashboard 2>&1 | head -5 || true
86
+ ```
87
+
46
88
  ## Next Steps
47
89
 
48
90
  - **If starting new work**: Run `/plan <feature-name>`
@@ -230,7 +230,13 @@ until ALL FOUR show fresh output in this session:
230
230
  "Should pass", "was passing earlier", and "I'm confident" are not evidence.
231
231
  Run the commands. Show the output. THEN declare done.
232
232
 
233
- 5. Stage transition: Run `bash scripts/beads-context.sh stage-transition <id> validate ship` exit 0 confirmed
233
+ 5. Context check: Run `bash scripts/beads-context.sh validate <id>` and address any warnings
234
+ 6. Stage transition: Run the following → exit 0 confirmed:
235
+ bash scripts/beads-context.sh stage-transition <id> validate ship \
236
+ --summary "<all checks pass/fail summary>" \
237
+ --decisions "<any failures diagnosed and fixed>" \
238
+ --artifacts "<scripts and commands run>" \
239
+ --next "<ship readiness notes>"
234
240
  </HARD-GATE>
235
241
  ```
236
242
 
@@ -147,19 +147,67 @@ Branch: <branch-name> deleted ✓
147
147
  bd create --title="Post-merge: <description of issue>" --type=bug --priority=1
148
148
  ```
149
149
 
150
- ### Step 8: Close Beads Issue (if healthy)
150
+ ### Step 8: Close Beads Issues (if healthy)
151
151
 
152
- If everything is clean, close the Beads issue:
152
+ If everything is clean, close all Beads issues referenced in the merged PR.
153
+
154
+ **Auto-detect beads issues from PR body and branch name:**
155
+
156
+ ```bash
157
+ # Get PR body and branch name
158
+ PR_BODY=$(gh pr view <number> --json body --jq '.body')
159
+ PR_BRANCH=$(gh pr view <number> --json headRefName --jq '.headRefName')
160
+
161
+ # Extract beads IDs from PR body (matches "Closes beads-xxx", "closes forge-xxx", etc.)
162
+ # Patterns: "Closes <prefix>-<id>", "Fixes <prefix>-<id>", "Resolves <prefix>-<id>"
163
+ BEADS_IDS=$(echo "$PR_BODY" | grep -oiE '(closes|fixes|resolves):?\s+[a-z]+-[a-z0-9]+' | grep -oiE '[a-z]+-[a-z0-9]{3,6}$')
164
+
165
+ # Validate each ID exists in beads
166
+ VALID_IDS=""
167
+ for id in $BEADS_IDS; do
168
+ if bd show "$id" >/dev/null 2>&1; then
169
+ VALID_IDS="$VALID_IDS $id"
170
+ fi
171
+ done
172
+ BEADS_IDS="$VALID_IDS"
173
+
174
+ # Also check branch name for beads ID — extract segment after last /
175
+ # then validate with bd show to avoid false matches like "pr-templa"
176
+ BRANCH_SLUG=$(echo "$PR_BRANCH" | sed 's|.*/||')
177
+ BRANCH_ID=$(echo "$BRANCH_SLUG" | grep -oE '[a-z]+-[a-z0-9]{3,6}' | head -1)
178
+ if [ -n "$BRANCH_ID" ] && ! bd show "$BRANCH_ID" >/dev/null 2>&1; then
179
+ BRANCH_ID="" # Not a valid beads ID — discard
180
+ fi
181
+ ```
182
+
183
+ **Close each matched issue:**
153
184
 
154
185
  ```bash
155
- bd close <id> --reason="Merged and verified on master"
186
+ # Close issues found in PR body
187
+ for id in $BEADS_IDS; do
188
+ bd close "$id" --reason="Merged and verified on master (PR #<number>)" 2>&1 || echo "Warning: could not close $id"
189
+ done
190
+
191
+ # If no issues found in body, try branch name match (skip if already closed above)
192
+ if [ -z "$BEADS_IDS" ] && [ -n "$BRANCH_ID" ]; then
193
+ bd close "$BRANCH_ID" --reason="Merged and verified on master (PR #<number>)" 2>&1 || echo "Warning: could not close $BRANCH_ID"
194
+ elif [ -n "$BRANCH_ID" ] && ! echo "$BEADS_IDS" | grep -qw "$BRANCH_ID"; then
195
+ bd close "$BRANCH_ID" --reason="Merged and verified on master (PR #<number>)" 2>&1 || echo "Warning: could not close $BRANCH_ID"
196
+ fi
197
+ ```
198
+
199
+ **If no beads issues detected at all**, prompt the user:
200
+ ```
201
+ ⚠ No beads issue ID found in PR body or branch name.
202
+ If this PR closes a beads issue, run: bd close <id> --reason="Merged and verified on master (PR #<number>)"
156
203
  ```
157
204
 
158
205
  ```
159
206
  <HARD-GATE: /verify exit>
160
207
  Do NOT declare /verify complete until:
161
208
  1. gh run list --branch master --limit 3 shows actual CI output (not "should be fine")
162
- 2. If healthy: Beads issue is closed (bd close <id> run and confirmed)
209
+ 2. If healthy: Beads issues extracted from PR body/branch and closed (bd close run and confirmed)
210
+ - If no beads ID found: user was warned and given manual close command
163
211
  3. If issues found: Beads tracking issue created for every problem
164
212
  4. Worktree removed (or confirmed already gone) — OR Step 6 was intentionally skipped because CI was unhealthy; if skipped, state explicitly: "cleanup deferred, CI was not healthy"
165
213
  "It should be fine" is not evidence. Run the command. Show the output.
@@ -276,7 +276,12 @@ Do NOT declare /dev complete until:
276
276
  ### Beads update
277
277
 
278
278
  ```bash
279
- bash scripts/beads-context.sh stage-transition <id> dev validate
279
+ bash scripts/beads-context.sh validate <id>
280
+ bash scripts/beads-context.sh stage-transition <id> dev validate \
281
+ --summary "<N tasks done, M decision gates fired>" \
282
+ --decisions "<key spec gaps and how they were resolved>" \
283
+ --artifacts "<changed source files and test files>" \
284
+ --next "<validation priorities — lint issues, type concerns>"
280
285
  ```
281
286
 
282
287
  ---
@@ -77,6 +77,44 @@ If exit code 0: proceed silently to Phase 1.
77
77
 
78
78
  ---
79
79
 
80
+ ### Parallel PR coordination check (soft block)
81
+
82
+ Before proceeding to Phase 1, check for merge conflicts and dependency issues with in-flight PRs:
83
+
84
+ ```bash
85
+ # Run merge simulation if on a feature branch
86
+ current_branch="$(git branch --show-current)"
87
+ if [[ "$current_branch" != "master" ]] && [[ "$current_branch" != "main" ]]; then
88
+ bash scripts/pr-coordinator.sh merge-sim "$current_branch" 2>&1 || true
89
+ fi
90
+
91
+ # Show current merge queue
92
+ bash scripts/pr-coordinator.sh merge-order 2>&1 || true
93
+
94
+ # Check for stale worktrees (informational)
95
+ bash scripts/pr-coordinator.sh stale-worktrees 2>&1 || true
96
+ ```
97
+
98
+ If merge conflicts or unmet dependencies are found:
99
+ - Display the findings to the developer
100
+ - Ask: "In-flight PRs have potential conflicts. Proceed with planning anyway? (y/n)"
101
+ - If `n`: exit cleanly, no side effects
102
+ - If `y`: log override via `bd comments add <id> "PR coordination override: proceeding despite in-flight conflicts"`, then continue to Phase 1
103
+
104
+ ---
105
+
106
+ ### Team identity verification
107
+
108
+ Before starting planning, verify team identity is mapped:
109
+
110
+ ```bash
111
+ bash scripts/forge-team/index.sh verify 2>&1 || true
112
+ ```
113
+
114
+ If verify reports issues, address them before proceeding (the output will include `FORGE_AGENT_7f3a:PROMPT:` directives with exact commands to run).
115
+
116
+ ---
117
+
80
118
  ## Phase 1: Design Intent (Brainstorming)
81
119
 
82
120
  **Goal**: Capture WHAT to build — purpose, constraints, success criteria, edge cases, approach.
@@ -154,7 +192,6 @@ Questions to cover (adapt to feature, don't ask mechanical copies):
154
192
  3. **Success criteria** — How will we know it's done? What is the minimum viable result?
155
193
  4. **Edge cases** — What happens when [key dependency] fails / [input] is missing / [state] is ambiguous?
156
194
  5. **Technical preferences** — Library A or B? Pattern X or Y? (when real options exist)
157
- 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?
158
195
 
159
196
  ### Step 3: Propose approaches
160
197
 
@@ -173,7 +210,7 @@ Save to `docs/plans/YYYY-MM-DD-<slug>-design.md` with these sections:
173
210
  - **Approach selected**: which option and why
174
211
  - **Constraints**: hard limits
175
212
  - **Edge cases**: decisions made during Q&A
176
- - **Ambiguity policy**: agent's fallback when spec gaps arise mid-dev
213
+ - **Ambiguity policy**: Use 7-dimension rubric scoring per /dev decision gate. >= 80% confidence: proceed and document. < 80%: stop and ask.
177
214
 
178
215
  Commit the design doc:
179
216
  ```bash
@@ -387,6 +424,9 @@ Expected output: <what running the test/code produces when done>
387
424
  - Feature logic SECOND
388
425
  - Integration/wiring THIRD
389
426
  - Uncertain/ambiguous tasks LAST (so they can be deferred if blocked)
427
+ - **File ownership**: Each task MUST include an `OWNS:` line listing files it will modify
428
+ - No two tasks in the same wave can own the same file
429
+ - Cross-wave ownership is allowed (sequential execution prevents conflicts)
390
430
 
391
431
  **YAGNI filter** (after initial task draft, before saving):
392
432
 
@@ -468,10 +508,15 @@ Do NOT proceed to /dev until ALL are confirmed:
468
508
  </HARD-GATE>
469
509
  ```
470
510
 
471
- After all HARD-GATE items pass, record the stage transition on the Beads issue:
511
+ After all HARD-GATE items pass, validate context and record the stage transition:
472
512
 
473
513
  ```bash
474
- bash scripts/beads-context.sh stage-transition <id> plan dev
514
+ bash scripts/beads-context.sh validate <id>
515
+ bash scripts/beads-context.sh stage-transition <id> plan dev \
516
+ --summary "<design approach chosen, task count>" \
517
+ --decisions "<key trade-offs resolved during Q&A>" \
518
+ --artifacts "docs/plans/YYYY-MM-DD-<slug>-design.md docs/plans/YYYY-MM-DD-<slug>-tasks.md" \
519
+ --next "<first dev task focus area>"
475
520
  ```
476
521
 
477
522
  ---
@@ -480,20 +525,20 @@ bash scripts/beads-context.sh stage-transition <id> plan dev
480
525
 
481
526
  ```
482
527
  ✓ Phase 1: Design intent captured
483
- - Design doc: docs/plans/2026-02-26-stripe-billing-design.md
484
- - Approach: Stripe SDK v4 (selected over v3)
485
- - Ambiguity policy: Make conservative choice + document in decisions log
528
+ - Design doc: docs/plans/<date>-<slug>-design.md
529
+ - Approach: <selected approach> (selected over <alternatives>)
530
+ - Ambiguity policy: Rubric scoring (>= 80% proceed, < 80% ask)
486
531
 
487
532
  ✓ Phase 2: Technical research complete
488
- - OWASP Top 10: 3 risks identified, 3 mitigations planned
489
- - TDD scenarios: 5 identified
490
- - Sources: 8 references
533
+ - OWASP Top 10: <N> risks identified, <N> mitigations planned
534
+ - TDD scenarios: <N> identified
535
+ - Sources: <N> references
491
536
 
492
537
  ✓ Phase 3: Setup complete
493
- - Beads: forge-xyz (in_progress)
494
- - Branch: feat/stripe-billing
495
- - Worktree: .worktrees/stripe-billing (baseline: 24/24 tests passing)
496
- - Task list: docs/plans/2026-02-26-stripe-billing-tasks.md (8 tasks)
538
+ - Beads: <issue-id> (in_progress)
539
+ - Branch: feat/<slug>
540
+ - Worktree: .worktrees/<slug> (baseline: <N>/<N> tests passing)
541
+ - Task list: docs/plans/<date>-<slug>-tasks.md (<N> tasks)
497
542
 
498
543
  ⏸️ Task list ready for review. Confirm to proceed.
499
544
 
@@ -124,6 +124,16 @@ Output:
124
124
  After you merge, run /verify to confirm everything landed correctly.
125
125
  ```
126
126
 
127
+ ### Step 6: Validate Context and Record Stage Transition
128
+
129
+ ```bash
130
+ bash scripts/beads-context.sh validate <id>
131
+ bash scripts/beads-context.sh stage-transition <id> premerge verify \
132
+ --summary "<docs updated, CI green, PR ready>" \
133
+ --artifacts "<updated doc files, PR URL>" \
134
+ --next "<merge instructions for user>"
135
+ ```
136
+
127
137
  ```
128
138
  <HARD-GATE: /premerge exit>
129
139
  Do NOT run gh pr merge.
@@ -365,7 +365,13 @@ Do NOT declare /review complete until:
365
365
  1. bash .claude/scripts/greptile-resolve.sh stats <pr-number> shows "All Greptile threads resolved"
366
366
  2. ALL human reviewer comments are either resolved or have a reply with explanation
367
367
  3. gh pr checks <pr-number> shows all checks passing
368
- 4. Stage transition: Run `bash scripts/beads-context.sh stage-transition <id> review premerge` exit 0 confirmed
368
+ 4. Context check: Run `bash scripts/beads-context.sh validate <id>` and address any warnings
369
+ 5. Stage transition: Run the following → exit 0 confirmed:
370
+ bash scripts/beads-context.sh stage-transition <id> review premerge \
371
+ --summary "<all feedback addressed summary>" \
372
+ --decisions "<comment resolutions — valid fixes and justified rejections>" \
373
+ --artifacts "<fixed files, commit SHAs>" \
374
+ --next "<doc update needs for premerge>"
369
375
  </HARD-GATE>
370
376
  ```
371
377