home / skills / codyswanngt / lisa / git-prune
This skill prunes local git branches that track deleted remotes by safely previewing, deleting only merged branches, and reporting results.
npx playbooks add skill codyswanngt/lisa --skill git-pruneReview the files below or copy the command above to add this skill to your agents.
---
name: git-prune
description: This skill should be used when pruning local branches that have been deleted on the remote. It fetches remote changes, identifies stale local branches, and safely deletes them.
allowed-tools: ["Bash"]
---
# Git Prune Local Branches
Remove local branches whose upstream tracking branches have been deleted on remote.
## Workflow
### Fetch and prune remote-tracking references
!git fetch --prune
### Find and delete stale local branches
!git branch -vv | grep ': gone]' | awk '{print $1}'
### Apply these requirements
1. **Preview**: Show which branches will be deleted before deleting
2. **Safe Delete**: Use `-d` (safe delete) which refuses to delete unmerged branches
3. **Report**: Show summary of deleted branches
### Never
- Force delete (`-D`) without user confirmation
- Delete the current branch
- Delete protected branches (dev, staging, main)
## Execute
Execute the workflow now.
This skill helps safely prune local Git branches that track remote branches removed on the remote. It fetches remote updates, identifies local branches whose upstreams are gone, previews them, and performs safe deletions while protecting important branches. The skill reports what was deleted and preserves unmerged work.
First it runs git fetch --prune to update remote-tracking refs. Then it scans local branches with git branch -vv to find entries marked ': gone]' and lists those branch names. It prompts for a preview, deletes branches using git branch -d (safe delete) while skipping the current branch and protected names, and finally prints a summary of deleted and retained branches.
Will this delete branches with unmerged commits?
No. The skill uses safe delete (git branch -d) which refuses to delete branches that contain commits not merged into the configured upstream or HEAD.
How does it protect important branches?
It skips deletion for the current branch and for configured protected names such as dev, staging, and main. You can extend the protected list before running if you need more safeguards.