---
name: multi-agent-uninstall
description: "Uninstall the pipeline from Claude Code + Copilot CLI. Keychain access tokens are always left untouched; --all-data also clears pipeline settings, logs, per-repo memory and the knowledge base. Asks for double confirmation. Use when the pipeline should be removed from Claude Code and Copilot CLI."
user-invocable: true
argument-hint: "[--dry-run] [--all-data] [--claude] [--copilot] [--target=<path>]"
metadata:
  language: en
---

# multi-agent-uninstall  -  Token-Preserving Uninstall

**Input**: $ARGUMENTS

Removes the pipeline itself from the system. **Different from `multi-agent-purge`:**

| Command | What it removes |
|---|---|
| `multi-agent-purge` | Active tasks' worktree / branch / log / state (development data) |
| `multi-agent-uninstall` | The pipeline itself: skills, commands, agents, scripts  -  from every CLI |

Two modes: **standard** (default) removes distributed files and keeps every data root; **full cleanup** (`--all-data`) also removes `multi-agent-preferences.json`, `~/.claude/logs/multi-agent/`, `~/.claude/memory/multi-agent/` and `~/.claude/knowledge/`. Tokens are never touched in either mode. Memory written inside a repo (`$PROJECT_ROOT/.multi-agent/memory/`) is never touched at all.

## Never deleted (either mode)

- Personal access tokens in the **Keychain** (GitHub, Jira, Bitbucket, Confluence, Telegram, Vercel, Firebase, etc.)
- `~/.claude/CLAUDE.md` and `~/.claude/rules/` (user-owned)
- User content OUTSIDE the `<!-- multi-agent-pipeline:begin/end -->` markers (`copilot-instructions.md`)

## Steps

1. **Determine the scope**  -  parse `$ARGUMENTS`:
   - No target flag: all installed targets (default)
   - `--claude / --copilot`: selective
   - `--all-data`: full cleanup (also removes settings, logs, per-repo memory and the knowledge base)
   - `--target=<path>`: adapter target (default cwd)
   - `--dry-run`: only report, delete nothing

2. **Ask the cleanup depth** (skip if `--all-data` or `--dry-run` already given)  -  `AskUserQuestion` in `outputLanguage`:
   - `question`: "How much should uninstall remove? Tokens are preserved either way."
   - `header`: "Scope" · `options`: `{ label: "Standard", description: "Remove pipeline files; keep settings, logs, memory, knowledge" }`, `{ label: "Full cleanup", description: "Also remove settings, logs, per-repo memory and the knowledge base" }`
   - **Full cleanup** adds `--all-data`.

3. **Show a preview** (run the script with `--dry-run`):
   ```bash
   node "$HOME/.copilot/scripts/uninstall.mjs" --dry-run --yes <flags>
   ```
   Show the output to the user verbatim.

4. **First confirmation**  -  native `AskUserQuestion` picker (no typed y/N):
   - `question`: "Remove the pipeline from the listed targets? Tokens are NOT touched." (`outputLanguage`)
   - `header`: "Uninstall" · `options`: `{ label: "Continue", description: "Proceed to the final confirmation" }`, `{ label: "Cancel", description: "Keep everything installed" }`
   - **Cancel** → exit.

5. **Second confirmation** (paranoia gate)  -  a second `AskUserQuestion` picker:
   - `question`: full cleanup -> "This also erases settings + all logs and is irreversible. Proceed?"; standard -> "This is irreversible. Permanently remove the pipeline files now?" (`outputLanguage`)
   - `header`: "Confirm" · `options`: `{ label: "Remove permanently", description: "Run the uninstall; tokens are preserved" }`, `{ label: "Cancel", description: "Abort, change nothing" }`
   - Anything other than **Remove permanently** → cancel.

6. **Remove**  -  run the real script with `--yes` (plus `--all-data` if chosen):
   ```bash
   node "$HOME/.copilot/scripts/uninstall.mjs" --yes <flags>
   ```

7. **Confirm**:
   ```
   ✓ multi-agent-pipeline removed.
   ℹ Personal access tokens preserved in the Keychain.
   ```

8. **Reinstall** (if the user wants): `npx @mmerterden/multi-agent-pipeline install --copilot`

## Notes

- `--dry-run` is always safe  -  zero side effects.
- The adapter target is cwd. For a different repo, use `--target=<path>`.
