Branch cleanup

From berkcangumusisik/claude-code-practices · View interactive version

Branch cleanup is an AI agent skill from the GitHub repository berkcangumusisik/claude-code-practices. Lists and removes stale local and remote branches that have been merged

How to use this skill

Skill file

Branch Cleanup

  1. Show current state:
git branch -vv
git branch --merged main 2>/dev/null || git branch --merged master
  1. List candidates for deletion:
  1. Show the list to the user with what would be deleted. Ask for confirmation before deleting anything.
  1. On confirmation:
# Delete merged local branches (never delete main/master/develop/staging)
git branch --merged main | grep -vE '^\*|main|master|develop|staging' | xargs -r git branch -d
  1. Report what was deleted and what was skipped.
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.