delete-merged-branches

Delete local and remote Git branches merged into a specified base branch.

3|Updated Dec 31, 2025
One-click install
npx skills add https://github.com/otomatty/zedi --skill delete-merged-branches
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: delete-merged-branches
Source: https://github.com/otomatty/zedi/tree/main/.cursor/skills/delete-merged-branches
Command: npx skills add https://github.com/otomatty/zedi --skill delete-merged-branches

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill automates the safe deletion of Git branches that have already been merged into a specified base branch, both locally and on the remote repository, helping to keep your repository tidy and organized.

Core Features & Use Cases

  • Safe Deletion: Identifies branches merged via ancestry or by matching GitHub's headRefOid for squash/rebase merges.
  • Remote & Local Cleanup: Removes branches from both your local machine and the remote (e.g., origin).
  • Closed PR Branch Pruning: Also targets remote branches of closed (unmerged) Pull Requests for cleanup.
  • Use Case: After merging a feature branch into develop, use this Skill to automatically remove the now-redundant feature branch from your local and remote repositories.

Quick Start

Run the delete-merged-branches script with 'develop' as the base branch to clean up merged branches.

Frequently Asked Questions about delete-merged-branches

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

FAQPage Schema
How do I clean up merged Git branches locally and remotely?

To clean up merged Git branches, you can use a script that safely deletes redundant local and remote branches by checking ancestry against a specified base branch. It removes matched branches from both your machine and the remote repository to keep things tidy.

Does Git branch cleanup work with squash and rebase merges?

Git branch cleanup handles squash and rebase merges by matching GitHub's headRefOid. This ensures that branches merged without a standard merge commit are still accurately identified and safely deleted.

Can I delete remote branches from closed unmerged pull requests?

You can delete remote branches from closed unmerged pull requests across the entire repository. The cleanup process prunes these orphaned remote branches automatically, preventing clutter from abandoned PR workflows.

Do I need GitHub CLI installed to delete merged branches?

You need both Git and GitHub CLI (gh) installed and authenticated to delete merged branches. The GitHub CLI is required to query pull request metadata and match headRefOid for accurate squash merge identification.

What is the best way to automate repository maintenance after merging a feature?

Automating repository maintenance after a merge involves running a branch deletion script against your base branch, such as develop. This safely removes the now-redundant feature branch from both local and remote repositories in one step.