#!/bin/bash # List all git worktrees # Usage: worktree-list.sh set -e # Get project root from current working directory (where Claude Code is running) PROJECT_ROOT="$(pwd)" echo "========================================" echo " Git Worktrees" echo "========================================" echo "" # Check if we're in a git repository if ! git -C "$PROJECT_ROOT" rev-parse --git-dir > /dev/null 2>&1; then echo "Error: Not a git repository" exit 1 fi # List all worktrees from git echo "Active Worktrees:" echo "" cd "$PROJECT_ROOT" WORKTREES=$(git worktree list --porcelain) if [ -z "$WORKTREES" ]; then echo " No worktrees found" else git worktree list fi echo "" # Show registry info if available REGISTRY_FILE="$PROJECT_ROOT/.auto-build-data/worktrees/worktree-registry.json" if [ -f "$REGISTRY_FILE" ]; then echo "Auto-Build Registry:" echo "" if command -v jq &> /dev/null; then jq -r '.worktrees[] | " \(.name) (\(.status))\n Branch: \(.branch)\n Path: \(.path)\n Created: \(.created)\n"' "$REGISTRY_FILE" 2>/dev/null || echo " (empty)" else cat "$REGISTRY_FILE" fi else echo "Registry not found. Run /ab:worktree create first." fi echo "" echo "Commands:" echo " Create: /ab:worktree create " echo " Cleanup: /ab:worktree cleanup [name]"