Clean up merged worktrees and branches with one command - #57
Merged
Merged
Conversation
cleanup-worktree.sh <issue>, planning/<name>, or a path removes a worktree and its local branch once GitHub reports its pull request as merged, which also works after a squash merge, and fast-forwards main. It runs only from the primary checkout and refuses unmerged, dirty, and ahead-of-PR worktrees; ignored review files do not count. --merged cleans every merged worktree, and --discard removes an unmerged one after confirmation. Failed removals are reported as errors. Closes #56 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
./scripts/cleanup-worktree.sh <issue-number>finds the worktree offeature/<issue>-*;planning/<name>finds a planning worktree; a path keeps working, for any branch.mainin a clean primary checkout ofmain(otherwise it fetches and says so).--mergedremoves every merged worktree and lists the kept ones with the reason;--discardremoves an unmerged worktree after confirmation.finish-feature.shandfinish-planning.shmention the cleanup step; README,docs/development.md,docs/workflow.md,docs/example.md, anddocs/project-map.mduse the new form.Issue / acceptance criteria
Closes #56
Risk
Verification evidence
./scripts/verify.shpassed, also without global or system Git configurationtests/cleanup-worktree-test.shwith real worktrees and squash merges on a local remote, also passing under macOS system bash 3.2)Independent review: Codex (
gpt-6-astra), read-only. CHANGES REQUIRED:fix/branch test.Not re-reviewed after the fixes.
Agent involvement
Planner: —
Implementer: Claude (Opus 5.5)
Reviewer: Codex (gpt-6-astra)
Production impact
None.
🤖 Generated with Claude Code