cleanup-merged-branches

Delete merged Git branches locally and remotely with safety checks.

2|Updated Feb 17, 2026
One-click install
npx skills add https://github.com/nodatall/primedirective --skill cleanup-merged-branches-nodatall
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cleanup-merged-branches
Source: https://github.com/nodatall/primedirective/tree/main/skills/cleanup-merged-branches
Command: npx skills add https://github.com/nodatall/primedirective --skill cleanup-merged-branches-nodatall

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Manually cleaning up merged Git branches carries high risk of accidentally deleting active work, unmerged feature branches, or branches tied to open pull requests, which can lead to lost code and broken team workflows.

Core Features & Use Cases

  • Safe Merged Branch Detection: Automatically identifies only branches fully merged into the configured base branch (main/master) to avoid targeting active work.
  • Strict Safety Guardrails: Blocks deletion of the base branch, unmerged branches, and branches with open pull requests, with fallback rules when GitHub CLI is unavailable to verify PR state.
  • Targeted or Bulk Cleanup: Supports cleaning up a single specified branch or all eligible merged branches in the repository.
  • Use Case: After merging a set of feature branches for a quarterly release, use this skill to automatically purge all merged local and remote branches without risking your ongoing development work or open PRs.

Quick Start

Use the cleanup-merged-branches skill to safely delete all merged feature branches from your local repository and the origin remote.

Frequently Asked Questions about cleanup-merged-branches

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

FAQPage Schema
How do I safely delete merged Git branches without removing active work?

To safely delete merged Git branches, the skill identifies only branches fully merged into the base branch (main/master) and blocks deletion of unmerged branches or those with open pull requests. This prevents accidental loss of active development work.

What is the best way to clean up merged local and remote Git branches in bulk?

The best way to clean up merged branches in bulk is using an automated skill that targets all eligible merged branches while enforcing strict safety gates. It verifies commit reachability and protects branches with open pull requests on both local and remote origins.

Do I need the GitHub CLI to verify open pull requests before branch cleanup?

You do not strictly need the GitHub CLI for branch cleanup, as the skill includes fallback rules when the CLI is unavailable. However, using the GitHub CLI provides strict open pull request state checks to prevent accidental data loss.

Can I use this to clean up Git branches tied to open pull requests?

You cannot use this to clean up Git branches tied to open pull requests. The skill enforces strict safety guardrails that explicitly block the deletion of branches with open pull requests to prevent broken team workflows and lost code.

Why does manual Git branch cleanup risk deleting unmerged feature branches?

Manual Git branch cleanup risks deleting unmerged feature branches because it lacks automated safety gates for commit reachability verification and base branch protection. Automated deletion applies strict checks to avoid targeting active work.