Skip to main content
Plugin hooks are experimental. Expect breaking changes while we iterate.
An Agent Plugin can ship hooks in three formats: A Claude Code plugin ships hooks/hooks.json too. Xum lists those hooks and never runs them. See Claude Code plugin hooks. In a Cursor plugin, Xum reads hooks/hooks.json in the Cursor format only. See Cursor hooks. For hooks in your own repository, use tool hooks instead.

Codex-format hooks

Xum reads the Codex CLI hooks format, so a Codex plugin’s hooks.json works without edits.

Where they come from

Xum reads hooks/hooks.json in the plugin. If plugin.json has extensions["com.openai"].hooks, that list replaces the default file. Each entry is a relative path to a hooks file or an inline hooks object. An empty list turns the default file off. Only managed plugins run these hooks. A managed plugin is one you installed from Settings → Plugins into ~/.xum/plugins. Project plugins and plugins in ~/.agents/plugins never run them. Xum also runs no Codex-format hook in these cases:
  • The project is not trusted.
  • The workspace is not a local or worktree workspace, for example an SSH, Docker, devcontainer, or Coder workspace.
  • The workspace is a multi-project workspace. Cursor-format hooks are the exception: they run in a multi-project workspace that uses the local or worktree runtime.
  • The chat is a /side chat.

Trust a hook

Installing a plugin trusts none of its hooks. The install preview lists them.
  1. Open Settings → Plugins and select Hooks on the plugin. You can also run Review Plugin Hooks… from the command palette.
  2. Read each hook. If Xum cut a long input, select Show full input first. Trust stays off until you do.
  3. Select Trust. Select Turn off to stop a hook.
Xum trusts the exact definition of a hook: its event, its matcher, and its handler. Reformatting the file keeps trust. Trust lapses in these cases:
  • The definition changes. The hook shows changed, needs review and does not run until you trust it again.
  • The hook moves to another place in its file, for example to another group. It then shows needs review.
  • You turn the hook off.
  • You uninstall the plugin. A reinstall under the same name starts with no trusted hooks.
Xum checks trust before each hook call, not once per turn. A revoke stops the next call. A newly trusted hook starts to run on your next message.

Events and handlers

Stop does not run after an interrupted or failed turn, a compaction, a sub-agent turn, or a delegated workspace turn. It also does not run when a message or a wake is already queued when the turn ends, because the turn continues with that input. Xum lists the other Codex events (PermissionRequest, PreCompact, PostCompact, SubagentStart, SubagentStop, SessionStart, SessionEnd, Interrupt) in Settings as “Never runs”. Xum runs only mcp_tool handlers. Such a handler calls tool on the plugin’s own MCP server server. That server must be enabled and running in the workspace, or the hook does not run. Xum lists command, prompt, and agent handlers as “Never runs”.
Xum fills ${field.path} placeholders in input from the event fields below. A placeholder that is the whole string keeps its JSON type. A placeholder inside a longer string becomes text. Within one plugin, matching hooks run one after another in file order. Plugins run in discovery order. PostToolUse runs in reverse plugin order. Codex-format hooks run before the tool hooks .xum/tool_pre, so tool_pre sees a rewritten input.

Matchers

UserPromptSubmit and Stop ignore matcher. On tool events:
  • "*", "", null, or no matcher matches every tool.
  • A list of names (letters, digits, _, and |, for example Bash|Edit) matches a whole name, not a substring.
  • Any other value is a regex. Codex uses the Rust regex dialect. Xum compiles it as a JavaScript RegExp.
  • A leading flag group of i, m, and s (for example (?i) or (?is)) becomes RegExp flags.
  • Xum translates (?P<name>...) to a JavaScript named group, and the \A and \z anchors to lookarounds that mean the start and end of the name, as in Rust. A group name must follow Rust’s rule and compile in JavaScript (letters, numbers, and _, at most 128 characters). A name used twice is refused.
  • Xum refuses other Rust syntax that JavaScript reads in a different way or rejects. Examples are inline flags after the start, negated flags ((?-i)), the x, U, u, and R flags, \pL, \p{...}, \x{...}, \b{start}, \<, \>, nested or POSIX classes ([[:alpha:]]), and &&, --, or ~~ in a class.
Xum drops a group with a refused or invalid matcher and shows a warning in Settings. Xum tests the matcher against the Xum tool name and against the Codex name below.

Timeouts

timeout is in whole seconds. The default is 10 seconds. Xum caps it at 30 seconds and raises 0 to 1 second. The Codex default of 600 seconds does not apply. Before UserPromptSubmit hooks run, Xum waits for the workspace’s MCP servers to start. The wait is at most the longest UserPromptSubmit timeout.

Event fields

Every event has these fields: Tool events always have cwd. On UserPromptSubmit and Stop, Xum leaves cwd out when it cannot resolve the workspace directory. A ${cwd} placeholder then becomes null (whole string) or empty text (inside a longer string). Per-event fields: last_assistant_message is the reply’s trailing text, after its last tool call, cut to its last 16,384 characters. It is null when the reply ends on a tool call or has no trailing text. model is Xum’s provider-qualified model string, for example openai:gpt-5.2. Codex sends the bare model name. A tool call outside a model turn has no turn_id and no model.

Tool names and the Bash contract

A hook that reads tool_input.script does not work. Read tool_input.command. For a background bash call, tool_response is the output so far. In an MCP name, Xum replaces each character other than [A-Za-z0-9_] with _. For the plugin’s own server, <server> is the server name in the plugin.

Outputs Xum honors

The hook’s MCP tool returns its output as JSON text. Xum joins the text blocks of the result. If the result has no text, Xum reads structuredContent. A UserPromptSubmit block applies only to a message you send (typed, edited, queued, or plan-review feedback). Automatic sends (goal and task continuations, wakes, follow-ups) ignore every block, because their sender would retry the same message in a loop. They keep the context of the other hooks. A hook whose output both blocks and adds context loses its own context. The prompt that a Stop block queues is different: no UserPromptSubmit hook runs for it at all, as in Codex. A UserPromptSubmit guard cannot check it. Each Stop hook continues one message at most 3 times, and all hooks together at most 50 times. When a hook continues the turn, Xum shows the notice “Plugin <name>: plugin continued turn n of 50”. A newer notice replaces one that is still waiting to show, so a long loop does not queue 50 notices. Xum’s own TODO and status nudges also count toward the 50, but show no notice. Cursor hooks share these limits. For a turn that an ACP client or xum run owns, Xum runs the Stop hooks but never continues the turn. For a goal turn, Xum continues only while the goal can take another turn: not after it is paused or replaced, or after it reaches its turn, cost, or budget limit. hookSpecificOutput must have hookEventName set to the event name. Stop has no hookSpecificOutput. A rewrite in updatedInput must match the tool’s input schema and pass the tool’s own input parser (its refinements and defaults). If it does not, Xum denies the call. The tool runs with the parsed value. For Bash, set updatedInput.command. The call keeps its other Xum arguments. The transcript keeps the model’s original tool call. Xum adds a note to the tool result that names the fields the hook changed, for example [plugin:guard] Rewrote this tool call's input (fields: script). The note never contains the values, because a hook can put a secret into the input, and the model provider and the chat log see the note. Xum honors an explicit deny or block when the rest of the output breaks a Codex rule, for example with an unknown field. It does not honor one when the output is malformed (a wrong type or a value outside an enum). Xum does not support permissionDecision: "ask", updatedMCPToolOutput, or suppressOutput. The two lists below say what each case does.

What blocks a PreToolUse call

A broken guard must not let a call through. Xum blocks a PreToolUse call when the hook’s output:
  • Is malformed: invalid JSON, a wrong type, or a value outside an enum. A deny in the same output does not apply.
  • Fails Codex’s schema: an unknown field, or hookSpecificOutput tagged for another event. An explicit deny next to an unknown field still applies, with its own reason.
  • Starts with { or [ and is not a JSON object, such as [] or a list of findings. Plain text that does not start with { or [ is ignored, a bare JSON scalar such as 42 included.
  • Uses a decision or field that Xum does not support: permissionDecision: "allow" without updatedInput, permissionDecision: "ask", the legacy decision: "approve", continue: false, stopReason, suppressOutput, updatedInput without allow, or a reason without a decision. Codex runs the call in these cases. Xum blocks it.
  • Has a result text over 1 MiB (1,048,576 characters).
The model sees Tool call blocked by plugin '<plugin>' hook: its output is malformed: <reason> as the tool error. You see a notice that names the plugin and says to turn the hook off in Settings > Plugins. A rewrite (updatedInput) next to an unknown or unsupported field makes Xum deny the call too, because the hook allowed only its rewrite. If the filled input of a PreToolUse hook is over 64 KiB (65,536 characters) as JSON, and the hook can run, Xum also denies the call. A model can pad a command to get past a guard, so Xum does not let it through.

What fails open

In these cases, Xum logs a warning and continues without the hook’s output:
  • On every event: the hook times out, errors, or returns an MCP error result (isError).
  • On every event: the server or tool is missing, disabled, or not running.
  • On PostToolUse, UserPromptSubmit, and Stop: the output is malformed, fails Codex’s schema, starts with { or [ and is not a JSON object, or is over 1 MiB. A deny or block in a malformed output is ignored too. With an unknown field, an explicit block on PostToolUse and UserPromptSubmit still applies. On Stop, an unknown field voids the whole output, a block included. On UserPromptSubmit, text that does not start with { or [ is context, as the table above says.
When an output parses but breaks a Codex rule (an unknown field, an unsupported decision), Xum still shows its systemMessage to you.

Size limits

Xum cuts the joined tool-event text at 32 KiB and adds [plugin hook context cut]. On UserPromptSubmit, Xum drops the context entries after the 64 KiB cap.

Known gaps

  • PostToolUse sees the MCP result after Xum’s transform, not the raw MCP response. Xum removes protocol _meta, cuts large text, and converts binary content to Xum’s { type: "content", value: [...] } shape.
  • UserPromptSubmit has no turn_id and no model.
  • Only bash and MCP tools have Codex names. Hooks match file edits, task, and other tools by their Xum names.

Cursor hooks

A Cursor plugin ships hooks in the Cursor hooks format: hooks/hooks.json, or the path or inline object of the hooks key in .cursor-plugin/plugin.json. Xum runs each command hook as a shell command. Xum runs three events and lists every other hook as “Never runs”. The size limits for one hooks.json file and for hooks per plugin apply.
hooks/hooks.json

Where they run

Only managed plugins run Cursor hooks. Xum runs none in these cases:
  • The project is not trusted.
  • The workspace is not a local or worktree workspace, for example an SSH, Docker, devcontainer, or Coder workspace. Every Cursor hook shows “Does not run in remote workspaces (SSH, Docker and devcontainer).” A multi-project workspace that uses the local or worktree runtime does run them, although it runs no Codex-format hook.
  • The chat is a /side chat.
  • XUM_DISABLE_AGENT_TOOLS, XUM_DISABLE_TERMINALS, or XUM_DISABLE_PROJECT_AUTOMATION is set to 1.
A Cursor hook runs as your OS user on the Xum host. Only the agent sandbox, when it is on, limits what it can do. Trust only hooks whose commands and files you have read.

Trust a hook

Trust works as for Codex-format hooks: select Hooks on the plugin, read each hook, and select Trust. If Xum cut a long entry, select Show full entry first. The panel warns: “Once trusted, this hook runs a shell command on this computer as you, without a sandbox. It can read and change any file you can.” Xum trusts the entry exactly as declared, including fields that Xum does not use. A change to any field, or a move to another place in the list, asks for trust again. The panel shows each value as declared: a hook with loop_limit: 80 shows 80 and stops at the ceiling of 50. Trust covers the entry, not the scripts it runs. A hook can run any file in the plugin, so Xum reviews the files instead:
  • When a plugin first has a hook that can run, the install preview lists every file of the plugin under Files, as file <path> added. An update that adds the plugin’s first such hook lists every file among its changes.
  • Later updates list each file that the update adds, changes, or removes.
  • A row names a symlink as symlink <path>, a change between file and symlink as file → symlink or symlink → file, and a file’s mode change as, for example, (mode 644 → 755).
  • A UTF-8 text file of at most 64 KiB shows its text. A symlink shows its link text. Any other file shows only the row, with “(contents not shown: binary or larger than 64 KiB)”.
  • Xum marks invisible and bidi control characters in file paths, file texts, and the preview’s warnings as <U+XXXX>, for example <U+202E>.
  • If Xum cut a long text, Xum does not install or update the plugin until you select Show full text on it.
  • A review too large to show fails with “This plugin’s review is too large to show, so Xum cannot install or change it. Contact its publisher.”
A file that changes on disk outside an update runs without a new review. Xum binds the trust of a command hook to the plugin commit whose files you reviewed. An update that this Xum version applies reviews the changed files, so it moves the binding to the new commit. If the plugin changed in another way, for example through an update by an older Xum build, or if you trusted the hook before Xum recorded the binding, the hook shows changed, needs review and does not run. The Hooks panel then shows the full file review again. While no command hook of the plugin is trusted, the Hooks panel lists every file of the plugin under Files, and Trust stays off until you select Show full text on each cut text. If a file’s content or mode changes before you trust the hook, also in a file whose text the review does not show, Xum refuses with “This plugin’s files changed since you reviewed them. Review them again.”

Events

afterAgentResponse and stop run when Codex Stop hooks run, with the same exceptions: not after an interrupted or failed turn, a compaction, a sub-agent turn, or a delegated workspace turn, and not when input is already queued. After a user Stop, no hook runs, and Xum kills a hook that is running. When Xum shuts down or closes the workspace’s session, it also kills a running afterAgentResponse or stop hook. Edits through bash run no afterFileEdit hook. These hooks never run, and the install review lists them under Not applied in Xum:
  • A hook on any other event (“event not applied in Xum”).
  • A hook with a matcher (“matcher not applied in Xum”).
  • A hook with type: "prompt" (“prompt hooks are not applied in Xum”).
A hook that Xum drops while it reads the hooks file, for example one without a command string or with a loop_limit that is not a whole number or null, also appears under Not applied in Xum with its reason. Xum lists at most 50 such hooks.

The command

Xum runs command with bash through the workspace runtime, as written. On Windows that is Git Bash. Xum does not rewrite a leading ./, so ./hooks/x.sh in a stop hook looks in the workspace root, as in Cursor. Name the script from the plugin folder instead, as in the example above. timeout is in seconds: the default is 10 and the cap is 30, as for Codex-format hooks. The process gets a minimal environment, not your shell’s: Xum also passes the same host variables as for a plugin MCP server, such as USER, LANG, TMPDIR, and the CA bundle paths, and the variables it sets for every command so that tools do not wait for input. The input on stdin has these fields:

Output and failures

A stop hook can print { "followup_message": "..." }. Xum then continues the turn with that text as the next prompt. Each stop hook continues one user turn at most 3 times. Set loop_limit to a whole number to change that, or to null for no limit of its own. All hooks together stop at 50 continuations per user turn, and your next message starts a new count. See the notice in Outputs Xum honors. The other two events cannot change anything. Xum checks only that their output is valid. No Cursor event can block, so every failure fails open. Xum logs it, skips the hook’s output, and shows “Plugin <name>: hook <event> failed (<reason>). Turn the hook off in Settings > Plugins.” Xum shows that notice once per hook in each workspace. It shows the notice again after the set of trusted hooks that the workspace runs changes in any plugin (also when you remove the project’s trust and restore it), after you archive and unarchive the workspace, or after Xum restarts. Other failures name their cause. Xum reads no stderr. Exit 127 means that the command, or a command it runs such as jq, was not found. failClosed has no effect on these events.

Claude Code plugin hooks

A Claude Code plugin’s hooks/hooks.json, and each file that the hooks key of .claude-plugin/plugin.json names, has the same shape as a Codex hooks file. Xum reads them and lists every hook in Settings as “Never runs”, on every Claude Code event and for every handler type, mcp_tool included. Claude Code matchers name Claude Code tools, which Xum does not map. Xum warns about and ignores inline hooks objects in the manifest and http handlers.

Xum-native hooks

A plugin can ship hooks.js in its root, or at the path that contributes.hooks in plugin.json names. Xum loads hooks.js from global plugins, and from project plugins in a trusted project. A package with only .codex-plugin/plugin.json, .claude-plugin/plugin.json or .cursor-plugin/plugin.json gets no hooks.js. Xum has no per-hook trust step for hooks.js. The install preview discloses it. hooks.js is a script that evaluates to an object of hook functions. It runs in a QuickJS sandbox and cannot call tools. A function can be async. Each call has 5 seconds. Tool hooks see only the tools that plugin.json lists in extensions.mux.hooks.tools. With no list, they see no tool. Tool hooks get Xum’s tool names and arguments, for example bash and args.script.
plugin.json
hooks.js
settings holds the structured settings (openai/settings) of the plugin’s own connected MCP servers, keyed by server name. These fields tell a hook that Xum left out data:
  • settingsOmitted: true: the settings JSON is over 64 KiB (65,536 UTF-8 bytes). The hook gets settings: {}.
  • resultOmitted: true: the tool result is over 256 KiB (262,144 characters) as JSON, or Xum cannot serialize it as JSON. tool.execute.after gets no result.
A hook that crashes, times out, or returns a malformed output never breaks the turn. Xum logs it and continues. Xum ignores an args rewrite that is not an object. Xum drops request.assemble context over 64 KiB (65,536 characters). Xum adds an annotation only to an object result.

Back up and restore your plugins

Settings → Backup can back up the plugins you installed from Settings → Plugins. Agent plugins is on by default. The backup records where each plugin came from, never the plugin itself, and a restore never installs a plugin. A restore only lists them, and you reinstall each one through the normal install review. For each plugin, the backup keeps:
  • The repository URL and the branch or tag the plugin tracks.
  • The commit it is pinned to.
  • Its folder in the repository, for a monorepo plugin.
  • The skills and MCP servers you chose to import.
It leaves out your consent, hook trust, install dates, and the auto-update flag. Project plugins and plugins you copied into a plugin folder by hand are not listed. A plugin you installed from this machine (a local path, a file:// URL, or a host such as localhost or 127.0.0.1) is not listed either: no other machine can use that source, and the list would publish it. A plugin whose source URL has whitespace, a control character, or a format character (such as a right-to-left mark or a zero-width space), for example an scp-style URL with a space in its path, is left out too: a backup does not carry such a URL, so the plugin keeps working here and Back up now does not fail for it. The same holds for a URL that spells a letter, a digit, or one of - . _ ~ as a percent escape (%67 for g), at any level (%2567 is %67 escaped again), because the secret scan could not see a token written that way. An escape such as %20 in My%20Project is fine, and so is a space escaped twice (%2520), unless it sits next to a token: Xum also decodes the escapes of a plugin’s list entry, up to four levels, and runs the secret scan on every decoded form. It leaves the plugin out when that finds a token, when an escape cannot be decoded, or when more levels remain. Xum also leaves a plugin out when a token sits behind a control character in any field of its list entry, a component name included, for example a newline before a token: a backup file writes a control character as an escape (\n), and the secret scan could not see the token written that way. The same holds for an scp-style source whose host is one character with no user, such as h:org/repo.git, because Git for Windows reads that as a drive. Write it as git@h:org/repo.git or as an ssh:// URL to keep it in the list. A plugin Xum generated from a Claude Code marketplace entry is not listed: Xum keeps only the entry’s name, which cannot rebuild an entry that points at another repository. Add that plugin again from the marketplace.

Reinstall after a restore

Preview changes and Restore both show a Plugins in this backup card that compares each listed plugin with this machine: Select Review and install to open Settings → Plugins with every Not installed plugin queued. A review previews only plain https URLs: a host name or IPv4 address, an optional port and a path of simple characters, with no user name, query, fragment, percent escape, backslash or host on this machine. An unusual URL can name a different host than the one you see (https://github.com\@attacker.example/x connects to attacker.example). An ssh source (ssh://[user@]host[:port]/path or [user@]host:path) is previewed at the https address of the same host and path (https://host/path), which must be plain too. A preview over ssh would make git sign in with your SSH keys to the host the backup names, before you agree to that plugin, and the https address never does. The preview is at the pinned commit, so a repository that serves that commit serves the code that was backed up. A source that is neither shows Add it yourself instead. Xum previews each one at its pinned commit, not at the tip of its branch, so you review the code that was backed up. Xum picks the first install method that fits, and you can change it under Install as. Read the preview, then select Install, or select Skip to leave that plugin out. When the backup recorded which skills and MCP servers you imported, the review starts with those, as far as the repository still offers them. If a preview fails, for example because the repository moved, fix the source in the form and preview again, or skip the plugin. A review reads the URL as written. A host name that DNS points at this machine (for example localtest.me or ip6-localhost) still passes, because Xum cannot look the name up before git does. Plugins that a remote marketplace names have the same limit. If a backup lists such a plugin, the preview contacts that host over https. It uses no SSH keys, but it does use a credential that git or your ~/.netrc file holds for that host name (a default entry in ~/.netrc matches every host), as for a plugin from a remote marketplace or a URL you type into Settings → Plugins. The preview starts only after you select Review and install, and for each next plugin after you install or skip the one before. Nothing installs unless you read the preview and select Install. The installed plugin sits at the pinned commit and keeps tracking the branch or tag the backup recorded, so update available can show.

Back up before you reinstall

A backup writes the list from the plugins installed on this machine. A plugin that the backup lists and you have not reinstalled yet would drop out of the backup. The same holds for a plugin that this machine does not back up (it came from this machine or from a Claude Code marketplace entry), and for a plugin that this machine installed from another repository or another folder of the repository under the same name. A new commit or branch of the same repository and folder is an update, not a removal. Xum compares the repository URL as written, so another spelling of the same repository (a trailing .git, or the host in another case) counts as another source. The one exception is the https address of an ssh source, because a review installs a listed ssh plugin from there: that install and the listed source count as the same plugin, in both directions. So Back up now stops when it would remove a plugin from the list. Settings → Backup names each plugin it would remove and shows Back up and remove. Select it to back up and remove those plugins, or reinstall them first. The check runs on the backup as it is when you back up, so it does not matter which section you visited in between. If what the backup would remove changed since the card appeared, Xum asks again. The card names only the plugins that Xum could read from the list. When the list also has parts Xum left out (see below), the card says so, and Back up and remove removes them too.

When the list cannot be read

If Xum cannot read part of the list, for example a plugin that a newer Xum recorded, it leaves that part out and shows a warning on the card. The rest of the restore still runs. If Xum cannot read the registry of your installed plugins (plugins.json in your Xum folder), or the registry has entries this version of Xum cannot read or lists one plugin name twice, Back up now fails. The error names the file and how many entries Xum cannot read. Xum does not write a list that would leave those plugins out. Repair the file, or turn off Agent plugins to back up without the list. A missing plugins.json is not an error: it means no plugins. One backup lists at most 512 plugins. With more installed, Back up now fails, says how many plugins are over the cap, and tells you to uninstall plugins or to turn off Agent plugins. If an installed plugin has something a backup cannot hold, such as a repository URL over 2,048 characters, a ref with whitespace, a control character or a format character (such as a bidi mark or a zero-width joiner), a folder over 1,024 characters, or more than 512 imported skills, Xum leaves that plugin out of the list and writes its name and the field to its log, never the URL or the ref. Back up now does not fail for it. If that plugin was in the backup before, Back up now asks you to confirm its removal first. Xum reads the registry and the plugin folders for the list, and for the Plugins in this backup card of Preview changes and Restore, while no install, update, or uninstall runs. If one runs, the backup, the preview, or the restore waits for it for up to 10 minutes. After that it fails and names the process that holds the lock. With Agent plugins off, a backup writes no list and removes the one already in the repository. Back up now asks first, and the card says that the whole list is removed. A restore skips the list and says that the backup has one.