Skill
/hanzo-web:clean-worktrees
Fuente: plugins/hanzo-web/skills/clean-worktrees/SKILL.md · hanzo-web v0.2.0
Cuándo usarlo
Cuando se acumulan worktrees de tareas terminadas o el repositorio ocupa demasiado.
Qué hace
- Hace primero una simulación y te enseña qué worktrees borraría, cuáles conserva y por qué.
- Solo borra un worktree si su merge está en develop y no tiene cambios sin commitear.
- De los que conserva te explica el motivo, y pregunta antes de hacer nada a mano.
- Te dice cuánto espacio ha liberado y qué worktrees quedan.
Qué te entrega
Qué se ha borrado, qué se ha conservado y por qué, y el espacio liberado.
Pídelo así
/hanzo-web:clean-worktrees
O con tus palabras: «limpia worktrees», «borra los worktrees mergeados».
A tener en cuenta
También puede instalar una limpieza diaria automática en macOS (launchd), si la activaste en init y das tu permiso.
Definición en el plugin
Las instrucciones que sigue la skill, tal como están en el plugin (en inglés).
Qué hace
Cuándo usarlo
Paths:
${CLAUDE_PLUGIN_ROOT}is this plugin's folder (Claude Code expands it). If you see it literally (e.g. in Cursor), use the "Plugin scripts" path from the session context, or the plugin folder two levels above this skill (../../from the folder of thisSKILL.md).
Script: ${CLAUDE_PLUGIN_ROOT}/scripts/clean-merged-worktrees.sh --repo <main checkout> [--dry-run]. It reads git.develop, git.production and project.slug from <main>/.claude/hanzo-project.json and logs to ~/Library/Logs/hanzo-<slug>-worktree-cleanup.log.
- Preview with
--dry-run. Show the result in a short table: worktree → remove / keep (reason). - Run it without
--dry-run. It removes a worktree only iforigin/<develop>has itsMerge branch '<branch>' into '<develop>'commit (plus<production>forrelease/*), every touched file matches the merge, and only.DS_Storefiles are uncommitted. - For each kept worktree, explain why (uncommitted changes, commits not in develop, no merge commit — e.g. squashed or renamed MR) and ask before doing anything by hand (
git -C <wt> status --short,git cherry origin/<develop> <branch>, thengit worktree remove+git branch -D). Never discard uncommitted work without an explicit yes. git worktree prune, then report freed space (du -sh <config.worktrees.dir>before/after) and remaining worktrees.
Daily automatic cleanup (macOS, optional)
Install only if config.worktrees.dailyCleanup.enabled and the user agrees:
- Copy the script to a stable path (the plugin cache path changes on every update):
mkdir -p ~/.claude/hanzo-web && cp "${CLAUDE_PLUGIN_ROOT}/scripts/clean-merged-worktrees.sh" ~/.claude/hanzo-web/ && chmod +x ~/.claude/hanzo-web/clean-merged-worktrees.sh. - Fill
${CLAUDE_PLUGIN_ROOT}/templates/worktree-cleanup.plist({{SLUG}},{{SCRIPT}}= the stable copy,{{REPO}},{{HOME}},{{HOUR}}) into~/Library/LaunchAgents/com.hanzo.<slug>.worktree-cleanup.plist. launchctl bootstrap gui/$(id -u) <plist>; test withlaunchctl kickstart gui/$(id -u)/com.hanzo.<slug>.worktree-cleanupand read both logs.- If the repo is under
~/Documents,~/Desktopor~/Downloads, macOS blocks launchd from reading it (Operation not permittedin the launchd log). The user must grant Full Disk Access to/bin/bashthemselves (System Settings › Privacy & Security); explain that this applies to every bash script and let them decide. - Behaviour: asleep at the hour → runs on wake; powered off → skipped that day. Uninstall:
launchctl bootout gui/$(id -u)/com.hanzo.<slug>.worktree-cleanup, then remove the plist, logs and the stable script copy.
After a plugin update, re-copy the script (step 1) so the daily job uses the new version.