Harness Engineering 6 months ahead, in a few hours.

Claude Code mods: what they are and how to vet one

Thomas Poulain ·

Anatomy of a Claude Code mod (plugin.json, hooks.json, register.js), a git push --force call denied, then how to inspect it with claude plugin validate, install it with /plugin install, and turn it off with --safe-mode or disableAllHooks.

A Claude Code mod is a plugin that ships JavaScript or TypeScript code running inside Claude Code itself. Claude Code calls the mod’s functions when something happens, such as a tool call or part of the interface being drawn, and each function can change that event or handle it on its own. Mods landed in Claude Code v2.1.287 for the terminal (v2.1.286 in the Desktop app’s Code tab), and they’re on by default.

How is a mod different from a hook?

A settings hook is a command Claude Code runs next to itself. A mod’s code runs in Claude Code’s own process, so it can:

  • draw a pane beside the transcript or a band above the prompt
  • hold a tool call while it asks you a question, or answer it without running the tool
  • add a slash command that runs your function right away, with no Claude turn
  • share variables between its functions, so one counts tool calls and another shows the count

/diff is a built-in mod, so you may already be running one. Watch the naming: the docs call a mod’s functions “hooks” too, and say “settings hooks” for the settings.json kind.

How do I install a Claude Code mod?

Like any plugin, from a marketplace: plugin name, @, marketplace name.

# Inside a Claude Code session
/plugin install token-chart@your-org

# From your shell
claude plugin install token-chart@your-org

Installed it from the shell during a session? Run /reload-plugins there. To try a mod without installing it, claude --plugin-dir ./my-mod loads it for one session. Then /plugin shows a dim line like 1 mod active · first-mod.

How do I check what a mod does before installing it?

Clone its repo first, then run:

claude plugin validate ./some-mod

It runs nothing and prints two lines worth reading:

  ❯ ./register.js hooks: session.start, tool.call, ui.render{component=Pane}
  ❯ ./register.js calls: $.fs.read, $.http.fetch, $.store.set, $.ui.open

hooks: lists the events the mod receives, and calls: lists every mods API method it calls. I trust that list because a mod’s code has no file or network access of its own. Everything goes through the $ object, and Claude Code refuses to load a mod that uses $ in a way the analysis can’t read.

In calls:, I look for $.fs.write, $.process.run (starts programs as you), $.http.fetch, $.env.get (your environment variables, API keys included) and $.model.complete (spends your plan or API key). In hooks:, tool.check means the mod can approve a tool call before the permission prompt shows up.

What does a minimal mod look like?

Three files are enough:

no-force-push/
├── .claude-plugin/
│   └── plugin.json
└── hooks/
    ├── hooks.json
    └── register.js

plugin.json is the manifest, and name is its only required key:

{
  "name": "no-force-push",
  "version": "0.1.0",
  "description": "Refuses git push --force"
}

In hooks/hooks.json, the modules key is what turns a plugin into a mod:

{
  "description": "The no-force-push hooks module",
  "modules": ["./register.js"]
}

hooks/register.js exports the register function Claude Code calls on load:

export function register(on) {
  // The matcher limits this 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: the command never runs
      return { deny: 'Force pushes are not allowed in this repo. Push to a new branch instead.' }
    }
    // Everything else goes on to the permission check, then to Bash
    return next(e)
  })
}

Start claude --plugin-dir ./no-force-push and ask for a force push. The command doesn’t run, and Claude reads the deny text as the tool’s result, so phrase it as an instruction Claude can act on. There’s no build step: Claude Code loads .js and .ts files directly and hot-reloads the module when you save. You can also just ask Claude for the mod, and it writes it with the built-in plugin-authoring skill.

How do I turn a mod off?

  • One mod: disable or uninstall its plugin from the Installed tab in /plugin.
  • All of them, for one session: claude --safe-mode, which also turns off your other customizations. It’s the first thing I try when I suspect a mod.
  • All of them, everywhere: "disableAllHooks": true in ~/.claude/settings.json. Your settings hooks and custom status line stop too.

Built-in mods, like the /diff one, ignore these and are disabled from /plugin. If you set CLAUDE_CODE_ENABLE_FUNCTION_HOOKS during early access, remove it: v2.1.287 ignores it, so 0 no longer keeps mods off.

What are the risks and limits of a mod?

A mod runs with your permissions. It can read and write your files, start programs, make network requests, read your settings, and see every prompt and tool call. It isn’t sandboxed: if you turn on Claude Code’s sandboxing, it isolates the Bash commands Claude runs, and a process a mod starts runs outside it.

The part that surprised me is permissions. A mod that handles tool.check can approve a call an ask rule would have prompted you for, or one your own PreToolUse hook blocked. On a machine without managed settings, and outside a Team or Enterprise plan, it can even approve a call that a deny rule refuses. It can’t change what the permission prompt shows you, though.

If you write a guard, a hook that throws or goes past its 10-second execution limit gets skipped, and the call carries on. Attach a .catch handler that returns a refusal if you want it to fail closed.

Only the terminal and the Desktop Code tab show what a mod draws. In the VS Code extension’s chat panel, with claude -p, or through the Agent SDK, the hooks still run and nothing is drawn.

When should you write a mod?

When you want to draw in the interface or rewrite an event. To allow a fixed command, a permission rule like Bash(npm test) is enough, and to block something with a script you already have, a settings hook does the job.

no-force-push would work as a settings hook too. It also only matches the command text, so git push -f slips through. Treat it as a reminder for Claude, and protect main on your Git host.


A mod is still a plugin: section 4.11 of module 4 of the course walks through how a Claude Code plugin is put together, and module 5 covers settings hooks and how to use them as guardrails.

To see these articles more often on Google, add Harness Engineering to your preferred sources.

You might also like