Remove Worktree
SkillAI & modelsTear down a Claude Code worktree created via scripts/create-worktree.sh. Use when the user says "close the worktree", "remove this worktree", "tear down the worktree", "I'm done with this worktree", or runs /remove-worktree. Handles cd-out if invoked from inside the worktree, runs the removal script, and optionally deletes the branch when merged into origin/main.
Available today. Use it from your connected AI after setup.
No other account needed.
Connect ahel once, and every AI you use reads what you have installed.
Then ask your AI: use the Remove Worktree skill
What this skill tells your AI
The instructions your AI receives, as published by nbramia/lifeos in .claude/skills/remove-worktree/SKILL.md and read by ahel’s review.
Tear down a worktree from ~/.claude/worktrees/LifeOS/.
Context
- Current directory: !
pwd - Worktree info (if inside one): !
cat .worktree-info 2>/dev/null || echo "(not in a worktree)" - Main repo checkout: !
dirname "$(git rev-parse --path-format=absolute --git-common-dir)" - Active worktrees: !
"$(dirname "$(git rev-parse --path-format=absolute --git-common-dir)")/scripts/list-worktrees.sh" 2>/dev/null || echo "(none)" - Arguments: $ARGUMENTS
Instructions
Step 1: Resolve the worktree name
In order of preference:
- If
$ARGUMENTScontains a name (first non-flag token), use it. - Else if cwd is inside a worktree and
.worktree-infoexists, readNAME=from it. - Else if exactly one worktree is active in the list above, use that.
- Else ask the user which worktree to remove.
Flatten any slashes (feat/foo → feat-foo) — the script expects the flat dir name.
Step 2: Check the delete-branch flag
If $ARGUMENTS contains --delete-branch, prepare to set LIFEOS_WORKTREE_DELETE_BRANCH=1. The script only deletes the branch if it's already merged into origin/main, so this is safe by default — but mention to the user that you're going to attempt branch deletion.
Step 3: Get out of the worktree if necessary
If pwd is under ~/.claude/worktrees/LifeOS/, cd to the main repo checkout (shown in Context above) first. git worktree remove --force will delete the directory out from under the shell otherwise.
Step 4: Run the removal script
From the main repo:
cd "$(dirname "$(git rev-parse --path-format=absolute --git-common-dir)")"
LIFEOS_WORKTREE_DELETE_BRANCH=<0 or 1> ./scripts/remove-worktree.sh <name>
Step 5: Report
In one or two sentences:
- Whether the worktree was removed
- Whether the branch was deleted (or why not — e.g., "not merged to origin/main")
- If anything looks orphaned, suggest
./scripts/cleanup-worktrees.sh
Do not summarize what the script printed line-by-line; the user already sees the output.
Signals
- GitHub stars
- 30
- Forks
- 7
- Last commit
- Sep 2026
Advanced
- Catalog kind
- skill
- Gateway key
remove-worktree- Source
- github.com/nbramia/lifeos