Skip to content
Back to skills

Git Prune Branches

ASecurity

Delete merged git branches — local, remote, or both. Use when the user says 'prune branches', 'clean up branches', 'delete merged branches', or stale branches pile up after a round of PR merges.

  • 12 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added September 27, 2026
developmentgit

Security analysis

A100/100

Scanned September 27, 2026

npx -y skills add Takazudo/claude-resources --skill git-prune-branches --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Git Prune Branches?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Git Prune Branches
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/takazudo-git-prune-branches/badge)](https://www.skillsdirectory.com/skills/takazudo-git-prune-branches)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: git-prune-branches
description: "Delete merged git branches — local, remote, or both. Use when the user says 'prune branches', 'clean up branches', 'delete merged branches', or stale branches pile up after a round of PR merges."
argument-hint: "[local|remote|both]"
---

# Git Prune Branches

Scope comes from `$ARGUMENTS`: `local`, `remote`, or `both`. If no scope is given, ask with AskUserQuestion (options: both, local, remote) — do not guess.

## Collect candidates

- **Local**: `git branch --merged <main>` — branches merged into the main branch.
- **Remote**: `git fetch --prune` first, then `git branch -r --merged origin/<main>`.

Never delete:

- The currently checked-out branch
- Protected branches: `main`, `master`, `develop`, `development`, `staging`, `production`
- Branches that are not fully merged (unless the user explicitly asks)

## Confirm, then delete

1. Show the deletion list, local and remote separately.
2. Ask for confirmation and wait for a yes. Remote deletion affects every user of the repo and is not easily undone — never skip this.
3. Delete with `git branch -d <branch>` (never `-D`, so unmerged branches are refused) and `git push origin --delete <branch>`.
4. Report what was deleted and anything that failed.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.