# Clean Gone Branches

> This skill should be used when user asks to "clean gone branches", "remove deleted local branches", "prune branches removed from remote", or explicitly invokes "clean-gone-branches".

- Skill: `majiayu000/clean-gone-branches-2` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds add majiayu000/clean-gone-branches-2`
- Raw SKILL.md: https://api.skillmd.com/api/skills/majiayu000/clean-gone-branches-2/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: majiayu000 (https://skillmd.com/u/majiayu000)
- Updated: 2026-09-09
- Page: https://skillmd.com/skills/majiayu000/clean-gone-branches-2

---


# Clean Gone Branches

Remove local git branches that have been deleted from the remote.

## Process

1. **Update remote references**
   - Run `git fetch --prune`.

2. **Inspect local state**
   - Run `git branch -vv` to find branches marked as `[gone]`.
   - Run `git worktree list` to see whether any of those branches still have worktrees.

3. **Remove worktrees first**
   - For each `[gone]` branch that still has a worktree, remove the worktree before deleting the branch.

4. **Delete the gone branches**
   - Delete each local branch marked as `[gone]`.

5. **Report the result**
   - List removed worktrees and deleted branches.
   - If there are no `[gone]` branches, report that nothing needed cleanup.

