---
name: unmog
description: |
  Fully undoes /mog by reading the brainrot manifest and reverting all identifier renames
  and removing the funny comment. Use when asked to "unmog", "undo mog",
  "fix my code", or "remove the brainrot".
allowed-tools:
  - Bash
  - Read
  - Write
  - Edit
  - Glob
  - Grep
  - AskUserQuestion
  - TodoWrite
---

## Unmog — The Redemption Arc

You are about to reverse the brainrot. Restore the codebase to its pre-mog state. This is the lawful good ending.

### Step 1 — Find the Manifest

Ask the user which directory to unmog (or use the one they specified). Look for `.brainrot-manifest.json` in that directory.

If the manifest doesn't exist:
> "Bruh... there's no manifest here. Either this code was never mogged or someone already unmogged it. Can't undo what was never done fam. That's giving delulu. You sure this is the right directory?"

### Step 2 — Read the Manifest

Read `.brainrot-manifest.json` and extract:
- The identifier mappings (original → brainrot)
- The funny comment location and content
- The list of modified files

### Step 3 — Reverse All Renames

For each file in `files_modified`:
1. Read the file
2. For each mapping, rename the brainrot name BACK to the original name
3. Use Edit with `replace_all: true` for each identifier

**CRITICAL**: Process renames carefully to avoid partial matches. Rename longer identifiers first to prevent substring issues. For example, rename `getRizzlerById` before `getRizzler` to avoid `getOriginalById` becoming `getOriginalById` with a broken intermediate state.

**Ordering strategy:**
1. Sort all brainrot names by length, longest first
2. Apply renames in that order
3. This prevents `skibidiHandle` from partially matching when renaming `skibidi`

### Step 4 — Remove the Funny Comment

Read the file specified in `funny_comment.file`, find the comment specified in `funny_comment.comment`, and remove that entire line (including the newline).

### Step 5 — Delete the Manifest

Remove `.brainrot-manifest.json` from the directory.

```bash
rm <target_directory>/.brainrot-manifest.json
```

### Step 6 — Verify

Do a quick scan of the modified files to make sure no brainrot identifiers remain. Grep for a few of the brainrot names to confirm they're gone.

### Step 7 — Report

Tell the user the unmog is complete, still in brainrot voice:

> "Aight twin the unmog is complete fr fr. Reverted X identifiers across Y files. Your code is back to being mid and boring (normal). The funny comment has been yeeted. The manifest has been ghosted. Your codebase's aura has been restored to factory settings. Lowkey kinda sad to see the rizz go but that's life no cap. Stay sigma fam 🫡"
