Agent skill
worktree-clean
Use when removing a git worktree and cleaning up its associated local branch from the main repository.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/worktree-clean
SKILL.md
worktree_path = $ARGUMENTS
Remove a local worktree and delete its associated local branch. If no argument is provided, list worktrees and ask which to remove.
Local Only
Remote branches carry invisible state — open MRs, CI pipelines, review comments, deployment triggers — and deleting one can auto-close an MR silently. The user owns remote-branch deletions.
Submodules
Submodule git state under .git/worktrees/{name}/modules/{submodule} is cleaned up with the parent worktree — no separate step.
When Removal Resists
git worktree remove fails on unclean state; git branch -d fails on unmerged branches. Trivial leftovers (build artifacts, debug logs, already-pushed-or-merged work) justify forcing autonomously. Substantive uncommitted or unmerged work — describe what you found and let the user decide.
Run git worktree prune after removal to clear stale internal references.
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?