com um clique
worktree-cleanup
// Clean up a git worktree and its local branch after a feature has been merged. Use after a PR is merged or a feature branch is no longer needed.
// Clean up a git worktree and its local branch after a feature has been merged. Use after a PR is merged or a feature branch is no longer needed.
| name | worktree-cleanup |
| description | Clean up a git worktree and its local branch after a feature has been merged. Use after a PR is merged or a feature branch is no longer needed. |
| user-invocable | true |
| argument-hint | Optional worktree name or branch name. If omitted, shows a list to choose from. |
You are cleaning up a git worktree and its associated local branch after the feature has been merged or is no longer needed.
Determine which worktree to clean up.
If the user provides an argument, use it as the worktree name or branch name.
If no argument is provided, first check if the current working directory is inside a worktree:
# Get the main repo root and current working directory
MAIN_ROOT=$(git worktree list | head -1 | awk '{print $1}')
CWD=$(pwd)
If CWD is inside a .claude/worktrees/ path (i.e., we're currently in a worktree), extract the worktree name and ask the user: "You're currently in worktree <name> — clean up this one?" If they confirm, use it. If they decline, fall through to the list.
If not in a worktree (or user declined), list all worktrees and ask the user which one to remove:
git worktree list
Exclude the main worktree (the first entry, which is the primary repo checkout).
If there are no worktrees to clean up, tell the user and stop.
Check if we're currently inside the worktree being removed (i.e., it was created with EnterWorktree in this session).
If inside the worktree: Call ExitWorktree with action: "remove" and discard_changes: true. This cleanly releases the directory lock, removes the worktree, and switches the session back to the main repo. Then skip to step 4 (branch deletion) — the worktree directory is already gone.
If NOT inside the worktree (cleaning up a worktree from a previous session or one created manually):
a. Make sure pwd is not inside the worktree path. If it is, cd to the main repo root first.
b. Remove the worktree using git's worktree command:
git worktree remove <path> --force
If that fails due to permissions (common on Windows), fall back to manual removal:
rm -rf <path>
git worktree prune
Delete the local branch if it exists. Determine the branch name from the worktree or the user's input:
git branch -d <branch-name>
If -d fails because the branch isn't merged to HEAD (but is merged to its remote tracking branch), use -D after confirming with the user.
Prune stale worktree references:
git worktree prune
Show a summary of what was cleaned up:
.claude/worktrees/<name> by convention.feature/<name> where <name> matches the worktree directory name.git worktree prune handles it.main, dev, or master branches.Orchestrates the complete release preparation process - detects changed products, analyzes commits for version bumps, updates version.json files, generates manifests and changelogs, and creates release branches. Use when preparing a new release.
Scaffolds a new AI provider package (Umbraco.AI.X) following the established provider plugin pattern. Use when adding support for a new AI vendor (e.g., Cohere, Groq, xAI, DeepSeek). Covers code, config, marketplace metadata, install scripts, and CI registration.
Generates changelogs for products from conventional commit history. Use when preparing a release, updating release documentation, or previewing unreleased changes before creating a release branch.
Check out a pull request into an isolated git worktree. Use when you want to review, test, or inspect a PR without affecting your current working directory.
Automates browser-based interactions with Umbraco.AI demo site using Playwright. Handles login, navigation, and editing of AI entities (connections, profiles, prompts, agents). Use when testing UI workflows, creating or editing AI entities through the backoffice, or demonstrating Umbraco.AI features.
Manages the Umbraco.AI demo site for development. Handles starting with DemoSite-Claude profile, port discovery via named pipes, and OpenAPI client generation. Use when starting, stopping, or checking the demo site, or when generating OpenAPI clients for frontend development.