用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/laicluse/agent-fieldkit --skill prune命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
| name | prune |
| description | Safely remove a finished or abandoned git worktree while preserving unintegrated work. |
Tear down a worktree, safely. The gate is the point: a worktree that is clean but not yet integrated still holds work, so it is kept by default.
resolve_bonsai_root() {
if [ -n "${BONSAI_BIN:-}" ]; then dirname "$(dirname "$BONSAI_BIN")"; return 0; fi
if [ -n "${CLAUDE_PLUGIN_ROOT:-}" ]; then printf '%s\n' "$CLAUDE_PLUGIN_ROOT"; return 0; fi
if command -v codex >/dev/null 2>&1; then
codex plugin list | awk '$1 == "bonsai@laicluse-agent-fieldkit" { print $NF; found=1; exit } END { exit found ? 0 : 1 }'
return $?
fi
return 1
}
ROOT="$(resolve_bonsai_root)" || { echo "bonsai plugin root not found" >&2; exit 1; }
BONSAI="${BONSAI_BIN:-$ROOT/bin/bonsai}"
node "$BONSAI" teardown <worktree|branch> --repo "<root>" --dry-run --json # classify only
node "$BONSAI" teardown <worktree|branch> --repo "<root>" --json # remove if safe
A worktree is removed only when it is integrated into the Git default branch
resolved from origin/HEAD, or from init.defaultBranch when that branch exists only locally, or when it is clean with nothing
ahead of that default. Otherwise teardown keeps it and returns removed: false
with a reason. --dry-run reports the same classification and warnings without
removing anything. --force overrides the gate and also deletes an unmerged
branch; reach for it only on a deliberate throwaway, and never wire it into an
unattended caller.