@torka/claude-workflows 0.4.0 → 0.5.0
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/commands/github-pr-resolve.md +150 -12
- package/package.json +1 -1
|
@@ -27,12 +27,22 @@ Before any operations, verify the environment is safe:
|
|
|
27
27
|
- For each branch, record if it's checked out in a worktree and where
|
|
28
28
|
|
|
29
29
|
6. **Check for uncommitted changes**: Run `git status --porcelain`.
|
|
30
|
-
- If output is non-empty,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
30
|
+
- If output is non-empty, offer handling options:
|
|
31
|
+
```
|
|
32
|
+
You have uncommitted changes in your working directory.
|
|
33
|
+
|
|
34
|
+
Options:
|
|
35
|
+
1. Stash changes now (I'll restore them at the end)
|
|
36
|
+
2. Proceed carefully (I'll warn before any checkout operation)
|
|
37
|
+
3. Let me commit/stash manually first (pause workflow)
|
|
38
|
+
```
|
|
39
|
+
- If stash chosen: Run `git stash push -m "github-pr-resolve: auto-stash"` and track `stash_used = true`
|
|
40
|
+
- Track stash state for restoration in Phase 5
|
|
41
|
+
|
|
42
|
+
7. **Initialize task tracking**: Use TodoWrite to create a task list for the session.
|
|
43
|
+
- Add tasks for each phase: PR assessment, review comments, CI fixes, merges, cleanup
|
|
44
|
+
- Update task status as work progresses (this ensures nothing is missed)
|
|
45
|
+
- The todo list provides visibility to the user and keeps the workflow on track
|
|
36
46
|
|
|
37
47
|
If gh authentication fails, STOP and clearly explain what the user needs to do.
|
|
38
48
|
|
|
@@ -83,11 +93,52 @@ Gather comprehensive information about all open PRs:
|
|
|
83
93
|
|
|
84
94
|
For each PR with pending reviews or requested changes:
|
|
85
95
|
|
|
86
|
-
### Step 1: Fetch review data
|
|
96
|
+
### Step 1: Fetch ALL review data (multiple sources required)
|
|
97
|
+
|
|
98
|
+
GitHub stores review feedback in THREE separate places. You MUST check all three:
|
|
99
|
+
|
|
100
|
+
1. **PR-level reviews** (approval/rejection decisions):
|
|
101
|
+
```bash
|
|
102
|
+
gh pr view <number> --json reviews,reviewDecision
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
2. **PR conversation comments** (general discussion):
|
|
106
|
+
```bash
|
|
107
|
+
gh pr view <number> --json comments
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
3. **Inline code review comments** (line-specific feedback - CRITICAL, OFTEN MISSED):
|
|
111
|
+
```bash
|
|
112
|
+
gh api repos/{owner}/{repo}/pulls/{number}/comments
|
|
113
|
+
```
|
|
114
|
+
This returns comments attached to specific lines of code. These are the most actionable!
|
|
115
|
+
|
|
116
|
+
**CRITICAL**: The `--json comments` flag does NOT include inline code review comments.
|
|
117
|
+
You MUST call the `/pulls/{number}/comments` API endpoint separately.
|
|
118
|
+
|
|
119
|
+
Parse each source and combine into a unified list with:
|
|
120
|
+
- Comment body/text
|
|
121
|
+
- Author (check if bot - see Step 1.5)
|
|
122
|
+
- File path and line number (for inline comments)
|
|
123
|
+
- Whether it's resolved/outdated
|
|
124
|
+
- Creation timestamp
|
|
87
125
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
126
|
+
### Step 1.5: Identify bot reviewers
|
|
127
|
+
|
|
128
|
+
Before categorizing comments, identify automated reviewers:
|
|
129
|
+
|
|
130
|
+
**Known CI/review bots:**
|
|
131
|
+
- `github-actions[bot]`
|
|
132
|
+
- `chatgpt-codex-connector[bot]` or similar Codex bots
|
|
133
|
+
- `coderabbitai[bot]`
|
|
134
|
+
- `dependabot[bot]`
|
|
135
|
+
- `renovate[bot]`
|
|
136
|
+
- `sonarcloud[bot]`
|
|
137
|
+
|
|
138
|
+
**Bot comment handling:**
|
|
139
|
+
- Bot comments are often MORE actionable than they appear (security suggestions, code quality)
|
|
140
|
+
- ALWAYS expand/check bot comments even if they seem informational
|
|
141
|
+
- Display bot comments separately in the summary
|
|
91
142
|
|
|
92
143
|
### Step 2: Categorize comments
|
|
93
144
|
|
|
@@ -146,8 +197,20 @@ If user chooses auto-address:
|
|
|
146
197
|
3. **After all accepted changes**:
|
|
147
198
|
- Show consolidated diff
|
|
148
199
|
- Ask for confirmation before committing
|
|
149
|
-
-
|
|
150
|
-
|
|
200
|
+
- **Stage ONLY modified files explicitly** (NEVER use `git add .` or `git commit -a`):
|
|
201
|
+
```bash
|
|
202
|
+
git add <file1> <file2> ... # Only files that were actually modified
|
|
203
|
+
```
|
|
204
|
+
- Verify staging is correct: `git status --short`
|
|
205
|
+
- If unexpected files are staged, warn user and ask how to proceed
|
|
206
|
+
- Commit: `git commit -m "fix: address review comments"`
|
|
207
|
+
- **Check upstream tracking before push**:
|
|
208
|
+
```bash
|
|
209
|
+
# If no upstream set, use -u flag
|
|
210
|
+
git rev-parse --abbrev-ref --symbolic-full-name @{upstream} 2>/dev/null || git push -u origin <branch>
|
|
211
|
+
# Otherwise just push
|
|
212
|
+
git push
|
|
213
|
+
```
|
|
151
214
|
|
|
152
215
|
### Step 5: Guided resolution for complex comments
|
|
153
216
|
|
|
@@ -211,6 +274,28 @@ For each open PR that needs CI verification:
|
|
|
211
274
|
- Max 5 minute wait per CI run
|
|
212
275
|
- 30 second polling interval
|
|
213
276
|
|
|
277
|
+
### CI Wait Strategy
|
|
278
|
+
|
|
279
|
+
At the start of Phase 3, if multiple PRs have CI running, ask user:
|
|
280
|
+
|
|
281
|
+
```
|
|
282
|
+
Multiple PRs have CI in progress:
|
|
283
|
+
- PR #39: CI running (2 min elapsed)
|
|
284
|
+
- PR #40: CI running (1 min elapsed)
|
|
285
|
+
- PR #41: CI running (just started)
|
|
286
|
+
|
|
287
|
+
Options:
|
|
288
|
+
1. Wait for all CIs before proceeding (slower but complete)
|
|
289
|
+
2. Process PRs as their CI completes (faster, may revisit)
|
|
290
|
+
3. Only process PRs with CI already complete
|
|
291
|
+
4. Check back in X minutes (pause workflow)
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
If a PR is created during the workflow (e.g., a CI fix PR), ask:
|
|
295
|
+
- "Wait for this PR's CI before continuing"
|
|
296
|
+
- "Continue with other ready PRs, check back later"
|
|
297
|
+
- "This PR is a prerequisite - wait for it, then re-check dependent PRs"
|
|
298
|
+
|
|
214
299
|
**Process:**
|
|
215
300
|
|
|
216
301
|
1. **Check CI status**: `gh pr view <pr-number> --json statusCheckRollup`
|
|
@@ -234,7 +319,9 @@ For each open PR that needs CI verification:
|
|
|
234
319
|
- Run the fix command
|
|
235
320
|
- Show the diff to user
|
|
236
321
|
- Ask for confirmation before committing
|
|
322
|
+
- **Stage ONLY files that were actually fixed** (use explicit paths, never `git add .`)
|
|
237
323
|
- Commit with message: "fix: auto-fix lint errors"
|
|
324
|
+
- **Check upstream tracking before push** (use `-u` flag if needed)
|
|
238
325
|
- Push and decrement retry counter
|
|
239
326
|
- If manual fix chosen:
|
|
240
327
|
- Inform user and pause for this PR
|
|
@@ -252,6 +339,38 @@ For each open PR that needs CI verification:
|
|
|
252
339
|
|
|
253
340
|
For each PR that passed CI (and has no pending review comments):
|
|
254
341
|
|
|
342
|
+
### Merge Order Strategy
|
|
343
|
+
|
|
344
|
+
When multiple PRs are ready to merge, order matters:
|
|
345
|
+
|
|
346
|
+
1. **Check for file overlap** between PRs:
|
|
347
|
+
```bash
|
|
348
|
+
gh pr diff <pr1> --name-only > /tmp/pr1_files
|
|
349
|
+
gh pr diff <pr2> --name-only > /tmp/pr2_files
|
|
350
|
+
comm -12 <(sort /tmp/pr1_files) <(sort /tmp/pr2_files)
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
2. **Recommended merge order**:
|
|
354
|
+
| Priority | Criteria | Rationale |
|
|
355
|
+
|----------|----------|-----------|
|
|
356
|
+
| 1 | CI/infrastructure fixes | Unblocks other PRs |
|
|
357
|
+
| 2 | PRs with no file overlap | Independent, safe in any order |
|
|
358
|
+
| 3 | Dependency PRs first | If PR B depends on PR A's changes |
|
|
359
|
+
| 4 | Oldest PRs | Reduce stale PR backlog |
|
|
360
|
+
| 5 | Smallest PRs | Quick wins |
|
|
361
|
+
|
|
362
|
+
3. **Present merge plan to user**:
|
|
363
|
+
```
|
|
364
|
+
Recommended merge order:
|
|
365
|
+
1. PR #41 "Fix CI" (infrastructure - may unblock others)
|
|
366
|
+
2. PR #40 "Add feature X" (no conflicts)
|
|
367
|
+
3. PR #39 "Update component Y" (no conflicts)
|
|
368
|
+
|
|
369
|
+
Proceed with this order? [Yes / Let me reorder / Merge one at a time]
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
4. **Between merges**: Re-check remaining PRs for new conflicts after each merge
|
|
373
|
+
|
|
255
374
|
### Pre-merge checks
|
|
256
375
|
|
|
257
376
|
1. Re-verify CI status (avoid race condition): `gh pr view <pr-number> --json statusCheckRollup`
|
|
@@ -301,6 +420,18 @@ For each PR that passed CI (and has no pending review comments):
|
|
|
301
420
|
|
|
302
421
|
## Phase 5: Final Cleanup & Summary
|
|
303
422
|
|
|
423
|
+
### Step 0: Restore stashed changes (if applicable)
|
|
424
|
+
|
|
425
|
+
If changes were stashed in Phase 0:
|
|
426
|
+
1. After returning to original branch (Step 4), run `git stash pop`
|
|
427
|
+
2. If pop fails (conflicts), warn user:
|
|
428
|
+
```
|
|
429
|
+
Could not automatically restore your stashed changes.
|
|
430
|
+
Your changes are still in the stash. Run `git stash list` to see them.
|
|
431
|
+
Restore manually with: `git stash pop` or `git stash apply`
|
|
432
|
+
```
|
|
433
|
+
3. Show `git status` to confirm restoration
|
|
434
|
+
|
|
304
435
|
### Step 1: Handle orphaned worktrees from merged PRs
|
|
305
436
|
|
|
306
437
|
For any worktrees whose branches were merged in Phase 4:
|
|
@@ -439,6 +570,13 @@ If the workflow fails at any point, display:
|
|
|
439
570
|
- NEVER use force push (`--force` or `-f`)
|
|
440
571
|
- ALWAYS preserve the user's working context (return to original branch)
|
|
441
572
|
|
|
573
|
+
### Commit Safety Rules
|
|
574
|
+
- NEVER use `git commit -a` or `git add .` without first reviewing what will be staged
|
|
575
|
+
- ALWAYS use explicit file paths when staging: `git add <specific-file>`
|
|
576
|
+
- ALWAYS run `git status` before committing to verify staged files
|
|
577
|
+
- If the commit includes unexpected files, STOP and ask user before proceeding
|
|
578
|
+
- ALWAYS check upstream tracking before push (use `-u` flag if no upstream)
|
|
579
|
+
|
|
442
580
|
### Worktree Safety Rules
|
|
443
581
|
- NEVER remove a worktree with uncommitted changes without explicit user confirmation
|
|
444
582
|
- ALWAYS check worktree status before operations
|