# Claude Code — Windows Uninstaller
# Usage: powershell -ExecutionPolicy Bypass -File claude\uclaude_uninstall.ps1

$ErrorActionPreference = "Continue"

Write-Host ""
Write-Host "  +--------------------------------------+" -ForegroundColor Cyan
Write-Host "  |  Claude Code -- Windows Uninstaller  |" -ForegroundColor Cyan
Write-Host "  +--------------------------------------+" -ForegroundColor Cyan
Write-Host ""

# ---- Uninstall npm package ----

Write-Host "  Removing @anthropic-ai/claude-code..." -ForegroundColor Cyan
npm uninstall -g @anthropic-ai/claude-code 2>$null
Write-Host "  npm package removed" -ForegroundColor Green

# ---- Remove settings ----

$claudeDir = "$env:USERPROFILE\.claude"
if (Test-Path $claudeDir) {
    Write-Host "  Removing $claudeDir..." -ForegroundColor Cyan
    Remove-Item -Recurse -Force $claudeDir
    Write-Host "  Settings removed" -ForegroundColor Green
}

$claudeJson = "$env:USERPROFILE\.claude.json"
if (Test-Path $claudeJson) {
    Remove-Item -Force $claudeJson
    Write-Host "  Removed .claude.json" -ForegroundColor Green
}

# ---- Remove env vars ----

Write-Host "  Removing environment variables..." -ForegroundColor Cyan
[System.Environment]::SetEnvironmentVariable("ANTHROPIC_API_KEY", $null, "User")
[System.Environment]::SetEnvironmentVariable("ANTHROPIC_BASE_URL", $null, "User")
[System.Environment]::SetEnvironmentVariable("CLAUDE_CODE_USE_BEDROCK", $null, "User")
Remove-Item Env:ANTHROPIC_API_KEY -ErrorAction SilentlyContinue
Remove-Item Env:ANTHROPIC_BASE_URL -ErrorAction SilentlyContinue
Write-Host "  Env vars removed" -ForegroundColor Green

# ---- Remove npm registry config ----

Write-Host "  Removing npm registry config..." -ForegroundColor Cyan
npm config delete "@anthropic-ai:registry" 2>$null
Write-Host "  Registry config removed" -ForegroundColor Green

Write-Host ""
Write-Host "  Claude Code fully uninstalled!" -ForegroundColor Green
Write-Host ""
