refactor(cli)!: rename all skills and agents to consistent ce- prefix (#503)
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
---
|
||||
name: ce-clean-gone-branches
|
||||
description: 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.
|
||||
---
|
||||
|
||||
# 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
|
||||
bash scripts/clean-gone
|
||||
```
|
||||
|
||||
[scripts/clean-gone](./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., `AskUserQuestion` in Claude Code, `request_user_input` in Codex, `ask_user` in Gemini). 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:
|
||||
|
||||
1. Check if it has an associated worktree (`git worktree list | grep "\\[$branch\\]"`)
|
||||
2. If a worktree exists and is not the main repo root, remove it first: `git worktree remove --force "$worktree_path"`
|
||||
3. 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.
|
||||
@@ -0,0 +1,48 @@
|
||||
#!/usr/bin/env bash
|
||||
# clean-gone: List local branches whose remote tracking branch is gone.
|
||||
# Outputs one branch name per line, or nothing if none found.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# Ensure we have current remote state
|
||||
git fetch --prune 2>/dev/null
|
||||
|
||||
# Find branches marked [gone] in tracking info.
|
||||
# `git branch -vv` output format:
|
||||
# * main abc1234 [origin/main] commit msg
|
||||
# + feature-x def5678 [origin/feature-x: gone] commit msg
|
||||
# old-branch 789abcd [origin/old-branch: gone] commit msg
|
||||
#
|
||||
# The leading column can be: ' ' (normal), '*' (current), '+' (worktree).
|
||||
# We match lines containing ": gone]" to find branches whose remote is deleted.
|
||||
|
||||
gone_branches=()
|
||||
|
||||
while IFS= read -r line; do
|
||||
# Skip the currently checked-out branch (marked with '*').
|
||||
# git branch -D cannot delete the active branch, and attempting it
|
||||
# would halt cleanup before other stale branches are processed.
|
||||
if [[ "$line" =~ ^\* ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
# Strip the leading marker character(s) and whitespace
|
||||
# The branch name is the first non-whitespace token after the marker
|
||||
branch_name=$(echo "$line" | sed 's/^[+* ]*//' | awk '{print $1}')
|
||||
|
||||
# Validate: skip empty, skip if it looks like a hash or flag, skip HEAD
|
||||
if [[ -z "$branch_name" ]] || [[ "$branch_name" =~ ^[0-9a-f]{7,}$ ]] || [[ "$branch_name" == "HEAD" ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
gone_branches+=("$branch_name")
|
||||
done < <(git branch -vv 2>/dev/null | grep ': gone]')
|
||||
|
||||
if [[ ${#gone_branches[@]} -eq 0 ]]; then
|
||||
echo "__NONE__"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
for branch in "${gone_branches[@]}"; do
|
||||
echo "$branch"
|
||||
done
|
||||
Reference in New Issue
Block a user