Quick fix
# One-liner: back up shared config before uninstalling (the only undo)
cp ~/.claude.json ~/.claude.json.bak
Full uninstall = remove package + remove tool config dir + manually restore the shared config sections.
What you will run into
After uninstalling a tool, leftover problems persist: shared config isn't restored (the ~/.claude.json / ~/.codex/config.toml the tool rewrote stay in their switched state);
the command still exists (after uninstall, ccr / cc-switch still resolves, or reinstall brings back old config).
Uninstalled but not cleanly.
Why this happens
The uninstall command only removes the tool itself (dpkg -r / npm rm -g + the tool's own config directory), it doesn't restore the shared config files it modified; the shell's hash cache can keep an uninstalled command resolving.
Uninstalling is not restoring: uninstallers (dpkg -r / npm rm -g) only delete files they declare ownership of (binaries, libraries, their own config dirs);
they never restore shared config files they modified during install (appended config entries in system files, PATH writes, launcher registrations).
So "still affects the system after uninstall" is the norm, not an anomaly.
Shell hash caching is the second layer: bash caches command paths in memory, and an uninstalled command can still be resolved in the same shell session (it disappears only in a new terminal).
Deterministic takeaway: leftover effects after uninstall are checked in two directions — file layer (which <cmd>, dpkg -l | grep, config dirs) and environment layer (PATH, shell hash: hash -r clears the cache);
when "it still runs after uninstall", first hash -r or open a new terminal to rule out the cache, then search PATH for leftover files;
fixed diagnostic: runs in the same terminal but not a new one = hash cache; runs in neither = file leftovers.
Step by step
1. Back up shared config before uninstalling — Required
cp ~/.claude.json ~/.claude.json.bak
Likewise ~/.codex/config.toml, ~/.claude/settings.json.
2. Full uninstall = remove package + remove tool config dir — Required
cc-switch:
dpkg -r cc-switch && rm -rf ~/.cc-switch
claude-code-router:
npm rm -g @musistudio/claude-code-router && rm -rf ~/.claude-code-router
3. Manually restore the shared config sections — Required
Restore the provider sections / the ANTHROPIC_* routing-injection sections, or restore from backup; don't delete shared files on the tool's behalf (other tools write them too).
4. Verify in a new shell — Required
command -v ccr
Should be empty; after reinstall, config should be fresh.
How to confirm it works
Zero-leftover verification (measured output shape):
ccr uninstall closure: 102 packages removed + config dir cleared → verify zero leftovers exit=0 (measured)
command -v ccr → emptyOther environments
| Environment | Notes |
|---|---|
| cc-switch | Uninstall command has no restore step (string audit); dpkg -r + rm -rf ~/.cc-switch |
| claude-code-router | npm rm + delete ~/.claude-code-router; manually confirm the settings.json routing-injection section (measured closure) |
| Shared config | Back up first, then act; don't delete shared files on the tool's behalf |
| shell hash | Verify with command -v in a new shell |
Symptom
Leftovers persist after uninstalling a tool:
- Shared config is not restored:
~/.claude.json/~/.codex/config.tomlstay in the state the tool rewrote them to; - Command still resolves:
ccr/cc-switchstill works after uninstall, or reinstall shows stale config.
Cause
The uninstall command only removes the tool itself (dpkg -r / npm rm -g plus the tool's own config dir) and does not restore the shared config files it modified; the shell hash cache can also keep resolving an uninstalled command.
Solution
- Back up shared config before uninstall:
cp ~/.claude.json ~/.claude.json.bak(same for~/.codex/config.toml,~/.claude/settings.json). - Full uninstall = remove package + remove tool config dir: cc-switch via
dpkg -r+rm -rf ~/.cc-switch; claude-code-router vianpm rm -g @musistudio/claude-code-router+rm -rf ~/.claude-code-router. - Restore the shared config sections manually (provider section / ANTHROPIC_* route-injection section) or from backup; do not delete shared files on behalf of other tools.
- Verify in a new shell:
command -v ccrshould be empty; reinstall should show fresh config.
Affected Tool Instances
- cc-switch: uninstall =
dpkg -r+rm -rf ~/.cc-switch, no restore step (string audit); measured closed loop. - claude-code-router: npm global package +
~/.claude-code-routerconfig dir; the~/.claude/settings.jsonroute-injection section needs manual confirmation; desktop release binary uses the OS uninstaller (outside npm management); measured closed loop 2026-08-28 (102 packages removed + dir cleared + verify zero leftovers exit=0).
Verification Evidence
- cc-switch: string audit confirms the management surface includes
~/.claude.json/~/.codex/config.toml/ opencode.json; the uninstall command has no restore step (manifest uninstall.note). - claude-code-router: measured closed loop 2026-08-28: install exit=0 → uninstall (102 packages removed + config dir cleared) → verify zero leftovers exit=0.
Applicable tools (2)
This problem is linked from the tool pages below — reachable from either side.
cc-switchclaude-code-routerSource & evidence
← Coding Agents & Terminal domain | Problem Catalog Experience | Facing another issue? Go to the Helpdesk