Home › Rules › Claude Code mods
Claude Code mods: what they are, examples, and how to make your first one
Short answer: a Claude Code mod is a plugin with a JavaScript or TypeScript file of event handlers that Claude Code runs inside its own process when something happens: a tool call, a prompt you send, or part of the screen being drawn. So a mod can draw a pane, add a /command that runs your code with no Claude turn, or hold, change or refuse a tool call. You install one like any plugin (/plugin install name@marketplace), or ask Claude to write one. Mods work in the terminal, the Desktop app's Code tab and the VS Code extension. A mod runs with your permissions and isn't sandboxed, so check it with claude plugin validate before you load someone else's.
What a mod is (and the two kinds of "hooks")
A small mod is three files: the plugin manifest (.claude-plugin/plugin.json), a hooks/hooks.json whose modules key points at your code, and that code file, which Anthropic calls the hooks module (usually hooks/register.js). The modules key is what makes a plugin a mod. Claude Code loads .js and .ts directly, so there's no Node.js, bundler or build step.
The naming trips people up, and Anthropic flags it. Claude Code already had hooks: shell commands, HTTP requests or prompts listed in a settings file. On the mods pages, "hook" means a mod's handler and the older kind is a settings hook. Both keep working side by side.
Mods vs plugins vs settings hooks vs skills vs MCP
Every mod is a plugin, but most plugins aren't mods. The same plugin can ship a mod plus skills, agents and MCP servers. Anthropic's comparison, trimmed:
| Mod | Settings hook | Skill | MCP server | |
|---|---|---|---|---|
| What it is | Functions Claude Code calls in its own process | A command, HTTP request or prompt run on a lifecycle event | A SKILL.md of instructions | An outside process that gives Claude tools |
| Can change | Tool calls, prompts, commands, turns, what the screen draws | Whether a tool call or prompt goes ahead, its arguments and result | What Claude knows and does | Which tools Claude has |
| Draws on screen | Yes | No | No | No |
| You write | JavaScript or TypeScript | A script plus a settings.json entry | Markdown | A server in any language |
| Pick it when | You want a pane, a band above the prompt, a custom command, or to rewrite an event | You want to block, allow or log an event with a script you have | You keep pasting the same instructions | Claude needs an outside system |
Anthropic says to check whether one of the other three already does the job before writing a mod. "Run Prettier after every edit" is a settings hook: see Claude Code hooks examples. Instructions belong in a skill: Claude Code skills examples.
What a mod can do
- Draw something you can use: a pane beside the transcript or a band above the prompt, with tabs, buttons and text fields.
- Redraw parts of Claude Code: a tool call's row, the spinner, the question dialog. Not the permission prompt.
- Step into a tool call: hold it while asking you something, answer it without running the tool, or refuse it. It can also send one request to a different model.
- Add commands and tools: a
/commandthat runs at once, even while Claude works, or a tool Claude can call.
Some of Claude Code's own features are mods, such as /diff and AGENTS.md loading. Run /plugin, open Installed, and look under Built-in. The source of several is in the mods folder of the Claude Code repo.
Where mods run: CLI, Desktop, VS Code, and the rest
| Where you run Claude Code | Hooks run | What it draws shows up |
|---|---|---|
claude in a terminal (incl. JetBrains) | Yes | Yes |
| Desktop app, Code tab | Yes | Yes, except terminal-only elements |
| Desktop app, WSL session | No | No |
| VS Code extension | Yes | Yes, extension 2.1.299 or later |
claude -p and the Agent SDK | Yes | No |
| Remote Control (claude.ai, mobile) | Yes, on your machine | In your terminal |
| Cloud session | Yes, if the plugin reaches it | No |
Version: mods are on by default. Use Claude Code v2.1.287 or later in the terminal (check with claude --version). If you set CLAUDE_CODE_ENABLE_FUNCTION_HOOKS during early access, remove it; newer versions ignore it.
Turning mods off: one mod, disable its plugin in /plugin. All of them for one session, claude --safe-mode. All you installed, everywhere, "disableAllHooks": true in ~/.claude/settings.json (this stops your settings hooks too, but the plugin's skills and MCP servers still load).
Try a mod: Anthropic's samples and installing one
Anthropic shares three sample mods in the claude-code-playground repo, as-is and without support:
token-weather: a forecast of your context window above the prompt.blast-radius: holds a risky shell command likerm -rfor a force push, shows what it would change, with buttons to go ahead or cancel.replay-theater: a/replaycommand that steps through the edits Claude made last turn.
git clone https://github.com/anthropics/claude-code-playground.git
# See what the mod does BEFORE you run it ("hooks:" and "calls:" lines)
claude plugin validate ./claude-code-playground/claude-code/mods/blast-radius
# Load it for this one session only (nothing is installed)
claude --plugin-dir ./claude-code-playground/claude-code/mods/blast-radius
Free rules starter pack for Cursor, Claude Code, Codex and Antigravity
One shared AGENTS.md that works across Cursor, Claude Code, Codex, Copilot and Antigravity, plus database and test rules in each tool's format. Unzip it into your project and fill in two sections. I'll email you the link.
Free. No spam. Unsubscribe anytime. See our privacy note.
Then run /plugin in the session: a dim line like 1 mod active · blast-radius confirms it loaded.
Is there a mods marketplace? Not a separate one. A mod installs from a plugin marketplace, as name@marketplace, and everything on our Claude Code plugins page applies unchanged:
# Inside a Claude Code session (Anthropic's example names)
/plugin install token-chart@your-org
# Or from your normal shell, then /reload-plugins in any open session
claude plugin install token-chart@your-org
Make your first mod (Anthropic's tutorial)
This is first-mod from Anthropic's "Create a mod" page. It counts Claude's tool calls, shows the count beside the spinner (Thinking · tool calls: 3…), and adds a /tally command.
first-mod/
├── .claude-plugin/
│ └── plugin.json # the plugin manifest
└── hooks/
├── hooks.json # "modules" points at your code (this makes it a mod)
└── register.js # your code, the "hooks module"
{
"name": "first-mod",
"version": "0.1.0",
"description": "Counts Claude's tool calls, shows the count beside the spinner, and adds a /tally command",
"author": { "name": "Your Name" }
}
{
"description": "The first-mod hooks module",
"modules": ["./register.js"]
}
// The count, shared by the hooks below
let calls = 0
// Claude Code calls this once when the mod loads
export function register(on) {
// Runs when the session starts, before your first prompt
on('session.start', async ($, e, next) => {
// Add the /tally command
await $.command.register({
name: 'tally',
description: 'Show how many tool calls Claude has made',
})
// Let the session start as usual
return next(e)
})
// Runs each time Claude is about to use a tool
on('tool.call', async ($, e, next) => {
calls += 1
// Ask Claude Code to draw the interface again, so the new count shows
$.ui.invalidate('ui.render')
// Let the tool run as usual
return next(e)
})
// Runs when you type /tally, and only then, because of the matcher
on('command.run', { command: 'tally' }, async () => {
// The text to print in the transcript
return { text: 'Claude has made ' + calls + ' tool calls since this mod loaded' }
})
// Runs each time Claude Code draws the spinner
on('ui.render', { component: 'Spinner' }, async ($, e, next) => {
// Keep Claude Code's spinner, with the count added after its word
return next({ ...e, props: { ...e.props, suffix: ' · tool calls: ' + calls + '…' } })
})
}
mkdir -p first-mod/.claude-plugin first-mod/hooks # then save the 3 files
claude plugin validate ./first-mod # expect "✔ Validation passed"
claude --plugin-dir ./first-mod # load it for one session; edits hot-reload
How it works: Claude Code calls register once and hands it on; each on(...) registers one hook. Every hook gets $ (the mods API, its only way to draw, read files, run programs or reach the network), e (the event) and next (pass it on to other mods and then Claude Code). A hook can observe and return next(e), rewrite by passing a changed copy, or answer by returning its own result, as /tally does. Edit the file while the session runs and it hot-reloads.
Claude Code also writes TypeScript type files for your exact version into .claude-plugin/types/, and claude plugin test runs .test.ts files with no session or sign-in. Don't start your plugin's name with claude-; validation fails it.
Or ask Claude to write it
In an interactive session, describe it, like Anthropic's example make a mod that shows the current git branch above the prompt. Claude uses a built-in plugin-authoring skill and writes the mod into ~/.claude/dev-mods/<session id>/ (in the default and acceptEdits modes you approve each file). When asked, choose Enable for this session for hot reloading. A mod Claude writes only loads in that session, and the folder is cleaned up later, so copy it somewhere like ~/mods/git-branch and use claude --plugin-dir ~/mods/git-branch to keep it.
Claude Code mod examples
The first is copied from Anthropic's docs. The second is ours, built only from patterns on Anthropic's pages; validate it before you trust it.
1. Refuse force pushes. Claude reads the deny text as the tool's result, so write it as an instruction.
// Anthropic's example ("React to events with a mod" page)
// The matcher limits the hook to Bash calls, so e.command is the shell command
on('tool.call', { tool: 'Bash' }, async ($, e, next) => {
if (/git push .*--force/.test(e.command)) {
// Returning without calling next answers the event, so the command never runs
return { deny: 'Force pushes are not allowed in this repository. Push to a new branch instead.' }
}
// Every other command goes on to the permission check and then to Bash
return next(e)
})
2. Our example: block rm -rf, and fail closed. Anthropic warns that if a guard hook throws or times out, Claude Code skips it and the command runs anyway. A .catch handler makes it refuse instead.
// OUR example (VibeKits), not from Anthropic's docs. Plugin name: no-rm-rf,
// same hooks.json as first-mod. Built from two patterns on Anthropic's
// "React to events" page: a tool.call guard and a fail-closed .catch.
async function guard($, e, next) {
if (/\brm\s+-rf\b/.test(e.command)) {
return { deny: 'rm -rf is blocked by the no-rm-rf mod. Delete the specific files you mean, one at a time.' }
}
return next(e)
}
export function register(on) {
on('tool.call', { tool: 'Bash' }, guard).catch(async ($, e, next) => {
// guard already called next: keep the result it produced
if (next.called) return next(e)
// guard threw or timed out first: refuse instead of letting the command run
return { deny: 'The no-rm-rf guard failed, so this command was not run: ' + next.error.kind }
})
}
A text match is a reminder for Claude, not a lock. Anthropic says the same about its own branch check and points to your Git host's branch protection for real enforcement. For a fixed command, a permission rule like Bash(npm test) needs no code.
Is a Claude Code mod safe?
Anthropic's words: a mod is code that runs with your permissions. It can read and write your files, start programs, make network requests, read environment variables and settings (including API keys), see and rewrite every prompt and tool call, approve a tool call before you're asked, and call a model on your plan. Claude Code's sandbox covers Claude's Bash commands, not processes a mod starts. And your permission rules don't cover a mod's own file calls: with Read(.env) denied, a mod can still read .env.
Before loading one you didn't write, clone it and run claude plugin validate ./some-mod. The calls: line lists what it can do. Look for $.fs (files), $.process (programs), $.http.fetch (network), $.env.get (keys), $.model.complete (spends your usage) and $.prompt.submit (types as you). In hooks:, tool.check means it can approve calls for you.
Mods at work: what admins can control
With managed settings or a Team or Enterprise /login, a built-in guard loads first, and by default a user's mod can't override deny or ask rules. Anthropic's example to allow only your organization's mods:
{
"pluginConfigs": {
"cc-plugin-sec-default@builtin": {
"options": {
"allowManagedModsOnly": true
}
}
}
}
Mod not working? Where to look
# Can mods load here at all? Run from a folder with no mod in it:
claude plugin test # "no hooks module to load" = yes
# Write a debug log and filter it for your mod
claude --debug-file ./mod-debug.log --plugin-dir ./first-mod
tail -f ./mod-debug.log | grep first-mod
- Your command isn't in the list: the module didn't load. Run
claude plugin validate; a typo shows as"tool.calls" is not an event. - Validate shows no
hooksline:hooks.jsonis missing themoduleskey. - Installed mod does nothing: its error lines go to the debug log only, so start with
claude --debugand look fornot loaded:. - Edits don't show up: installed plugins are cached by version. Develop with
--plugin-dir, or bump the version and reinstall. - Hook skipped: a hook gets 10 seconds per event (50 ms for
prompt.edit).
Where Anthropic's own pages disagree
- Minimum version. The admin page says mods are on by default "in Claude Code v2.1.286 and later." The overview and "Create a mod" pages say v2.1.287 or later in the terminal, with 2.1.286 only for the Desktop app's copy. Use 2.1.287 or later to be safe.
- Three names for one guard. It's
sec-default@builtininprependPlugins,cc-plugin-sec-defaultin/plugin, andcc-plugin-sec-default@builtinunderpluginConfigs. Copy the name each example uses. - Web pages vs your version. The reference says the type files on GitHub can be older than your Claude Code, and "Create a mod" says the type files Claude Code writes for your version beat any page. If this page disagrees with them, they win.
Related setups
A mod ships inside a plugin, so start with Claude Code plugins for marketplaces and scopes. For automation that's just a script, use settings hooks. Google Antigravity has its own plugin system: see Antigravity plugins.
Next step for Claude Code: Agent Skills
Skills are folders your AI coding agent loads only when the job comes up, and Claude Code, Cursor and OpenAI Codex all read the same SKILL.md format. The Vibe Coder Skills Pack ($9) is 6 ready-to-copy SKILL.md skills (fix-one-bug, stop-the-loop, leak-check, ship-check, explain-project, builder-handoff) for Claude Code, Cursor and OpenAI Codex. Also included in the 6-kit bundle.
Get the Skills Pack for $9 on Gumroad → See what's inside
One .zip of skill folders plus one markdown file. 7-day refund, no questions asked.
Best value
All 6 kits for $29 — or $20.30 with code WELCOME30 (through Nov 30)
Mods change how Claude Code looks and behaves. The kits tell it what to build, step by step: a small game, a Discord bot, an email-triage agent, an MVP, or a cleanup of messy code.
Get all 6 kits for $29 → See what's in each kit
$29 instead of $48 for the six kits bought separately; WELCOME30 takes 30% off that at checkout ($20.30). Instant download from Gumroad. 7-day refund, no questions asked.
Related
- Claude Code plugins (install, official marketplace, plugins vs skills)
- Claude Code hooks examples (7 copy-paste settings hooks)
- Cursor hooks (hooks.json, every event, examples, fixes)
- Claude Code skills examples (7 copy-paste SKILL.md files)
- Claude Code subagents examples (7 copy-paste subagents)
- Custom slash commands (Claude Code, Cursor, Codex, Copilot)
- AI coding horror stories (real incidents and how to avoid them)
- CLAUDE.md examples
- Google Antigravity plugins (install, marketplace, plugins vs skills)
- Free rules file generator
Sources
- Claude Code docs: Mods overview
- Claude Code docs: Create a mod
- Claude Code docs: React to events with a mod
- Claude Code docs: Use the mods API
- Claude Code docs: Draw in the interface with a mod
- Claude Code docs: Interface gallery for mods
- Claude Code docs: Test a mod
- Claude Code docs: Troubleshoot a mod
- Claude Code docs: Manage mods for your organization
- Claude Code docs: Mods reference
- Claude Code docs: Hooks reference
- Claude Code docs: Plugin manifest reference
- Anthropic on GitHub: sample mods (claude-code-playground)
- Anthropic on GitHub: built-in mods source (claude-code/mods)
Every command, file name, setting and limit here was checked Nov 9, 2026 on Anthropic's own Claude Code docs. Mods are new and Anthropic says their events and methods can change between releases, so the type files Claude Code writes for your version win over this page. If something here no longer matches, tell us at [email protected].