automation
Clean Up Gone Git Branches with clean-gone Skill
Teach your AI agent to safely delete stale Git branches and worktrees after PR merges with clean-gone.
Where this fits
You've just merged three PRs. Locally, your branch list is littered with [gone] branches no longer on the remote, plus worktrees attached to them. Instead of manually checking git status and deleting each, tell your agent: "clean up branches that are gone on the remote." That is the gap clean-gone fills: a safe-by-default Git hygiene routine for agents.
Why agents benefit
- It separates dry runs from destructive action: the agent can call with
--dry-runand show a plan before asking for confirmation. - It checks for unmerged commits and uncommitted work before deleting, so the agent won't recommend deletion when it would lose data.
- It handles worktrees attached to gone branches, not just branch refs; many cleanup scripts miss that.
- It constrains allowed tools to read-only Git operations plus
AskUserQuestion, keeping the agent inside a predictable permission envelope. - It gives agents an explicit confirmation protocol, reducing risk when run inside automated workflows.
Practical scenarios
After a PR merge wave
The agent scans all local branches, identifies those whose upstream is [gone], presents a dry-run list, then deletes only branches with no unmerged commits and no attached worktrees after the user confirms.
Before starting fresh work
The developer wants a clean branch list. The agent prunes gone branches and removes associated worktrees, then reports which branches remain and their upstream status.
Recovering from remote branch deletion
A teammate deleted a remote branch that still has unmerged local commits. The agent detects the divergence, warns the user, and asks whether to keep or force-delete instead of assuming.
Add it to your agent workflow
Install with npx:
npx skills add rlajous/claude-code-commands --skill clean-gone
Then invoke it conversationally:
User: Clean up branches that are gone on the remote.
Agent: Running dry-run first...
Removed if confirmed:
feature/old-login (gone, no unmerged commits)
fix/sidebar (gone, worktree attached)
Proceed? [Yes / No]
Compare before adopting
Before adopting, look at how long the repository has been maintained, whether issues are addressed, and whether current Git versions are supported. Compare with generic git fetch --prune plus manual deletion: clean-gone remains useful because it also removes worktrees and asks for confirmation. Check the allowed-tools list against your agent runtime, and decide whether you want agent-initiated destructive Git cleanup or only user-invoked mode.
Why it is worth tracking
This skill has more than 30 stars on GitHub, and its author positions it as part of a broader command set for Claude Code and compatible runtimes. It is worth tracking because its safety-first design aligns with how teams want agents to handle destructive operations: show a plan, ask for consent, act only within a narrow tool scope. As Git worktree usage grows, a skill that cleans refs and attached worktrees in one pass becomes more valuable; evaluate it again when your team expands agent automation to daily repo maintenance. For a snapshot of its quality signals, see the skill page at https://www.openagentskill.com/skills/rlajous-clean-gone.
Featured Skill
clean-gone
Skill by rlajous