cleanup-merged

Prune remotes and delete merged or upstream-gone local branches.

1|Updated Apr 11, 2026
One-click install
npx skills add https://github.com/zeveck/zskills-dev --skill cleanup-merged
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cleanup-merged
Source: https://github.com/zeveck/zskills-dev/tree/main/.claude/skills/cleanup-merged
Command: npx skills add https://github.com/zeveck/zskills-dev --skill cleanup-merged

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

After PRs merge on GitHub, local clones often accumulate stale feature branches that clutter development workflows. This skill automatically prunes remotes, switches to the main branch, pulls updates, and deletes local branches whose upstream has been deleted or whose PR has merged, while refusing to modify a dirty working tree.

Core Features & Use Cases

  • Prunes origin to remove references to deleted branches and keeps local refs in sync.
  • Switches to the main branch, pulls latest changes, then deletes merged or upstream-gone feature branches.
  • Respects worktree state and refuses to delete branches with unpushed commits, ensuring safe cleanup.

Quick Start

Run cleanup-merged after merging a PR to prune stale branches and update your local main branch.

Frequently Asked Questions about cleanup-merged

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

FAQPage Schema
How do I automatically delete local git branches after a PR is merged?

Git branch cleanup removes stale local branches after PR merges by pruning remotes, switching to the main branch, pulling latest changes, and deleting merged or upstream-gone branches. This keeps local clones in sync with the remote repository without manual branch deletion.

What is the safest way to clean up stale git branches without losing unpushed commits?

Safe git branch cleanup avoids data loss by refusing to modify a dirty working tree and skipping branches with unpushed commits. It only deletes local branches whose upstream has been deleted on the remote or whose PR has already been fully merged.

How do I prune stale local branches in a GitHub-based team workflow?

To prune stale local branches in a GitHub-based team workflow, run a cleanup operation that fetches and prunes origin to remove deleted remote refs. It then deletes local feature branches whose upstream tracking is gone, keeping team clones aligned after PR merges.

Does automated branch cleanup work with git worktrees?

Automated branch cleanup respects worktree state by checking the working tree before modifying anything. It bails on dirty working trees to prevent data loss, but successfully deletes merged or upstream-gone branches in clean worktree environments across personal or team repositories.

Why does my local branch cleanup refuse to delete branches in a dirty working tree?

Local branch cleanup refuses to delete branches in a dirty working tree as a safety mechanism to prevent losing uncommitted changes. It ensures data integrity by aborting the cleanup process until all local modifications are committed or stashed before attempting branch deletion.