From theclauu
Clean up stale worktrees, merged branches, and dead remote tracking branches. Prompts before deleting.
npx claudepluginhub artemis-xyz/theclauu --plugin theclauuThis skill uses the workspace's default tool permissions.
Prune stale worktrees, merged local branches, and dead remote-tracking refs.
Generates design tokens/docs from CSS/Tailwind/styled-components codebases, audits visual consistency across 10 dimensions, detects AI slop in UI.
Records polished WebM UI demo videos of web apps using Playwright with cursor overlay, natural pacing, and three-phase scripting. Activates for demo, walkthrough, screen recording, or tutorial requests.
Delivers idiomatic Kotlin patterns for null safety, immutability, sealed classes, coroutines, Flows, extensions, DSL builders, and Gradle DSL. Use when writing, reviewing, refactoring, or designing Kotlin code.
Prune stale worktrees, merged local branches, and dead remote-tracking refs.
Run these steps sequentially, presenting findings to the user before any destructive action.
git worktree list
For each worktree (excluding the main working tree), check the last commit date:
git -C <worktree-path> log -1 --format="%ci %s" 2>/dev/null
Flag any worktree with no commits in the last 7 days as stale.
git branch --merged main | grep -v -E '^\*|main|master'
These branches are fully merged into main and safe to delete.
git fetch --prune origin
git branch -vv | grep ': gone]'
These track remote branches that no longer exist (already merged & deleted on GitHub).
gh pr list --author @me --state merged --limit 50 --json headRefName,number,title
Cross-reference with local branches.
TheClauu writes per-branch handoffs at ~/.claude/notes/projects/<slug>/context-resume/<branch-key>.md (v0.3.5+). When a branch is deleted, its handoff lingers forever unless cleaned.
Derive this project's slug:
REMOTE=$(git remote get-url origin 2>/dev/null)
if [ -n "$REMOTE" ]; then
# Extract org/repo from URL (handles https + ssh)
SLUG=$(echo "$REMOTE" | sed -E 's|.*github.com[:/]([^/]+/[^/.]+)(\.git)?$|\1|' | tr '/' '-' | tr '/' '-')
SLUG=$(echo "$REMOTE" | python3 -c "import sys, re; m = re.search(r'github\.com[:/]([^/]+)/([^/.]+)', sys.stdin.read()); print(f'{m.group(1)}--{m.group(2)}'.lower() if m else '')")
else
SLUG=$(basename "$(pwd)")
fi
HANDOFF_DIR="$HOME/.claude/notes/projects/$SLUG/context-resume"
Iterate handoffs and classify each:
[ -d "$HANDOFF_DIR" ] || exit 0
for f in "$HANDOFF_DIR"/*.md; do
[ -f "$f" ] || continue
name=$(basename "$f" .md)
# Skip synthetic keys — they're not branch-names and need manual handling
case "$name" in
_unknown|_detached-*) continue ;;
esac
# Reverse the sanitization: handoff filenames have / replaced with -. We can't perfectly reverse
# (a branch named "foo-bar" and "foo/bar" both sanitize to "foo-bar"). Compromise: check if the
# sanitized name matches any CURRENT local branch's sanitized form. If no match anywhere, it's stale.
exists=$(git branch --format="%(refname:short)" | while read b; do
sanitized=$(echo "$b" | tr '/' '-')
[ "$sanitized" = "$name" ] && echo "yes" && break
done)
[ -z "$exists" ] && echo "STALE_HANDOFF: $f"
done
A handoff is classified as stale when no current local branch sanitizes to its filename. Categories to flag in the summary:
gh pr list). Safe auto-propose.Present findings in the Step 5 summary table under a new "Stale handoff" row.
Show a summary table:
| Category | Branch/Worktree/Handoff | Last Activity | Action |
|---|---|---|---|
| Stale worktree | ... | ... | Remove? |
| Merged local | ... | ... | Delete? |
| Gone remote | ... | ... | Delete? |
| Stale handoff | <slug>/context-resume/<branch>.md | ... | Delete? |
CRITICAL: Remove worktrees BEFORE deleting their branches.
# Worktrees first
git worktree remove <path>
git worktree prune
# Then branches
git branch -d <branch>
# Prune remote refs
git remote prune origin
# Stale handoff files (only those the user confirmed)
rm "$HOME/.claude/notes/projects/<slug>/context-resume/<branch-key>.md"
Report what was cleaned up.
_detached-* or _unknown handoffs without explicit user prompt. Those aren't tied to a current branch and deletion risk is higher.<slug>/context-resume.md without the / subdir). It's the backward-compat fallback; if the user hasn't yet done a handoff on the current branch, they still depend on it.rm -rf the whole context-resume/ directory. Only the specific stale files the user confirmed.