@torka/claude-workflows 0.7.0 → 0.7.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.
@@ -37,8 +37,12 @@ Before any operations, verify the environment is safe:
37
37
 
38
38
  8. **Build worktree inventory**: Run `git worktree list --porcelain` to detect all worktrees.
39
39
  - Parse the output to build a map: `{ branch_name -> worktree_path }`
40
- - **For each worktree path, verify it exists on the filesystem**
41
- - **If a path doesn't exist (stale entry), run `git worktree prune` to clean it up before continuing**
40
+ - **For each worktree path:**
41
+ a) Verify the directory exists on the filesystem
42
+ b) If it exists, verify git metadata is valid: `git -C <path> rev-parse --git-dir 2>/dev/null`
43
+ c) If directory exists but git command fails, this is a **stale worktree** (metadata broken but directory remains)
44
+ - **If any paths don't exist OR have invalid git metadata, run `git worktree prune` to clean up before continuing**
45
+ - After pruning, re-run `git worktree list --porcelain` to get the updated inventory
42
46
  - Identify which worktree is the main worktree vs linked worktrees
43
47
  - For each branch, record if it's checked out in a worktree and where
44
48
 
@@ -132,6 +136,8 @@ Store the WIP branches list for use in subsequent phases. Also maintain a separa
132
136
 
133
137
  ## Phase 3: Cleanup Merged Branches
134
138
 
139
+ **Note on GitHub auto-delete:** Many repositories have "Automatically delete head branches" enabled in GitHub settings. When enabled, merged/squash-merged PR branches are automatically deleted from the remote. The workflow handles this gracefully - if remote deletion fails because the branch is already gone, it continues normally.
140
+
135
141
  For all branches identified as merged (via regular merge OR squash merge):
136
142
 
137
143
  ### Step 1: Categorize merged branches by worktree status
@@ -190,8 +196,14 @@ Options:
190
196
  - WARN: "Worktree at '<path>' has uncommitted changes that will be LOST"
191
197
  - Ask for explicit confirmation: "Proceed anyway?" / "Skip this worktree"
192
198
  - If skip, move to next branch
193
- 3. Remove worktree: `git worktree remove <worktree-path>`
194
- 4. If removal fails (locked, etc.), inform user and skip
199
+ 3. Remove worktree: `git worktree remove --force <worktree-path>`
200
+ - The `--force` flag is needed because worktrees often contain untracked build artifacts (.next, node_modules, coverage, etc.)
201
+ - This is safe here because we already: (a) confirmed the branch is merged/squash-merged, (b) warned about uncommitted changes if any
202
+ 4. If removal still fails (locked, etc.):
203
+ a) Run `git worktree prune` to clean up stale metadata
204
+ b) If directory still exists, inform user: "Leftover directory at '<path>' needs manual removal: `rm -rf '<path>'`"
205
+ c) **Do NOT attempt `rm -rf` directly** - this may be blocked by safety hooks in some environments
206
+ d) Continue with branch deletion if possible
195
207
  5. Proceed to delete branch (now safe)
196
208
 
197
209
  **If option 2 (Skip):**
@@ -207,7 +219,10 @@ Options:
207
219
 
208
220
  For each branch now eligible for deletion:
209
221
  - Delete local: `git branch -d <branch>` (use `-D` for squash-merged branches that git doesn't recognize as merged)
210
- - Delete remote (if exists): `git push <remote> --delete <branch>`
222
+ - Delete remote (if tracking branch exists):
223
+ 1. First check if remote branch exists: `git ls-remote --heads <remote> <branch>`
224
+ 2. If output is empty, remote branch is already deleted (likely by GitHub auto-delete) - skip remote deletion
225
+ 3. If remote branch exists: `git push <remote> --delete <branch>`
211
226
 
212
227
  ### Step 6: Clean up orphaned tracking branches
213
228
 
@@ -407,7 +422,7 @@ If the workflow fails at any point, display:
407
422
 
408
423
  ### Worktree Safety Rules
409
424
  - NEVER remove a worktree with uncommitted changes without explicit user confirmation
410
- - NEVER force remove a worktree (`git worktree remove --force`) - always handle uncommitted changes properly
425
+ - `--force` flag for worktree removal IS allowed when: (a) branch is confirmed merged/squash-merged, AND (b) uncommitted changes have been checked and user warned if any exist. The `--force` is needed to handle untracked build artifacts (.next, node_modules, etc.)
411
426
  - ALWAYS check worktree status (`git -C <path> status --porcelain`) before attempting branch deletion
412
427
  - ALWAYS run `git worktree prune` after removing worktrees to clean up stale entries
413
428
  - NEVER attempt to remove the main worktree (git will error, but check anyway)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@torka/claude-workflows",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "description": "Claude Code workflow helpers: epic automation, git cleanup, agents, and design workflows",
5
5
  "keywords": [
6
6
  "claude-code",