Anthropic adds Claude Code Mods for JavaScript and TypeScript plugins
Claude Code Mods let JavaScript or TypeScript plugins replace agent behavior, inspect session events, spawn subagents, and change the UI. Practitioners have shared a mod-building skill and hot-reload workflows.

TL;DR
- Claude Code Mods are JavaScript or TypeScript plugins that can replace agent behavior and draw custom UI, as described in the launch demo.
- In-process hooks expose conversation context, subagent spawning, and structured results, according to the interview clip.
- Claude Code can build a mod from a prompt and hot-reload it into the session, following the prompt-to-mod walkthrough.
- Community tooling already includes a free mod-building skill that daniel_mac8 shared during the early preview.
Anthropic's roughly 80-line Token Weather example turns context usage into a weather forecast above the prompt. The published built-in source reveals that AGENTS.md support and the /diff pane use the same extension mechanism.
Version requirements
Mods are enabled by default in Claude Code 2.1.287 or later, according to Anthropic's October 1 guide. A September 25 independent breakdown still documented the preview flag CLAUDE_CODE_ENABLE_FUNCTION_HOOKS=1.
The API can change between releases. Every mod load writes declarations into .claude-plugin/types/, which the guide identifies as the authoritative API for that build.
Function hooks
A mod uses the standard plugin package layout specified in the guide:
.claude-plugin/plugin.json: the plugin manifest.hooks/hooks.json: amodulesarray naming exactly one module.- The module: exports
register(on, options)and attaches handlers withon(event, matcher?, hook).
Each handler receives ($, e, next): the host API, plain event data, and a continuation. Hooks form a middleware chain, with Claude Code's normal behavior at the bottom.
A handler has three moves:
- Observe: await
next(e), inspect the result, then return it. - Rewrite: pass a modified event to
next. - Answer: return directly without calling
next, denying an action or supplying the implementation itself.
That third move lets a plugin serve a tool or slash command instead of passing it through to the core.
Session context and subagents
Thariq Shihipar, on Anthropic's Claude Code team, outlined three in-process capabilities in the podcast conversation:
- Inspect conversation turn counts and token usage.
- Spawn subagents from the plugin.
- Parse their results and return structured output.
For usage widgets, $.session.usage() exposes context.tokens, context.window, and context.percent, as documented in the Token Weather tutorial. The token figure represents the input the last response was answered over; the call only sends a token-count request when a breakdown is requested.
UI rendering
The biggest unlock is component-level UI interception. A ui.render hook can replace the AbovePrompt band or draw a Pane, using constructors returned by $.ui.resolve(e) in the official example.
The constructors vary by surface, and JSX is supported with h as the factory. The guide demonstrates two different uses:
- Token Weather: context percentage, tokens used versus window size, a 12-turn sparkline, and the last turn's token change.
- Blast Radius: holds a risky Bash call, measures what it would affect, and opens a Proceed/Cancel pane. Its
rm -rf builddemo previews nine files totaling 1.1 MB before execution.
Hot reload and state
Claude Code can write a weather-forecast mod from a plain-language request, then display it when the turn ends after hot reload is approved, according to the walkthrough.
Reloading re-runs register and fires session.start again. Anthropic's working example spells out the lifecycle details:
- Module-level variables reset on reload.
- Named values in
$.statelive in the host for the session and survive reloads. - Calling
$.state.getduring rendering subscribes that drawing; a later$.state.settriggers a redraw without$.ui.invalidate. - Prompt-generated mods load only in the current session, and their temporary folders are cleaned up later. Keeping one requires copying the folder out and installing it as a plugin.
Development loading also supports claude --plugin-dir ./token-weather, with saves reloading the watched module in place.
Validation and tests
A free claude-mod-builder skill appeared during the early preview, packaging the function-hook model for Claude to use.
Anthropic's tutorial provides two separate checks:
claude plugin validate ./token-weather: reports hooked events, API calls, and state reads and writes. State keys must be declared in the plugin'sPluginStatetype contract, referenced by the manifest.claude plugin test ./token-weather: runs*.test.tsfiles against the real Claude Code runtime. Test hooks sit beneath the mod in the chain, where they can stub usage figures and other host responses.
The built-in Mods README adds a useful testing detail: a call left unanswered by those test hooks throws an error naming its event.
Plugin marketplaces
A GitHub repository with .claude-plugin/marketplace.json supplies an ordinary plugin marketplace. The documented installation sequence is:
Anthropic describes directory submissions as forthcoming, available once the directory accepts plugins containing Mods. That differs from the demo post, which describes Claude Directory sharing as already possible.
Sandbox and admin authority
A mod's sandbox has no DOM or Node; filesystem, HTTP, process, and other external operations go through $. Anthropic nevertheless warns in its guide that installed mods run on the user's machine with the same access Claude Code has.
The public function-hooks design thread demonstrates how authority composes:
- The first registered plugin wraps those registered afterward.
- An administrator can remove capabilities from
$, preventing plugins beneath that layer from invoking them. - A wildcard hook on
*observes every event, including plugins' own API calls, enabling an audit log.
Built-in mods
Claude Code's published Mods source lists four built-in plugins, with their tests:
agents-md: loadsAGENTS.mdwhen a project has noCLAUDE.mdby default. Options also support loading both files, using onlyCLAUDE.md, or retaining only managed instructions.diff: renders uncommitted changes beside the transcript, file by file, and refreshes as Claude edits files and runs commands.telemetry: supplies first-party analytics hooks to built-in plugins, refuses installed plugins, and sends nothing when Claude Code analytics are off.sec-default: protects organizational hooks, prompt content, managed settings, tool policy, and deny rules from user-installed plugins. It sits outermost on managed machines or for Team and Enterprise organizations unless managed configuration changes that placement, and adds no policy of its own.