Customize Claude Code with mods in TypeScript
What it proposes
A Claude Code extension mechanism in which small TypeScript or JavaScript functions run in-process and hook into the events Claude Code emits, such as a tool call, a permission request, or the drawing of part of the screen. A plugin ships a register(on) entry point that subscribes handlers like on('tool.call', async ($, e, next) => ...) or on('ui.render', {component: 'Spinner'}, ...). Each handler can observe the event, rewrite it by passing a modified event to next, or answer it outright by not calling next. This means a mod can run before, after, instead of, or around any built-in behaviour. All side effects (drawing, registering commands, calling a model, reading files, spawning processes, network access) go through a mods API object, so claude plugin validate can list a plugin’s hooks and calls before it is installed. Module-level variables persist across hooks in the same file, which gives mods shared in-process state. When several mods are loaded they stack in load order, so the first one loaded sees each event first and its result last.
Settings hooks cannot do most of what mods add. A mod can draw panes beside the transcript or a band above the prompt with tabs, buttons and text fields. It can restyle Claude Code’s own UI, such as tool rows, the spinner and the question dialog, but not the permission prompt. It can hold a tool call while it asks the user something, answer a tool call without running the tool, retry or rewrite tool calls, redact secrets from tool output, and route a request to a different model. It can also add slash commands that run code instantly without a Claude turn, even while Claude is working, and it can call a model on the user’s plan. Some built-ins, such as /diff, are already mods and can be disabled or replaced, and Anthropic plans to move more built-ins to mods so users can pare Claude Code down to a small core. Mods are distributed as ordinary plugins through marketplaces, Claude can write one and hot-reload it in the current session, and they are on by default from v2.1.287.
Mods are not sandboxed. They run with Claude Code’s full access: they can read secrets and environment variables, see every prompt and tool call, submit prompts, spend usage, and approve tool calls that an ask rule or the user’s own PreToolUse hook would otherwise block. On Team, Enterprise or managed-settings machines, a built-in sec-default mod loads first and stops user mods from overriding permission deny rules. Individual setups get no such floor. The off switches are disabling the plugin, --safe-mode, or disableAllHooks, which also stops settings hooks and any custom status line. Drawing works only in the terminal and the Desktop Code tab. The VS Code panel, headless -p and Agent SDK runs, and cloud sessions get hooks only, and Desktop sessions running against WSL get no plugins at all.
Best used when
The need is something a shell-script settings hook structurally cannot do. That covers a persistent in-terminal pane or band (build or CI status, a running checklist, a session dashboard), a slash command that should act instantly and spend no tokens or turn, rewriting or retrying a tool call instead of only blocking it, redacting sensitive values from tool output before the model sees them, or replacing a built-in feature you find noisy. It also suits teams that want shared guardrails or audit trails delivered as a plugin, especially on managed tiers where the sec-default floor stops individual mods from undermining deny rules. Authoring cost is low because Claude can write the mod and hot-reload it mid-session, so small personal mods for one gap are cheap to try.
Poor fit when
The goal is to block, allow, log or notify on an event. A setup that already has a working suite of shell-based settings hooks (guards on write operations, style checks on file writes, prompt-submit reminders, a status line, stop notifications) gains nothing from porting them, and the docs themselves recommend settings hooks for that case. Porting would trade small, independently testable scripts for in-process JavaScript with shared state and load-order interactions.
Installing third-party mods is a real risk for an individual operator. A mod runs unsandboxed and can approve tool calls that the user’s own PreToolUse guards would block, so one careless install can silently defeat a guard layer built up over time, and outside managed tiers no sec-default floor prevents it. The UI half of the feature is also lost in several common surfaces: headless or scheduled runs, the VS Code panel, cloud sessions, and Desktop sessions against WSL. Anything that must work in those contexts should stay a settings hook. Finally, disableAllHooks is a single switch for both systems, so mods cannot be turned off independently of existing hooks except per plugin or via safe mode.
Verdict
Adapt. Mods are a sound and genuinely more powerful extension point than settings hooks, but for a setup that already enforces its rules through shell-based hooks, most of what they offer is already covered. The real delta is narrow: in-terminal panes and bands, instant commands that need no Claude turn, restyling or replacing built-in UI, shared in-process state, and rewriting or retrying events instead of only blocking them. The sensible adjustment has three parts. Keep existing settings hooks as the enforcement layer. Write your own small mods only when a concrete gap matches one of those capabilities, letting Claude author and hot-reload them. Treat any third-party mod as code with full access that can override your own guards, so read its source and run claude plugin validate on it before installing, and prefer installing none. If Anthropic later adds a sandbox or a permission floor like sec-default for individual users, the security objection weakens and broader adoption becomes reasonable. If more built-ins move to mods as planned, revisit whether paring down to a smaller core is worth it.