ai-worktree:teardown

Remove an AI worktree and delete its associated branch from the main repository.

Updated May 31, 2025
One-click install
npx skills add https://github.com/dEitY719/dotfiles --skill ai-worktree-teardown
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ai-worktree:teardown
Source: https://github.com/dEitY719/dotfiles/tree/main/claude/skills/ai-worktree-teardown
Command: npx skills add https://github.com/dEitY719/dotfiles --skill ai-worktree-teardown

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Cleanly teardown an AI worktree after work is done by removing the worktree, deleting its branch, and syncing the main repository to keep history clean and up to date.

Core Features & Use Cases

  • Teardown a specified AI worktree from the main repository, removing the worktree and its associated branch after validating context.
  • Ensure the main branch is up to date before branch deletion, with safe fallbacks for conflicts and non-merged branches.
  • Handle common edge cases (missing worktree path, inside a worktree, dirty or unpushed changes) with clear errors and optional force/keep-branch controls.

Quick Start

Run /ai-worktree:teardown <worktree-path> from the main repository to remove the specified worktree and its associated branch.

Frequently Asked Questions about ai-worktree:teardown

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I safely remove a git worktree and delete its branch?

To safely remove a git worktree and delete its branch, run the teardown command from the main repository to validate context, sync the main branch, remove the worktree, and delete the associated branch if merged.

What happens if I try to teardown a worktree with uncommitted changes?

Teardown a worktree with uncommitted or dirty changes triggers a clear error to prevent data loss. You can override this edge case using the --force option to proceed with the removal and branch deletion.

Can I remove a git worktree but keep the branch?

Yes, you can remove a git worktree but keep the branch by using the --keep-branch option. This removes the worktree directory and syncs the main repository without deleting the associated branch.

How to delete a git worktree when the branch is not merged?

To delete a git worktree when the branch is not merged into the main repository, use the --force option. This bypasses the safe fallback for non-merged branches and executes the branch deletion.

Why does git worktree teardown fail when run inside the worktree?

Git worktree teardown fails when run inside the worktree because the process enforces operating from the main repository. You must navigate to the main repository directory before executing the teardown command.