---
name: macos-uninstall
description: >
  Completely uninstall a macOS application — the app bundle plus every trace it
  left behind (caches, preferences, application support data, launch agents,
  launch daemons, package receipts, logs, privileged helpers). Use this skill
  whenever the user asks to remove, uninstall, delete, or clean up a Mac app,
  even if they phrase it casually ("get rid of X", "I don't want X anymore",
  "clean up X from my machine"). Also use it proactively when the user says they
  just installed something and regret it.
---

# macOS App Uninstaller

The goal is to find every file the app placed on the system, show the user a
clear list, remove what you can directly, and give a single copy-paste command
for the parts that need `sudo`.

## Step 1 — Identify the app name

Derive the search term from what the user said. If they said "Muse Hub", search
for `muse` and `musehub`. If they said "iFlyDown", search for `iflydown` and
`ifly`. Use a short, lowercase root so you catch vendor-prefixed bundle IDs
(e.g. `com.muse.musehub`). Also consider whether the app is known to embed
itself inside another app (e.g. Muse Hub inside Audacity) — if so, search
inside that host app's bundle too.

## Step 2 — Search for all traces

Run these searches in parallel. Adjust the search term for each location.

```bash
# App bundles
find /Applications ~/Applications -maxdepth 3 -iname "*<term>*" 2>/dev/null

# User-level support files
find \
  "$HOME/Library/Application Support" \
  "$HOME/Library/Caches" \
  "$HOME/Library/Preferences" \
  "$HOME/Library/Logs" \
  "$HOME/Library/HTTPStorages" \
  "$HOME/Library/LaunchAgents" \
  "$HOME/Library/Containers" \
  "$HOME/Library/Group Containers" \
  -maxdepth 3 -iname "*<term>*" 2>/dev/null

# System-level files (require sudo to remove)
find \
  /Library/Application\ Support \
  /Library/Caches \
  /Library/LaunchAgents \
  /Library/LaunchDaemons \
  /Library/Logs \
  /Library/PrivilegedHelperTools \
  -maxdepth 3 -iname "*<term>*" 2>/dev/null

# Package receipts
pkgutil --pkgs | grep -i "<term>"

# Running launch items
launchctl list | grep -i "<term>"

# Browser data (Chrome, Firefox, Safari)
find \
  "$HOME/Library/Application Support/Google/Chrome" \
  "$HOME/Library/Application Support/Firefox" \
  "$HOME/Library/Safari" \
  -maxdepth 4 -iname "*<term>*" 2>/dev/null

# Finder and Spotlight preferences (search plist contents)
plutil -p "$HOME/Library/Preferences/com.apple.finder.plist" 2>/dev/null | grep -i "<term>"
plutil -p "$HOME/Library/Preferences/com.apple.corespotlightui.plist" 2>/dev/null | grep -i "<term>"
```

Collect all results before proceeding.

## Step 3 — Show a clean list

Present the findings as a grouped list. Group by category so the user can see
at a glance what will be removed:

- **App** — the .app bundle(s)
- **Package receipts** — `pkgutil` entries
- **Launch agents / daemons** — plist files and any running services
- **Application support** — data the app stored
- **Caches / HTTP storage**
- **Preferences** — .plist files
- **Logs**
- **Privileged helpers** — items in `/Library/PrivilegedHelperTools`
- **Browser data** — IndexedDB, site storage
- **System preference entries** — Finder recent folders, Spotlight state

If nothing is found, say so clearly and stop. Do not guess at paths or provide
hypothetical removal commands for files that don't exist.

## Step 4 — Ask for confirmation

Ask: "Shall I remove all of these?" and wait for the user to confirm before
touching anything.

Exception: if the user already said "yes, remove everything" earlier in the
conversation, you may skip this check.

## Step 5 — Remove what you can directly

Remove user-level files (those under `$HOME`) using the `rm -rf` Bash tool.

Unload any running launch agents before removing them:
```bash
launchctl unload "$HOME/Library/LaunchAgents/<plist>" 2>/dev/null
```

For Finder/Spotlight plist entries, use PlistBuddy:
```bash
/usr/libexec/PlistBuddy -c "Delete :FXRecentFolders:0" ~/Library/Preferences/com.apple.finder.plist
killall Finder
```

Also forget package receipts (requires sudo — add to sudo block below):
```bash
sudo pkgutil --forget <receipt-id>
```

## Step 6 — Provide a single sudo command

Collect every path that needs elevated permissions (anything under `/Applications`,
`/Library`, or inside another app bundle) into one shell command. Format it
clearly so the user can copy and paste it into their terminal:

```bash
sudo rm -rf \
  "/Applications/App Name.app" \
  /Library/LaunchDaemons/com.vendor.app.plist \
  /Library/PrivilegedHelperTools/com.vendor.helper && \
sudo pkgutil --forget com.vendor.app.pkg && \
echo "Done"
```

Tell the user: "Run this in your terminal — it will ask for your password once."

## Step 7 — Confirm completion

After the user runs the sudo command (they will paste the output or say "done"),
confirm the app is fully removed. Optionally run the search again to verify
nothing was missed.

## Notes

- Only include paths that actually appeared in the search results. Never guess.
- Do not remove items from `/System` or `/usr` — those are OS files.
- If the app left behind a login item, tell the user to remove it manually in
  System Settings → General → Login Items.
- If a launch daemon is actively running, tell the user to stop it first:
  `sudo launchctl unload /Library/LaunchDaemons/<plist>` before removing.
- Some apps embed themselves inside other apps (e.g. plugins, modules). Search
  inside the host app bundle if the app name suggests this.
