User asked: do per-tool READMEs document uninstall? Sub-agent audit
(gpt-5.5 sh + glm-5.1 ps1) found multiple BLOCKERs in uninstall scripts.
Fixes:
1. claude/README.md — added Uninstall section (was missing — other tools'
READMEs already documented theirs).
2. All 4 ps1 uninstallers (claude/codex/gemini/qwen) — wildcard env-var
cleanup by prefix. Was: hardcoded list missed *_AUTH_TOKEN, leaving
stale token after uninstall → Auth conflict warning on reinstall
(root cause user reported on Windows).
Prefixes:
claude → ANTHROPIC_*, CLAUDE_*, DISABLE_TELEMETRY, ...
codex → OPENAI_*
gemini → GEMINI_*, GOOGLE_API_KEY, GOOGLE_CLOUD_PROJECT
qwen → QWEN_*, DASHSCOPE_*
3. codex/ucodex_uninstall.ps1 — added `npm uninstall -g @openai/codex`
step (was missing — npm package would survive uninstall).
4. codex/ucodex_uninstall.ps1 — also clears npm registry override
`@openai:registry`.
Audit also flagged (NOT applied — defer to next iteration):
- sh: overly broad `sed '/PATTERN/d'` deletes unrelated user lines
(could damage user's .bashrc — use marker comments instead)
- sh: missing /var/root scan (macOS root user)
- sh: missing systemd/LaunchAgent cleanup
- sh: backup restore not implemented
- All: should preserve some user data (history, projects) — current
behavior is destructive
Tests: tests/test_uninstall_completeness.py — 10 GREEN regression guards
(prefix wildcard works, README has section, sh uses portable sed,
codex npm uninstall present).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
67 lines
2.5 KiB
PowerShell
67 lines
2.5 KiB
PowerShell
# 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
|
|
# >>> wildcard env cleanup (Item 18 audit) <<<
|
|
$prefixesToRemove = @("ANTHROPIC_", "CLAUDE_", "DISABLE_TELEMETRY", "DISABLE_AUTOUPDATER", "DISABLE_ERROR_REPORTING")
|
|
$userVars = [System.Environment]::GetEnvironmentVariables("User")
|
|
foreach ($name in @($userVars.Keys)) {
|
|
foreach ($p in $prefixesToRemove) {
|
|
if ($name -like "${p}*" -or $name -eq $p) {
|
|
[System.Environment]::SetEnvironmentVariable($name, $null, "User")
|
|
Remove-Item -Path "Env:\$name" -ErrorAction SilentlyContinue
|
|
Write-Host " Removed env: $name" -ForegroundColor Cyan
|
|
break
|
|
}
|
|
}
|
|
}
|
|
# <<< end wildcard cleanup >>>
|
|
|
|
[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 ""
|