Skip to content
Stuart Jackson edited this page Nov 25, 2026 · 3 revisions

Mods

A mod is a plugin whose TypeScript or JavaScript runs inside Claude Code: it can draw a status line, a pane, a band above the prompt, or toasts, add slash commands and tools, and watch or rewrite events such as tool calls. This page holds the main points and the rules for augur plugins; Anthropic's mods docs hold the detail.

Sources (read 2026-11-22; re-read before relying on a version or an API name):

Where mods run

  • Claude Code only: the terminal (v2.1.287+), the Desktop Code tab (v2.1.286+), the VS Code chat panel, claude -p and the Agent SDK (hooks run, nothing is drawn). On by default.
  • Not claude.ai chat or Cowork. The mods docs do not mention them; chat loads a different set of components (Platform-Support#what-each-surface-loads).

So a mod breaks the "every surface" principle in Home#principles. A mod MUST ship as its own plugin, never inside a skills or connector plugin, and its README MUST say "Claude Code only". That keeps the cross-surface plugins clean and lets users turn the mod off on its own.

Security

Mods are not sandboxed (Overview). A mod runs with the user's permissions, can read environment variables and settings (which may hold keys), sees every prompt and tool call, and can approve calls that deny and ask rules would stop. $.fs and $.process can bypass permission rules (Admin).

For a public marketplace that means:

  • A mod MUST do only what its README says, and MUST NOT send data anywhere the README does not name.
  • Every change to a mod MUST be reviewed as code, not as text.
  • Users can inspect a mod before installing: claude plugin validate <dir> lists its hooks: and calls:.

In an untrusted folder no mod loads until the trust prompt is accepted.

Layout

plugins/<name>/
  .claude-plugin/plugin.json   # metadata; optional "types" names the .d.ts for $.state
  hooks/hooks.json             # { "modules": ["./register.tsx"] }  <- this makes it a mod
  hooks/register.tsx           # ES module exporting register(on, options); no build step
  tests/*.test.ts              # imports claude-code/testing
  types/index.d.ts             # state atoms and $ namespaces

Plugin names starting claude-, anthropic-, or cc-plugin- are rejected (Reference).

The API in one screen

on(event, [matcher], hook) registers a handler ($, e, next); .catch(...) makes it fail closed (Reference, Events).

Need Use
A line under the prompt $.ui.status
Panes, toasts, redraws $.ui.*, ui.render event
A slash command $.command.register and the command.run event
State for this session $.state atoms
State across sessions $.store (JSON)
Run a program $.process.run (argv, no shell, 30 s default)
Files, HTTP, time $.fs, $.http.fetch, $.clock (no setTimeout)

Key events: session.start, prompt.submit, turn.*, tool.call, tool.check, command.run, ui.render. Full list: Events.

Every mod command answers help (Skill-Authoring#rules-for-augur-plugins): its argumentHint lists help, and /<command> help explains the command in any project and changes nothing. The decision is proved like any other (commandStep in pane-rules.ts, usageCommand in the status line's usage-rules.ts), and the mod's tests pin the answer.

Loader rules

These fail validation or the load if broken (Create, Events, Troubleshoot):

  • Write every call in full ($.ui.status); MUST NOT alias $ or its namespaces, and pass $ only to top-level functions in the same file.
  • Event names are string literals; imports are static and relative, plus claude-code; ES modules only.
  • One registration per event unless each has a matcher.
  • A hook that throws or times out is skipped (fails open); add .catch where failing closed matters.
  • Module-level variables reset on every reload: keep state in $.state or $.store.
  • session.start does not fire after /clear, /resume, or /branch.
  • All installed mods share one worker; three crashes unload every non-built-in mod. A mod MUST time out its slow calls (the status line gives gh and claude 5 seconds).

Develop and test

Step Command
Live session, reload on save; generates the API types claude --plugin-dir plugins/<name>
Manifest and loader checks claude plugin validate plugins/<name> --strict
Tests (no session, no network) claude plugin test, from the plugin folder
Type check tsc -p plugins/<name> after --plugin-dir has generated the types
Debug log claude --debug-file <path>

All four MUST pass before a push. CI and pnpm quality lint and format a mod and run claude plugin validate . --strict (Development#quality), but not its tests or type check: those need the types only --plugin-dir generates, so they run by hand. Generated types are not committed (.gitignore).

Releasing

Installed copies are cached by version: users get a change only after the version in plugin.json changes and the plugin updates (Deployment#publish). After an update, Claude Code users run /reload-plugins.

Clone this wiki locally