Skill: /remove-brain
Model preference: #highcap (per horizon_aios_model_prefs.md; overridable by a prompt directive).
Deprovision a brain with horizon_aios_remove_brain.py — the counterpart to horizon_aios_create_brain.py. Removes the brain's OS user account, its per-brain group, its workspace folder, its user-profile config, and its stored credential. The shared brains group is left intact (other brains use it).
When to invoke
The user types /remove-brain, or asks to "remove a brain", "delete a brain account", "deprovision a brain", or "tear down a brain user".
Arguments
/remove-brain <brain-name> [--yes] [--keep-credential] [--horizon-root PATH] [--dry-run]
<brain-name>— required positional; must match^[a-z][a-z0-9_]{1,31}$. The script refuses reserved names (brains,root,administrator, the invoking user, etc.).--yes/-y— skip the interactive confirmation prompt.--keep-credential— do not delete the stored OS-keystore credential.--horizon-root PATH— explicit root; otherwise derived from the script location.--dry-run— print what would be removed without changing anything.
Step-by-step execution
Step 1 — Check elevation
This hard-requires the administrative context — the script exits with an error if not run as Administrator (Windows) or root (Unix). (Privileges are checked only on a real run, not --dry-run.) If the session is not elevated and the user did NOT pass --dry-run, do not run it: tell the user to re-run from an elevated terminal (or with sudo) and stop.
Step 2 — Confirmation
Without --yes, the script prompts interactively and requires the user to type the brain name to confirm. A non-interactive agent session cannot answer that prompt — if you intend to run it unattended and the user has clearly confirmed the destructive removal, pass --yes. Otherwise surface that confirmation is required.
Step 3 — Run
python "$HORIZON_SYSTEM/sbin/horizon_aios_remove_brain.py" <brain-name>
Append --yes / --keep-credential / --horizon-root / --dry-run as requested.
Step 4 — Report
Relay the removal output and the final "Verify removal" result. If anything is still present after removal (exit code 2), surface what remained so the user can clean it up.
Exit 2 means the teardown did not finish and the residue will make the next create-brain mint a suffixed profile. Do not paper over it — never rename the profile directory aside to free the name, which reads as success and leaves an untracked profile behind. If the blocker is a live handle the script could not name, a reboot then a re-run is the remedy; the re-run finishes from the ProfileList row.
Notes for the executing agent
- Destructive and irreversible — it deletes the OS account, workspace, profile, and credential. Confirm intent before running with
--yes. - The Windows profile directory is resolved from
ProfileList\<SID>\ProfileImagePath, never constructed asC:\Users\<brain>: Windows suffixes a colliding profile (C:\Users\<brain>.LEATHERDECK, then.000), and a run that deletes the constructed path misses the real profile and still exits 0. The script removes every profile directory and ProfileList row belonging to the brain, including residue whose account is already gone. A--dry-runprints the resolved path — if it shows a bareC:\Users\<brain>for a brain you know is suffixed, stop and report it. - Links (home
~/.claude→ workspace, workspace.claude/skills→skills_bin) are removed as reparse points (rmdir/unlink) BEFORE any recursive delete, soskills_binis never followed/destroyed — do not work around this; just run the script. - The shared
brainsgroup is intentionally kept. Only the per-brain group is removed.