Home › Rules › Claude Code mods

Claude Code mods: what they are, examples, and how to make your first one

From Anthropic's own Claude Code docs (Mods overview, Create a mod, React to events, Use the mods API, Mods reference, Troubleshoot a mod, Manage mods for your organization), checked Nov 9, 2026. Sources below.

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:

ModSettings hookSkillMCP server
What it isFunctions Claude Code calls in its own processA command, HTTP request or prompt run on a lifecycle eventA SKILL.md of instructionsAn outside process that gives Claude tools
Can changeTool calls, prompts, commands, turns, what the screen drawsWhether a tool call or prompt goes ahead, its arguments and resultWhat Claude knows and doesWhich tools Claude has
Draws on screenYesNoNoNo
You writeJavaScript or TypeScriptA script plus a settings.json entryMarkdownA server in any language
Pick it whenYou want a pane, a band above the prompt, a custom command, or to rewrite an eventYou want to block, allow or log an event with a script you haveYou keep pasting the same instructionsClaude 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

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 CodeHooks runWhat it draws shows up
claude in a terminal (incl. JetBrains)YesYes
Desktop app, Code tabYesYes, except terminal-only elements
Desktop app, WSL sessionNoNo
VS Code extensionYesYes, extension 2.1.299 or later
claude -p and the Agent SDKYesNo
Remote Control (claude.ai, mobile)Yes, on your machineIn your terminal
Cloud sessionYes, if the plugin reaches itNo

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:

Try a sample mod for one session
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

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:

Install a mod from a marketplace
# 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.

The three files
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"
1. first-mod/.claude-plugin/plugin.json
{
  "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" }
}
2. first-mod/hooks/hooks.json
{
  "description": "The first-mod hooks module",
  "modules": ["./register.js"]
}
3. first-mod/hooks/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 + '…' } })
  })
}
4. Validate and load it
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: block git push --force
// 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): no-rm-rf/hooks/register.js
// 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:

managed-settings.json: only your organization's mods run
{
  "pluginConfigs": {
    "cc-plugin-sec-default@builtin": {
      "options": {
        "allowManagedModsOnly": true
      }
    }
  }
}

Mod not working? Where to look

Check whether mods can load, and read the debug log
# 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

Where Anthropic's own pages disagree

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

Sources

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].

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.

After that, an occasional email when I publish a new guide or rules file.

Free. No spam. Unsubscribe anytime. See our privacy note.