Command Palette

Search for a command to run...

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

worktree-cleanup

БесплатноБез исполняемых скриптовНе проверен

Remove a git worktree and its branch after PACT workflow completes. Use when: PR is merged, sub-scope work is consolidated, or manual cleanup is needed…

Synaptic-Labs-AIот Synaptic-Labs-AI★ 73 звезды на GitHub

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

Worktree Cleanup

Remove a git worktree and its associated branch after work is complete. Typically invoked after a PR is merged, after CONSOLIDATE merges sub-scope branches, or manually by the user.

When to Use

  • After peer-review merges a PR (automatic cleanup)
  • After CONSOLIDATE merges sub-scope branches
  • Manual cleanup of stale worktrees (/PACT:worktree-cleanup)
  • User aborts a workflow and wants to clean up

Process

Follow these steps in order. Surface all git errors clearly — the user resolves them.

Step 1: Identify Target

Determine which worktree to remove.

If a worktree path or branch name was provided: Use that directly.

If no target was specified: List all worktrees and ask the user which to clean up.

git worktree list

Present the list and ask: "Which worktree should I remove?"

Step 1.5: Harvest docs/ Artifacts Before Teardown

git worktree remove deletes the worktree's docs/ directory irrecoverably — that directory is gitignored and worktree-ephemeral, so the phase artifacts it holds (docs/preparation/, docs/architecture/, docs/plans/, docs/review/, docs/decision-logs/) are gone the instant the worktree is removed. Those artifacts are the fuller substance behind each phase's distilled HANDOFF. This step is the single chokepoint that protects them for all teardown callers — peer-review auto-cleanup, CONSOLIDATE sub-scope early-teardown, and manual /PACT:worktree-cleanup alike — so harvest MUST precede remove.

Run this exact command, substituting the target worktree's absolute path from Step 1 — that path is the harvest target. Step 2 removes only the .worktrees/{branch} form, so a worktree named by a path elsewhere is harvested here and then refused by Step 2; report that mismatch instead of reading the harvest as covering the removal.

{abs_worktree} must be a single line and must contain no \n or \r at all — a path, unlike a ref, may legally contain one, so report it instead of substituting it. Do not substitute a value you have not checked for newlines — the fence cannot stop a value that supplies its own heredoc delimiter line. A value that is empty is also not a worktree path; report it. If the path still contains the literal {abs_worktree} placeholder, stop and report it.

WORKTREE=
WORKTREE_EXTRA=
{ IFS= read -r WORKTREE; IFS= read -r WORKTREE_EXTRA || :; } <<'PACT WORKTREE'
{abs_worktree}
PACT WORKTREE
[ -z "$WORKTREE_EXTRA" ] || { echo "Cannot harvest: the worktree path must be a single line."; exit 1; }
[ "$WORKTREE" != "$(printf '{%s}' abs_worktree)" ] || { echo "Cannot harvest: the worktree path placeholder was not substituted."; exit 1; }
[ -n "$WORKTREE" ] || { echo "Cannot harvest: no worktree path was supplied."; exit 1; }
[ -d "$WORKTREE/docs" ] && echo DIR_PRESENT || { [ -x "$WORKTREE" ] && echo DIR_ABSENT || echo CANNOT_OBSERVE; }
find -L "$WORKTREE/docs" -type f

Then apply this guard. It is two independent decisions — what to harvest, and whether removal is licensed. A failed probe must never suppress the harvest; it only withholds the removal.

1. Harvest whatever find listed. Every listed file is an unharvested artifact, however the probe ended. If a secretary/team is reachable, trigger a secretary harvest of the worktree's docs/ artifacts and confirm it completes before going on. The secretary reads + distills each artifact into pact-memory (its pact-handoff-harvest Step 3.5 resolves artifact_paths events and reads the disk artifacts while the worktree is still live — this guard is what guarantees that liveness). If find listed nothing, there is nothing to harvest.

2. Removal is licensed only if the probe was conclusive — DIR_ABSENT, or DIR_PRESENT with find exiting zero — and every listed artifact was harvested; then proceed directly to Step 2. Otherwise do NOT remove: surface a loud warning naming what is unharvested or unreadable and will be irrecoverably deleted by removal, and let the user decide whether to proceed, harvest manually first, or abort. A non-zero exit means docs/ holds a subtree your instrument could not read, so no harvest can have covered it.

marker find exit files listed harvest removal
DIR_ABSENT non-zero none nothing to harvest licensed
DIR_PRESENT zero none nothing to harvest licensed
DIR_PRESENT zero some harvest them licensed once harvested
DIR_PRESENT non-zero some harvest what was listed refused — unread subtree
DIR_PRESENT non-zero none nothing to harvest refused — unread subtree
CANNOT_OBSERVE non-zero none nothing to harvest refused — marker untrustworthy

This guard is conditional by design: it must NOT unconditionally block, or it would break the no-team manual-cleanup path. (A user who chooses --force past the loud warning is the accepted out-of-scope edge.)

Полный SKILL.md на GitHub

Установить worktree-cleanup в Claude Code и Claude Desktop

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

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

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

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

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

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

FAQ

Что делает скилл worktree-cleanup?

Remove a git worktree and its branch after PACT workflow completes. Use when: PR is merged, sub-scope work is consolidated, or manual cleanup is needed. Triggers on: worktree cleanup, remove worktree, delete worktree, branch cleanup.

Как установить скилл worktree-cleanup?

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

Скилл worktree-cleanup запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

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

Сравнить worktree-cleanup с