# backup.ps1 — Backup existing ~/.claude/ files before install $ErrorActionPreference = "Stop" $claudeDir = Join-Path $env:USERPROFILE ".claude" $timestamp = Get-Date -Format "yyyy-MM-dd_HHmmss" $backupDir = Join-Path $claudeDir "backup-$timestamp" if (-not (Test-Path $claudeDir)) { Write-Host "No ~/.claude/ directory found. Nothing to backup." -ForegroundColor Yellow exit 0 } Write-Host "Backing up ~/.claude/ files to $backupDir" -ForegroundColor Cyan New-Item -ItemType Directory -Path $backupDir -Force | Out-Null # Backup individual files $files = @("CLAUDE.md", "settings.json", "keybindings.json") foreach ($file in $files) { $src = Join-Path $claudeDir $file if (Test-Path $src) { Copy-Item $src (Join-Path $backupDir $file) -Force Write-Host " Backed up: $file" -ForegroundColor Green } } # Backup directories $dirs = @("skills", "rules", "commands") foreach ($dir in $dirs) { $src = Join-Path $claudeDir $dir if (Test-Path $src) { Copy-Item $src (Join-Path $backupDir $dir) -Recurse -Force Write-Host " Backed up: $dir/" -ForegroundColor Green } } Write-Host "" Write-Host "Backup complete: $backupDir" -ForegroundColor Green