monkey1sai

claude-command-commit-commands-clean-gone

Converted from Claude plugin command "clean_gone" (commit-commands).

monkey1sai 2 Updated 3mo ago
GitHub

Install

npx skillscat add monkey1sai/openai-cli/claude-command-commit-commands-clean-gone

Install via the SkillsCat registry.

SKILL.md

Claude Command (Imported): clean_gone

  • Source: C:\Users\monke\.claude\plugins\cache\claude-plugins-official\commit-commands\2cd88e7947b7\commands\clean_gone.md
  • Plugin: commit-commands
  • Version: 2cd88e7947b7

Notes

  • Claude command files may use ! prefixes for shell execution. In Codex, run those commands in the terminal manually.

Original Command Frontmatter (Reference)

description: Cleans up all git branches marked as [gone] (branches that have been deleted on the remote but still exist locally), including removing associated worktrees.

Original Command Body

Your Task

You need to execute the following bash commands to clean up stale local branches that have been deleted from the remote repository.

Commands to Execute

  1. First, list branches to identify any with [gone] status
    Execute this command:

    git branch -v

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

  2. Next, identify worktrees that need to be removed for [gone] branches
    Execute this command:

    git worktree list
  3. Finally, remove worktrees and delete [gone] branches (handles both regular and worktree branches)
    Execute this command:

    # Process all [gone] branches, removing '+' prefix if present
    git branch -v | grep '\[gone\]' | sed 's/^[+* ]//' | awk '{print $1}' | while read branch; do
      echo "Processing branch: $branch"
      # Find and remove worktree if it exists
      worktree=$(git worktree list | grep "\\[$branch\\]" | awk '{print $1}')
      if [ ! -z "$worktree" ] && [ "$worktree" != "$(git rev-parse --show-toplevel)" ]; then
        echo "  Removing worktree: $worktree"
        git worktree remove --force "$worktree"
      fi
      # Delete the branch
      echo "  Deleting branch: $branch"
      git branch -D "$branch"
    done

Expected Behavior

After executing these commands, you will:

  • See a list of all local branches with their status
  • Identify and remove any worktrees associated with [gone] branches
  • Delete all branches marked as [gone]
  • Provide feedback on which worktrees and branches were removed

If no branches are marked as [gone], report that no cleanup was needed.