Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

caro.prune

БесплатноЗапускает вложенные скриптыНе проверен

Safely reclaim disk space in the caro project. Cleans Rust build cache, stale git worktrees (both .claude/worktrees/ and .worktrees/), empty stubs, and…

wildcardот wildcard★ 41 звезда на GitHub

Об этом скилле

caro.prune Skill

Purpose: Reclaim disk space without losing any work. Caro's worktree-heavy workflow + Rust build caches grow the repo to 100 GB+ within weeks of active development. This skill turns that back into ~5–15 GB while preserving every worktree that has dirty files, an unpushed branch, or a locked flag.

Codified from: the 2026-05-16 cleanup pass that reduced the project from 101 GB → 18 GB in ~5 min by removing 53 stale worktrees + the entire target/ cache.


When to Use

  • du -sh . shows the project > 30 GB
  • df -h . shows < 100 GB free on the volume
  • Before a long session where the repo will be growing (releases, big refactors)
  • After finishing a multi-week sprint with many merged PRs (their worktrees linger)
  • Periodic hygiene — once a month is a good cadence

When NOT to Use

  • Mid-build (cargo build running) — Tier 1 will wipe the cache out from under it
  • Right before a benchmark run — you want the warm cache
  • If git worktree list shows < 10 worktrees — not enough fat to be worth the audit
  • On a worktree branch that isn't main and isn't your own — leave the parent alone

Safety Invariants

The skill never removes:

  1. A worktree marked locked (held by another session, cua-driver, etc.)
  2. A worktree with any uncommitted changes (git status --porcelain non-empty)
  3. A worktree whose HEAD is not reachable from origin/main AND not contained in any remote branch (i.e. work that exists nowhere else)
  4. The main checkout at /Users/kobik-private/workspace/caro
  5. Files outside the project root

If you want to remove a flagged worktree anyway, do it manually after verifying with the user — never extend the heuristic to be more aggressive.


The Five Tiers

Tier 1 — cargo clean (~60–70 GB, zero audit, 1 cmd)

cargo clean

Rebuild after: cargo build takes ~3–5 min for debug, ~5–8 min for release on M-series Apple Silicon.

Tier 2 — Prune .claude/worktrees/ (~15–18 GB)

These are ephemeral session worktrees from Claude Code's worktree integration. Most are named claude/<adjective-name-hash> and tied to merged or pushed branches. Run the audit script in scripts/audit_worktrees.sh (below) targeting .claude/worktrees/.

Tier 3 — Prune .worktrees/ (~7–10 GB)

Feature/PR worktrees. Same audit, different path. Watch for nested worktrees under .worktrees/pr_review/<N>/ — they're listed as .worktrees/<N> by basename but actually live one level deeper.

Tier 4 — Empty stubs (0 GB, cosmetic)

find .worktrees -maxdepth 1 -type d -empty -not -path .worktrees -exec rmdir {} +

Leftover empty dirs from previous git worktree remove calls.

Tier 5 — node_modules/ (~1 GB)

rm -rf node_modules        # reinstall with `pnpm install` when needed

The Audit Heuristic (run this before any worktree removal)

Save the following as /tmp/audit_wts.sh or paste into Bash directly. It takes the worktree root (.claude/worktrees or .worktrees) as $1 and writes two files:

  • /tmp/wts_safe.txt — pipe-delimited list of worktrees safe to remove
  • /tmp/wts_keep.txt — flagged for user review (dirty / unmerged / locked)
WT_ROOT="${1:?usage: audit_wts.sh <worktree-root>}"
MAIN=$(git rev-parse origin/main)

git worktree list --porcelain \
  | awk '/^worktree/ {wt=$2}
         /^branch/   {br=$2}
         /^detached/ {br="DETACHED"}
         /^locked/   {locked=1}
         /^$/        {print wt"|"br"|"locked; wt=""; br=""; locked=0}
         END         {if(wt) print wt"|"br"|"locked}' \
  | grep "/${WT_ROOT}/" > /tmp/wts_list.txt

: > /tmp/wts_safe.txt
: > /tmp/wts_keep.txt

while IFS='|' read -r wt br locked; do
  name=$(basename "$wt")
  if [ "$locked" = "1" ]; then
    echo "LOCKED|$name|$br" >> /tmp/wts_keep.txt
    continue
  fi
  br_short=${br#refs/heads/}
  dirty=$(git -C "$wt" status --porcelain 2>/dev/null | wc -l | tr -d ' ')
  head=$(git -C "$wt" rev-parse HEAD 2>/dev/null)
  merged="no"
  git merge-base --is-ancestor "$head" "$MAIN" 2>/dev/null && merged="yes"
  on_remote=$(git branch -r --contains "$head" 2>/dev/null | head -1 | tr -d ' ')
  size=$(du -sh "$wt" 2>/dev/null | cut -f1)

  if [ "$dirty" = "0" ] && { [ "$merged" = "yes" ] || [ -n "$on_remote" ]; }; then
    echo "$size|$name|$br_short|merged=$merged|remote=$on_remote" >> /tmp/wts_safe.txt
  else
    echo "size=$size dirty=$dirty merged=$merged remote=$on_remote | $name | $br_short" >> /tmp/wts_keep.txt
  fi
done < /tmp/wts_list.txt

echo "=== SAFE TO REMOVE ($(wc -l < /tmp/wts_safe.txt)) ==="
cat /tmp/wts_safe.txt
echo
echo "=== KEEP/REVIEW ($(wc -l < /tmp/wts_keep.txt)) ==="
cat /tmp/wts_keep.txt

Execute removal (after reviewing /tmp/wts_safe.txt)

while IFS='|' read -r size name br merged remote; do
  # try the literal path; if that fails, try nested (pr_review/N)
  for wt in "$WT_ROOT/$name" "$WT_ROOT/pr_review/$name"; do
    if [ -d "$wt" ] &&
Полный SKILL.md на GitHub

Установить caro.prune в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

audit_wts.shremove_safe.sh

FAQ

Что делает скилл caro.prune?

Safely reclaim disk space in the caro project. Cleans Rust build cache, stale git worktrees (both .claude/worktrees/ and .worktrees/), empty stubs, and node_modules using a tiered audit that preserves any worktree with uncommitted changes, missing remotes, or a lock file. Use when du shows the project > 30 GB or disk free is low.

Как установить скилл caro.prune?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл caro.prune запускает скрипты?

Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.

Похожие скиллы

Сравнить caro.prune с