# How the Agent Reach Uninstall Command Handles Config Retention with --keep-config

> Learn how the Agent Reach uninstall command uses --keep-config to preserve your configuration and credentials while removing other installations. Understand unattended removals and data retention.

- Repository: [Pnant/Agent-Reach](https://github.com/Panniantong/Agent-Reach)
- Tags: how-to-guide
- Published: 2026-07-18

---

**The `--keep-config` flag preserves the `~/.agent-reach` directory containing [`config.yaml`](https://github.com/Panniantong/Agent-Reach/blob/main/config.yaml) and credentials while allowing the uninstaller to remove all skill installations and mcporter entries.**

When removing Agent Reach from your system, the `uninstall` command normally deletes all artefacts including configuration files, stored tokens, and API keys. However, by supplying the `--keep-config` option implemented in [`agent_reach/cli.py`](https://github.com/Panniantong/Agent-Reach/blob/main/agent_reach/cli.py), users can retain their settings while still cleaning up skill directories and integration entries.

## How --keep-config Works in agent_reach/cli.py

The logic for preserving configuration resides in the `_cmd_uninstall` function located in [`agent_reach/cli.py`](https://github.com/Panniantong/Agent-Reach/blob/main/agent_reach/cli.py). When executed, the command evaluates whether the user has requested config retention before deciding whether to delete the `~/.agent-reach` directory.

### Parsing the Flag via argparse

The flag is defined in the argument parser between lines 98-102. When the user runs `agent-reach uninstall --keep-config`, argparse stores this boolean value in the `keep_config` variable:

```python
keep_config = args.keep_config

```

### Conditional Config Directory Removal

Inside the `_cmd_uninstall` function (lines 102-105), the code checks `if not keep_config:` to determine whether to proceed with deletion. If the flag is **absent**, the function removes the entire configuration directory using `shutil.rmtree`. If the flag is **present**, the code skips the removal operation and prints a preservation message:

```

Skipping config directory (--keep-config): /home/username/.agent-reach

```

### Unchanged Cleanup Operations

Regardless of the `--keep-config` setting, the uninstaller continues to remove:

- OpenClaw skill installations
- Claude Code skill directories  
- Generic Agent skill folders
- All mcporter registry entries

These operations ensure that while credentials remain intact, the software is fully unregistered from the host environment.

## Practical Usage Examples

To perform a complete uninstallation that removes all configuration data:

```bash
agent-reach uninstall

```

To uninstall while preserving your `~/.agent-reach` directory containing [`config.yaml`](https://github.com/Panniantong/Agent-Reach/blob/main/config.yaml) and API keys:

```bash
agent-reach uninstall --keep-config

```

Executing the second command produces output similar to:

```

Agent Reach Uninstaller
========================================
  Skipping config directory (--keep-config): /home/username/.agent-reach
  Removed OpenClaw skill: /home/username/.openclaw/skills/agent-reach
  Removed Claude Code skill: /home/username/.claude/skills/agent-reach
  Removed Agent skill: /home/username/.agents/skills/agent-reach
  Removed mcporter entry: exa
  Removed mcporter entry: xiaohongshu

```

## Summary

- The `--keep-config` flag prevents deletion of the `~/.agent-reach` directory during uninstallation.
- The retention logic is implemented in `_cmd_uninstall` within [`agent_reach/cli.py`](https://github.com/Panniantong/Agent-Reach/blob/main/agent_reach/cli.py) (lines 102-105).
- When enabled, the uninstaller skips `shutil.rmtree` for the config directory but continues removing skills and mcporter entries.
- Preserved files include [`config.yaml`](https://github.com/Panniantong/Agent-Reach/blob/main/config.yaml), stored tokens, cookies, and API keys.

## Frequently Asked Questions

### What files are preserved when using --keep-config?

The flag preserves the entire `~/.agent-reach` directory, which includes the [`config.yaml`](https://github.com/Panniantong/Agent-Reach/blob/main/config.yaml) file and all subdirectories containing stored tokens, cookies, and API keys required for authentication with various services.

### Does --keep-config affect skill or mcporter removal?

No. The flag only impacts the configuration directory retention. According to the source code in [`agent_reach/cli.py`](https://github.com/Panniantong/Agent-Reach/blob/main/agent_reach/cli.py), the uninstaller continues to remove all skill installations (OpenClaw, Claude Code, and Agent directories) and delete all mcporter registry entries regardless of the `--keep-config` setting.

### Where is the config retention logic implemented?

The logic resides in the `_cmd_uninstall` function in [`agent_reach/cli.py`](https://github.com/Panniantong/Agent-Reach/blob/main/agent_reach/cli.py), specifically between lines 102-105, where the code checks the `keep_config` boolean before conditionally executing `shutil.rmtree` on the configuration path.

### Can I reinstall Agent Reach and reuse my saved configuration?

Yes. By using `--keep-config`, the `~/.agent-reach` directory remains intact on your filesystem. When you reinstall Agent Reach, the application will read the existing [`config.yaml`](https://github.com/Panniantong/Agent-Reach/blob/main/config.yaml) and credentials, allowing you to resume operations without reconfiguring API keys or authentication tokens.