How to Safely Back Up Local Agent Data Before Uninstalling

    This guide explains how to safely back up data from a local AI agent before uninstalling it. You will learn how to inventory application files, back up workspace documents, revoke exposed credentials, remove background tasks and leftover configurations, and verify that the uninstallation is complete. The article includes platform-specific residual file paths for macOS, Windows, and Linux, a ready-to-paste AI assistant prompt, and a read-only verification script.

    1. Introduction: Why Local Agents Need a Backup Before Uninstall

    Desktop AI agents that can read and write local files and execute terminal commands are increasingly used by developers for code refactoring, document organization, and automated operations. These tools can access disks directly, run commands, and call external services, which significantly improves productivity. However, their broad access also means that uninstalling them is not as simple as deleting an app icon:

    • Workspace documents may exist only locally. Markdown notes, code drafts, and configuration scripts created or modified by the agent are the only copy on this machine if they were never committed to a repository or synced elsewhere.
    • Credentials are often stored in plaintext in configuration files. Model API keys and access tokens can be used by anyone and may generate charges if they leak through residual files.
    • A normal uninstall often leaves “shadow components.” Uninstallers typically do not remove configuration directories, caches, logs, startup items, scheduled tasks, and system permissions.
    • Memory files may contain sensitive information. Some agents write conversation summaries, project background, or even pasted keys into memory or history files.

    The secure approach is not to “uninstall first and recover later,” but to treat uninstallation as a data lifecycle management process: inventory, back up, clean up, and then verify. This article provides a complete procedure, along with an uninstallation instruction template that you can paste directly into an AI assistant.

    2. Preparation: Inventory, Backup, and Credential Audit

    2.1 Inventory: Know What Was Installed and Where the Data Is

    Start with a simple checklist to use as a reference for all subsequent steps:

    Inventory Item What to Confirm
    Application info Application name, version, and installation source (official installer, package manager, or built from source)
    Data directories Configuration, cache, log, and workspace directories
    Credentials Whether API keys, access tokens, SSH keys, or cloud service credentials were configured
    Background components Whether startup items, scheduled tasks, or background daemons were set up
    Related components Whether browser extensions, command-line tools, editor plugins, or standalone runtimes were installed
    Permissions Whether full disk access, accessibility, screen recording, or notification permissions were granted

    Use read-only commands first to locate these quickly and record the results:

    1. # <APP> represents the application identifier (usually the lowercase app name or executable name)
    2. APP="<APP>"
    3. # 1. Locate the executable
    4. command -v "$APP" 2>/dev/null || which "$APP" 2>/dev/null
    5. # 2. Search for common data and configuration directories in the user's home directory (list only, no modifications)
    6. find "$HOME" -maxdepth 4 -type d -iname "*${APP}*" 2>/dev/null
    7. # 3. Check for residual processes (simplified cross-platform approach)
    8. ps -e 2>/dev/null > /tmp/ps.txt || tasklist > /tmp/ps.txt
    9. grep -i "$APP" /tmp/ps.txt

    2.2 Backup: Workspace Documents Are Often the Only Copy

    When an agent asks whether to keep documents in the workspace, it refers to these Markdown notes and project files. Regardless of whether you plan to keep or delete them, copy them to a location independent of the agent’s data directory before uninstalling. The recommended approach is “archive + checksum + second copy”:

    1. BACKUP="$HOME/Documents/agent-workspace-backup"
    2. mkdir -p "$BACKUP"
    3. STAMP=$(date +%Y%m%d-%H%M%S)
    4. # Assume the workspace is at ~/agent-workspace; replace it with the actual path if different
    5. if [ -d "$HOME/agent-workspace" ]; then
    6. tar -czf "$BACKUP/workspace-$STAMP.tar.gz" -C "$HOME" "agent-workspace"
    7. # Record a checksum so you can verify the backup later
    8. sha256sum "$BACKUP/workspace-$STAMP.tar.gz" > "$BACKUP/workspace-$STAMP.sha256"
    9. ls -lh "$BACKUP"
    10. else
    11. echo "Default workspace not found. Confirm the workspace path in the agent's settings before backing up."
    12. fi

    macOS includes shasum, and Linux includes sha256sum. If neither is available, you can run shasum -a 256 <file_path>.

    After creating the archive, open it and check a few files to confirm they are readable. Only proceed to cleanup once the backup is verified. If possible, also save a copy on an external drive or personal cloud storage to reduce the risk of a single point of failure.

    2.3 Credential Audit: Revoke First, Then Delete Local Files

    • List each key and token configured in the agent, noting which service it belongs to and what it is used for.
    • Revoke or rotate these keys in the service provider’s console. Deleting the configuration file does not invalidate the credential; as long as the key remains valid, it can still be used.
    • Check whether you ever pasted passwords, keys, or internal addresses into the agent. If so, treat them as exposed and replace them immediately, then clean up related conversations and memory files.
    • Check SSH configuration and authorized_keys, Git credential caches, and shell configuration files such as ~/.zshrc and ~/.bashrc for aliases or environment variables written by the agent.

    3. Execution: Phased and Safe Cleanup

    Follow this order: stop running → official uninstall → clean configuration → remove background tasks → revoke permissions → handle related components. Each step should be reversible, and you should confirm the correct path before every deletion.

    3.1 Phase 0: Environment Detection

    1. # Detect the OS kernel type; treat as Windows if the command is not available
    2. uname -s 2>/dev/null || echo "WINDOWS"
    3. # macOS only: check the system version
    4. sw_vers 2>/dev/null
    5. # Windows environment variables (view in CMD)
    6. # echo %LOCALAPPDATA% & echo %APPDATA%

    Use the results to select the appropriate residual paths for your platform. Replace placeholders such as <APP> and <VENDOR> with the actual names recorded in step 2.1:

    Platform Configuration and Data Cache and Logs Background Startup and Preferences
    macOS ~/Library/Application Support/\ ~/Library/Caches/\, ~/Library/Logs/\ ~/Library/LaunchAgents, ~/Library/Preferences/\.plist
    Windows %APPDATA%\, %LOCALAPPDATA%\, %PROGRAMDATA%\ Cache directories under %LOCALAPPDATA%\ Registry Run/RunOnce startup entries, Startup folder, Task Scheduler
    Linux ~/.config/\, ~/.local/share/\ ~/.cache/\ ~/.config/systemd/user/\*, ~/.config/autostart/\*.desktop

    3.2 Phase 1: Backup and Credential Disposal

    Run the backup script from section 2 and verify the checksum. Then confirm that key credentials have been revoked and record a line such as “Revoked: “ to close out the credential list. Only after this step should you start deleting files.

    3.3 Phase 2: Stop the Application and Revoke System Permissions

    1. # macOS / Linux: list matching processes first, then terminate after confirmation
    2. pgrep -fl "<APP>"
    3. pkill -f "<APP>"
    • macOS: Go to System Settings → Privacy & Security and remove the app from entries such as Full Disk Access, Accessibility, and Automation.
    • Windows: In Settings → Privacy & Security → App Permissions, disable the app’s permissions one by one.
    • Linux desktop environments: Check the privacy or permission settings provided by your desktop environment; full disk access is generally not granted.

    3.4 Phase 3: Perform the Uninstall

    • Use the official uninstaller first: On Windows, uninstall from Settings → Apps → Installed apps; on macOS, remove the app from the Applications folder or use its bundled uninstaller.
    • Package manager installations: Use the system package manager to uninstall, following the documentation for your distribution or system.
    • Source-built installations: First check for an uninstall script or an uninstall target in the project’s Makefile. If none exists, record all installed files and delete them manually.
    • Do not delete immediately: Move data directories to the recycle bin or trash instead of running rm -rf right away. This leaves room for recovery if you misjudge something.

    3.5 Phase 4: Clean Configuration, Cache, and Plugins

    Delete the corresponding directories once confirmed, or move them to the trash first:

    1. # macOS / Linux example (replace with actual paths and verify first)
    2. mv "$HOME/.config/<APP>" "$HOME/.Trash/" 2>/dev/null
    3. mv "$HOME/.cache/<APP>" "$HOME/.Trash/" 2>/dev/null
    4. # Check macOS install receipts to see which packages were written by the app
    5. pkgutil --pkgs | grep -i "<APP>"
    6. # Once confirmed unnecessary, run pkgutil --forget <package_id>

    Also check browser extension lists, editor plugin marketplaces, and command-line tool directories for similarly named residual components and remove them one by one.

    3.6 Phase 5: Remove Background Tasks and Startup Items

    • macOS: Check ~/Library/LaunchAgents for related plist files and run launchctl list | grep -i "<APP>" to confirm background agents have stopped.
    • Windows: Disable related entries in Settings → Apps → Startup and delete related tasks in Task Scheduler.
    • Linux: Check user-level services with systemctl --user list-units | grep -i "<APP>", the user crontab (crontab -l), and system-level scheduled task directories.
    • Remove browser extensions installed by the agent and revoke its read access to data such as tabs and downloads.
    • Check shell startup files for aliases, environment variables, and PATH entries.
    • Delete passwords and certificates saved for the app in your keychain or credential manager.
    • If a standalone runtime was installed, after uninstalling the main application, check whether any other apps depend on it. Only remove it if nothing depends on it.

    4. Instruction Phase: Let an AI Assistant Execute the Full Process

    Install any desktop AI assistant with local operation capabilities and use it to assist with the uninstallation. Paste the following instructions in full into the chat and press Enter. The assistant’s logic is “read-only check first, then generate a plan, and finally execute step by step with your confirmation.”

    Three points to emphasize:

    1. The assistant only performs detection, generates scripts, and executes step by step. You are the one who actually confirms deletions.
    2. Remove anything outside the instructions before pasting, especially sensitive information such as keys and tokens.
    3. For every command involving deletion, verify the path before allowing it to run.
    1. You are assisting the user in safely and thoroughly uninstalling a locally installed desktop AI agent application.
    2. Follow the steps below strictly. At the start of each phase, explain the purpose and expected impact of that phase, and wait for the user's confirmation before proceeding.
    3. Phase 0: Environment Detection
    4. 1. Run `uname -s` (if it fails, inform the user that the current environment is Windows).
    5. 2. Ask the user for the exact name and version of the application to uninstall, using <APP> as a placeholder throughout.
    6. 3. Perform a read-only search in the user's home directory for configuration, cache, and data directories related to <APP>.
    7. 4. Summarize and output the detected paths without making any modifications.
    8. Phase 1: Backup and Credential Audit
    9. 1. Guide the user to confirm the workspace directory location.
    10. 2. Package the workspace into a dated archive, save it to an independent directory specified by the user, and generate a SHA-256 checksum file.
    11. 3. List the names of keys and tokens found in configuration files (show key names only, not values).
    12. 4. Remind the user to revoke these credentials in the respective service consoles.
    13. Phase 2: Stop Running and Revoke Permissions
    14. 1. List processes related to <APP> and terminate them after user confirmation.
    15. 2. Prompt the user to remove <APP> application permissions in system settings for each platform.
    16. Phase 3: Uninstall and Residual Cleanup
    17. 1. Prefer the system's built-in uninstall entry or package manager uninstall command.
    18. 2. List each configuration, cache, and log directory to be deleted, explaining its purpose and the consequence of deletion.
    19. 3. After user confirmation, move items to the recycle bin first rather than permanently deleting them.
    20. 4. Clean startup items, scheduled tasks, user-level services, browser extensions, and editor plugins.
    21. Phase 4: Verification and Wrap-up
    22. 1. Re-check common paths for any remaining <APP>-related files.
    23. 2. Prompt the user to restart the system and confirm no related processes or startup items remain.
    24. 3. Output a cleanup report: items deleted, items retained (such as backup archives), and items the user needs to handle manually.
    25. Safety rules:
    26. - Do not output the full contents of any key or token.
    27. - Do not execute downloads or remote scripts from unknown sources.
    28. - Any deletion or uninstall operation must be confirmed by the user first.
    29. - When permissions are insufficient, prompt the user to grant them; do not attempt to elevate privileges yourself.

    If the assistant asks whether to keep documents in the workspace, answer according to your needs:

    • If you no longer need these notes after uninstallation, you can clean them up along with the workspace, provided that the backup in Phase 1 has passed verification.
    • If you still want to organize these materials, choose to keep them and move the directory out of the agent’s data directory.

    5. Verification: Confirm a Thorough Uninstall with a Checklist and Script

    Check Item Verification Method Pass Criteria
    Backup usability List the archive directory and compare hashes with the checksum file Hash matches, and spot-checked files open correctly
    Credential invalidation Confirm key status in the console Shows as revoked or rotated
    Process and startup Run pgrep -fl "<APP>" after restart No output
    Residual files Re-check configuration, cache, and log directories No related files, or only the backup archive remains
    Permission revocation Check system privacy settings and app permissions The app no longer appears in the list
    Related components Check browser extensions, editor plugins, and shell configuration All related items have been removed

    You can also save the following read-only self-check script as check.sh and run it with bash check.sh:

    1. #!/usr/bin/env bash
    2. APP="<APP>" # Replace with the actual application identifier
    3. echo "[1] Process check"
    4. pgrep -fl "$APP" 2>/dev/null || echo " No related processes found"
    5. echo "[2] Common directory residuals (view only, no deletion)"
    6. for d in \
    7. "$HOME/.config/$APP" "$HOME/.local/share/$APP" "$HOME/.cache/$APP" \
    8. "$HOME/.${APP}" \
    9. "$HOME/Library/Application Support/$APP" "$HOME/Library/Caches/$APP" \
    10. "$HOME/Library/Logs/$APP" "$HOME/Library/LaunchAgents"
    11. do
    12. # Only check for directory existence to avoid treating user files as directories
    13. if [ -d "$d" ] && [ "$d" != "$HOME/Library/LaunchAgents" ]; then
    14. echo " Exists: $d"
    15. fi
    16. done
    17. echo "[3] Background startup items (macOS)"
    18. launchctl list 2>/dev/null | grep -i "$APP" || echo " No related background agents found"
    19. echo "[4] Backup files"
    20. ls -lh "$HOME/Documents/agent-workspace-backup" 2>/dev/null \
    21. || echo " Backup directory not found, please confirm the backup path"

    The script only reads information and does not perform deletions. If you find residuals, go back to the corresponding phase in section 3 to handle them.

    6. Common Mistakes and Advanced Tips

    • Mistake 1: Equating uninstall with deleting the installer. The installer only determines where the software resides; data, configuration, credentials, and background tasks determine what it leaves behind.
    • Mistake 2: Deleting local files without revoking credentials. Files can be recovered, but a leaked key cannot be “taken back.”
    • Mistake 3: Not backing up the workspace before deletion. Documents generated by agents often have no version history and are difficult to recover once deleted.
    • Mistake 4: Confusing “uninstall” with “deactivate.” If you will use the agent again soon, you can simply disable startup items, restrict network access, and rotate keys; only perform a thorough cleanup following this article’s process when you are certain you no longer need it.
    • Enterprise environments require additional consideration: Devices often have centrally managed endpoint management or security software. Confirm company policies with your IT administrator before uninstalling. Work materials that need long-term retention can be archived to compliant enterprise storage.
    • Individual users may consider cloud archiving: You can use object storage services to store workspace archives and enable versioning or cross-region redundancy so that your materials no longer depend on a single computer. For example, Baidu AI Cloud Object Storage (BOS) offers multiple storage tiers and lifecycle management capabilities, allowing you to set storage types and automatic transition rules based on data access frequency, meeting retention requirements while controlling costs.

    7. Conclusion

    Uninstalling a local AI agent is essentially about revoking the permissions granted to it, cleaning up the traces it left behind, and properly handling the data it touched. As long as you follow the principle of “inventory first, back up first, revoke first, delete after, and verify last,” whether you operate manually or use an AI assistant, you can achieve a clean, secure, and auditable result.