git-clean-gone-branches

Identify and remove local git branches with deleted remote tracking branches.

Updated Apr 22, 2026
One-click install
npx skills add https://github.com/yxc023/agent-config-studio --skill git-clean-gone-branches-yxc023
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: git-clean-gone-branches
Source: https://github.com/yxc023/agent-config-studio/tree/main/.opencode/skills/git-clean-gone-branches
Command: npx skills add https://github.com/yxc023/agent-config-studio --skill git-clean-gone-branches-yxc023

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve?

Identifies local git branches whose remote tracking branches have been deleted, and cleans them up to reduce repository clutter.

Core Features & Use Cases

  • Detects local branches with gone remotes and lists them for review.
  • Removes associated worktrees before deleting branches to ensure a clean state.
  • Provides a safe confirmation step to prevent accidental data loss in shared repositories.

Quick Start

Run the skill to identify and remove all local branches whose remote tracking branches are gone, including any related worktrees.

Frequently Asked Questions about git-clean-gone-branches

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I clean local git branches whose remote tracking branches are gone?

To clean gone git branches, run git fetch --prune to discover stale remote tracking references, list the local branches for review, and safely remove them after a confirmation prompt. Associated worktrees are removed before branch deletion to ensure a clean state.

What is the safest way to delete stale git worktrees and branches together?

The safest way to delete stale git worktrees and branches is to use a confirmation step that prevents accidental data loss, removing any associated worktrees first before deleting the local branches to maintain repository integrity.

How does git fetch --prune help with stale branch cleanup?

Git fetch --prune performs discovery by syncing remote tracking references, allowing the cleanup process to accurately identify and list local git branches whose remote counterparts have been deleted and are ready for safe removal.

Can I automate stale branch cleanup across multiple workspaces?

Yes, you can automate stale branch cleanup across multiple workspaces by running this skill in automation scripts, which handles discovering gone branches and removing them along with their associated worktrees safely.

Why do I need a confirmation step when removing gone git branches?

A confirmation step is needed when removing gone git branches to prevent accidental data loss in shared repositories, ensuring you review the list of stale local branches before approving their deletion.

Does stale branch cleanup work for onboarding workflows with accumulated branches?

Stale branch cleanup works for onboarding workflows by removing local git branches whose remote tracking branches have been deleted, reducing repository clutter when new workspaces accumulate stale branches.