/worktrees:finish [--pr | --merge] [--force]from worktrees
Use when completing work in a worktree. Handles PR creation or direct merge, worktree removal, and branch cleanup. Invoke with "/worktrees:finish" or when user mentions "finish worktree", "clean up worktree", "merge worktree", "done with worktree", or "complete worktree work".
Ships in worktrees. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Complete work in a worktree and clean up.
--pr - Create a pull request (default)--merge - Direct merge to target branch--force - Force cleanup with uncommitted changesBefore finishing, verify:
# Check for uncommitted changes
git status
# Run tests
npm test # or your test command
# Push if needed
git push -u origin $(git branch --show-current)
For peer workflows and standard code review.
# Fetch latest changes
git fetch origin main
# Rebase to include latest main
git rebase origin/main
# Force push rebased branch
git push --force-with-lease
gh pr create \
--base main \
--title "feat: <description>" \
--body "## Summary
<What this PR accomplishes>
## Changes
- <Bullet list of changes>
## Testing
<How to test>
"
# Return to main project directory
cd ../.. # Exit .worktrees/<name> to project root
# Pull merged changes
git checkout main
git pull origin main
# Remove worktree
git worktree remove .worktrees/<name>
# Delete local branch if still exists (PR merge usually deletes remote)
git branch -d feature/<name> 2>/dev/null
# Prune stale references
git worktree prune
For orchestrator integration where work merges directly.
# From main project directory (not worktree)
cd /path/to/main/project
git checkout <target-branch>
git merge feature/<name> --no-ff -m "Merge <description>"
npm test # Verify integration
# Remove worktree
git worktree remove .worktrees/<name>
# Delete local branch
git branch -d feature/<name>
# If pushed to remote, delete remote branch
git push origin --delete feature/<name>
# Prune stale references
git worktree prune
When worktree has uncommitted changes and you want to discard:
# Force remove worktree (discards all uncommitted changes!)
git worktree remove --force .worktrees/<name>
# Delete branch
git branch -D feature/<name>
# Prune
git worktree prune
Warning:
--forcediscards uncommitted work permanently.
For cleaning up multiple worktrees:
#!/bin/bash
# cleanup-worktree.sh <worktree-name>
NAME=$1
BRANCH="feature/${NAME}"
WORKTREE=".worktrees/${NAME}"
# Check if worktree exists
if git worktree list | grep -q "$WORKTREE"; then
# Remove worktree
git worktree remove "$WORKTREE" || git worktree remove --force "$WORKTREE"
fi
# Delete local branch
git branch -d "$BRANCH" 2>/dev/null || git branch -D "$BRANCH" 2>/dev/null
# Delete remote branch if exists
git push origin --delete "$BRANCH" 2>/dev/null
# Prune
git worktree prune
echo "Cleanup complete for $NAME"
After cleanup:
# Verify worktree removed
git worktree list
# Verify branch deleted
git branch -a | grep <name>
# Should show no results for worktree or branch
Error: fatal: cannot remove worktree with uncommitted changes
Solutions:
git add . && git commit -m "WIP"git stashgit worktree remove --force .worktrees/<name>Error: fatal: worktree is locked
Solution:
git worktree unlock .worktrees/<name>
git worktree remove .worktrees/<name>
Error: error: branch is not fully merged
Solutions:
git branch -D feature/<name>If worktree directory was manually deleted:
git worktree prune
| Task | Command |
|---|---|
| Remove worktree | git worktree remove .worktrees/<name> |
| Force remove | git worktree remove --force .worktrees/<name> |
| Delete local branch | git branch -d feature/<name> |
| Force delete branch | git branch -D feature/<name> |
| Delete remote branch | git push origin --delete feature/<name> |
| Prune stale entries | git worktree prune |
| Create PR | gh pr create --base main |
| Merge PR | gh pr merge --squash --delete-branch |
What SKILL.md sets; muted values are Claude Code's defaults
6 skills in this plugin
/conceptsworktrees:conceptsComprehensive reference for git worktrees. Covers concepts, commands, conflict resolution, and best practices. Invoke with "/worktrees:concepts" or when user mentions "worktree reference", "explain worktrees", "worktree documentation", "worktree commands", "worktree concepts", or "learn about worktrees"./newworktrees:newUse when creating a new git worktree. Handles gitignore setup, worktree creation, and provides guidance. Invoke with "/worktrees:new <name>" or when user mentions "create worktree", "new worktree", "start feature in worktree", or "isolated workspace"./orchestratorworktrees:orchestratorUse for multi-subagent parallel development. A main Claude instance manages multiple concurrent subagents, each working in isolated worktrees. Invoke with "/worktrees:orchestrator <feature>" or when user mentions "orchestrate agents", "parallel subagents", "coordinate development", "multi-agent workflow", "spawn subagents", or "divide feature into tasks"./peerworktrees:peerUse for independent development with PR-based integration. Multiple Claude instances work autonomously, each creating PRs to main. Invoke with "/worktrees:peer <feature>" or when user mentions "peer workflow", "independent worktree", "autonomous development", "PR-based workflow", or "multi-instance development"./statusworktrees:statusDisplay comprehensive worktree status including active worktrees, stale references, and uncommitted changes. Invoke with "/worktrees:status" or when user mentions "worktree status", "list worktrees", "check worktrees", "worktree health", or "audit worktrees".npx claudepluginhub aaronbassett/agent-foundry --plugin worktreesOther plugins' skills for the same job