@torka/claude-workflows 0.4.0 → 0.6.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.
@@ -1,5 +1,5 @@
1
1
  ---
2
- description: 'Assess open PRs, handle review comments, run CI, and merge'
2
+ description: 'Autonomously process, fix, and merge all open PRs with minimal user interaction'
3
3
  ---
4
4
 
5
5
  IT IS CRITICAL THAT YOU FOLLOW THIS WORKFLOW EXACTLY.
@@ -16,431 +16,327 @@ Before any operations, verify the environment is safe:
16
16
 
17
17
  3. **Detect default branch**: Run `gh repo view --json defaultBranchRef -q .defaultBranchRef.name`. Fallback to `main` if this fails.
18
18
 
19
- 4. **Record current branch and worktree**:
19
+ 4. **Detect repository merge strategy**:
20
+ - Run: `gh repo view --json squashMergeAllowed,mergeCommitAllowed,rebaseMergeAllowed`
21
+ - Determine preferred strategy in order: squash > merge > rebase
22
+ - Store for use in Phase 4 merge commands
23
+ - Default to `--squash` if detection fails
24
+
25
+ 5. **Record current branch and worktree**:
20
26
  - Run `git branch --show-current` to get current branch name
21
27
  - **If empty (detached HEAD)**: Run `git rev-parse HEAD` to save the commit SHA instead
22
28
  - Run `git rev-parse --show-toplevel` to record the current worktree path
23
- - Track whether we started in detached HEAD state for Phase 5 restoration
24
29
 
25
- 5. **Build worktree inventory**: Run `git worktree list --porcelain` to detect all worktrees.
26
- - Parse the output to build a map: `{ branch_name -> worktree_path }`
27
- - For each branch, record if it's checked out in a worktree and where
30
+ 6. **Build worktree inventory**: Run `git worktree list --porcelain` to detect all worktrees.
28
31
 
29
- 6. **Check for uncommitted changes**: Run `git status --porcelain`.
30
- - If output is non-empty, WARN the user (but do NOT block)
31
- - Note: We only block if we need to checkout branches later for review comment fixes
32
+ 7. **Check for uncommitted changes**: Run `git status --porcelain`.
33
+ - If output is non-empty, WARN the user but continue
32
34
 
33
- 7. **Initialize operation log**: Create an in-memory log to track all operations performed.
34
- - Track: operation type, target (PR/branch), status (success/failed)
35
- - Log each operation as it completes
35
+ 8. **Initialize tracking**:
36
+ - Create counters: merged=0, skipped=0, failed=0, auto_fixed=0
37
+ - Create lists: merged_prs[], skipped_prs[], failed_prs[]
36
38
 
37
39
  If gh authentication fails, STOP and clearly explain what the user needs to do.
38
40
 
39
41
  ---
40
42
 
41
- ## Phase 1: PR Discovery & Assessment
42
-
43
- Gather comprehensive information about all open PRs:
43
+ ## Phase 1: PR Discovery & Batch Planning
44
44
 
45
- 1. **Fetch all open PRs**: Run `gh pr list --state open --json number,title,headRefName,baseRefName,statusCheckRollup,reviewDecision,isDraft,createdAt,url`
45
+ **Goal**: Assess all PRs and start batch processing immediately.
46
46
 
47
- 2. **For each PR, gather additional details**:
48
- - Review status: `gh pr view <number> --json reviews,reviewDecision`
49
- - CI status: Parse `statusCheckRollup` from the list query
50
- - Mergeable status: `gh pr view <number> --json mergeStateStatus,mergeable`
47
+ 1. **Fetch all open PRs**:
48
+ ```bash
49
+ gh pr list --state open --json number,title,headRefName,baseRefName,statusCheckRollup,reviewDecision,isDraft,url,author,mergeStateStatus,mergeable,state
50
+ ```
51
51
 
52
- 3. **Categorize PRs**:
52
+ 2. **For each PR, categorize**:
53
53
 
54
- | Category | Description | Action |
55
- |----------|-------------|--------|
56
- | Ready to Merge | CI passed, approved, no conflicts | Phase 4 |
57
- | Needs Review Comments | Has pending/requested changes | Phase 2 |
58
- | CI Running | Checks in progress | Phase 3 |
59
- | CI Failed | Checks failed | Phase 3 |
60
- | Draft | Marked as draft | Skip unless user requests |
61
- | Conflicts | Has merge conflicts | Warn user |
54
+ | Category | Detection | Auto-Action |
55
+ |----------|-----------|-------------|
56
+ | Ready to Merge | CI passed, mergeable=true | Merge immediately |
57
+ | CI Pending | statusCheckRollup has IN_PROGRESS | Wait and poll |
58
+ | CI Failed - Lint | Failed with lint/format errors | Auto-fix |
59
+ | CI Failed - Other | Tests/types/build failed | Skip with log |
60
+ | Behind Main | mergeStateStatus=BEHIND | Update branch, wait for CI |
61
+ | Conflicts | mergeable=CONFLICTING | Skip, warn user |
62
+ | Draft | isDraft=true | Skip |
63
+ | Already Merged | state=MERGED | Log and skip |
62
64
 
63
- 4. **Present summary table**:
65
+ 3. **Present summary** (informational only, no blocking):
64
66
  ```
65
- Open PRs Assessment:
66
-
67
- | # | Title | Branch | Status | Reviews | CI | Mergeable |
68
- |---|-------|--------|--------|---------|----|-----------|
69
- | 42 | Add auth | feature-auth | Ready | Approved | | Yes |
70
- | 43 | Fix bug | bugfix-123 | Review | Changes Requested | | Yes |
71
- | 44 | New API | api-v2 | CI | - | Running | Yes |
72
- | 45 | Refactor | refactor | Conflicts | - | | No |
67
+ Processing X open PRs...
68
+
69
+ | # | Title | Author | Status | Action |
70
+ |---|-------|--------|--------|--------|
71
+ | 42 | bump cross-env | dependabot | CI Passed | Will merge |
72
+ | 35 | bump sharp | dependabot | CI Pending | Will wait |
73
+ | 32 | bump linting | dependabot | CI Failed | Will auto-fix |
74
+ | 28 | new feature | user | Draft | Will skip |
75
+ | 25 | refactor auth | user | Conflicts | Will skip |
73
76
  ```
74
77
 
75
- 5. **Ask user how to proceed**:
76
- - "Process all PRs in order"
77
- - "Let me select which PRs to process"
78
- - "Skip to specific phase" (if user only wants merging)
78
+ 4. **Check for blockers** - ONLY pause if:
79
+ - There are PRs with merge conflicts (warn user which ones will be skipped)
80
+ - There are draft PRs (inform user they will be skipped)
81
+ - All PRs have non-auto-fixable failures
82
+
83
+ Otherwise, proceed automatically.
84
+
85
+ 5. **Sort PRs by priority**:
86
+ 1. Infrastructure PRs first (CI/workflow changes)
87
+ 2. PRs with passing CI
88
+ 3. PRs with pending CI
89
+ 4. PRs needing fixes
79
90
 
80
91
  ---
81
92
 
82
93
  ## Phase 2: Review Comments Handling
83
94
 
84
- For each PR with pending reviews or requested changes:
95
+ **Note**: This phase only runs if PRs have pending review comments. For batch processing of simple dependency bumps, this phase is typically skipped.
85
96
 
86
- ### Step 1: Fetch review data
97
+ For PRs with `reviewDecision: CHANGES_REQUESTED`:
87
98
 
88
- Run `gh pr view <number> --json reviews,reviewDecision,comments` and `gh api repos/{owner}/{repo}/pulls/{number}/comments` to get:
89
- - Review decision (APPROVED, CHANGES_REQUESTED, REVIEW_REQUIRED)
90
- - All review comments with file paths and line numbers
99
+ 1. Fetch review comments
100
+ 2. If all comments are trivial (typos, formatting, docstrings) - auto-fix
101
+ 3. If comments require logic changes - skip PR and inform user
102
+ 4. Push fixes without asking for confirmation
91
103
 
92
- ### Step 2: Categorize comments
104
+ ---
93
105
 
94
- Analyze each comment and categorize:
106
+ ## Phase 3: CI Loop (Autonomous)
95
107
 
96
- | Category | Auto-addressable? | Examples |
97
- |----------|-------------------|----------|
98
- | Add comment/docstring | Yes | "Please add a comment explaining this", "Add JSDoc" |
99
- | Rename variable/function | Yes | "Rename `x` to `count`", "Use more descriptive name" |
100
- | Add type annotation | Yes | "Add type for this parameter" |
101
- | Fix typo | Yes | "Typo: 'recieve' -> 'receive'" |
102
- | Logic change | No - guided | "This should handle the null case" |
103
- | Refactor request | No - guided | "Extract this into a separate function" |
104
- | Question/clarification | No - guided | "Why is this needed?" |
105
- | Approval/praise | Skip | "LGTM", "Nice work" |
108
+ **Configuration:**
109
+ - Polling interval: 30 seconds
110
+ - Max wait per PR: 10 minutes
111
+ - Max fix attempts: 2 per PR
106
112
 
107
- ### Step 3: Display summary and ask user
113
+ **For each PR, process in a loop:**
108
114
 
109
- For each PR with comments:
115
+ ### Step 1: Check Current State
116
+ ```bash
117
+ gh pr view <number> --json state,statusCheckRollup,mergeStateStatus,mergeable
118
+ ```
119
+
120
+ - If `state=MERGED`: Log `[X/N] PR #<number> - Already merged`, continue to next
121
+ - If `state=CLOSED`: Log and skip
122
+
123
+ ### Step 2: Handle Branch Behind Main
110
124
 
125
+ If `mergeStateStatus=BEHIND`:
111
126
  ```
112
- PR #42: "Add user authentication"
113
- Review status: Changes Requested
114
- Reviewer: @reviewer-name
115
-
116
- Comments: 5 total
117
- - 3 auto-addressable (add docstring, rename var, fix typo)
118
- - 2 need guidance (logic change, refactor request)
119
-
120
- Options:
121
- 1. Auto-address 3 simple comments (Recommended)
122
- 2. Guide me through all 5 comments
123
- 3. View all comments first
124
- 4. Skip this PR
127
+ -> Updating branch to latest main...
125
128
  ```
129
+ ```bash
130
+ gh api repos/{owner}/{repo}/pulls/{number}/update-branch -X PUT
131
+ ```
132
+ Then wait 30s and re-check CI.
126
133
 
127
- ### Step 4: Auto-address simple comments
128
-
129
- If user chooses auto-address:
134
+ ### Step 3: Wait for CI
130
135
 
131
- 1. **Checkout the PR branch** (if not already):
132
- - Check if branch is in a worktree - if so, operate there with `git -C`
133
- - Otherwise: `git checkout <branch>`
136
+ While CI is pending and elapsed < 10 minutes:
137
+ ```
138
+ -> Waiting for CI... (Xs)
139
+ ```
140
+ - Sleep 30 seconds
141
+ - Re-check status
134
142
 
135
- 2. **For each auto-addressable comment**:
136
- - Read the file at the specified path
137
- - Identify the exact location (line number from review comment)
138
- - Make the change based on the comment type:
139
- - **Add comment/docstring**: Generate appropriate documentation
140
- - **Rename**: Use find/replace for the identifier
141
- - **Add type annotation**: Infer or use suggested type
142
- - **Fix typo**: Apply the correction
143
- - Show diff to user: "Change X to Y in file.ts:42"
144
- - Ask: "Apply this change?" / "Skip" / "Edit manually"
143
+ ### Step 4: Handle CI Results
145
144
 
146
- 3. **After all accepted changes**:
147
- - Show consolidated diff
148
- - Ask for confirmation before committing
149
- - Commit: `git commit -am "fix: address review comments"`
150
- - Push: `git push`
145
+ **If CI passes**: Proceed to Phase 4 (merge)
151
146
 
152
- ### Step 5: Guided resolution for complex comments
147
+ **If CI fails**:
148
+ 1. Get failure logs:
149
+ ```bash
150
+ gh run list --branch <branch> --status failure --limit 1 --json databaseId -q '.[0].databaseId'
151
+ gh run view <id> --log-failed 2>&1 | head -100
152
+ ```
153
153
 
154
- If user chooses guided resolution or has complex comments remaining:
154
+ 2. Analyze failure type:
155
155
 
156
- For each complex comment:
157
- 1. Display the comment with full context:
156
+ **Lint/Formatting errors** (auto-fixable):
158
157
  ```
159
- File: src/auth/login.ts
160
- Line: 42-45
161
- Reviewer: @reviewer-name
162
- Comment: "This should handle the null case - what happens if user is undefined?"
163
-
164
- Current code:
165
- 40 | const user = getUser(id);
166
- 41 | return user.name; // <- reviewer's concern
167
- 42 | }
158
+ X CI failed (lint errors)
159
+ -> Auto-fixing lint errors...
168
160
  ```
169
-
170
- 2. Ask user with `AskUserQuestion`:
161
+ - Checkout branch (handle worktree)
162
+ - Run `npm install && npm run lint -- --fix`
163
+ - If changes exist:
164
+ ```bash
165
+ git add -A
166
+ git commit -m "fix: auto-fix lint errors"
167
+ git push
168
+ ```
169
+ - Wait for CI to re-run
170
+ - Decrement retry counter
171
+ - If this is the 2nd consecutive failure with same error: skip PR
172
+
173
+ **Type errors / Test failures / Build errors** (NOT auto-fixable):
171
174
  ```
172
- How would you like to address this?
173
- 1. Show me the file (I'll make the fix)
174
- 2. Suggest a fix (Claude will propose code)
175
- 3. Mark as resolved with reply
176
- 4. Skip for now
175
+ X CI failed (type errors) - skipping
177
176
  ```
177
+ - Add to skipped_prs with reason
178
+ - Continue to next PR immediately
178
179
 
179
- 3. **If "Suggest a fix"**:
180
- - Analyze the code and comment
181
- - Propose a code change
182
- - Show diff and ask for confirmation
183
- - Apply if accepted
184
-
185
- 4. **If "Mark as resolved with reply"**:
186
- - Ask user for reply text
187
- - Post reply: `gh api repos/{owner}/{repo}/pulls/{number}/comments/{comment_id}/replies -f body="<reply>"`
180
+ **Secrets unavailable** (Dependabot):
181
+ - Try updating branch first (may get new CI workflow)
182
+ - If still fails after update: skip with note
188
183
 
189
- ### Step 6: Post-comment handling
184
+ ### Step 5: Timeout Handling
190
185
 
191
- After addressing comments:
192
- - Ask: "Re-request review from @reviewer?" / "Mark ready for review?" / "Leave as-is"
193
- - If re-request: `gh pr ready <number>` (if was draft) or comment @-mentioning reviewer
194
-
195
- ### Safety Guardrails
196
-
197
- - NEVER auto-address comments that involve logic changes
198
- - ALWAYS show diff before committing auto-addressed changes
199
- - ALWAYS confirm before pushing
200
- - Track which comments were addressed vs skipped for summary
201
- - NEVER modify code that the comment doesn't directly reference
186
+ If 10 minutes elapsed and CI still pending:
187
+ ```
188
+ ! CI timed out after 10 minutes - skipping
189
+ ```
190
+ - Add to skipped_prs
191
+ - Continue to next PR
202
192
 
203
193
  ---
204
194
 
205
- ## Phase 3: CI Loop
206
-
207
- For each open PR that needs CI verification:
208
-
209
- **Configuration:**
210
- - Max 3 fix attempts per PR
211
- - Max 5 minute wait per CI run
212
- - 30 second polling interval
213
-
214
- **Process:**
215
-
216
- 1. **Check CI status**: `gh pr view <pr-number> --json statusCheckRollup`
217
-
218
- 2. **If CI is running**:
219
- - Display: "Waiting for CI on PR #<number>... (attempt X/3, Xs elapsed)"
220
- - Wait 30 seconds
221
- - Re-check (up to 5 minutes total)
222
-
223
- 3. **If CI passes**: Mark PR as ready for merge, proceed to Phase 4
224
-
225
- 4. **If CI fails**:
226
- - Fetch and display the failure output
227
- - Categorize the failure:
228
- - **Lint/Formatting errors**: Offer to run `npm run lint -- --fix` automatically
229
- - **Type errors**: Show errors, ask user: "Skip this PR", "I'll fix manually"
230
- - **Test failures**: Show test output, ask user: "Skip this PR", "I'll fix manually"
231
- - **Build errors**: Show error, ask user: "Skip this PR", "I'll fix manually"
232
- - If auto-fix chosen (lint only):
233
- - Checkout branch (handle worktree if needed)
234
- - Run the fix command
235
- - Show the diff to user
236
- - Ask for confirmation before committing
237
- - Commit with message: "fix: auto-fix lint errors"
238
- - Push and decrement retry counter
239
- - If manual fix chosen:
240
- - Inform user and pause for this PR
241
- - Ask: "Continue with other PRs?" or "Wait for manual fix?"
242
-
243
- 5. **If max retries exceeded**:
244
- - Ask user: "Skip this PR", "Abort workflow", or "I'll fix manually"
245
- - Handle accordingly
246
-
247
- **IMPORTANT**: NEVER auto-fix test failures or type errors. Only lint/formatting issues are safe to auto-fix.
195
+ ## Phase 4: Merge (No Confirmation Needed)
248
196
 
249
- ---
197
+ For each PR that passed CI:
250
198
 
251
- ## Phase 4: Merge PRs
199
+ ### Pre-merge Verification
200
+ ```bash
201
+ gh pr view <number> --json state,mergeStateStatus,mergeable
202
+ ```
252
203
 
253
- For each PR that passed CI (and has no pending review comments):
204
+ - If `state=MERGED`: Log and continue (already merged)
205
+ - If `mergeable=CONFLICTING`: Skip (conflicts appeared)
254
206
 
255
- ### Pre-merge checks
207
+ ### Execute Merge
256
208
 
257
- 1. Re-verify CI status (avoid race condition): `gh pr view <pr-number> --json statusCheckRollup`
258
- 2. Check merge state: `gh pr view <pr-number> --json mergeStateStatus,mergeable`
209
+ ```bash
210
+ gh pr merge <number> --squash --delete-branch
211
+ ```
259
212
 
260
- ### Handle branch behind default branch
213
+ (Use detected strategy from Phase 0: --squash, --merge, or --rebase)
261
214
 
262
- **If `mergeStateStatus` is `BEHIND`:**
263
- - Ask user: "Update branch via GitHub" or "Skip this PR"
264
- - If update chosen:
265
- - Run: `gh api repos/{owner}/{repo}/pulls/{pr-number}/update-branch -X PUT`
266
- - If the API call fails (e.g., merge conflicts), inform user and offer to skip
267
- - Wait for CI to re-run after update
268
- - Re-check merge state
215
+ **Handle results:**
216
+ - Success: Log `Merged`, increment counter
217
+ - "Already merged" error: Log as success, continue
218
+ - Other error: Log error, add to failed_prs, continue to next PR
269
219
 
270
- ### Handle merge conflicts
220
+ **Output format:**
221
+ ```
222
+ [1/8] PR #42 "bump cross-env"
223
+ -> CI passed -> merged
271
224
 
272
- **If `mergeable` is `CONFLICTING`:**
273
- - STOP - cannot auto-merge
274
- - Show the PR URL
275
- - Ask user: "Skip this PR" or "I'll resolve conflicts manually"
276
- - If manual resolution, wait for user confirmation then re-check
225
+ [2/8] PR #35 "bump sharp"
226
+ -> Waiting for CI... (45s)
227
+ -> CI passed -> merged
277
228
 
278
- ### Merge
229
+ [3/8] PR #32 "bump linting group"
230
+ X CI failed (lint errors)
231
+ -> Auto-fixing lint errors...
232
+ -> Pushed fix, waiting for CI... (30s)
233
+ -> CI passed -> merged
279
234
 
280
- - Present merge summary before proceeding:
281
- ```
282
- Ready to merge:
283
- PR #42: "Add user authentication" (feature-auth -> main)
235
+ [4/8] PR #28 "new feature"
236
+ - Skipped (draft PR)
284
237
 
285
- This will:
286
- - Merge the PR using repository's merge strategy
287
- - Delete the remote branch
238
+ [5/8] PR #25 "refactor auth"
239
+ - Skipped (merge conflicts)
240
+ ```
288
241
 
289
- Proceed? [Yes / Skip / Abort]
290
- ```
291
- - Run `gh pr merge <pr-number> --delete-branch`
292
- - This respects the repository's merge strategy settings
293
- - The `--delete-branch` flag removes the remote branch after merge
242
+ ---
294
243
 
295
- ### Handle merge failure
244
+ ## Phase 5: Cleanup & Summary (Automatic)
296
245
 
297
- - Report the error
298
- - Ask user how to proceed
246
+ ### Step 1: Auto-cleanup (no prompts)
299
247
 
300
- ---
301
-
302
- ## Phase 5: Final Cleanup & Summary
248
+ 1. Prune remote refs:
249
+ ```bash
250
+ git fetch --prune
251
+ ```
303
252
 
304
- ### Step 1: Handle orphaned worktrees from merged PRs
253
+ 2. For each merged PR's branch, delete local if exists:
254
+ ```bash
255
+ git branch -d <branch> 2>/dev/null || true
256
+ ```
305
257
 
306
- For any worktrees whose branches were merged in Phase 4:
307
- - The remote branch is now deleted, but the local worktree may still exist
308
- - For each such worktree, ask user:
309
- ```
310
- Worktree at '<path>' is now on merged branch '<branch>'.
258
+ 3. Prune worktrees:
259
+ ```bash
260
+ git worktree prune
261
+ ```
311
262
 
312
- Options:
313
- 1. Remove worktree (Recommended)
314
- 2. Keep worktree (switch to <default-branch>)
315
- ```
316
- - If remove: `git worktree remove <path>`
317
- - If keep: `git -C <path> checkout <default-branch>`
263
+ ### Step 2: Return to original context
318
264
 
319
- ### Step 2: Clean up local branches
265
+ - If original branch exists: `git checkout <original-branch>`
266
+ - If it was merged: checkout default branch
267
+ - If was detached HEAD: `git checkout <original-sha>`
320
268
 
321
- For each PR merged in Phase 4:
322
- - Delete local branch if it exists: `git branch -d <branch>`
323
- - Skip if branch is checked out in a remaining worktree
269
+ ### Step 3: Display Final Summary
324
270
 
325
- ### Step 3: Clean up stale refs
271
+ ```
272
+ =====================================================
273
+ PR Resolution Complete
274
+ =====================================================
326
275
 
327
- 1. Run `git fetch --prune` to clean up all stale remote refs
328
- 2. Run `git worktree prune` to clean up stale worktree admin entries
276
+ RESULTS:
277
+ Merged: X PRs
278
+ - #42 "bump cross-env"
279
+ - #35 "bump sharp"
280
+ - #32 "bump linting group" (auto-fixed lint)
329
281
 
330
- ### Step 4: Return to original context
282
+ Skipped: X PRs
283
+ - #28 "new feature" (draft)
284
+ - #25 "refactor auth" (merge conflicts)
331
285
 
332
- - **If original state was a branch**: Run `git checkout <original-branch>` (if it still exists, otherwise stay on default branch)
333
- - **If original state was detached HEAD**: Run `git checkout <original-commit-sha>` to restore exact position
334
- - If the original branch was merged and deleted, inform user: "Your original branch '<branch>' was merged. You are now on '<default-branch>'."
286
+ Failed: X PRs
287
+ - #20 "breaking change" (type errors - needs manual fix)
335
288
 
336
- ### Step 5: Display final summary
289
+ AUTO-FIXES APPLIED:
290
+ - X lint errors fixed automatically
337
291
 
338
- ```
339
- =====================================================
340
- GitHub PR Resolution Complete!
341
- =====================================================
292
+ REMAINING WORK:
293
+ - PR #25 has merge conflicts at: src/auth.ts
294
+ - PR #20 needs manual fix for type errors
342
295
 
343
- PRs PROCESSED:
344
- ✓ Merged X PRs
345
- - PR #42: "Add user authentication"
346
- - PR #43: "Fix login bug"
347
- ○ Skipped X PRs (CI failed / conflicts)
348
- - PR #45: "Refactor" (merge conflicts)
349
-
350
- REVIEW COMMENTS:
351
- ✓ Auto-addressed X comments
352
- ✓ Manually resolved X comments
353
- ○ Skipped X comments
354
-
355
- CI FIXES:
356
- ✓ Auto-fixed X lint issues
357
- ○ X PRs need manual fixes
358
-
359
- CLEANUP:
360
- ✓ Deleted X remote branches
361
- ✓ Deleted X local branches
362
- ✓ Removed X worktrees
363
-
364
- CURRENT STATE:
365
- Branch: <current-branch>
366
- Worktree: <current-worktree-path>
367
-
368
- REMAINING OPEN PRs:
369
- - PR #45: "Refactor" - merge conflicts, needs manual resolution
370
- - PR #46: "Draft feature" - draft, skipped
371
-
372
- WARNINGS (if any):
373
- - PR #45 has merge conflicts at src/auth/login.ts
374
296
  =====================================================
375
297
  ```
376
298
 
377
299
  </workflow>
378
300
 
379
- ## Error Recovery
380
-
381
- If the workflow fails at any point, display:
382
-
383
- 1. **Operations completed successfully** (from the operation log)
384
- 2. **The operation that failed** and the error message
385
- 3. **Current repository state**:
386
- - Current branch: `git branch --show-current`
387
- - Uncommitted changes: `git status --porcelain`
388
- - Any in-progress operations: check for rebase/merge/cherry-pick
301
+ ## Safety Rules
389
302
 
390
- 4. **Recovery guidance based on failure point**:
303
+ ### ALWAYS Auto-fix
304
+ - Lint errors (`npm run lint -- --fix`)
305
+ - Formatting errors
391
306
 
392
- **If failed during review comment fix:**
393
- - Changes may be uncommitted
394
- - Check: `git status` and `git diff`
395
- - Either commit or stash the changes
396
- - PR is still open (safe)
307
+ ### NEVER Auto-fix
308
+ - Type errors (TypeScript)
309
+ - Test failures
310
+ - Build errors
311
+ - Logic changes in review comments
397
312
 
398
- **If failed during CI fix commit:**
399
- - Changes may be uncommitted
400
- - Check: `git status`
401
- - Commit manually: `git commit -am "fix: ..."`
402
- - Push: `git push`
313
+ ### Branch Safety
314
+ - NEVER use force push
315
+ - ALWAYS preserve user's starting context
316
+ - ALWAYS use detected merge strategy
403
317
 
404
- **If failed during merge:**
405
- - PR still exists, not merged
406
- - Check PR status: `gh pr view <number>`
407
- - Retry via GitHub UI or: `gh pr merge <number>`
318
+ ### Timing
319
+ - 30 second polling interval
320
+ - 10 minute max wait per PR
321
+ - 2 max fix attempts before skipping
408
322
 
409
- **If failed during worktree cleanup:**
410
- - Worktree may be partially removed
411
- - Run: `git worktree prune` to clean up
412
- - Check: `git worktree list`
323
+ ### Error Handling
324
+ - "Already merged" is a success, not an error
325
+ - Continue to next PR on any error
326
+ - Log all failures for summary
327
+ - Never block on a single PR failure
413
328
 
414
- **If failed during branch deletion:**
415
- - Local branch may be deleted but remote still exists (or vice versa)
416
- - Check: `git branch -a | grep <branch>`
417
- - Manual cleanup if needed
329
+ ---
418
330
 
419
- 5. **Always safe to re-run**: The workflow is idempotent - running it again will skip already-completed operations.
331
+ ## Error Recovery
420
332
 
421
- ---
333
+ If the workflow fails at any point:
422
334
 
423
- ## Safety Rules
335
+ 1. **Show completed operations**
336
+ 2. **Show current state**: `git branch --show-current`, `git status --porcelain`
337
+ 3. **Re-run is safe**: The workflow is idempotent - merged PRs show as "Already merged"
424
338
 
425
- ### PR Safety Rules
426
- - NEVER merge without CI passing
427
- - NEVER force merge when conflicts exist
428
- - ALWAYS verify merge state before merging
429
- - ALWAYS respect retry limits
430
-
431
- ### Review Comment Safety Rules
432
- - NEVER auto-address comments that involve logic changes
433
- - ALWAYS show diff before committing changes
434
- - ALWAYS confirm before pushing
435
- - NEVER modify code that the comment doesn't directly reference
436
- - ALWAYS track which comments were addressed for summary
437
-
438
- ### Branch Safety Rules
439
- - NEVER use force push (`--force` or `-f`)
440
- - ALWAYS preserve the user's working context (return to original branch)
441
-
442
- ### Worktree Safety Rules
443
- - NEVER remove a worktree with uncommitted changes without explicit user confirmation
444
- - ALWAYS check worktree status before operations
445
- - ALWAYS run `git worktree prune` after removing worktrees
446
- - ALWAYS use `git -C <path>` for operations in linked worktrees
339
+ **Common issues:**
340
+ - "Already merged" - Normal, PR was auto-merged externally
341
+ - CI timeout - Re-run later or check GitHub Actions
342
+ - Merge conflicts - Resolve manually, then re-run
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@torka/claude-workflows",
3
- "version": "0.4.0",
3
+ "version": "0.6.0",
4
4
  "description": "Claude Code workflow helpers: epic automation, git cleanup, agents, and design workflows",
5
5
  "keywords": [
6
6
  "claude-code",