Clean up both local and remote git branches that have been merged. Use when: (1) User says 'prune branches', 'clean up branches', or 'delete merged branches', (2) User wants to clean both local and remote branches at once, (3) After a round of PR merging when stale branches accumulate.
Scanned 9/8/2026
Install to Claude Code
npx -y skills add Takazudo/claude-resources --skill git-prune-branches-both --agent claude-codeInstalls into .claude/skills of the current project.
Are you the author of Git Prune Branches Both?
Add the live security badge to your README — it updates automatically with every re-scan.
[](https://www.skillsdirectory.com/skills/takazudo-git-prune-branches-both)More formats (shields.io, HTML) on the badges page.
---
name: git-prune-branches-both
description: >-
Clean up both local and remote git branches that have been merged. Use when: (1) User says 'prune
branches', 'clean up branches', or 'delete merged branches', (2) User wants to clean both local
and remote branches at once, (3) After a round of PR merging when stale branches accumulate.
---
# Git Prune Branches (Both Local and Remote)
Check and prune both local and remote branches that have been merged:
## Step 1: Prune Local Branches
1. Get the list of all local branches using `git branch`
2. For each branch, check if it has been merged using `git branch --merged`
3. Exclude protected branches (main, master, develop, etc.)
4. Create a list of local branches that are safe to delete
## Step 2: Prune Remote Branches
1. Fetch the latest remote information using `git fetch --prune`
2. Get the list of all remote branches using `git branch -r`
3. For each remote branch, check if it has been merged into the remote main branch
4. Exclude protected branches
5. Create a list of remote branches that are safe to delete
## Step 3: Confirm and Execute
1. Present both lists to the user clearly:
- Local branches to be deleted
- Remote branches to be deleted
2. Ask for confirmation: "The above local and remote branches will be deleted. Proceed? (yes/no)"
3. If user confirms with "yes" or similar affirmative response:
- Delete local branches using `git branch -d <branch-name>`
- Delete remote branches using `git push origin --delete <branch-name>`
4. Report the results for both operations
**Important:** Never delete:
- The currently checked out branch (for local)
- Protected branches: main, master, develop, development, staging, production
- Branches that are not fully merged (unless explicitly requested)
**Note:** Remote deletion affects the repository for all users and cannot be easily undone. Ensure user confirmation before proceeding.
Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.
No comments yet. Be the first to comment!