forge-workflow 0.0.1
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.
- package/.claude/commands/dev.md +314 -0
- package/.claude/commands/plan.md +389 -0
- package/.claude/commands/premerge.md +179 -0
- package/.claude/commands/research.md +42 -0
- package/.claude/commands/review.md +442 -0
- package/.claude/commands/rollback.md +721 -0
- package/.claude/commands/ship.md +134 -0
- package/.claude/commands/sonarcloud.md +152 -0
- package/.claude/commands/status.md +77 -0
- package/.claude/commands/validate.md +237 -0
- package/.claude/commands/verify.md +221 -0
- package/.claude/rules/greptile-review-process.md +285 -0
- package/.claude/rules/workflow.md +105 -0
- package/.claude/scripts/greptile-resolve.sh +526 -0
- package/.claude/scripts/load-env.sh +32 -0
- package/.forge/hooks/check-tdd.js +240 -0
- package/.github/PLUGIN_TEMPLATE.json +32 -0
- package/.mcp.json.example +12 -0
- package/AGENTS.md +169 -0
- package/CLAUDE.md +99 -0
- package/LICENSE +21 -0
- package/README.md +414 -0
- package/bin/forge-cmd.js +313 -0
- package/bin/forge-validate.js +303 -0
- package/bin/forge.js +4228 -0
- package/docs/AGENT_INSTALL_PROMPT.md +342 -0
- package/docs/ENHANCED_ONBOARDING.md +602 -0
- package/docs/EXAMPLES.md +482 -0
- package/docs/GREPTILE_SETUP.md +400 -0
- package/docs/MANUAL_REVIEW_GUIDE.md +106 -0
- package/docs/ROADMAP.md +359 -0
- package/docs/SETUP.md +632 -0
- package/docs/TOOLCHAIN.md +849 -0
- package/docs/VALIDATION.md +363 -0
- package/docs/WORKFLOW.md +400 -0
- package/docs/planning/PROGRESS.md +396 -0
- package/docs/plans/.gitkeep +0 -0
- package/docs/plans/2026-02-27-forge-test-suite-v2-decisions.md +21 -0
- package/docs/plans/2026-02-27-forge-test-suite-v2-design.md +362 -0
- package/docs/plans/2026-02-27-forge-test-suite-v2-tasks.md +343 -0
- package/docs/plans/2026-03-02-superpowers-gaps-decisions.md +26 -0
- package/docs/plans/2026-03-02-superpowers-gaps-design.md +239 -0
- package/docs/plans/2026-03-02-superpowers-gaps-tasks.md +260 -0
- package/docs/plans/2026-03-04-agent-command-parity-design.md +163 -0
- package/docs/plans/2026-03-04-verify-worktree-cleanup-decisions.md +7 -0
- package/docs/plans/2026-03-04-verify-worktree-cleanup-design.md +165 -0
- package/docs/plans/2026-03-05-forge-uto-decisions.md +6 -0
- package/docs/plans/2026-03-05-forge-uto-design.md +116 -0
- package/docs/plans/2026-03-05-forge-uto-tasks.md +244 -0
- package/docs/plans/2026-03-10-command-creator-and-eval-decisions.md +52 -0
- package/docs/plans/2026-03-10-command-creator-and-eval-design.md +350 -0
- package/docs/plans/2026-03-10-command-creator-and-eval-tasks.md +426 -0
- package/docs/plans/2026-03-10-stale-workflow-refs-decisions.md +8 -0
- package/docs/plans/2026-03-10-stale-workflow-refs-design.md +80 -0
- package/docs/plans/2026-03-10-stale-workflow-refs-tasks.md +90 -0
- package/docs/plans/2026-03-14-beads-plan-context-decisions.md +9 -0
- package/docs/plans/2026-03-14-beads-plan-context-design.md +171 -0
- package/docs/plans/2026-03-14-beads-plan-context-tasks.md +160 -0
- package/docs/plans/2026-03-14-skill-eval-loop-decisions.md +33 -0
- package/docs/plans/2026-03-14-skill-eval-loop-design.md +118 -0
- package/docs/plans/2026-03-14-skill-eval-loop-results.md +78 -0
- package/docs/plans/2026-03-14-skill-eval-loop-tasks.md +160 -0
- package/docs/plans/2026-03-15-agent-command-parity-v2-decisions.md +11 -0
- package/docs/plans/2026-03-15-agent-command-parity-v2-design.md +145 -0
- package/docs/plans/2026-03-15-agent-command-parity-v2-tasks.md +211 -0
- package/docs/research/TEMPLATE.md +292 -0
- package/docs/research/advanced-testing.md +297 -0
- package/docs/research/agent-permissions.md +167 -0
- package/docs/research/dependency-chain.md +328 -0
- package/docs/research/forge-workflow-v2.md +550 -0
- package/docs/research/plugin-architecture.md +772 -0
- package/docs/research/pr4-cli-automation.md +326 -0
- package/docs/research/premerge-verify-restructure.md +205 -0
- package/docs/research/skills-restructure.md +508 -0
- package/docs/research/sonarcloud-perfection-plan.md +166 -0
- package/docs/research/sonarcloud-quality-gate.md +184 -0
- package/docs/research/superpowers-integration.md +403 -0
- package/docs/research/superpowers.md +319 -0
- package/docs/research/test-environment.md +519 -0
- package/install.sh +1062 -0
- package/lefthook.yml +39 -0
- package/lib/agents/README.md +198 -0
- package/lib/agents/claude.plugin.json +28 -0
- package/lib/agents/cline.plugin.json +22 -0
- package/lib/agents/codex.plugin.json +19 -0
- package/lib/agents/copilot.plugin.json +24 -0
- package/lib/agents/cursor.plugin.json +25 -0
- package/lib/agents/kilocode.plugin.json +22 -0
- package/lib/agents/opencode.plugin.json +20 -0
- package/lib/agents/roo.plugin.json +23 -0
- package/lib/agents-config.js +2112 -0
- package/lib/commands/dev.js +513 -0
- package/lib/commands/plan.js +696 -0
- package/lib/commands/recommend.js +119 -0
- package/lib/commands/ship.js +377 -0
- package/lib/commands/status.js +378 -0
- package/lib/commands/validate.js +602 -0
- package/lib/context-merge.js +359 -0
- package/lib/plugin-catalog.js +360 -0
- package/lib/plugin-manager.js +166 -0
- package/lib/plugin-recommender.js +141 -0
- package/lib/project-discovery.js +491 -0
- package/lib/setup.js +118 -0
- package/lib/workflow-profiles.js +203 -0
- package/package.json +115 -0
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
# Research: PR4 - CLI Command Automation
|
|
2
|
+
|
|
3
|
+
**Date**: 2026-02-14
|
|
4
|
+
**Feature**: Automate Forge workflow commands with executable CLI dispatcher
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Objective
|
|
9
|
+
|
|
10
|
+
Transform Forge from **documentation-driven workflow** to **CLI-automated workflow**.
|
|
11
|
+
|
|
12
|
+
**Deliverables**:
|
|
13
|
+
1. Executable command dispatcher (`bin/forge-cmd.js`)
|
|
14
|
+
2. Intelligent stage detection (auto-detect workflow stage 1-9)
|
|
15
|
+
3. Automated command handlers (`/research`, `/plan`, `/ship`, `/review`)
|
|
16
|
+
4. PR body auto-generation (from research + plan + tests)
|
|
17
|
+
5. Review aggregation (Greptile + SonarCloud + GitHub Actions)
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Codebase Analysis
|
|
22
|
+
|
|
23
|
+
### Current Architecture
|
|
24
|
+
|
|
25
|
+
**CLI Entry Points**:
|
|
26
|
+
- `bin/forge.js` (3,800+ lines) - Setup with agent configuration
|
|
27
|
+
- `bin/forge-validate.js` (304 lines) - Validation with switch dispatch
|
|
28
|
+
|
|
29
|
+
**Commands**: `.claude/commands/` - 11 markdown files defining workflow stages
|
|
30
|
+
|
|
31
|
+
**Critical Gap**: Commands are documentation only, not executable code
|
|
32
|
+
|
|
33
|
+
### Existing Patterns to Follow
|
|
34
|
+
|
|
35
|
+
**State Management** (lib/setup.js):
|
|
36
|
+
- saveSetupState() - Persist progress
|
|
37
|
+
- loadSetupState() - Resume from last state
|
|
38
|
+
- isSetupComplete() - Check completion
|
|
39
|
+
|
|
40
|
+
**Validation Pattern** (bin/forge-validate.js):
|
|
41
|
+
- Modular dispatch with switch statement
|
|
42
|
+
- Separate handler functions per command
|
|
43
|
+
- Export for testing
|
|
44
|
+
|
|
45
|
+
**Test Infrastructure**:
|
|
46
|
+
- 576 tests across 36 files
|
|
47
|
+
- E2E framework with fixtures
|
|
48
|
+
- Snapshot testing
|
|
49
|
+
- 80% coverage thresholds
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Security Analysis (OWASP Top 10)
|
|
54
|
+
|
|
55
|
+
### A03: Injection (CRITICAL for CLI)
|
|
56
|
+
|
|
57
|
+
**Command Injection Risk**:
|
|
58
|
+
- User input in `/research <name>`, `/plan <slug>`
|
|
59
|
+
- **Mitigation**: Never use exec() with user input
|
|
60
|
+
|
|
61
|
+
**Safe Pattern**:
|
|
62
|
+
```javascript
|
|
63
|
+
// UNSAFE
|
|
64
|
+
exec(`gh pr create --title "${userInput}"`);
|
|
65
|
+
|
|
66
|
+
// SAFE
|
|
67
|
+
execFile('gh', ['pr', 'create', '--title', userInput]);
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
**Input Validation**:
|
|
71
|
+
- Feature slugs: `/^[a-z0-9-]+$/` only
|
|
72
|
+
- No spaces, dots, slashes
|
|
73
|
+
- Max length: 50 characters
|
|
74
|
+
|
|
75
|
+
**Path Traversal Prevention**:
|
|
76
|
+
```javascript
|
|
77
|
+
const slug = path.basename(userInput); // Strip paths
|
|
78
|
+
if (!/^[a-z0-9-]+$/.test(slug)) {
|
|
79
|
+
throw new Error('Invalid feature slug');
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### A01: Broken Access Control
|
|
84
|
+
|
|
85
|
+
**File Permission Checks**:
|
|
86
|
+
```javascript
|
|
87
|
+
fs.accessSync(dir, fs.constants.W_OK); // Check before write
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
**Git Repository Validation**:
|
|
91
|
+
```javascript
|
|
92
|
+
// Verify correct repo before operations
|
|
93
|
+
const config = fs.readFileSync('.git/config', 'utf-8');
|
|
94
|
+
if (!config.includes('expected-repo')) {
|
|
95
|
+
throw new Error('Wrong repository');
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### A04: Insecure Design
|
|
100
|
+
|
|
101
|
+
**Stage Prerequisites**:
|
|
102
|
+
- Don't run `/ship` before `/validate` passes
|
|
103
|
+
- Validate workflow order
|
|
104
|
+
- Provide clear error messages
|
|
105
|
+
|
|
106
|
+
**Idempotency**:
|
|
107
|
+
- Check existing state before creating resources
|
|
108
|
+
- Don't duplicate PRs, branches, Beads issues
|
|
109
|
+
- Safe to re-run commands
|
|
110
|
+
|
|
111
|
+
### A05: Security Misconfiguration
|
|
112
|
+
|
|
113
|
+
**Secret Management**:
|
|
114
|
+
- Read from `.env.local` (already implemented)
|
|
115
|
+
- Never log full API keys (show first 6 chars only)
|
|
116
|
+
- Redact secrets in error messages
|
|
117
|
+
|
|
118
|
+
### Security Checklist
|
|
119
|
+
|
|
120
|
+
- [ ] All user input validated with `/^[a-z0-9-]+$/`
|
|
121
|
+
- [ ] No exec() with user input
|
|
122
|
+
- [ ] Path traversal prevented
|
|
123
|
+
- [ ] File permissions checked
|
|
124
|
+
- [ ] Git repo validated
|
|
125
|
+
- [ ] Stage prerequisites validated
|
|
126
|
+
- [ ] Idempotency implemented
|
|
127
|
+
- [ ] API keys never logged
|
|
128
|
+
- [ ] API responses validated
|
|
129
|
+
- [ ] Atomic file writes
|
|
130
|
+
- [ ] Dangerous operations require confirmation
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
## Key Decisions
|
|
135
|
+
|
|
136
|
+
### Decision 1: Plain Node.js (No CLI Framework)
|
|
137
|
+
|
|
138
|
+
**What**: Use plain Node.js without Commander.js/yargs/oclif
|
|
139
|
+
|
|
140
|
+
**Why**:
|
|
141
|
+
- Forge has established patterns (bin/forge-validate.js)
|
|
142
|
+
- Custom logic needed
|
|
143
|
+
- No framework overhead
|
|
144
|
+
- Testing infrastructure in place
|
|
145
|
+
|
|
146
|
+
**Alternatives Rejected**:
|
|
147
|
+
- Commander.js (unnecessary for 9 commands)
|
|
148
|
+
- Yargs (too complex)
|
|
149
|
+
- oclif (heavyweight)
|
|
150
|
+
|
|
151
|
+
### Decision 2: Command Dispatcher Architecture
|
|
152
|
+
|
|
153
|
+
**Pattern**:
|
|
154
|
+
```
|
|
155
|
+
bin/forge-cmd.js (CLI entrypoint)
|
|
156
|
+
↓
|
|
157
|
+
lib/commands/
|
|
158
|
+
├── status.js → Stage detection
|
|
159
|
+
├── research.js → Parallel-AI automation
|
|
160
|
+
├── plan.js → Branch + plan + OpenSpec
|
|
161
|
+
├── ship.js → PR body generation
|
|
162
|
+
└── review.js → Review aggregation
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
**Why**: Separation of concerns, testability
|
|
166
|
+
|
|
167
|
+
### Decision 3: Stage Detection Algorithm
|
|
168
|
+
|
|
169
|
+
**Multi-factor with confidence scoring**:
|
|
170
|
+
|
|
171
|
+
Factors:
|
|
172
|
+
1. Branch state (exists, commits, matches PR)
|
|
173
|
+
2. File existence (research doc, plan, tests)
|
|
174
|
+
3. PR state (open, reviews, approval)
|
|
175
|
+
4. Check results (CI/CD status)
|
|
176
|
+
5. Beads issue state
|
|
177
|
+
|
|
178
|
+
Confidence:
|
|
179
|
+
- High (90-100%): All indicators consistent
|
|
180
|
+
- Medium (70-89%): Most agree
|
|
181
|
+
- Low (<70%): Conflicting, suggest manual override
|
|
182
|
+
|
|
183
|
+
### Decision 4: Review Aggregation Format
|
|
184
|
+
|
|
185
|
+
**Output**:
|
|
186
|
+
```
|
|
187
|
+
✓ Review Aggregation: 24 issues
|
|
188
|
+
|
|
189
|
+
Critical (3):
|
|
190
|
+
1. [Greptile] SQL injection (src/api/users.js:42)
|
|
191
|
+
2. [SonarCloud] Security hotspot (src/auth/login.js:78)
|
|
192
|
+
3. [GitHub Actions] Build failed
|
|
193
|
+
|
|
194
|
+
High (8):
|
|
195
|
+
4. [Greptile] Missing error handling (...)
|
|
196
|
+
...
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
**Why**: Consolidated, prioritized feedback
|
|
200
|
+
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
## TDD Test Scenarios
|
|
204
|
+
|
|
205
|
+
### Test 1: Stage Detection
|
|
206
|
+
|
|
207
|
+
```javascript
|
|
208
|
+
test('detect stage 1 when no branch, no research', () => {
|
|
209
|
+
const stage = detectStage(freshProject);
|
|
210
|
+
assert.strictEqual(stage.stage, 1);
|
|
211
|
+
assert.strictEqual(stage.confidence, 'high');
|
|
212
|
+
});
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
### Test 2: Research Automation
|
|
216
|
+
|
|
217
|
+
```javascript
|
|
218
|
+
test('create research doc from parallel-ai', async () => {
|
|
219
|
+
mockParallelAI({ results: [{ title: 'Best practices' }] });
|
|
220
|
+
|
|
221
|
+
await researchCommand(fixture, 'stripe-billing');
|
|
222
|
+
|
|
223
|
+
const doc = readFile(fixture, 'docs/research/stripe-billing.md');
|
|
224
|
+
assert.ok(doc.includes('# Research: Stripe Billing'));
|
|
225
|
+
});
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
### Test 3: PR Body Generation
|
|
229
|
+
|
|
230
|
+
```javascript
|
|
231
|
+
test('generate PR body from all sources', async () => {
|
|
232
|
+
createFile(fixture, 'docs/research/feature.md', RESEARCH);
|
|
233
|
+
createFile(fixture, '.claude/plans/feature.md', PLAN);
|
|
234
|
+
|
|
235
|
+
const prBody = await generatePRBody(fixture, 'feature');
|
|
236
|
+
|
|
237
|
+
assert.ok(prBody.includes('## Summary'));
|
|
238
|
+
assert.ok(prBody.includes('## Key Decisions'));
|
|
239
|
+
});
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
### Test 4: Review Aggregation
|
|
243
|
+
|
|
244
|
+
```javascript
|
|
245
|
+
test('aggregate all review sources', async () => {
|
|
246
|
+
mockGitHubAPI({ checks: [{ name: 'Tests', status: 'failed' }] });
|
|
247
|
+
mockGreptileAPI({ comments: [{ severity: 'critical' }] });
|
|
248
|
+
|
|
249
|
+
const review = await aggregateReview(123);
|
|
250
|
+
|
|
251
|
+
assert.strictEqual(review.critical.length, 1);
|
|
252
|
+
});
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
### Test 5: E2E Workflow
|
|
256
|
+
|
|
257
|
+
```javascript
|
|
258
|
+
test('complete research workflow end-to-end', async () => {
|
|
259
|
+
execSync('node bin/forge-cmd.js status', { cwd: fixture });
|
|
260
|
+
execSync('node bin/forge-cmd.js research test-feature', { cwd: fixture });
|
|
261
|
+
execSync('node bin/forge-cmd.js plan test-feature', { cwd: fixture });
|
|
262
|
+
|
|
263
|
+
const branch = execSync('git branch --show-current', { cwd: fixture });
|
|
264
|
+
assert.ok(branch.includes('feat/test-feature'));
|
|
265
|
+
});
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
---
|
|
269
|
+
|
|
270
|
+
## Scope Assessment
|
|
271
|
+
|
|
272
|
+
**Complexity**: High
|
|
273
|
+
- Multiple handlers with complex logic
|
|
274
|
+
- API integrations (GitHub, Greptile, SonarCloud)
|
|
275
|
+
- Intelligent stage detection
|
|
276
|
+
- PR body generation from multiple sources
|
|
277
|
+
|
|
278
|
+
**Type**: Strategic (architecture change, requires OpenSpec)
|
|
279
|
+
|
|
280
|
+
**Timeline**: 3-4 days
|
|
281
|
+
- Day 1: Dispatcher + /status enhancement
|
|
282
|
+
- Day 2: /research + /plan automation
|
|
283
|
+
- Day 3: /ship + /review automation
|
|
284
|
+
- Day 4: Testing + documentation
|
|
285
|
+
|
|
286
|
+
**Dependencies**:
|
|
287
|
+
- ✅ PR3 (Testing Infrastructure) - COMPLETE
|
|
288
|
+
- Beads CLI (`bd`)
|
|
289
|
+
- GitHub CLI (`gh`)
|
|
290
|
+
- Parallel AI API key
|
|
291
|
+
|
|
292
|
+
**Risks**:
|
|
293
|
+
1. API rate limits → Caching, retry logic
|
|
294
|
+
2. Complex stage detection → Confidence scoring
|
|
295
|
+
3. Integration testing → Fixtures, mocking
|
|
296
|
+
|
|
297
|
+
---
|
|
298
|
+
|
|
299
|
+
## Sources
|
|
300
|
+
|
|
301
|
+
**Codebase**:
|
|
302
|
+
- bin/forge.js, bin/forge-validate.js
|
|
303
|
+
- .claude/commands/*.md
|
|
304
|
+
- lib/setup.js (state management)
|
|
305
|
+
- test/e2e/ (E2E patterns)
|
|
306
|
+
|
|
307
|
+
**Web Research** (Parallel AI):
|
|
308
|
+
- Command Pattern in Node (Medium)
|
|
309
|
+
- Node.js Best Practices
|
|
310
|
+
- Multi-Agent Systems
|
|
311
|
+
- Workflow orchestration patterns
|
|
312
|
+
|
|
313
|
+
**Security**:
|
|
314
|
+
- OWASP Top 10 2021
|
|
315
|
+
- CWE-78 (Command Injection)
|
|
316
|
+
- CWE-22 (Path Traversal)
|
|
317
|
+
|
|
318
|
+
---
|
|
319
|
+
|
|
320
|
+
## Next: /plan pr4-cli-automation
|
|
321
|
+
|
|
322
|
+
Create OpenSpec proposal with:
|
|
323
|
+
1. Command dispatcher architecture
|
|
324
|
+
2. Stage detection algorithm
|
|
325
|
+
3. Security mitigations
|
|
326
|
+
4. Test strategy
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
# Research: /premerge + /verify Workflow Restructure
|
|
2
|
+
|
|
3
|
+
**Date**: 2026-02-24
|
|
4
|
+
**Objective**: Determine if restructuring `/merge` → `/premerge` (pre-merge doc prep) and making `/verify` read-only is the right approach, and identify potential problems.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Codebase Analysis
|
|
9
|
+
|
|
10
|
+
### Current State
|
|
11
|
+
|
|
12
|
+
| Component | Location | Status |
|
|
13
|
+
| --- | --- | --- |
|
|
14
|
+
| `/merge` command | `.claude/commands/merge.md` | Exists — currently does docs + handoff |
|
|
15
|
+
| `/verify` command | `.claude/commands/verify.md` | Exists — finds gaps, commits fixes, can create PRs |
|
|
16
|
+
| Workflow table (stage 8) | `CLAUDE.md`, `AGENTS.md`, `docs/WORKFLOW.md`, all 11 command files | All say `/merge` |
|
|
17
|
+
|
|
18
|
+
### The Loop Problem
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
/merge → doc commits → PR
|
|
22
|
+
User merges
|
|
23
|
+
/verify → finds gaps → commits to master → PROTECTED → needs new PR
|
|
24
|
+
User merges again
|
|
25
|
+
/verify again?
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Every post-merge doc fix requires its own PR because `master` is branch-protected.
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## Web Research Findings
|
|
33
|
+
|
|
34
|
+
### Finding 1: Post-merge doc commits on protected branches are fundamentally broken
|
|
35
|
+
|
|
36
|
+
**Source**: Multiple CI/CD resources (Terramate, Medium, GitHub Docs)
|
|
37
|
+
|
|
38
|
+
Post-merge commits to protected branches fail because:
|
|
39
|
+
- They bypass the PR validation flow
|
|
40
|
+
- Squash merges create "phantom conflicts" when the same branch is re-merged
|
|
41
|
+
- Stale approval dismissal means post-merge commits lose approval status
|
|
42
|
+
- Each failure requires another follow-up PR → recursive loop
|
|
43
|
+
|
|
44
|
+
**Verdict**: Our problem is a known anti-pattern. Pre-merge documentation is the correct fix.
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
### Finding 2: Pre-merge documentation is the correct pattern
|
|
49
|
+
|
|
50
|
+
**Source**: LinearB, GitHub Actions best practices, Graphite
|
|
51
|
+
|
|
52
|
+
Successful teams enforce documentation as part of the PR itself — not as a follow-up. The PR is only ready to merge when it contains code + tests + docs.
|
|
53
|
+
|
|
54
|
+
**Verdict**: Moving doc updates into the feature branch (before handoff) is confirmed correct.
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
### Finding 3: Keep pre-merge checks fast and focused
|
|
59
|
+
|
|
60
|
+
**Source**: ZenCoder AI, LinearB
|
|
61
|
+
|
|
62
|
+
Overly complex pre-merge checklists slow down merging and get skipped. Each check should be targeted and relevant to the specific PR.
|
|
63
|
+
|
|
64
|
+
**Verdict**: `/premerge` should check only docs that are actually relevant to the feature — not a blanket update of all files every time.
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## Problems We Could Face
|
|
69
|
+
|
|
70
|
+
### Problem 1: Simultaneous PRs conflict on shared doc files
|
|
71
|
+
|
|
72
|
+
If two PRs are open and both update `PROGRESS.md` or `CLAUDE.md`, one will have a merge conflict.
|
|
73
|
+
|
|
74
|
+
**Mitigation**: `/premerge` should warn if the branch is behind `master` and tell user to rebase first. Since user merges sequentially, this is rare but possible.
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
### Problem 2: CLAUDE.md has managed sections that must not be touched
|
|
79
|
+
|
|
80
|
+
`CLAUDE.md` has `<!-- OPENSPEC:START/END -->` and `<!-- USER:START/END -->` blocks managed by external tools. Breaking the structure causes `openspec update` to fail.
|
|
81
|
+
|
|
82
|
+
**Mitigation**: `/premerge` must only update the **USER section** (between `<!-- USER:START -->` and `<!-- USER:END -->`). Never modify managed blocks.
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
### Problem 3: Doc commits on feature branch re-trigger full CI
|
|
87
|
+
|
|
88
|
+
When `/premerge` pushes doc update commits, Greptile and other CI tools re-run. This could add new Greptile review comments on the documentation changes.
|
|
89
|
+
|
|
90
|
+
**Mitigation**: This is acceptable — doc updates should be reviewed. `/premerge` output should tell the user to re-check CI after the doc push, and run `/review` again if needed.
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
### Problem 4: Stage 8 label `/merge` appears in 4+ locations
|
|
95
|
+
|
|
96
|
+
The workflow table with stage 8 = `/merge` exists in:
|
|
97
|
+
1. `CLAUDE.md`
|
|
98
|
+
2. `AGENTS.md`
|
|
99
|
+
3. `docs/WORKFLOW.md` (407 lines)
|
|
100
|
+
4. The "Integration with Workflow" section inside **each of the 11 command files**
|
|
101
|
+
|
|
102
|
+
Missing any of these creates inconsistency.
|
|
103
|
+
|
|
104
|
+
**Mitigation**: Update all locations as part of the implementation PR. The 11 command files are the easiest to miss.
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
### Problem 5: `/verify` becomes nearly trivial
|
|
109
|
+
|
|
110
|
+
If all doc updates happen pre-merge, `/verify` has almost nothing to do post-merge. Risk: it gets skipped entirely.
|
|
111
|
+
|
|
112
|
+
**Mitigation**: Give `/verify` a clear, focused purpose:
|
|
113
|
+
- `git checkout master && git pull` (update local)
|
|
114
|
+
- Confirm the feature entry is in `PROGRESS.md` on main (quick sanity check)
|
|
115
|
+
- Output "clean — ready for next feature, run /status"
|
|
116
|
+
- If something IS missing: create a Beads issue, never commit inline
|
|
117
|
+
|
|
118
|
+
This makes it lightweight and always worth running.
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
### Problem 6: PR #47 already open with the old merge.md update
|
|
123
|
+
|
|
124
|
+
PR #47 currently contains the old `merge.md` update (handoff-only version). Now we're replacing it with `premerge.md` + updated `verify.md` + all doc references.
|
|
125
|
+
|
|
126
|
+
**Mitigation**: Amend the same branch (`fix/merge-command-no-auto-merge`) — add `premerge.md`, delete `merge.md`, update everything. PR #47 will automatically update.
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## Clarified Command Design (Final)
|
|
131
|
+
|
|
132
|
+
### `/premerge <pr-number>` — Everything before the user clicks merge
|
|
133
|
+
|
|
134
|
+
All documentation and changes go here. The PR must be 100% complete before handoff.
|
|
135
|
+
|
|
136
|
+
Checklist:
|
|
137
|
+
- All CI checks passing
|
|
138
|
+
- Branch up to date with master (warn if behind)
|
|
139
|
+
- `PROGRESS.md` updated
|
|
140
|
+
- `README.md` updated (if user-facing)
|
|
141
|
+
- `API_REFERENCE.md` updated (if API changes)
|
|
142
|
+
- Architecture docs updated (if structural)
|
|
143
|
+
- `CLAUDE.md` USER section updated (if conventions changed)
|
|
144
|
+
- `AGENTS.md` updated (if agent config/skills changed)
|
|
145
|
+
- `docs/WORKFLOW.md` updated (if workflow changed)
|
|
146
|
+
- Commit all doc updates to feature branch → push
|
|
147
|
+
- Archive OpenSpec (if strategic)
|
|
148
|
+
- Sync Beads
|
|
149
|
+
- **STOP** → present PR URL → wait for user to merge
|
|
150
|
+
|
|
151
|
+
### `/verify` — Post-merge health check (not a doc check)
|
|
152
|
+
|
|
153
|
+
Runs AFTER user confirms they've merged. Focuses on system health, not documentation.
|
|
154
|
+
|
|
155
|
+
Checklist:
|
|
156
|
+
- `git checkout master && git pull` (confirm merge landed)
|
|
157
|
+
- Did CI pass on main after merge? (`gh run list --branch master --limit 3`)
|
|
158
|
+
- Are deployments up? (Vercel preview → production, or other deploy targets)
|
|
159
|
+
- Any post-merge failures or broken checks on main?
|
|
160
|
+
- Is the PR marked as merged (not just closed)?
|
|
161
|
+
- If any issues: report them clearly — these may need hotfix PRs
|
|
162
|
+
|
|
163
|
+
**Never commits.** If documentation gaps are found at this stage, create a Beads issue rather than committing inline.
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
## Key Decisions
|
|
168
|
+
|
|
169
|
+
### Decision 1: Delete `/merge`, create `/premerge` — don't alias
|
|
170
|
+
|
|
171
|
+
**Why**: An alias creates confusion. Clean break is better.
|
|
172
|
+
|
|
173
|
+
**Evidence**: User confirmed "delete it."
|
|
174
|
+
|
|
175
|
+
### Decision 2: `/verify` = post-merge health check, not doc verification
|
|
176
|
+
|
|
177
|
+
**Why**: Documentation completeness is `/premerge`'s job. `/verify` should answer: "did everything land and run correctly after the merge?" — deployments, CI on main, merge status.
|
|
178
|
+
|
|
179
|
+
**Evidence**: User explicitly clarified this: "check if the pull request has been merged properly, if deployments are working properly, if we are facing any issues."
|
|
180
|
+
|
|
181
|
+
### Decision 3: `/premerge` owns ALL documentation updates
|
|
182
|
+
|
|
183
|
+
**Why**: Eliminates the recursive PR loop entirely. The PR contains code + tests + docs as a single complete unit. User merges once.
|
|
184
|
+
|
|
185
|
+
**Evidence**: Web research confirms pre-merge documentation is the correct pattern. Post-merge commits on protected branches are a known anti-pattern.
|
|
186
|
+
|
|
187
|
+
---
|
|
188
|
+
|
|
189
|
+
## Scope Assessment
|
|
190
|
+
|
|
191
|
+
**Tactical** (no OpenSpec needed) — this is a workflow command update, not an architecture change.
|
|
192
|
+
|
|
193
|
+
**Complexity**: Medium — 4+ files to update, careful with managed sections in CLAUDE.md.
|
|
194
|
+
|
|
195
|
+
**Risk**: Low — command files are documentation, no code logic affected.
|
|
196
|
+
|
|
197
|
+
---
|
|
198
|
+
|
|
199
|
+
## Sources
|
|
200
|
+
|
|
201
|
+
- [GitHub Docs: Managing branch protection rules](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-protected-branches/managing-a-branch-protection-rule)
|
|
202
|
+
- [Mastering Terraform Workflows: apply-before-merge vs apply-after-merge](https://terramate.io/rethinking-iac/mastering-terraform-workflows-apply-before-merge-vs-apply-after-merge/)
|
|
203
|
+
- [The case for apply before merge](https://medium.com/@DiggerHQ/the-case-for-apply-before-merge-bc08a7a9bfea)
|
|
204
|
+
- [LinearB: Pre-merge Workflow Automation](https://linearb.io/resources/automate-pre-merge-workflow-automation-for-dev-efficiency)
|
|
205
|
+
- [Graphite: Mandatory pull request checks](https://graphite.com/guides/mandatory-pull-request-checks-and-requirements-in-github)
|