worktree-destruction-safety
БесплатноБез исполняемых скриптовНе проверенUse when creating, removing, pruning, moving, or deleting a git worktree, including orca worktree and agent-harness worktree-rm.
от fmflurry★ 173 звезды на GitHubОб этом скилле
Worktree Destruction Safety (mandatory)
why-not-tooled: whether a checkout is safe to destroy depends on live git state, not a static analyzer.
A worktree directory is the only copy of any uncommitted work inside it. Removing one is a destructive data operation, not bookkeeping — treat it with the same caution as rm -rf, never like git branch -d.
Boundary with worktree-switching: that rule (where configured) governs entering, creating, and switching between worktrees. This rule governs their destruction — git worktree remove, git worktree prune, git worktree move, orca worktree rm, or any raw filesystem delete of a worktree directory. Read both; they do not overlap.
Why this exists
Two incidents shaped this rule. A raw git worktree remove --force + git worktree prune run outside Orca's pipeline destroyed a worktree with no trash step, so the content was not recoverable. Later, orca worktree rm returned before the removal finished ("removing": true). Orca always runs git worktree remove --force internally, whatever CLI flags are passed. During that background removal, the repo's main checkout received reset --hard and pull, which destroyed an uncommitted tracked edit and an untracked file. The actor is unknown. The old checks inspected only the worktree being removed, not the other checkouts of the repo.
Orca-managed detection (read-only, portable)
A repo is Orca-managed when either is true:
- it appears in
orca repo list - the target path is enumerated by
orca worktree list --json
If the orca CLI is not installed or not on PATH, the Orca routing below does not apply — say so explicitly. The mandatory pre-removal checks further down apply regardless of Orca's presence; they are plain git and are always in scope.
Mandatory: route worktree lifecycle through Orca when Orca-managed
Inside an Orca-managed repo, creation goes through orca worktree create .... Removal goes through agent-harness worktree-rm (below), which routes to Orca itself.
Forbidden by default in an Orca-managed repo: raw git worktree remove, git worktree prune, git worktree move, a direct orca worktree rm call, and rm -rf <worktree-dir>. These bypass the checks and the trash step (~/orca/workspaces/<repo>/.orca-worktree-trash/).
The only removal path: agent-harness worktree-rm
agent-harness worktree-rm <path> # dry run: runs the checks, exits 3
agent-harness worktree-rm <path> --confirmed # removes
The command:
- runs the pre-removal checks below and lists the target's ignored files before removing anything;
- routes the removal through Orca when the repo is Orca-managed, never with
--forceor--run-hooks; otherwise it runsgit worktree removewithout--force; - verifies every other checkout that was dirty at start (content, file modes, index state, untracked files) and snapshots it first;
- waits for the removal to finish, then a settle window, then re-scans every other checkout;
- restores a changed checkout only if its HEAD is unchanged and it is clean.
In autonomous mode it removes the worktree only when the checks below pass, including a merged branch. With the flag off, a branch that is still ahead of origin/<base> is refused even when a pull request was squash-merged.
Exit codes: 0 removed and verified. 1 refused (a check STOP, or a snapshot that could not be created); the output names the reason. 2 usage error. 3 dry run (no --confirmed). 4 removal failed, or a changed checkout could not be restored. On 4 the snapshot refs are kept, and the output gives inspect and restore commands (git -C <checkout> stash apply --index <ref>, plus the diff to inspect first).
On success, each snapshot's sha is printed before its ref is released. The commit stays recoverable until git gc prunes it.
Timing knobs: env AGENT_HARNESS_WORKTREE_RM_WAIT (default 60 s) and AGENT_HARNESS_WORKTREE_RM_SETTLE (default 20 s). Timing and Orca overrides are honoured only in test mode. Config key worktreeIdleMinutes (default 60) sets the activity window for check 3.
Mandatory pre-removal checks (any mechanism, any repo)
Run in order, before any removal — through worktree-rm or (per the Escape hatch) by a human:
git -C <path> status --porcelain— any output (uncommitted or untracked content) → STOP, surface it to the human. Never pass--forcepast this.git -C <path> rev-list --count origin/<base>..HEAD— non-zero → STOP, report the exact count of commits not on the base branch.orca worktree list --json(when Orca-managed) — alastActivityAtwithinworktreeIdleMinutes→ a session may be live in it → STOP. An activity state that cannot be read is also a STOP (the check fails closed).- Resolve the path being acted on and diff it against
git worktree list --porcelainimmediately before executing, so the agent removes the path it believe
Установить worktree-destruction-safety в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл worktree-destruction-safety?
Use when creating, removing, pruning, moving, or deleting a git worktree, including orca worktree and agent-harness worktree-rm.
Как установить скилл worktree-destruction-safety?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл worktree-destruction-safety запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic