git-clean-gone-branches
Automates the removal of stale local branches that no longer exist on the remote server.
Install
mkdir -p .claude/skills/git-clean-gone-branches && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/16615" && unzip -o skill.zip -d .claude/skills/git-clean-gone-branches && rm skill.zipInstalls to .claude/skills/git-clean-gone-branches
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Clean up local branches whose remote tracking branch is gone. Use when the user says "clean up branches", "delete gone branches", "prune local branches", "clean gone", or wants to remove stale local branches that no longer exist on the remote. Also handles removing associated worktrees for branches that have them.Key capabilities
- →Discover local branches with gone remote tracking branches
- →Present a list of gone branches for user confirmation
- →Delete confirmed local branches
- →Remove associated worktrees for deleted branches
- →Report deleted branches and worktrees
How it works
This skill fetches the latest remote state, identifies local branches whose remote tracking branches are gone, and then, after user confirmation, deletes them along with any associated worktrees.
Inputs & outputs
When to use git-clean-gone-branches
- →prune stale local git branches
- →clean up deleted feature branches
- →remove abandoned experiment branches
About this skill
Clean Gone Branches
Delete local branches whose remote tracking branch has been deleted, including any associated worktrees.
Workflow
Step 1: Discover gone branches
Run the discovery script to fetch the latest remote state and identify gone branches:
bash scripts/clean-gone
The script runs git fetch --prune first, then parses git branch -vv for branches marked : gone].
If the script outputs __NONE__, report that no stale branches were found and stop.
Step 2: Present branches and ask for confirmation
Show the user the list of branches that will be deleted. Format as a simple list:
These local branches have been deleted from the remote:
- feature/old-thing
- bugfix/resolved-issue
- experiment/abandoned
Delete all of them? (y/n)
Wait for the user's answer using the platform's question tool (e.g., ask_user in Copilot CLI). If no question tool is available, present the list and wait for the user's reply before proceeding.
This is a yes-or-no decision on the entire list -- do not offer multi-selection or per-branch choices.
Step 3: Delete confirmed branches
If the user confirms, delete each branch. For each branch:
- Check if it has an associated worktree (
git worktree list | grep "\\[$branch\\]") - If a worktree exists and is not the main repo root, remove it first:
git worktree remove --force "$worktree_path" - Delete the branch:
git branch -D "$branch"
Report results as you go:
Removed worktree: .worktrees/feature/old-thing
Deleted branch: feature/old-thing
Deleted branch: bugfix/resolved-issue
Deleted branch: experiment/abandoned
Cleaned up 3 branches.
If the user declines, acknowledge and stop without deleting anything.
When not to use it
- →When the user wants to delete specific branches manually
- →When the user wants to keep local branches even if remote is gone
Limitations
- →The skill requires user confirmation for deletion.
- →The skill only deletes branches whose remote tracking branch is gone.
How it compares
This skill automates the identification and deletion of stale local branches and their worktrees, unlike manually checking and deleting each one.
Compared to similar skills
git-clean-gone-branches side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| git-clean-gone-branches (this skill) | 0 | 3mo | Review | Beginner |
| resolve-conflicts | 81 | 8mo | Review | Intermediate |
| openspec-onboard | 10 | 6mo | Review | Beginner |
| codex-cli-bridge | 9 | 9mo | Review | Intermediate |
Try saying
Example prompts that trigger this skill in your AI assistant.
More by All-The-Vibes
View all by All-The-Vibes →You might also like
resolve-conflicts
antinomyhq
Use this skill immediately when the user mentions merge conflicts that need to be resolved. Do not attempt to resolve conflicts directly - invoke this skill first. This skill specializes in providing a structured framework for merging imports, tests, lock files (regeneration), configuration files, and handling deleted-but-modified files with backup and analysis.
openspec-onboard
studyzy
Guided onboarding for OpenSpec - walk through a complete workflow cycle with narration and real codebase work.
codex-cli-bridge
alirezarezvani
Bridge between Claude Code and OpenAI Codex CLI - generates AGENTS.md from CLAUDE.md, provides Codex CLI execution helpers, and enables seamless interoperability between both tools
skill-sync
KyleKing
Syncs Claude Skills with other AI coding tools like Cursor, Copilot, and Codeium by creating cross-references and shared knowledge bases. Invoke when user wants to leverage skills across multiple tools or create unified AI context.
github-workflow-automation
ruvnet
Advanced GitHub Actions workflow automation with AI swarm coordination, intelligent CI/CD pipelines, and comprehensive repository management
git-advanced-workflows
wshobson
Master advanced Git workflows including rebasing, cherry-picking, bisect, worktrees, and reflog to maintain clean history and recover from any situation. Use when managing complex Git histories, collaborating on feature branches, or troubleshooting repository issues.