Command Palette

Search for a command to run...

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

worktree-setup

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

Create an isolated git worktree with a feature branch for PACT workflows. Use when: starting a new feature, beginning orchestrate or comPACT, creating…

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

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

Worktree Setup

Create an isolated git worktree with a feature branch for PACT workflows. This provides filesystem isolation so multiple features or sub-scopes can run in parallel without interference.

When to Use

  • Starting a new feature workflow (/PACT:orchestrate, /PACT:comPACT)
  • ATOMIZE phase creating sub-scope isolation
  • Manually isolating work for a feature branch

Process

Follow these steps in order. Stop and report any errors to the user.

Step 1: Check for Existing Worktree

Before creating anything, check if a worktree already exists for this branch.

git worktree list
  • If a worktree for the target branch already exists, reuse it. Report: "Reusing existing worktree at {path}" and skip to Step 4. Only a worktree at .worktrees/{branch} receives the venv link; a reused worktree elsewhere is still reused, just without the link.
    • If the worktree appears in the list but is marked prunable, run git worktree prune first and proceed to create a new one.
  • If the branch exists but has no worktree, ask the user: "Branch {branch} already exists. Check out existing branch, or create a new branch name?"

Step 2: Ensure .worktrees/ Directory

All worktrees live in .worktrees/ relative to the repo root.

# Resolve the main checkout root.
LOCAL_GIT_DIR=$(git rev-parse --git-dir 2>/dev/null)
MAIN_GIT_DIR=$(git rev-parse --git-common-dir 2>/dev/null)
if [ "$(cd "$LOCAL_GIT_DIR" 2>/dev/null && pwd -P)" = "$(cd "$MAIN_GIT_DIR" 2>/dev/null && pwd -P)" ]; then
  REPO_ROOT=$(git rev-parse --show-toplevel 2>/dev/null)
else
  REPO_ROOT=$(cd "$(dirname "$MAIN_GIT_DIR")" 2>/dev/null && pwd -P)
fi
REPO_TOP=$(git -C "$REPO_ROOT" rev-parse --show-toplevel 2>/dev/null)
REPO_COMMON_PHYS=$(cd "$REPO_ROOT" 2>/dev/null && cd "$(git rev-parse --git-common-dir 2>/dev/null)" 2>/dev/null && pwd -P)
MAIN_COMMON_PHYS=$(cd "$(git rev-parse --git-common-dir 2>/dev/null)" 2>/dev/null && pwd -P)
[ -n "$REPO_ROOT" ] && [ -n "$REPO_TOP" ] && [ -n "$REPO_COMMON_PHYS" ] && [ "$REPO_COMMON_PHYS" = "$MAIN_COMMON_PHYS" ] && [ "$(cd "$REPO_TOP" 2>/dev/null && pwd -P)" = "$(cd "$REPO_ROOT" 2>/dev/null && pwd -P)" ] || { echo "Cannot determine the main checkout root (computed ${REPO_ROOT:-<none>})."; exit 1; }

# Create directory and ensure gitignored
mkdir -p "$REPO_ROOT/.worktrees"
# Append the slash-free rule only when git does not already ignore the path (".worktrees/" does not match a symlink).
git -C "$REPO_ROOT" check-ignore -q .worktrees 2>/dev/null || {
  if grep -qxF '/.worktrees' "$REPO_ROOT/.gitignore" 2>/dev/null; then
    echo "WARNING: .worktrees is NOT ignored even though .gitignore has a '/.worktrees' line — a later negation rule cancels it, so git add -A can stage the worktree collection"
  else
    # Terminate a final line that lacks a newline, so the entry cannot merge into it.
    if [ -s "$REPO_ROOT/.gitignore" ] && [ -n "$(tail -c 1 "$REPO_ROOT/.gitignore" 2>/dev/null)" ]; then
      printf '\n' >> "$REPO_ROOT/.gitignore"
    fi
    echo '/.worktrees' >> "$REPO_ROOT/.gitignore"
  fi
}

Step 3: Create the Worktree

{branch} must be a single line and must contain no \n or \r at all — a value that contains either is not a branch name, 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. If the name still contains the literal {branch} placeholder, stop and report it.

A .worktrees that is itself a symlink is supported: the collection is wherever that link resolves, and the worktree is created at the resolved location. A symlink below the collection root, or a target that resolves outside the resolved root, is refused.

# Shell variables do not survive between Bash calls, so recompute the paths here.
LOCAL_GIT_DIR=$(git rev-parse --git-dir 2>/dev/null)
MAIN_GIT_DIR=$(git rev-parse --git-common-dir 2>/dev/null)
if [ "$(cd "$LOCAL_GIT_DIR" 2>/dev/null && pwd -P)" = "$(cd "$MAIN_GIT_DIR" 2>/dev/null && pwd -P)" ]; then
  REPO_ROOT=$(git rev-parse --show-toplevel 2>/dev/null)
else
  REPO_ROOT=$(cd "$(dirname "$MAIN_GIT_DIR")" 2>/dev/null && pwd -P)
fi
REPO_TOP=$(git -C "$REPO_ROOT" rev-parse --show-toplevel 2>/dev/null)
REPO_COMMON_PHYS=$(cd "$REPO_ROOT" 2>/dev/null && cd "$(git rev-parse --git-common-dir 2>/dev/null)" 2>/dev/null && pwd -P)
MAIN_COMMON_PHYS=$(cd "$(git rev-parse --git-common-dir 2>/dev/null)" 2>/dev/null && pwd -P)
[ -n "$REPO_ROOT" ] && [ -n "$REPO_TOP" ] && [ -n "$REPO_COMMON_PHYS" ] && [ "$REPO_COMMON_PHYS" = "$MAIN_COMMON_PHYS" ] && [ "$(cd "$REPO_TOP" 2>/dev/null && pwd -P)" = "$(cd "$REPO_ROOT" 2>/dev/null && pwd -P)" ] || { echo "Cannot determine the main checkout root (computed ${REPO_ROOT:-<none>})."; exit 1; }

BRANCH=
BRANCH_EXTRA=
{ IFS= read -r BRANCH; IFS= read -r BRANCH_EXTRA || :; } <<'PACT BRANCH'
{branch}
PACT BRANCH
[ -z "$BRANCH_EXTRA" ] || { echo "Cannot create worktree: the branch va
Полный SKILL.md на GitHub

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

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

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

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

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

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

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

FAQ

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

Create an isolated git worktree with a feature branch for PACT workflows. Use when: starting a new feature, beginning orchestrate or comPACT, creating sub-scope isolation for ATOMIZE, or manually isolating work. Triggers on: worktree setup, feature isolation, parallel workflow, new worktree.

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

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

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

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

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

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