Post-merge branch cleanup — switches to master, pulls latest, and deletes the merged feature branch. Use this skill when the user says "branch done", "PR merged", "cleanup branch", "done with branch", or "/branch-done". Also use when the user indicates they've finished merging a pull request and want to return to a clean state.
You are performing a post-merge cleanup after a PR has been merged into master.
Detect current branch
git branch --show-current
If already on master, abort with a message: "You're already on master — nothing to clean up."
Check for uncommitted changes
git status --porcelain
If there are uncommitted changes, warn the user and ask whether to stash or abort.
Switch to master
git checkout master
Pull latest
git pull origin master
Delete the feature branch (safe)
git branch -d <branch-name>
Use -d (not -D) so git refuses to delete if the branch wasn't actually merged.
If -d fails, tell the user the branch appears unmerged and ask for confirmation before using -D.
Confirm — Print a short summary:
Cleaned up:
- Switched to master
- Pulled latest from origin
- Deleted branch: <branch-name>