# Clean All

> Delete all non-main branches (local + remote) and prune stale refs

- Skill: `majiayu000/clean-all` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds add majiayu000/clean-all`
- Raw SKILL.md: https://api.skillmd.com/api/skills/majiayu000/clean-all/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-all

---

Clean up all branches except main, locally and remotely.

1. Run `git remote prune origin` to remove stale remote tracking refs.
2. Delete all local branches except `main`: `git branch | grep -v "main" | xargs git branch -D`
3. Delete all remote branches except `main`: `git branch -r | grep -v "origin/main\|origin/HEAD" | sed 's|origin/||' | xargs -I{} git push origin --delete {}`
4. Remove any `.claude/worktrees/*` directories: `git worktree remove` each, then delete leftover empty dirs.
5. Verify with `git branch -a` and `ls .claude/worktrees/` — only `main` should remain.
6. Report summary: how many local branches, remote branches, and worktrees were cleaned up.

If everything is already clean, just say so.

