agentsclimarketplace

Clean gone branches

Skill dceoy/ai-coding-agent-skills/skills/clean-gone-branches

Agent skills for AI coders

Install
npx -y skills add dceoy/ai-coding-agent-skills --skill clean-gone-branches

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 2 stars2 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

Clean up all git branches marked as [gone] (branches deleted on the remote but still existing locally), including removing associated worktrees.

SKILL.md

2.3 KB, as published. Nobody here has run it

Clean Gone Branches Skill

Remove stale local branches that have been deleted from the remote repository, along with any associated worktrees.

When to Use

  • After merging and deleting remote branches, to clean up local tracking branches.
  • When git branch -v shows branches marked as [gone].
  • Periodic local repository maintenance.

Agent Compatibility

This skill is tool-agnostic and can be executed by Claude Code, Codex CLI, or Cursor CLI.

Inputs

  • None required. The skill operates on the current git repository.

Before deleting anything, inspect the branch list and worktree list so the user can understand what will be removed.

Workflow

  1. List branches to identify any with [gone] status:

    git branch -v
    

    Branches with a + prefix have associated worktrees and must have their worktrees removed before deletion.

  2. List worktrees that may need removal for [gone] branches:

    git worktree list
    
  3. Remove worktrees and delete [gone] branches. Strip leading +, *, or spaces from git branch -v output before extracting branch names:

    git branch -v | grep '\[gone\]' | sed 's/^[+* ]//' | awk '{print $1}' | while read branch; do
      echo "Processing branch: $branch"
      worktree=$(git worktree list | grep "\\[$branch\\]" | awk '{print $1}')
      if [ -n "$worktree" ] && [ "$worktree" != "$(git rev-parse --show-toplevel)" ]; then
        echo "  Removing worktree: $worktree"
        git worktree remove --force "$worktree"
      fi
      echo "  Deleting branch: $branch"
      git branch -D "$branch"
    done
    
  4. Report results: List which worktrees and branches were removed. If no branches are marked as [gone], report that no cleanup was needed.

Safety Notes

  • Do not delete the current branch.
  • Do not remove the repository's main worktree.
  • Only delete branches shown by git branch -v as [gone]; do not infer stale branches by name.

Outputs

  • Console output listing removed worktrees and deleted branches.
  • If no [gone] branches exist, a message indicating no cleanup was needed.

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.