/execute-setup — Worktree Setup Phase
$TM=python3 ~/.claude/scripts/task_manager.py
Input (from /execute-validate output):
$TICKET— validated ticket ID$PROJECT_ROOT— project root directory
Step 4 — WORKTREE_GUARD
Locate the worktree:
WORKTREE_PATH=../<PROJECT_ROOT_BASENAME>-worktrees/<TICKET>
If worktree exists:
- Display status:
"✅ Worktree encontrada:
<WORKTREE_PATH>" - Always sync runtime/config files from project root:
mkdir -p $WORKTREE_PATH/public $WORKTREE_PATH/e2e [ -f <PROJECT_ROOT>/.env ] && cp <PROJECT_ROOT>/.env $WORKTREE_PATH/.env [ -f <PROJECT_ROOT>/public/config.json ] && cp <PROJECT_ROOT>/public/config.json $WORKTREE_PATH/public/config.json [ -f <PROJECT_ROOT>/.npmrc ] && cp <PROJECT_ROOT>/.npmrc $WORKTREE_PATH/.npmrc [ -f <PROJECT_ROOT>/e2e/.env.e2e ] && cp <PROJECT_ROOT>/e2e/.env.e2e $WORKTREE_PATH/e2e/.env.e2e - Proceed to next phase.
If worktree does not exist:
Warn:
"⚠️ Worktree
<WORKTREE_PATH>não encontrada. A worktree deveria ter sido criada pelo/interpret. Criar agora a partir deorigin/develop?"If user confirms:
git fetch origin git worktree add $WORKTREE_PATH <branch_from_index> origin/develop mkdir -p $WORKTREE_PATH/public $WORKTREE_PATH/e2e [ -f <PROJECT_ROOT>/.env ] && cp <PROJECT_ROOT>/.env $WORKTREE_PATH/.env [ -f <PROJECT_ROOT>/public/config.json ] && cp <PROJECT_ROOT>/public/config.json $WORKTREE_PATH/public/config.json [ -f <PROJECT_ROOT>/.npmrc ] && cp <PROJECT_ROOT>/.npmrc $WORKTREE_PATH/.npmrc [ -f <PROJECT_ROOT>/e2e/.env.e2e ] && cp <PROJECT_ROOT>/e2e/.env.e2e $WORKTREE_PATH/e2e/.env.e2eIf user declines:
"⛔ Worktree creation cancelled. Cannot proceed." Stop.
✅ SUCCESS PATH
If worktree exists or was created successfully:
- From this point,
PROJECT_ROOT = WORKTREE_PATH(for all subsequent operations).
Return setup result:
{
"ticket": "<TICKET>",
"setup_passed": true,
"worktree_path": "<WORKTREE_PATH>",
"status": "created | existing"
}
Proceed to next phase: /execute-transition (transition to doing)
Safety rules
- Never delete or reset existing worktrees without explicit user confirmation.
- Always sync
.env,public/config.json,.npmrc, ande2e/.env.e2eto maintain environment consistency.