thenuke02/cs2-analyzer
0
1# CS2 Analyzer Parallel Development Setup2# Based on Boris Cherny's "3-5 git worktrees at once" strategy3#4# NOTE: Claude Code 2.1.50+ has native worktree support.5# Preferred usage: claude --worktree feature-auth6# Native worktrees live at .claude/worktrees/<name> and auto-clean on exit.7# This script is kept for manual multi-worktree setup with specific branches.8#9# Usage: .\scripts\worktree-setup.ps110#11# This creates 5 parallel worktrees for independent development:12# - ai-coaching: LLM features (ai/coaching.py, ai/patterns.py)13# - api-endpoints: Backend work (api.py, infra/cache.py)14# - ui-frontend: Visualization (static/, visualization/)15# - bugfix-hotfix: Quick fixes (never blocks feature work)16# - performance: Optimization (metrics_optimized.py)17 18$WORKTREE_DIR = "..\cs2-worktrees"19 20Write-Host "CS2 Analyzer - Parallel Development Setup" -ForegroundColor Cyan21Write-Host "==========================================" -ForegroundColor Cyan22Write-Host ""23 24# Create worktree directory25if (-not (Test-Path $WORKTREE_DIR)) {26 New-Item -ItemType Directory -Force -Path $WORKTREE_DIR | Out-Null27 Write-Host "Created worktree directory: $WORKTREE_DIR" -ForegroundColor Green28}29 30# Function to create a worktree31function New-Worktree {32 param(33 [string]$Name,34 [string]$Branch,35 [string]$Description36 )37 38 $path = "$WORKTREE_DIR\$Name"39 40 if (Test-Path $path) {41 Write-Host " [EXISTS] $Name - already exists" -ForegroundColor Yellow42 return43 }44 45 Write-Host " Creating $Name ($Description)..." -ForegroundColor White46 47 # Check if branch exists48 $branchExists = git branch --list $Branch49 50 if ($branchExists) {51 git worktree add $path $Branch 2>$null52 } else {53 git worktree add -b $Branch $path 2>$null54 }55 56 if ($LASTEXITCODE -eq 0) {57 Write-Host " [OK] $Name created on branch $Branch" -ForegroundColor Green58 } else {59 Write-Host " [FAIL] Failed to create $Name" -ForegroundColor Red60 }61}62 63Write-Host "Creating worktrees..." -ForegroundColor Cyan64Write-Host ""65 66# Create each worktree67New-Worktree -Name "ai-coaching" -Branch "feature/ai-coaching" -Description "LLM features"68New-Worktree -Name "api-endpoints" -Branch "feature/api-work" -Description "Backend work"69New-Worktree -Name "ui-frontend" -Branch "feature/ui-improvements" -Description "Visualization"70New-Worktree -Name "bugfix-hotfix" -Branch "bugfix/current" -Description "Quick fixes"71New-Worktree -Name "performance" -Branch "perf/optimization" -Description "Optimization"72 73Write-Host ""74Write-Host "Worktree setup complete!" -ForegroundColor Green75Write-Host ""76Write-Host "Launch separate Claude sessions in each:" -ForegroundColor Cyan77Write-Host ""78Write-Host " cd $WORKTREE_DIR\ai-coaching && claude" -ForegroundColor White79Write-Host " cd $WORKTREE_DIR\api-endpoints && claude" -ForegroundColor White80Write-Host " cd $WORKTREE_DIR\ui-frontend && claude" -ForegroundColor White81Write-Host " cd $WORKTREE_DIR\bugfix-hotfix && claude" -ForegroundColor White82Write-Host " cd $WORKTREE_DIR\performance && claude" -ForegroundColor White83Write-Host ""84Write-Host "Or use PowerShell shortcuts (add to `$PROFILE):" -ForegroundColor Cyan85Write-Host ""86Write-Host ' function cs2-ai { cd ..\cs2-worktrees\ai-coaching }' -ForegroundColor Gray87Write-Host ' function cs2-api { cd ..\cs2-worktrees\api-endpoints }' -ForegroundColor Gray88Write-Host ' function cs2-ui { cd ..\cs2-worktrees\ui-frontend }' -ForegroundColor Gray89Write-Host ' function cs2-fix { cd ..\cs2-worktrees\bugfix-hotfix }' -ForegroundColor Gray90Write-Host ' function cs2-perf { cd ..\cs2-worktrees\performance }' -ForegroundColor Gray91Write-Host ""92Write-Host "List all worktrees:" -ForegroundColor Cyan93git worktree list94Write-Host ""95 