clean-remote-worktrees

Classify and delete merged remote worktree branches from origin.

Updated Apr 17, 2026
One-click install
npx skills add https://github.com/smallorbit/smallorbit-plugins --skill clean-remote-worktrees
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: clean-remote-worktrees
Source: https://github.com/smallorbit/smallorbit-plugins/tree/main/plugins/swarmkit/skills/clean-remote-worktrees
Command: npx skills add https://github.com/smallorbit/smallorbit-plugins --skill clean-remote-worktrees

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires git, gh, jq, and includes scripts (resource) components.

What problem does it solve?

Sweep orphaned remote worktree-* branches left behind by merged PRs, crashes, or merges that skipped the delete operation. This keeps remote refs tidy without altering local state.

Core Features & Use Cases

  • Classifies remote branches by PR state and identifies candidates for deletion without touching local worktrees.
  • Deletes only branches whose most-recent PR is MERGED; skips OPEN, CLOSED-not-merged, and no-PR branches; supports interactive and automated cleanups.
  • Complements swarmkit:clean-worktrees by focusing solely on remote state while leaving local worktrees intact and safe.

Quick Start

Identify stale remote worktree branches with classify.sh and delete the merged ones after confirmation.

Frequently Asked Questions about clean-remote-worktrees

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

FAQPage Schema
How do I clean up orphaned remote worktree branches left after merged PRs?

To clean up orphaned remote worktree branches, you can use a script that classifies remote branches by PR state and deletes those whose most recent PR is merged. This sweeps stale remote refs without altering local state.

Does deleting remote worktree branches affect my local worktrees?

Deleting remote worktree branches does not affect local worktrees. The cleanup process operates only on remote branches discovered from origin, ensuring local state remains entirely intact and safe.

How does branch classification identify which remote worktrees to delete?

Branch classification identifies remote worktrees to delete by checking PR state. It deletes only branches with a MERGED PR status, skipping OPEN, CLOSED-not-merged, and no-PR branches to ensure safe batch deletion.

Do I need gh and jq to automate remote branch cleanup?

Yes, you need gh and jq to automate remote branch cleanup. These dependencies are required alongside git to query PR states and process JSON data for classifying and deleting orphaned worktree branches.

What is the best way to batch delete merged worktree branches on origin?

The best way to batch delete merged worktree branches is using a dedicated delete script with safety checks. It targets only merged PR branches from origin, supporting both interactive and automated cleanup contexts.

Why are orphaned worktree branches left on the remote after a PR merge?

Orphaned worktree branches are left on the remote after a PR merge due to crashes or merge operations that skipped the delete step. These stale branches persist on origin until explicitly classified and swept.