Skip to content

Commit 86d1c87

Browse files
Nick Sullivanclaude
andcommitted
✨ Add cleanup-worktree command for post-merge cleanup
Adds a command to safely remove git worktree directories after their PRs have been merged. Verifies merge status before cleanup, preserves all branches, and returns user to the primary repo on main. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent aa59706 commit 86d1c87

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
description: Clean up a git worktree after its PR has been merged
3+
model: haiku
4+
---
5+
6+
# Cleanup Git Worktree
7+
8+
<objective>
9+
Safely remove a git worktree directory after its associated PR has been merged to main,
10+
preserving branches and leaving the user in the primary repo ready for the next task.
11+
</objective>
12+
13+
<merge-verification>
14+
Confirm the worktree's branch was merged before any cleanup. Pull main in the primary
15+
repo to get the latest state, then verify the branch appears in the merged history.
16+
17+
If the branch is unmerged, stop and explain the situation. Merged work is safe to clean
18+
up; unmerged work requires user decision.
19+
</merge-verification>
20+
21+
<cleanup-scope>
22+
Remove only the worktree directory itself. Preserve all branches (local and remote) for
23+
git history and potential future reference.
24+
25+
Use `git worktree list` to find the primary repo location. The current working directory
26+
may be inside the worktree being cleaned up, so navigate to the primary repo first.
27+
</cleanup-scope>
28+
29+
<success-criteria>
30+
Worktree directory removed, all branches preserved, user returned to primary repo on
31+
main with latest changes pulled.
32+
33+
Celebrate the successful merge with congratulatory language acknowledging the completed
34+
work.
35+
</success-criteria>

0 commit comments

Comments
 (0)