forge-workflow 0.0.3 → 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 (83) hide show
  1. package/.claude/commands/dev.md +26 -0
  2. package/.claude/commands/plan.md +48 -5
  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 +26 -0
  9. package/.cline/workflows/plan.md +48 -5
  10. package/.cline/workflows/premerge.md +0 -3
  11. package/.cline/workflows/rollback.md +4 -4
  12. package/.cline/workflows/ship.md +71 -41
  13. package/.cline/workflows/status.md +9 -38
  14. package/.cline/workflows/validate.md +47 -2
  15. package/.codex/skills/dev/SKILL.md +26 -0
  16. package/.codex/skills/plan/SKILL.md +48 -5
  17. package/.codex/skills/premerge/SKILL.md +0 -3
  18. package/.codex/skills/rollback/SKILL.md +4 -4
  19. package/.codex/skills/ship/SKILL.md +71 -41
  20. package/.codex/skills/status/SKILL.md +9 -38
  21. package/.codex/skills/validate/SKILL.md +47 -2
  22. package/.cursor/commands/dev.md +26 -0
  23. package/.cursor/commands/plan.md +48 -5
  24. package/.cursor/commands/premerge.md +0 -3
  25. package/.cursor/commands/rollback.md +4 -4
  26. package/.cursor/commands/ship.md +71 -41
  27. package/.cursor/commands/status.md +9 -38
  28. package/.cursor/commands/validate.md +47 -2
  29. package/.cursor/hooks/state/continual-learning-index.json +19 -0
  30. package/.cursor/hooks/state/continual-learning.json +8 -0
  31. package/.github/prompts/dev.prompt.md +26 -0
  32. package/.github/prompts/plan.prompt.md +48 -5
  33. package/.github/prompts/premerge.prompt.md +0 -3
  34. package/.github/prompts/rollback.prompt.md +4 -4
  35. package/.github/prompts/ship.prompt.md +71 -41
  36. package/.github/prompts/status.prompt.md +9 -38
  37. package/.github/prompts/validate.prompt.md +47 -2
  38. package/.kilocode/workflows/dev.md +26 -0
  39. package/.kilocode/workflows/plan.md +48 -5
  40. package/.kilocode/workflows/premerge.md +0 -3
  41. package/.kilocode/workflows/rollback.md +4 -4
  42. package/.kilocode/workflows/ship.md +71 -41
  43. package/.kilocode/workflows/status.md +9 -38
  44. package/.kilocode/workflows/validate.md +47 -2
  45. package/.opencode/commands/dev.md +26 -0
  46. package/.opencode/commands/plan.md +48 -5
  47. package/.opencode/commands/premerge.md +0 -3
  48. package/.opencode/commands/rollback.md +4 -4
  49. package/.opencode/commands/ship.md +71 -41
  50. package/.opencode/commands/status.md +9 -38
  51. package/.opencode/commands/validate.md +47 -2
  52. package/.roo/commands/dev.md +26 -0
  53. package/.roo/commands/plan.md +48 -5
  54. package/.roo/commands/premerge.md +0 -3
  55. package/.roo/commands/rollback.md +4 -4
  56. package/.roo/commands/ship.md +71 -41
  57. package/.roo/commands/status.md +9 -38
  58. package/.roo/commands/validate.md +47 -2
  59. package/AGENTS.md +7 -1
  60. package/CLAUDE.md +5 -4
  61. package/LICENSE +21 -21
  62. package/README.md +21 -19
  63. package/bin/{forge-validate.js → forge-preflight.js} +21 -15
  64. package/bin/forge.js +209 -138
  65. package/docs/AGENT_INSTALL_PROMPT.md +1 -1
  66. package/docs/BEADS_GITHUB_SYNC.md +251 -0
  67. package/docs/ENHANCED_ONBOARDING.md +6 -6
  68. package/docs/EXAMPLES.md +4 -4
  69. package/docs/GREPTILE_SETUP.md +1 -1
  70. package/docs/MANUAL_REVIEW_GUIDE.md +1 -1
  71. package/docs/ROADMAP.md +6 -6
  72. package/docs/SETUP.md +1 -2
  73. package/docs/VALIDATION.md +11 -11
  74. package/install.sh +1 -3
  75. package/lib/agents-config.js +3 -3
  76. package/lib/detect-agent.js +191 -0
  77. package/lib/detect-worktree.js +47 -0
  78. package/lib/file-hash.js +26 -0
  79. package/lib/setup-action-log.js +139 -0
  80. package/lib/setup-summary-renderer.js +106 -0
  81. package/lib/setup.js +75 -1
  82. package/package.json +3 -4
  83. package/docs/WORKFLOW.md +0 -400
@@ -26,60 +26,97 @@ Do NOT create PR until:
26
26
  ### Step 1: Verify /validate Passed
27
27
  Ensure all four validation checks completed successfully with fresh output in this session.
28
28
 
29
- ### Step 2: Update Beads
29
+ ### Step 2: Freshness Check — Is Branch Still Current?
30
+
31
+ 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.
32
+
33
+ ```bash
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
+ git fetch origin "$BASE" || { echo "✗ Fetch failed — cannot verify freshness"; exit 1; }
37
+ BEHIND=$(git rev-list --count HEAD..origin/"$BASE")
38
+ ```
39
+
40
+ - If `BEHIND > 0`: **STOP**. Print: "$BASE has advanced since /validate ($BEHIND new commits). Run /validate again to rebase and re-check."
41
+ - If `BEHIND = 0`: Continue to push.
42
+ - If fetch fails: the `|| { ...; exit 1; }` guard catches this — **STOP**. Do NOT push without confirming freshness.
43
+
44
+ This is NOT a full rebase — just a check. The rebase happens in /validate where the full test suite runs afterward.
45
+
46
+ ### Step 3: Update Beads
30
47
  ```bash
31
48
  bd update <id> --status done
32
49
  bd sync
33
50
  ```
34
51
 
35
- ### Step 3: Push Branch
52
+ ### Step 4: Push Branch
53
+
54
+ 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.
55
+
36
56
  ```bash
37
- git push -u origin <branch-name>
57
+ git push --force-with-lease -u origin <branch-name>
38
58
  ```
39
59
 
40
- ### Step 4: Create PR
60
+ ### Step 5: Create PR
61
+
62
+ 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.
63
+
64
+ If no Beads issue exists (hotfix, external contribution), skip the "Closes" line.
41
65
 
42
66
  ```bash
43
- gh pr create --title "feat: <feature-name>" --body "$(cat <<'EOF'
44
- ## Summary
45
- [Auto-generated from commits and design doc]
67
+ gh pr create --title "<type>: <concise description>" --body "$(cat <<'EOF'
68
+ ## Problem
69
+ [What was broken, what need existed, or what user pain this addresses]
46
70
 
47
- ## Design Doc
48
- See: docs/plans/YYYY-MM-DD-<slug>-design.md
71
+ ## Root Cause
72
+ [Why it happened, why it was missing, or what gap existed]
49
73
 
50
- ## Decisions Log
51
- See: docs/plans/YYYY-MM-DD-<slug>-decisions.md (if any undocumented decisions arose during /dev)
74
+ ## Fix
75
+ [What this PR does to solve it approach, not implementation details]
76
+
77
+ ## Value
78
+ [Who benefits, what improves, what risk is removed]
52
79
 
53
- ## Beads Issue
80
+ ## Beads
54
81
  Closes: <issue-id>
55
82
 
56
- ## Key Decisions
57
- [From design doc - 3-5 key decisions with reasoning]
83
+ <details>
84
+ <summary>Implementation Details</summary>
58
85
 
59
- ## TDD Test Coverage
60
- - Unit tests: [count] tests, [X] scenarios
61
- - Integration tests: [count] tests
62
- - E2E tests: [count] tests
63
- - All tests passing ✓
86
+ ### Test Coverage
87
+ - Tests: [count] passing
88
+ - Scenarios covered: [list key scenarios]
64
89
 
65
- ## Security Review
66
- - OWASP Top 10: All mitigations implemented
67
- - Security tests: [count] scenarios passing
68
- - Automated scan: No vulnerabilities
90
+ ### Security Review
91
+ - OWASP Top 10: [summary — applicable risks and mitigations]
92
+ - Automated scan: [result]
69
93
 
70
- ## Test Plan
94
+ ### Design Doc
95
+ See: docs/plans/YYYY-MM-DD-<slug>-design.md
96
+
97
+ ### Decisions Log
98
+ See: docs/plans/YYYY-MM-DD-<slug>-decisions.md (if any undocumented decisions arose during /dev)
99
+
100
+ ### Key Decisions
101
+ [From design doc — 3-5 key decisions with reasoning]
102
+
103
+ ### Documentation Updated
104
+ [List docs updated in this PR, or "None — no doc-facing changes"]
105
+
106
+ ### Validation
71
107
  - [x] Type check passing
72
- - [x] Lint passing
73
- - [x] Code review passing
74
- - [x] E2E tests passing
108
+ - [x] Lint passing (0 errors, 0 warnings)
109
+ - [x] All tests passing
75
110
  - [x] Security review completed
76
111
 
112
+ </details>
113
+
77
114
  🤖 Generated with [Claude Code](https://claude.com/claude-code)
78
115
  EOF
79
116
  )"
80
117
  ```
81
118
 
82
- ### Step 5: Record Stage Transition
119
+ ### Step 6: Record Stage Transition
83
120
  ```bash
84
121
  bash scripts/beads-context.sh stage-transition <id> ship review
85
122
  ```
@@ -88,20 +125,13 @@ bash scripts/beads-context.sh stage-transition <id> ship review
88
125
 
89
126
  ```
90
127
  ✓ Validation: /validate passed (all 4 checks — fresh output confirmed)
128
+ ✓ Freshness: Branch is up-to-date with master
91
129
  ✓ Beads: Marked done & synced (forge-xyz)
92
130
  ✓ Pushed: feat/stripe-billing
93
131
  ✓ PR created: https://github.com/.../pull/123
132
+ - PR body: Problem → Root Cause → Fix → Value (narrative format)
94
133
  - Beads linked: forge-xyz
95
- - Design doc linked: docs/plans/2026-02-26-stripe-billing-design.md
96
- - Decisions log linked: docs/plans/2026-02-26-stripe-billing-decisions.md
97
- - Test coverage documented
98
- - Security review documented
99
-
100
- PR Summary:
101
- - 12 commits
102
- - 18 test cases, all passing
103
- - OWASP Top 10 security review completed
104
- - 3 key architectural decisions documented
134
+ - Implementation details in collapsible section
105
135
 
106
136
  ⏸️ PR created, awaiting automated checks (Greptile, SonarCloud, GitHub Actions)
107
137
 
@@ -123,9 +153,9 @@ Stage 7: /verify → Post-merge CI check on main
123
153
 
124
154
  ## Tips
125
155
 
126
- - **Complete PR body**: Include design doc, decisions log, and test coverage
127
- - **Link everything**: Design doc, decisions log, Beads issue
128
- - **Document security**: OWASP Top 10 review in PR body
156
+ - **Lead with why**: Problem Root Cause Fix Value is what reviewers need first
157
+ - **Collapsible details**: Design doc, decisions log, test coverage go in `<details>` — available but not in the way
158
+ - **Document security**: OWASP Top 10 review in collapsible section
129
159
  - **Test coverage**: Show all test scenarios passing
130
160
  - **Wait for checks**: Let GitHub Actions, Greptile, SonarCloud run
131
161
  - **NO auto-merge**: Always wait for /review phase
@@ -13,60 +13,31 @@ This command helps you understand the current state of the project before starti
13
13
 
14
14
  ## What This Command Does
15
15
 
16
- ### Step 1: Check Project Health
17
- ```bash
18
- bd stats
19
- ```
20
- - How many open / in-progress / completed issues?
21
- - Any blocked issues?
16
+ ## Step 0: Sync team state
22
17
 
23
- ### Step 2: Check Active Work
24
18
  ```bash
25
- # Active Beads issues
26
- bd list --status in_progress
19
+ # Sync team state before showing status
20
+ bash scripts/sync-utils.sh auto-sync
27
21
  ```
28
22
 
29
- For each in-progress issue, show compact progress:
23
+ ### Step 1: Smart Status (ranked issues with conflict detection)
30
24
  ```bash
31
- bash scripts/beads-context.sh parse-progress <issue-id>
25
+ bash scripts/smart-status.sh
32
26
  ```
33
- Display the compact output (e.g., "3/7 tasks done | Last: Validation logic (def5678)")
27
+ 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.
34
28
 
35
- Hint: `bd show <id>` for full context on any issue.
29
+ For full context on any issue: `bd show <id>`
36
30
 
37
- ### Step 3: Review Recent Work
31
+ ### Step 2: Review Recent Commits
38
32
  ```bash
39
- # Recent commits
40
33
  git log --oneline -10
41
-
42
- # Recently completed Beads
43
- bd list --status completed --limit 5
44
34
  ```
45
35
 
46
- ### Step 4: Determine Context
36
+ ### Step 3: Determine Context
47
37
  - **New feature**: No active work, ready to start fresh
48
38
  - **Continuing work**: In-progress issues found, resume where left off
49
39
  - **Review needed**: Work marked complete, needs review/merge
50
40
 
51
- ## Example Output
52
-
53
- ```
54
- ✓ Project Health: 3 open, 1 in-progress, 12 completed
55
-
56
- Active Work:
57
- - forge-ctc: Clean up stale workflow refs (in_progress)
58
- 3/7 tasks done | Last: Validation logic (def5678)
59
- → bd show forge-ctc for full context
60
-
61
- Recent Completions:
62
- - forge-uto: Sync AGENTS.md with agent cleanup (closed 2 days ago)
63
- - forge-abc: Auth refresh tokens (closed 5 days ago)
64
-
65
- Context: Continuing work
66
-
67
- Next: Resume with /dev or /validate (check issue status)
68
- ```
69
-
70
41
  ## Next Steps
71
42
 
72
43
  - **If starting new work**: Run `/plan <feature-name>`
@@ -1,4 +1,9 @@
1
1
 
2
+ > **Note:** Three things share the "validate" name in Forge:
3
+ > - `/validate` (this command): Workflow Stage 3 — rebases onto the base branch, then runs type/lint/test/security checks
4
+ > - `forge-preflight` (formerly forge-validate): CLI tool — checks prerequisites before a stage
5
+ > - `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)
6
+
2
7
  Run comprehensive validation including type checking, linting, code review, security review, and tests.
3
8
 
4
9
  # Validate
@@ -11,10 +16,50 @@ This command validates all code before creating a pull request.
11
16
  /validate
12
17
  ```
13
18
 
14
- Or use the unified validation script:
19
+ Or use the validation script (checks only — no rebase):
15
20
 
16
21
  ```bash
17
- bun run check # Runs all validation steps automatically (check is the npm script name; /validate is the workflow command)
22
+ bun run check # Runs lint/test/security checks only. Does NOT rebase onto the base branch.
23
+ # Use /validate for the full workflow (rebase + checks).
24
+ ```
25
+
26
+ ```
27
+ <HARD-GATE: /validate entry — rebase onto latest base branch>
28
+ Before running ANY validation checks:
29
+
30
+ 0. Resolve the base branch dynamically (do NOT hardcode master or main):
31
+ BASE=$(git remote show origin 2>/dev/null | grep 'HEAD branch' | awk '{print $NF}')
32
+ if [ -z "$BASE" ] || [ "$BASE" = "(unknown)" ]; then BASE="master"; fi
33
+
34
+ This handles repos using main, master, or any other default branch.
35
+ Falls back to "master" when HEAD is unresolved (detached remote, empty repo).
36
+
37
+ 1. Fetch latest base branch:
38
+ git fetch origin "$BASE" || { echo "✗ Fetch failed — cannot verify branch freshness"; exit 1; }
39
+
40
+ The `|| { ...; exit 1; }` guard ensures fetch failures are never silently skipped.
41
+
42
+ 2. Check if branch is behind:
43
+ BEHIND=$(git rev-list --count HEAD..origin/"$BASE")
44
+
45
+ 3. If BEHIND > 0:
46
+ a. Run: git rebase origin/"$BASE" || REBASE_FAILED=1
47
+ b. If rebase succeeds (REBASE_FAILED unset): print "✓ Rebased onto latest $BASE ($BEHIND commits integrated)"
48
+ c. If rebase fails (REBASE_FAILED=1 — conflicts or any other error):
49
+ - Capture conflicting files BEFORE aborting: git diff --name-only --diff-filter=U
50
+ - Run: git rebase --abort
51
+ - Print the captured conflicting file list
52
+ - Print: "✗ Rebase conflict — resolve manually, then re-run /validate"
53
+ - STOP. Do NOT proceed to any validation checks.
54
+
55
+ 4. If BEHIND = 0:
56
+ Print "✓ Branch is up-to-date with $BASE" and continue.
57
+
58
+ Rationale: Without this step, validation checks run against stale code that doesn't
59
+ include recent base branch changes. Integration issues are only caught after the PR is
60
+ created, wasting CI cycles and review time. Rebasing here ensures /validate results
61
+ reflect the true state of what will be merged.
62
+ </HARD-GATE>
18
63
  ```
19
64
 
20
65
  ## What This Command Does
@@ -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:
@@ -23,7 +23,13 @@ Before ANY planning work begins:
23
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,6 +50,32 @@ 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.
@@ -181,6 +213,11 @@ Do NOT begin Phase 2 (web research) until:
181
213
 
182
214
  **Goal**: Find HOW to build it — best practices, known issues, security risks, TDD scenarios.
183
215
 
216
+ Record the phase transition before starting research:
217
+ ```bash
218
+ bash scripts/beads-context.sh stage-transition <id> plan research
219
+ ```
220
+
184
221
  Run these in parallel:
185
222
 
186
223
  ### Web research (parallel-deep-research skill)
@@ -271,13 +308,19 @@ Do NOT begin Phase 3 (setup) until:
271
308
 
272
309
  ## Phase 3: Setup + Task List
273
310
 
274
- **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
275
319
 
276
- ### 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:
277
321
 
278
322
  ```bash
279
- bd create --title="<feature-name>" --type=feature
280
- bd update <id> --status=in_progress
323
+ bd create --title="<sub-task-name>" --type=feature --parent=<epic-id>
281
324
  ```
282
325
 
283
326
  ### Step 2: Branch + worktree
@@ -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