Why Deleted AI Shells Still Run Hooks in Claude Code, Codex, and Cursor
You tried an AI coding shell or terminal orchestrator a month ago, decided not to keep it, and dragged the app from /Applications to the Trash. Weeks later, every time you start a session, submit a prompt, or run a tool call in Claude Code, Codex, or Cursor, that agent still spawns a shell to call the app you removed.
A desktop wrapper that coordinates other people's coding agents needs to know when each agent starts, waits for input, or finishes a turn. Most of them get those signals by writing lifecycle hooks into the agents' own configuration files, such as ~/.claude/settings.json, ~/.codex/hooks.json, ~/.cursor/hooks.json, or ~/.gemini/settings.json, and by dropping plugin files into folders owned by Amp, Grok, Copilot CLI, or pi. None of those files sit inside ~/Library under the removed app's name, so dragging the app to the Trash or using an uninstaller that only checks the app's own folders leaves every hook behind. Many installers wrap their hook command in a shell check so a missing script exits with status zero instead of crashing your session, which hides the leftover until you notice slower agent startups, extra shell and Python processes on every tool call, or a stray error line when you open the config by hand.
Check your agent configs yourself
You do not need any third-party tool to see whether removed AI shells left hooks behind. All of the Terminal commands below are read-only and change nothing on disk.
If you have jq installed, print every command string across the main agent hook files:
jq -r '.. | objects | .command? // empty' ~/.claude/settings.json ~/.codex/hooks.json ~/.cursor/hooks.json ~/.gemini/settings.json 2>/dev/null
If jq is not installed, grep across those files plus ZCode and Antigravity hook configurations shows the file name and line number for each command entry:
grep -nH '"command"' ~/.claude/settings.json ~/.codex/hooks.json ~/.cursor/hooks.json ~/.gemini/settings.json ~/.zcode/cli/config.json ~/.gemini/config/hooks.json 2>/dev/null
Next, check the directories where tools drop standalone per-installer hook and extension files:
ls -la ~/.grok/hooks ~/.copilot/hooks ~/.config/amp/plugins ~/.pi/agent/extensions 2>/dev/null
When a command line names a script under your home folder or /Applications, check two things rather than one. First, test whether the script path itself still exists with ls -l. Second, if the script still sits in a hidden dot folder such as ~/.orca/agent-hooks, check whether Orca.app is actually still installed in /Applications or ~/Applications. Dragging Orca.app to the Trash leaves ~/.orca behind on disk, so a [ -f ~/.orca/agent-hooks/... ] guard sees the file, passes the check, and launches a shell and python3 on every single tool call for an app you no longer have.
What six AI shells write into other agents
Both Claude Code hooks and Cursor hooks run deterministic shell commands at lifecycle events such as SessionStart, PreToolUse, PostToolUse, and Stop. Inspecting the source code and documentation of six desktop AI shells and terminals shows how differently each one integrates with local coding agents:
| Tool | Agents written into | Where scripts and plugins live | What happens after dragging .app to Trash |
|---|---|---|---|
| Orca | 24 agents | Scripts in ~/.orca/agent-hooks, whole plugin files in Amp, Copilot CLI, Grok, Hermes, pi, omp, and Prime Agent, plus 10 skills in 22 skill roots |
Runs ~/.orca scripts on every event if ~/.orca remains; spawns a shell guard per event if ~/.orca is deleted |
| cmux | 21 agents | ~/.cmux, 8 cmux-named plugin and hook files across Grok, Copilot CLI, Amp, pi, omp, Campfire, and Kiro, plus shared config entries |
Shared config entries check command -v cmux and exit cleanly once cmux is gone; standalone plugin files remain |
| Herdr | 18 agents | Scripts written inside each agent's own folder (such as ~/.claude/hooks/herdr-agent-state.sh) via herdr integration install |
Owned by the separate herdr-core runtime rather than Herdr.app, so trashing the app leaves them active |
| T3 Code | 0 agent configs | Reads agent settings without modifying them; stores its own state and worktrees in ~/.t3/userdata and ~/.t3/worktrees |
Leaves no hooks in other agents; ~/.t3 stays on disk with your worktrees |
| Runner | 0 persistent files | Passes hooks on the command line each time it launches an agent session | Leaves zero residue in agent configuration files |
| Rex | 1 hook + skill folder | rex skill setup adds one SessionStart hook and a skill folder; user config init.lua lives in ~/.config/rex |
The SessionStart hook entry and ~/.config/rex stay until removed |
Runner is worth noting as the clean counterexample. Its design notes explain that after studying how cmux and Orca edit global agent configuration files, its author chose to pass hook flags on the command line of each agent process Runner launches. Sessions started inside Runner report their state as expected, sessions started in your regular terminal never touch Runner's hooks, and dragging Runner to the Trash leaves nothing in ~/.claude or ~/.cursor to clean up.
Not every agent stores hooks the same way
Even when two AI shells target the same coding agents, those agents do not share a single JSON schema. Reading the installers behind Orca and cmux surfaces four distinct configuration shapes on macOS:
- Standard
hooksevent maps. Claude Code (~/.claude/settings.json), Codex (~/.codex/hooks.json), Cursor (~/.cursor/hooks.json), Gemini CLI (~/.gemini/settings.json), strict-JSON Devin configs (~/.config/devin/config.json), object-form Kiro agent files (~/.kiro/agents/*.json), and Claude-compatible settings in~/.qwen,~/.qoder,~/.qoder-cn,~/.codebuddy,~/.openclaude,~/.commandcode, and~/.factorymap event names underhooksto arrays of command objects or matcher groups. Orca also embeds a$OSTYPEcasestatement with a Windows PowerShell branch inside every Claude Code hook it writes. - Nested
hooks.eventsobjects. ZCode (~/.zcode/cli/config.json) places its event arrays one level deeper underhooks.eventsalongsidehooks.enabled. - Installer-keyed
hooks.jsonwrappers. Antigravity (~/.gemini/config/hooks.json) namespaces each installer's events under a top-level key such asorca-statusand passes the entire shell guard as a single-quoted string to/bin/sh -c '...'. Even fallback JSON output differs by host: printing{"decision":"ask"}is a neutral default in Antigravity, whereas Gemini CLI interprets"ask"as an active instruction to prompt for confirmation, so removing a hook that intentionally prints"ask"in Gemini CLI would weaken a permission check. - External file pointers. Muse (
~/.config/muse/settings.json) stores no inline hook array at all; it keeps amanaged_hooks_pathkey pointing to an external hooks file on disk.
Dead local MCP servers fail for the same reason in ~/.cursor/mcp.json, Claude Desktop's ~/Library/Application Support/Claude/claude_desktop_config.json, and ~/.claude.json (both top-level mcpServers and per-project projects[<path>].mcpServers). When an uninstalled app registered a local MCP binary or script that no longer exists, every new session tries and fails to spawn that server.
What not to delete blindly
Once you spot leftover entries in ~/.claude/settings.json, it is tempting to run a search-and-replace or delete whole folders matching a tool's name. Several traps make blind name-matching unsafe:
- Never delete config lines by tool name alone. A string like
orcacan match your own shell alias, a project directory, or/usr/local/bin/orcaand~/.local/bin/orca, where unrelated tools use the same binary name. An entry is only safe to cut when every script path it runs is provably missing (or sits inside an app-owned script folder like~/.orca/agent-hooksafter that app is gone) and the command runs nothing else alongside it. A compound hook such asnotify; ~/gone.shorcat < ~/notes.mdstill performs real work and should be edited by hand rather than dropped whole. - Leave skill folders alone. Orca copies ten skills into 22 agent skill directories under generic task names that do not contain
orca. Deleting them by guesswork risks wiping skills another installer put there or prompts you customized yourself. - Leave
command -vguards andherdr-corealone. cmux's shared-config entries checkcommand -v cmuxand become inert once the binary is gone, with no missing script path to distinguish an orphaned entry from an intentional setup across machines. Herdr's hook scripts and~/.config/herdrbelong toherdr-core, which is installed separately fromHerdr.appand may still be used from Terminal. - Respect shared roots, Node version managers, and unmounted drives. Plugin files under
~/.config/opencodebelong to OpenCode's own configuration tree. Paths under/Volumesor an empty mount-point folder may live on an external drive that is simply unplugged. Likewise, ifnvmorpyenvremoved an oldnodeorpython3.12binary that an MCP server referenced, the entry in~/.claude.jsonstill holds yourserver.jspath andenvAPI keys; update the interpreter path instead of deleting the server block.
Before editing any shared JSON config by hand, quit the agent so it does not overwrite your changes on exit, save a copy, and verify that your edited file is still valid JSON:
cp ~/.claude/settings.json ~/.claude/settings.json.bak && jq empty ~/.claude/settings.json
If jq empty prints nothing and exits with zero, you did not leave a trailing comma or broken brace behind.
Where Mole fits
Mole handles both sides of this problem without matching blindly on tool names or reformatting your settings files.
On the Clean tab, clicking the Moon in the top-right corner opens AI Tool Cleanup & Care. Under Unused tools and maintenance, the Orphaned hooks and MCP servers row scans ~/.claude/settings.json (and Claude-shaped agent configs), ~/.codex/hooks.json, ~/.cursor/hooks.json, ~/.gemini/settings.json, Devin, Kiro, ZCode, Antigravity, Muse, ~/.grok/hooks, ~/.copilot/hooks, ~/.cursor/mcp.json, ~/.claude.json, and Claude Desktop's config. An entry is listed only when every script or program it executes is provably gone (including ~/.orca/agent-hooks scripts left behind after Orca is uninstalled) and no other live command shares the entry. The row starts unticked, names the exact broken MCP server keys and missing hook scripts on each line, and stays locked while the owning agent is running. When you confirm cleanup, Mole first saves a full copy of the original file to the Trash, cuts only the dead entries' bytes in place so the rest of your JSON keeps its exact key order and formatting, and verifies the parsed result before replacing the file. Per-installer files in ~/.grok/hooks and ~/.copilot/hooks whose every entry is dead move to the Trash whole; recovery from the Trash works as long as you have not emptied it.
When you remove Orca or cmux through Apps › Uninstall, Mole also lists the exact named plugin files they drop into Amp, Copilot CLI, Grok, Hermes, pi, omp, Prime Agent, Campfire, and Kiro for review alongside ~/.orca or ~/.cmux, while uninstalling T3 Code lists ~/.t3 unticked so you never lose uncommitted worktrees by accident. For the broader story behind testing nearly 30 AI tools, see building AI tool cleanup into Mole; for removing the agents themselves, see uninstalling Claude Code, Codex CLI and OpenCode and cleaning up AI coding tools.
FAQ
Why does Claude Code or Cursor still run a hook after I deleted the app?
Dragging an AI shell from /Applications to the Trash removes the app bundle, not the lines it wrote into ~/.claude/settings.json, ~/.codex/hooks.json, or ~/.cursor/hooks.json. Those agents read their own config files on every session and keep firing every configured command until the entry itself is removed.
Does an orphaned hook break my coding agent or just slow it down?
It depends on how the installer wrote the hook. Unguarded entries or missing MCP servers fail on every session start or event. Guarded entries such as Orca's return cleanly when ~/.orca is gone, so nothing looks broken, yet the agent still spawns a shell process on every prompt and tool call, or runs python3 for nothing if ~/.orca/agent-hooks stayed on disk.
Is it safe to delete ~/.claude/settings.json or ~/.cursor/hooks.json to clear leftover hooks?
Do not delete shared settings files whole unless you want to lose everything else in them. ~/.claude/settings.json also stores your permissions, model preferences, environment variables, and your own hooks. Back up the file first and remove only the dead hook objects inside the hooks map.
Why doesn't Mole remove cmux entries in shared settings or Herdr hooks automatically?
cmux's shared-config hooks check command -v cmux rather than a file path, so once cmux is gone they run nothing and cannot be distinguished safely from a config synced across Macs where one still uses cmux. Herdr's scripts belong to the standalone herdr-core CLI rather than Herdr.app, so trashing the desktop app does not prove herdr-core is no longer used.
How can I undo a hook edit if something stops working?
If you copied the config to a .bak file before editing by hand, copy it back while the agent is quit. If Mole edited the file through Orphaned hooks and MCP servers, open the Trash, find the backed-up <Tool> settings.json copy inside Mole's recovery folder before emptying the Trash, and move it back to its original path.