Worktree Cleanup

SkillDev tools

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.

Available today. Use it from your connected AI after setup.

Connect ahel once, and every AI you use reads what you have installed.

Then ask your AI: use the Worktree Cleanup skill

What this skill tells your AI

The instructions your AI receives, as published by incubateur-ademe/benefriches in .claude/skills/worktree-merge/SKILL.md and read by ahel’s review.

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:
# 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:
# 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

Signals

GitHub stars
45
Forks
3
Last commit
Sep 2026
Advanced
Catalog kind
skill
Gateway key
worktree-merge
Source
github.com/incubateur-ademe/benefriches