git-clean-branches

Identifies and deletes merged or stale Git branches after user confirmation.

1|Updated Sep 11, 2026
One-click install
npx skills add https://github.com/lldwb/lldwb-claude-skills --skill git-clean-branches-lldwb
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: git-clean-branches
Source: https://github.com/lldwb/lldwb-claude-skills/tree/main/skills/git-clean-branches
Command: npx skills add https://github.com/lldwb/lldwb-claude-skills --skill git-clean-branches-lldwb

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Over time Git repositories accumulate dozens of merged or abandoned branches, making branch lists noisy and hard to navigate. Manually checking which branches are safe to delete is tedious and error-prone, and a wrong deletion can destroy unmerged work. ## Core Features & Use Cases - Read-only preview by default: Runs in dry-run mode first, listing branches merged into a base branch (e.g. main or release/v2.1) and branches stale beyond a configurable day threshold, then waits for explicit user confirmation before deleting anything. - Protected branch safeguards: Reads a configurable protection list from git config branch.cleanup.protected (with wildcard support like release/*), never deletes unmerged branches unless --force is explicitly confirmed per branch, and requires separate confirmation for remote branch deletion. - Use Case: After a release cycle, ask to clean up all feature branches already merged into release/v2.1 plus any local branches untouched for 90 days; review the two-section report, confirm, and have local and remote branches deleted one by one with per-branch results. ## Quick Start Ask the assistant to clean up Git branches that are already merged into main and have not been touched in 90 days, starting with a dry-run preview before any deletion.

Frequently Asked Questions about git-clean-branches

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

FAQPage Schema
How do I delete Git branches that are already merged?

Run the cleanup with a base branch such as main; it lists branches from `git branch --merged <base>` in a dry-run preview first. After you confirm the list, each branch is deleted locally with `git branch -d` and results are reported per branch.

How to find and remove stale Git branches older than 90 days?

Use the stale threshold option, which scans `git for-each-ref` by committer date and lists branches whose last commit exceeds the given number of days. The stale list is shown separately from merged branches and is only deleted after your confirmation.

Can I protect certain branches like develop or release from deletion?

Yes, register protected patterns with `git config --add branch.cleanup.protected`, supporting wildcards like `release/*`. Without configuration, a default list protects HEAD, main, master, develop, and release/* from any deletion.

Does it delete remote branches on origin as well?

Remote deletion is opt-in via the remote flag and requires explicit user request, since it affects collaborators. Remote branches are listed in a separate section and removed with `git push origin --delete`, with success or failure reported per branch.

What happens if a branch is not fully merged or is used by a worktree?

Unmerged branches are never deleted by default because `git branch -d` refuses them; forced deletion with `-D` requires explicit per-branch confirmation. Branches occupied by a worktree are reported as failures with a suggestion to handle them via worktree tooling instead.