Merge a worktree branch into main, remove the worktree, and delete the branch. Use when done with a worktree and ready to integrate or discard the work.
Scanned 9/3/2026
Install to Claude Code
npx -y skills add incubateur-ademe/benefriches --skill worktree-merge --agent claude-codeInstalls into .claude/skills of the current project.
Are you the author of Worktree Merge?
Add the live security badge to your README — it updates automatically with every re-scan.
[](https://www.skillsdirectory.com/skills/incubateur-ademe-worktree-merge)More formats (shields.io, HTML) on the badges page.
---
name: worktree-merge
effort: low
description: Merge a worktree branch into main, remove the worktree, and delete the branch. Use when done with a worktree and ready to integrate or discard the work.
allowed-tools: Bash
user-invocable: true
---
# Worktree Cleanup
Merge a completed worktree branch into main, remove the worktree directory, and delete the branch.
## Instructions
### Step 1: List active worktrees
Run `git worktree list` and parse the output to find all worktrees **except** the main one.
If there are no worktrees to clean up, tell the user and stop.
### Step 2: Ask user which worktree to clean up
Use the `AskUserQuestion` tool to present the list of active worktrees as options. Show the branch name and directory path in each option.
### Step 3: Confirm merge strategy
Use `AskUserQuestion` to ask whether to:
1. **Merge into main** — merge the branch into main before cleanup
2. **Remove only** — just remove the worktree and branch without merging (for abandoned work)
### Step 4: Execute cleanup
#### If merging:
```bash
# 1. Ensure we're on main and up to date
git checkout main
# 2. Merge the branch
git merge --ff-only <branch-name>
# 3. Remove worktree and delete branch
scripts/remove-worktree.sh <branch-name> --delete-branch
```
#### If removing without merge:
```bash
# Remove worktree and delete branch
scripts/remove-worktree.sh <branch-name> --delete-branch
```
### Step 5: Report result
Show what was done: merged (if applicable), worktree removed, branch deleted.
## Arguments
$ARGUMENTS
Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.
No comments yet. Be the first to comment!