clean-gone-branches

Delete local git branches with gone remotes after verifying merge status via gh CLI.

5|3|Updated Jun 18, 2024
One-click install
npx skills add https://github.com/Unique-AG/ai --skill clean-gone-branches-unique-ag
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: clean-gone-branches
Source: https://github.com/Unique-AG/ai/tree/main/.claude/skills/clean-gone-branches
Command: npx skills add https://github.com/Unique-AG/ai --skill clean-gone-branches-unique-ag

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Delete local git branches whose remotes are gone, after verifying via gh CLI that each was actually merged.

Core Features & Use Cases

  • Fetch remote state with git fetch --prune and detect local branches with gone remotes.
  • Verify each candidate's merge status via gh pr list to ensure safe deletion.
  • Present a summary and require explicit confirmation before performing deletion with git branch -D.
  • Use during post-release cleanups or repo transitions to keep workspace tidy.

Quick Start

Run the cleanup workflow to safely remove local branches whose remotes are gone after confirming they were merged.

Frequently Asked Questions about clean-gone-branches

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

FAQPage Schema
How do I safely delete local git branches after their remotes are gone?

You can safely delete local git branches with gone remotes by first running git fetch --prune to update remote tracking status, then verifying each branch was actually merged via gh pr list before forcing deletion with git branch -D.

What does git branch -vv [gone] mean and how do I clean up those branches?

The [gone] marker in git branch -vv indicates a local branch's remote tracking reference has been deleted. To clean them up, you verify their merge status through the gh CLI and then execute a forced branch deletion.

Do I need the gh CLI to remove orphaned local branches after a sprint release?

Yes, you need the gh CLI to verify merge status for each candidate branch before deletion. The gh pr list command validates that orphaned branches were actually merged, preventing accidental loss of unmerged work.

Is there a way to confirm which local branches will be deleted before removing them?

The cleanup workflow presents a summary of all detected orphaned branches and requires explicit confirmation before performing any deletion with git branch -D, ensuring you review candidates first.

Can I use this orphaned branch cleanup during repository transitions or post-release?

Yes, this workflow is designed for post-release cleanups and repo transitions to keep your workspace tidy by safely removing local branches whose remotes are gone after confirming their merge status.

Why should I verify merge status before deleting git branches with gone remotes?

Verifying merge status via gh pr list before deleting git branches with gone remotes ensures no unmerged work is lost, because the [gone] status only indicates the remote was deleted, not that the code was merged.