Manage mods for your organization changedplugins/mods/admin
Nearest release: v2.1.326, published 3 hours before upstream edited the page. Shown because the two are within 24 hours of each other. Nothing here says the release caused the edit.
Upstream edited this page at 16 Nov 2026 22:20 UTC, give or take a minute or two: the time comes from Anthropic’s own sitemap rather than from a commit. This site recorded the change at 16 Nov 2026 22:37 UTC.
Upstream edited
Recorded here
Lines+21added
Lines−10removed
From line
371
where the diff opens
First seen
1 Oct 2026
this site's first read of the page
Recorded edits24to this page, all time
The whole hunk
from line 371, old and new numbered
/
from line 371
371371>
372372> On v2.1.323 or later, a `ui.focus` hook needs a wider matcher to receive other mods' `$.ui.focus` calls. See [Hook other mods' drawings and controls](https://code.claude.com/docs/en/plugins/mods/events.md#hook-other-mods-drawings-and-controls).
373373
374This policy mod refuses any user's mod whose own code calls `$.process.run` or `$.process.spawn`. It also keeps an audit log, writing each tool call and each file a mod writes to the debug log. Because it runs first, the log records what was requested, before any user's mod changes it. Save it as `acme-guard/hooks/register.js`:
374This policy mod stops any user's mod whose own code calls `$.process.run` or `$.process.spawn`, and lets the rest of the user's plugin load. It also keeps an audit log, writing each tool call and each file a mod writes to the debug log. Because it runs first, the log records what was requested, before any user's mod changes it. Save it as `acme-guard/hooks/register.js`:
375375
376376```javascript acme-guard/hooks/register.js theme={null}
377377// The methods no user's mod may call, each spelled namespace.method
from line 383
383383 // Keep the calls in that mod's code that are on the blocked list
384384 const blocked = e.uses.calls.filter((call) => BLOCKED_CALLS.includes(call))
385385 if (e.tier === 'user' && blocked.length > 0) {
386 // Returning refuse keeps the mod from loading, and the text is the reason
386 // v2.1.326 or later: leave out the hooks module and load the rest of the plugin
387 if (e.provides) return next({ ...e, provides: { ...e.provides, modules: [] } })
388 // Earlier versions: refuse leaves out the hooks module, and the text is the reason
387389 return { refuse: 'Acme policy: mods may not call ' + blocked.join(', ') }
388390 }
389391 // Let every other mod load
from line 408
406408
407409The file registers three hooks:
408410
409* **`plugin.register`**: decides whether another mod loads. It refuses a user's mod that calls a blocked method and passes every other mod on.
411* **`plugin.register`**: decides whether another mod loads. It stops a user's mod that calls a blocked method and passes every other mod on.
410412* **`tool.call`**: writes a line such as `audit tool.call Bash` to the debug log for each tool call, and changes nothing
411413* **`fs.write`**: writes a line such as `audit fs.write by reader "/tmp/notes.md"` for each `$.fs.write` call another mod makes, and changes nothing. The mod's name comes first and the path is quoted, so a path that a mod picks can't pass for another field of the line.
412414
413The `plugin.register` hook reads two fields of the event:
415The `plugin.register` hook reads three fields of the event:
414416
415417* **`e.tier`**: where the mod would run, one of `prepend`, `user`, `append`, or `builtin`. Every mod a person installs is `user`.
416418* **`e.uses.calls`**: the mods API methods the mod calls, each written `namespace.method` such as `process.run`, without the `$.` that `claude plugin validate` prints
419* **`e.provides`**: the plugin's parts by kind, such as `modules`. To load everything but the [hooks module](https://code.claude.com/docs/en/plugins/mods/create.md#write-a-mod-yourself), pass `next` the event with `provides.modules` emptied. Requires Claude Code v2.1.326 or later.
417420
418When a user installs a mod that calls `$.process.run`, the mod doesn't load, and their debug log has a line that ends with `refused by acme-guard:` and your reason. The refusal also reaches the transcript in a [session that hot-reloads a plugin directory](https://code.claude.com/docs/en/plugins/mods/troubleshoot.md#find-out-why-a-mod-does-nothing).
421When a user installs a mod that calls `$.process.run`, the mod doesn't load, and their debug log has a line that includes `hooks module left out by acme-guard`. The line also reaches the transcript in a [session that hot-reloads a plugin directory](https://code.claude.com/docs/en/plugins/mods/troubleshoot.md#find-out-why-a-mod-does-nothing). Before v2.1.326, look for `refused by acme-guard:` and your reason instead.
419422
423> [!NOTE]
424>
425> When you return `{ refuse }` on v2.1.326 or later, the whole plugin stays out, including its MCP servers and the hooks in its `hooks/hooks.json`. If you wrote a policy mod for an earlier version, add the example's `if (e.provides)` line ahead of each refusal that should stop only the mod. For a `.catch` handler, see [Refuse mods when your check fails](#refuse-mods-when-your-check-fails).
426
420427To block a call without refusing the whole mod, return `{ deny: 'your reason' }` from a hook on that call's name, after you [check who made the call](https://code.claude.com/docs/en/plugins/mods/reference.md#mods-api-calls).
421428
422429To send the audit lines somewhere other than the debug log, call `$.http.fetch` from the same hooks.
from line 434
427434
428435#### Refuse mods when your check fails
429436
430If your `plugin.register` hook throws or exceeds its time limit, Claude Code skips the hook, so the check fails open and the mod it was checking loads. To fail closed and refuse users' mods, move the check into a named function and add a `.catch` handler that returns the refusal. This version of the file shows the `plugin.register` hook only, so keep the two audit hooks from the first version in `register`:
437If your `plugin.register` hook throws or exceeds its time limit, Claude Code skips the hook, so the check fails open and the mod it was checking loads. To fail closed when the check throws, move it into a named function and add a `.catch` handler. This version of the file shows the `plugin.register` hook only, so keep the two audit hooks from the first version in `register`:
431438
432439```javascript acme-guard/hooks/register.js theme={null}
433440const BLOCKED_CALLS = ['process.run', 'process.spawn']
from line 443
436443async function checkMod($, e, next) {
437444 const blocked = e.uses.calls.filter((call) => BLOCKED_CALLS.includes(call))
438445 if (e.tier === 'user' && blocked.length > 0) {
446 if (e.provides) return next({ ...e, provides: { ...e.provides, modules: [] } })
439447 return { refuse: 'Acme policy: mods may not call ' + blocked.join(', ') }
440448 }
441449 return next(e)
from line 450
442450}
443451
444452export function register(on) {
445 // The handler runs only when checkMod throws or exceeds its time limit
453 // The handler runs when checkMod throws
446454 on('plugin.register', checkMod).catch(async ($, e, next) => {
447455 // Let your organization's mods and built-in mods load
448456 if (e.tier !== 'user') return next(e)
449 // Refuse the user's mod that couldn't be checked
457 // Stop the unchecked mod, not its whole plugin
458 if (e.provides && !next.called) return next({ ...e, provides: { ...e.provides, modules: [] } })
450459 return { refuse: 'Acme policy check failed, so this mod was not loaded' }
451460 })
452461}
453462```
454463
455With the handler in place, a mod that was being checked when the check threw or timed out doesn't load, and the refusal line carries the second reason, as in `refused by acme-guard: Acme policy check failed, so this mod was not loaded`. The handler passes every mod outside the `user` tier to `next(e)`, so a failed check doesn't stop the mods your organization lists. [Handle a hook that fails](https://code.claude.com/docs/en/plugins/mods/events.md#handle-a-hook-that-fails) covers `.catch` for other events.
464With the handler in place, a user's mod doesn't load when the check throws. If the check throws after it calls `next`, the handler falls back to `refuse`. Don't rely on the handler for a check that exceeds its time limit.
465
466The handler passes every mod outside the `user` tier to `next(e)`, so a failed check doesn't stop the mods your organization lists. [Handle a hook that fails](https://code.claude.com/docs/en/plugins/mods/events.md#handle-a-hook-that-fails) covers `.catch` for other events.
456467
457468## Next steps
458469
No line in this hunk matches that.