Skip to content

Claude Code

Claude Code’s /diff is now a mod you can delete

5 min read

Written by an AI model from the linked sources and checked against them by a second model. How we work

Image: claude.com

Anthropic on October 3 opened Claude Code to mods. A mod is a TypeScript function that attaches to one of the events Claude Code emits and runs before it, after it, or in its place. Hooks never had this much reach. A mod can rewrite the event, draw its own interface, or take over a built-in feature, and /diff is one of the built-in features already handed over this way.

Mods work in the Claude Code CLI and the desktop app, per Claude’s launch post. They come packaged inside plugins, so you install and share them like any other plugin, through the Claude directory or /plugin in the CLI. They also run unconfined. “Mods run with the same access to your machine as Claude Code itself,” Anthropic writes. Its advice is to install them only from sources you trust, as you would any code.

What hooks couldn’t do

Hooks were the earlier way to customize Claude Code, and they work at a distance from it. The Claude Code docs describe hook handlers as shell commands, HTTP endpoints, MCP tool calls, LLM prompts or subagents. When an event fires, Claude Code sends the handler a JSON description of it, on stdin for a command hook or as the POST body for an HTTP hook. The handler can look at it, act, and optionally send back a decision. A PreToolUse hook, for example, can block a tool call. The handler only ever sees a copy of the event. It never runs inside the program.

Mods run inside it. The docs say a plugin can register hooks as JavaScript functions that Claude Code calls in its own process, and those functions can draw in the interface as well as act on events. A plugin that does this is a mod. Regular hooks keep working alongside mods. The launch post states the gap directly: “hooks can’t rewrite events, draw new UI, or replace features. Mods can.”

Anthropic says developers had been asking for this kind of control without having to wait for features to ship. The design went up on GitHub for feedback before launch, and in a September 9 community update the team had committed to shipping function hooks “on the scale of weeks”.

How a mod attaches to an event

Claude Code emits an event every time it does something: calling a tool, asking for permission, drawing part of the screen. A mod attaches to one of these events and runs before it, after it, or instead of it. It can also wrap the event, running code on both sides. Anthropic lists what a single function can do:

  • rewrite a prompt before it reaches the model;
  • block, rewrite or retry a tool call;
  • approve or deny a permission request;
  • redact secrets from tool output before Claude reads it.

Secret-handling guardrails already exist as hooks. Collections such as awesome-claude-code-hooks on GitHub include PreToolUse guardrails that block reads of .env files or writes of secret-like values, along with hooks that stop destructive git and filesystem commands. The redaction item on Anthropic’s list works at a different point: the tool’s output, before Claude reads it.

Mods can also change what you see on screen. A mod can edit or replace parts of the interface Claude Code draws, such as a tool result or a question from Claude, and it can add buttons and inputs that other mods respond to. For now a mod can target the terminal, the desktop app, or both.

When several mods attach to the same event, they run in the order they load. The first mod to load sees the event first and the result last, and Anthropic says this is what lets you stack mods from different authors. You can also ask Claude Code to write a mod for you. It writes the TypeScript, installs it, and hot reloads it, which swaps the new code into your running session without a restart.

/diff is now optional

Some built-in Claude Code features now ship as mods, and /diff is one of them. You can turn it off in /plugin or replace it with your own version. Anthropic plans to move more built-in features to mods over time, so you can “pare Claude Code down to a small core and add back only what you want.”

Anthropic frames the whole project the same way: “We want Claude Code to feel like yours, so you can shape it to the way you work.”

Who controls mods on a team

Mods ship inside plugins, so the plugin controls a team already uses apply to them too. Admins can allow or block plugin marketplaces. On Team and Enterprise plans, the owner sets this in the admin console. On Claude API and third-party API plans, admins push managed settings to users’ machines.

On Team and Enterprise plans, and on any machine with managed settings, a built-in mod called sec-default (“security default”) loads first. It stops mods that users install from doing risky things, such as overriding your permission deny rules, and its source code is public so you can see what it restricts. Admins can load their own mods first instead. If they do, Anthropic says to add sec-default to their list to keep its restrictions.

Anthropic’s examples for teams lean on the same mechanics:

  • CI/CD status: a pane beside the conversation that shows the pipeline’s status and updates as builds pass or fail;
  • production safeguards: a required confirmation before any command touches production config;
  • audit logging: a mod that loads first and records every call that every other mod makes.

Getting started

Mods are available now in both the CLI and the desktop app. You can install plugins that include mods from the Claude directory or with /plugin. To write your own, start with Anthropic’s getting-started guide and the documentation, or ask Claude Code to write a first one inside a live session. To share a mod, package it in a plugin and submit it to the Claude directory.

No comments yet. Be the first.

Join the conversation

Sign in to leave a comment. It appears after moderation.