Worktree delete

From the-agency-ai/the-agency · View interactive version

Worktree delete is an AI agent skill from the GitHub repository the-agency-ai/the-agency. Remove a git worktree and optionally delete its branch

How to use this skill

Skill file

<!--

Flag #62/#63: allowed-tools removed. Inherits Bash(*) from

.claude/settings.json. Restricting to specific subcommand patterns at the

skill level silently blocks agents on permission prompts the agent cannot

see — see dispatch #171 for the devex incident that surfaced this trap.

-->

Delete Worktree

Remove a git worktree from .claude/worktrees/ and optionally clean up its branch.

Arguments

Instructions

Step 0: Parse arguments

If $ARGUMENTS is empty, list worktrees and ask which to delete.

Step 1: Validate

  1. Verify .claude/worktrees/<name>/ exists as a git worktree.
  2. Check for uncommitted changes. If dirty, warn and ask to confirm.

Step 2: Determine the branch

Get branch name from the worktree.

Step 3: Remove the worktree

  1. git worktree remove .claude/worktrees/<name> (add --force only if user confirmed dirty deletion)
  2. git worktree prune

Step 4: Offer branch cleanup

Ask:

Delete branch <branch> as well?

1. Yes — safe delete (git branch -d)

2. Yes — force delete (git branch -D)

3. No — keep the branch

Step 5: Report

Worktree deleted:
  Path:   .claude/worktrees/<name>/ (removed)
  Branch: <branch> (deleted/kept)
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.