Advanced 7 concepts to know first

Mods

Plugins whose JavaScript or TypeScript functions run inside Claude Code on its events, so they can watch, rewrite or answer a tool call or prompt, add commands, and draw their own interface.

The animation needs JavaScript; every step is described below.

0:15

Know these first

7 concepts · basics first
  1. Context

    The context window is everything Claude can see in a session: your messages, the files it reads, tool output and auto-loaded instructions. It fills as you work, and Claude Code compacts it when it gets full.

  2. Hooks

    Your own commands that Claude Code runs automatically at fixed points in its loop, so a rule always holds instead of depending on the model remembering it.

  3. MCP

    The Model Context Protocol connects Claude Code to outside tools and data, such as an issue tracker, a database or Figma, through servers that hand Claude new tools to call.

  4. Slash Commands

    Type / to run a command: built-ins that control the Claude Code session itself, plus prompts packaged as skills, plugin commands and MCP prompts, including ones you write yourself.

  5. Memory

    CLAUDE.md files you write and auto memory notes Claude writes for itself: plain markdown on disk, loaded at the start of every session so Claude doesn't start from zero.

  6. Skills

    A SKILL.md file of instructions that Claude loads only when a task calls for it, or that you run yourself as a /command. Custom slash commands are now skills.

  7. Plugins

    A directory of skills, subagents, hooks and MCP servers that Claude Code installs and loads as one unit, usually from a marketplace, so a whole setup can be shared with one command.

  8. Mods · you are here

Hooks let a shell command run at fixed points in Claude Code’s loop. A mod goes a level deeper: it’s a plugin whose JavaScript or TypeScript functions run inside Claude Code, called on its events: a tool call, a submitted prompt, a turn, even a piece of the interface being drawn. Because it stays loaded, a mod can keep state between events, add a pane beside the transcript, or register a slash command that runs your code at once, with no Claude turn.

How a mod handles an event

A mod exports register(on). Each call to on attaches a function to an event, optionally narrowed by a matcher:

on('tool.call', { tool: 'Bash' }, async ($, e, next) => {
  if (/git push .*--force/.test(e.command)) return { deny: 'Push to a new branch instead.' }
  return next(e)
})

The handlers for an event form a chain, like middleware. next(e) passes the event on to other mods and finally to Claude Code’s own behavior. So a handler has three moves: observe (do something, return next(e)), rewrite (call next with a changed copy), or answer (return a result without calling next, so the usual behavior never runs; above, the push is refused and Claude reads the reason). Anything beyond its own code (drawing, files, processes, the network, a model call) goes through the mods API, $.

Where it lives

A mod is three files: .claude-plugin/plugin.json, hooks/hooks.json with "modules": ["./register.js"], and the module itself. Try one for a session with claude --plugin-dir ./my-mod, share it through a marketplace like any plugin, or describe what you want and have Claude write it. Mods need Claude Code v2.1.287 or later and are on by default. Some of Claude Code’s own features, such as /diff, are built as mods.

Hooks run wherever the plugin loads, including claude -p, but what a mod draws appears only in the terminal and the Desktop app’s Code tab.

The catch

A mod is code running with your permissions and isn’t sandboxed. It can read your files and secrets, see every prompt and tool call, approve a call before you’re asked, and spend your usage. Install only from authors you trust, and before installing, run claude plugin validate ./some-mod: its hooks: and calls: lines list what the mod hooks and asks Claude Code to do. Started with --safe-mode, a session leaves installed mods out.

If a settings hook, a skill or an MCP server already does the job, reach for that first.

Where it sits

Before this

Plugins Hooks
Mods

Leads to

Nothing yet.

The ideas underneath · Field Guide

Further reading from claude.dev

Posts from Anthropic's developer blog that go deeper. Summaries are ours; the posts are Anthropic's.

Sources

  1. Mods overview . Claude Code docs: what a mod is, trust, where mods run, comparison with hooks, skills and MCP
  2. Create a mod . Claude Code docs: files, register(on), --plugin-dir, claude plugin validate
  3. React to events with a mod . Claude Code docs: observe, rewrite, answer; matchers; guarding tool calls

Verified against the official Claude Code docs on October 1, 2026 · next review by January 1, 2027. Claude Code changes quickly; the docs are the source of truth.