cleanup-cache
Clean system caches (npm, Homebrew, Yarn, browsers, Python/ML) to free disk space
Clean up merged worktrees and their branches
$ npx -y skills add davila7/claude-code-templates --agent claude-codeHow it fires
How this command gets triggered: by you, by Claude, or both.
/worktree-cleanupContext preview
What this command does when you run it.
Clean up merged worktrees and their branches
allowed-tools: Bash(git:*), Bash(rm:*), Bash(ls:*), Bash(pwd:*), Bash(grep:*) argument-hint: --all | --branch claude/name | --dry-run description: Clean up merged worktrees and their branches
Remove worktrees and branches that have been merged: $ARGUMENTS
You are in the **main repository** (not a worktree). Clean up finished worktrees.
This project uses the following branch prefixes for worktrees:
All three prefixes must be checked in every step below.
1. Verify this is the main working tree (first entry in `git worktree list`) 2. If inside a worktree, warn: "Run `/worktree-cleanup` from the main repo, not from a worktree." 3. Fetch latest from origin: `git fetch origin --prune` 4. Get the main branch name (main or master)
Parse `$ARGUMENTS` for options:
1. List all worktrees: `git worktree list` 2. List all matching branches:
git branch --list 'claude/*' 'claude-daniel/*' 'review/*'
3. For each matching branch, check if it's been merged into main:
git branch --merged origin/<main-branch> | grep -E '^\s+(claude/|claude-daniel/|review/)'
4. Also check remote branches:
git branch -r --merged origin/<main-branch> | grep -E 'origin/(claude/|claude-daniel/|review/)'
5. For squash-merged branches (not detected by `--merged`), check if the branch diff is empty against main:
# A branch is effectively merged if its changes already exist in main git diff origin/main...<branch> --stat
If the diff is empty or very small (only whitespace), consider it merged.
Show a table of all worktrees/branches:
| # | Worktree | Branch | Merged? | Dirty? | Action | |---|---------|--------|---------|--------|--------| | 1 | eager-mendeleev | claude/eager-mendeleev | Yes | Clean | Will remove | | 2 | agent-a7e312d0 | review/code-reviewer-2026-04-01 | No | Clean | Skipped |
If `--dry-run` was specified, show the table and stop.
Otherwise, use AskUserQuestion to confirm cleanup (unless `--all` was specified with only merged branches).
For each worktree/branch to clean up:
1. Remove the worktree:
git worktree remove <path>
If that fails (dirty worktree), warn and skip — **never force-remove**.
2. Delete the local branch:
git branch -d <branch>
Use `-d` (not `-D`) for merged branches. For `--force-all` unmerged branches, use `-D` only after explicit user confirmation.
3. Delete the remote branch (if it exists):
git push origin --delete <branch>
If the remote branch doesn't exist, ignore the error silently.
After all removals:
git worktree prune
Show what was cleaned up:
Cleanup Complete ────────────────────────────────── Removed: <N> worktree(s) Deleted: <N> local branch(es) Deleted: <N> remote branch(es) Skipped: <N> unmerged branch(es) ──────────────────────────────────
If any unmerged branches were skipped, list them and suggest:
Ready-to-use configurations for Anthropic's Claude Code. A comprehensive collection of AI agents, custom commands, settings, hooks, external integrations (MCPs), and project templates to enhance your development workflow.
Repo: davila7/claude-code-templates
Clean system caches (npm, Homebrew, Yarn, browsers, Python/ML) to free disk space
Create an SEO-optimized blog article for a Claude Code component with AI-generated cover image