How to Completely Uninstall a Local Coding Agent: A Full Cleanup Guide
This guide explains why uninstalling a local coding agent requires more than deleting an app, and walks through a layered cleanup process. It covers pre-uninstall preparation such as asset inventory, data classification, encrypted backups, and credential rotation; four cleanup layers for stopping processes and services, removing the software, clearing configuration and cache, and erasing credentials and environment variables; platform differences across Linux, macOS, and Windows; post-uninstall security verification; a prompt-based workflow for non-technical users; and common mistakes to avoid. The goal is a safe, thorough, and auditable removal that leaves no exposed ports, orphaned credentials, or lost workspace data.
1. The Problem: Why “Uninstalling” Is More Than Deleting an App
As local coding agents become common in enterprise development environments, these tools often exist in multiple forms, including background daemons, CLI plugins, and IDE extensions. They are also deeply integrated with the local file system, terminal environment variables, and SSH key management modules. Simply “deleting the app” usually removes only the top-level entry point. The harder problems hide in three areas:
Workspace memory mixed with user assets
To provide a coherent session experience, a local agent usually maintains a “long-term memory” file under the user directory, such as a Markdown file containing role settings, context summaries, and task history. Some implementations even give these files anthropomorphic names. These files may contain both prompts edited manually by the user and decision records automatically generated by the agent. When you run the official uninstall script, these directories are often deleted recursively without discrimination, causing unrecoverable data loss.Leftover background services and port listeners
Many local agents register system-level services during installation, such as a systemd unit, a launchd plist, or a Windows Service. These services maintain long-lived sessions or expose local HTTP/WebSocket interfaces. If you delete only the CLI entry point and ignore the service units, the process will start automatically at the next boot and listen on ports again at127.0.0.1or0.0.0.0. On shared development machines or CI runners, these “zombie services” may be flagged by internal scanners as an unknown exposed surface.Credentials and configuration files scattered across the system
Sensitive information such as API keys, OAuth tokens, model service base URLs, and tenant IDs is usually not stored in a single.envfile. Instead, it is spread across user-level configuration directories (~/.config/), project-level hidden directories, the system keychain (Keychain / Credential Manager / Secret Service), and environment variable injection files (.bashrc,.zshrc, PowerShell$PROFILE). Without a unified cleanup strategy, this easily creates “orphaned credentials.”
2. Four Essential Preparations Before Uninstalling
Before performing any deletion, complete the following steps to significantly reduce irreversible risk.
2.1 Asset inventory: map the dependencies
Run a lightweight script to enumerate possible installation traces and produce a “cleanup list.” Example code:
#!/usr/bin/env bash# Enumerate common trace locations and write output to cleanup_map.txtOUT="cleanup_map.txt"{echo "=== Executables ==="command -v claw-agent-cli 2>/dev/nullecho "=== User config directories ==="ls -d ~/.config/claw* ~/.claw* 2>/dev/nullecho "=== System service units ==="ls /etc/systemd/system/*claw* 2>/dev/nullls ~/Library/LaunchAgents/*claw* 2>/dev/nullecho "=== Environment variable injection ==="grep -rn "CLAW_" ~/.bashrc ~/.zshrc ~/.profile 2>/dev/null} > "$OUT" 2>&1echo "Inventory written to $OUT"
Practical tip: Include this list in your change management process. In an enterprise environment, an uninstall should be treated as a configuration change, with the operator, timestamp, and rollback point recorded.
2.2 Data classification: separate “disposable” from “must-keep”
Divide workspace data into three categories:
| Class | Examples | Handling strategy |
|---|---|---|
| Core assets | Manually written soul.md, project-level AGENTS.md, custom skill scripts |
Back up first with encrypted packaging |
| Rebuildable data | Caches, vector indexes, log slices | Can be deleted directly; no backup needed |
| Sensitive credentials | API keys, tokens, certificate private keys | Rotate immediately after backup |
2.3 Backup and encrypted archiving
Package the core assets and encrypt them immediately. Do not leave a plaintext archive in a temporary directory:
tar -czf ~/agent_assets_$(date +%Y%m%d).tar.gz \~/.config/myagent/workspace \~/.config/myagent/skills 2>/dev/null# Symmetric encryption with GPGgpg -c --cipher-algo AES256 ~/agent_assets_$(date +%Y%m%d).tar.gz# Securely delete the plaintext archiveshred -u ~/agent_assets_$(date +%Y%m%d).tar.gz
2.4 Rotate credentials first
Before uninstalling, revoke or rotate the related API keys in the service provider’s console. Even if the local credentials are completely removed, an active key can still be exploited through logs or backup snapshots.
3. Layered Cleanup Execution
Break the cleanup into four layers. Proceed and verify layer by layer to avoid the common problem of “deleting half and missing half.”
3.1 Layer 1: Stop runtime processes and services
# Linux (systemd)systemctl --user stop claw-agent.service 2>/dev/nullsystemctl --user disable claw-agent.service 2>/dev/nullsudo systemctl stop claw-agent.socket 2>/dev/null# macOS (launchd)launchctl unload ~/Library/LaunchAgents/ai.claw.agent.plist 2>/dev/null# Fallback: terminate by process namepkill -f "claw-agent" 2>/dev/null
Afterward, confirm in both directions with ps aux | grep -i claw and lsof -i :<port> that no listeners remain.
3.2 Layer 2: Uninstall the software itself
Prefer the system package manager to avoid dependency leftovers from a manual rm -rf:
# npm global packagenpm uninstall -g @example/claw-agent# Homebrewbrew uninstall claw-agent# Python pipxpipx uninstall claw-agent
If the installation method was “download a binary plus a symlink,” manually clean up the symlink targets under ~/.local/bin/ or /usr/local/bin/.
3.3 Layer 3: Configuration and cache cleanup
Scan in the order “global → user → project”:
# Global and user levelrm -rf ~/.config/claw-agentrm -rf ~/.cache/claw-agentrm -rf ~/.local/share/claw-agent# Project level (run at the repository root)find . -maxdepth 3 -name ".claw*" -type d -exec rm -rf {} + 2>/dev/null
Note: Do not use unbounded commands such as find / -name "*claw*" -delete. A container image layer from a cloud vendor may contain system files with the same name prefix, and deleting them by mistake can break the dependency chain.
3.4 Layer 4: Credential and environment variable removal
# Linux keyring (Secret Service)secret-tool clear service claw-agent 2>/dev/null# macOS Keychainsecurity delete-generic-password -s "claw-agent" 2>/dev/null# Windows Credential Manager (PowerShell)cmdkey /delete:claw-agent 2>/dev/null
Also check shell startup files and remove lines that inject environment variables automatically:
sed -i.bak '/CLAW_API_KEY=/d' ~/.bashrc ~/.zshrc 2>/dev/null
4. Cross-Platform Differences and Automation
4.1 Platform adaptation
- Linux: Distinguish user-level from system-level systemd units. With SELinux enabled, a policy module may record the service context separately.
- macOS: In addition to launchd, check application containers under
~/Library/Application Support/and plist preference files in~/Library/Preferences/. - Windows: Service registration entries are under
HKLM\SYSTEM\CurrentControlSet\Services\, and user configuration lives in both%APPDATA%and%LOCALAPPDATA%.
4.2 Idempotency design
Wrap the steps in an idempotent script so it can be run repeatedly without side effects:
cleanup_agent() {local target="$1"[[ -e "$target" ]] && rm -rf "$target" && echo "Removed: $target" || echo "Skip (not found): $target"}
For large-scale enterprise operations, use configuration management tools such as Ansible or SaltStack to deliver playbooks, incorporate the cleanup logic into the CMDB change process, and keep the processing state of each node auditable.
5. Post-Uninstall Security Verification
Finishing the cleanup does not close the security loop. Run the following checks:
Port and process recheck
ss -tulnp | grep -i clawps -ef | grep -i claw | grep -v grep
Filesystem residue scan
Uselocateorfindwith a whitelist mechanism, limiting the scan root directory to avoid full-disk false positives.Credential validity check
Call the service provider’s API and confirm the old key returns401/403, closing the loop on the server side.Startup items and scheduled tasks check
- Linux:
crontab -l,systemctl list-timers - macOS:
launchctl list | grep -i claw - Windows:
schtasks /query /fo LIST | findstr /i claw
- Linux:
6. A Simplified Approach for Non-Technical Users
If the operator is not comfortable with the command line, use a collaboration model of “natural language instructions plus a desktop agent.” The core idea is to hand a standardized cleanup playbook (prompt) to an assistant with local execution permissions. The assistant calls system APIs step by step and requests human confirmation before each high-risk action.
A typical phased instruction template is shown below:
You are helping me safely uninstall a local coding agent. Follow the phases strictly. At the end of each phase, output a summary and wait for confirmation:[Phase 0] Environment detection: identify the operating system, package manager, and user directory structure;[Phase 1] Asset backup: locate workspace, skills, and memory files, package and encrypt them, and report the path;[Phase 2] Service shutdown: list all related daemons and startup items, and terminate them one by one after confirmation;[Phase 3] Software uninstall: call the corresponding package manager and output the uninstall log;[Phase 4] Residue cleanup: scan configuration and cache across the global/user/project layers, and list each item before deletion;[Phase 5] Credential handling: search for sensitive items in the keychain and environment variables, and prompt me to rotate them manually;[Phase 6] Verification report: summarize results across the four dimensions of ports, processes, files, and startup items.
The essence of this model is separating human decision-making from machine execution efficiency: the agent handles discovery and execution, while the human handles authorization and fallback. In developer tooling practice related to Baidu AI Cloud, this “explainable, interruptible, and rollback-capable” interaction paradigm is gradually becoming a baseline requirement for local agent operations.
7. Common Mistakes and Risk Avoidance
| Mistake | Consequence | Correct approach |
|---|---|---|
| Running the official “one-click uninstall” directly | User memory files are silently deleted | Back up the workspace before uninstalling |
| Deleting only the app and ignoring daemons | Auto-start at boot and port exposure | Stop services first, then remove the software |
Running find / -name "*agent*" across the whole disk |
Deleting system dependencies by mistake and breaking the environment | Limit scan paths and build a whitelist |
| Not rotating the API key after uninstalling | Credentials reused through logs or snapshots | Revoke on the server side before uninstalling |
| Not checking shell startup scripts | Leftover environment variables pollute later sessions | Audit .bashrc/.zshrc/$PROFILE |
8. Summary
Completely uninstalling a local agent is essentially converging four dimensions: identity, assets, credentials, and runtime. Identity refers to CLI and GUI entry points; assets refer to workspace memory and skill scripts; credentials refer to keys scattered across the keychain and environment variables; and runtime refers to daemons and listening ports. Missing any one dimension can lead to privacy leaks or system instability.
The recommended engineering path is: inventory → backup → stop services → uninstall the software → layered cleanup → rotate credentials → four-dimension verification. On top of this, script the process, make it idempotent, and include it in change management to achieve removal that is truly safe, thorough, and auditable.
