Anthropic's native binary installation (currently in beta) doesn't provide an uninstall method. This script removes both npm and native binary installations completely.
Use Anthropic's official uninstall when they release one. This is a temporary solution.
The native binary installation lacks proper uninstall functionality, and having both npm and native binary versions installed can cause conflicts and break your local setup. Common issues include:
- Mixed installations pointing to different binaries
- Shell completions from both versions conflicting
- PATH resolution picking the wrong installation
- npm's uninstall failing with ENOTEMPTY errors
This script provides a clean slate by removing all Claude Code installations and configurations, regardless of how they were installed.
chmod +x uninstall-claude.sh
./uninstall-claude.shOptions:
--force- Skip prompts--quiet- Silent mode (implies --force, perfect for scripts)--help- Show help
Examples:
# Interactive (asks before removing ~/.claude)
./uninstall-claude.sh
# Automation/CI-CD
./uninstall-claude.sh --quiet- Binaries:
~/.local/bin/claude,/usr/local/bin/claude, etc. - NPM packages: Global installations and broken leftovers
- Shell configs: Removes Claude lines from
.bashrc,.zshrc, etc. (creates backups) - Data directory:
~/.claude(prompts unless --force)
Shell config backups: Before modifying any shell config file, creates timestamped backups:
~/.zshrc.claude-backup.20250904-143022Path validation: Only removes the expected ~/.claude directory, refuses to delete unexpected paths.
Binary safety: Only removes files ending with /claude from PATH to prevent accidents.
Exit codes: Returns 0 on success, non-zero if any major operation failed (good for CI/CD).
Just use npm's official command:
npm uninstall -g @anthropic-ai/claude-codeBut if that fails with ENOTEMPTY errors (common), run this script instead.
"Could not remove" warnings:
# Script shows exact commands to run
sudo rm -f /usr/local/bin/claudeClaude still in PATH after uninstall:
- Restart terminal
- Run
./cc-uninstall.sh --forceagain
For automation: Script returns exit code 0 on success, non-zero if issues occurred.
- macOS (Intel/Apple Silicon)
- Linux (x64/ARM, including Alpine/musl)
- Windows via WSL
MIT License - see LICENSE file for details.
Use at your own risk. Script removes files and directories.