Skip to content
Claude Code Mods

Mod

diff

Source verified. Source URL responded on 2026-09-21. Not a security review.Built in
  • Development
  • Workflow
License
© Anthropic PBC. All rights reserved. Use is subject to Anthropic's Commercial Terms of Service.

Adds /diff: the session's uncommitted changes in a pane beside the transcript, file by file with their hunks, refreshed as Claude edits files and runs commands.

Notice

Early access. Hooks modules load only where function hooks are enabled, and the API these mods are written against may change between releases without notice. They are not listed in the repository's marketplace; the copies that matter are the ones already in your Claude Code.

On this page

What it does

diff is the diff pane as a plugin. /diff opens the session's uncommitted changes in a pane beside the transcript, one row per changed file with every file's hunks beneath, and closes it again. Each toggle leaves "Diff panel shown" or "Diff panel hidden" in the transcript.

The pane refreshes as Claude edits files and runs shell commands. While it is open it polls the repository's HEAD, so a commit or checkout made elsewhere shows too.

It compares the working tree against HEAD split at the session's start (the default, using the start the engine gives in $.session.usage(), so a resumed session keeps its first and /clear begins anew), against HEAD plainly, or against the merge-base with the default branch. The base line under the header names a base other than the session's, and the choice is kept per repository in the plugin's store. A picker shows one earlier turn's edits instead of the working tree, read from the session's messages.

Files that changed before the session started (by their timestamp, among the paths already dirty when the pane first read the repository) and noise (lockfiles, generated and test files) are listed apart and folded until asked for. A rename lists as git prints it. Outside a git repository /diff says so and does nothing else.

The main loop's first successful edit of a session opens the pane by itself, as the built-in panel opens on its first checkpoint. That needs a layout that docks the pane beside the transcript (the fullscreen layout), a terminal wide enough (144 columns when the person never chose, 110 when they kept it open before; a person who closed it is left alone) and file checkpointing on. A subagent's edit opens nothing, and where the surface does not say, nothing opens by itself. A docked pane fetches before it opens, so it never lands on "Loading diff…". A session resumed or continued whose transcript already holds such an edit opens the pane on the same terms as soon as the width is known.

Under the fullscreen layout a terminal under 110 columns gets the built-in's line asking for a wider one and nothing opens. Without that layout (CLAUDE_CODE_NO_FLICKER=0, which /diff learns from the command's presentation) the pane opens inline at any width, focused and as tall as its content, in the built-in dialog's shape.

Git runs when the built-in panel's would. Nothing runs at the session's start. One git rev-parse, in the directory the session started in, runs when /diff or the first edit a pane has room to open on first needs the repository (an answer of no repository is kept too, until /clear or /resume forgets it). The working tree is read only by a fetch for a pane that is open, after an edit that landed or a shell command that ran. The one read the built-in has no counterpart for is a git status at a pane's first fetch, which stands in for the change time the built-in dates a moved file by.

How it works

The module is hooks/register.ts, and everything under hooks/ is its parts. These are the hooks it registers.

session.start: binds the engine once and registers /diff (a session where another /diff is listed leaves the plugin idle). It asks nothing of the repository, which /diff or the first edit pins when it comes. Off its dispatch it reads the transcript, and for a resumed session whose turns edited it opens the pane as the first edit would.

ui.render of PromptHint: reads the terminal's width and whether its layout docks a pane, which decide whether the first edit opens the pane.

ui.render of Pane: draws the pane. Docked, that is the header, base line, source picker, file list and toggles over the window of hunks. Inline, it is the dialog.

command.run of diff: pins the repository when none is, opens or closes the pane (focused and closing on Escape without the fullscreen layout), says which, and remembers the choice.

command.run of clear and resume: closes the pane and forgets the session's state, the pinned repository with it.

ui.close of the pane: backs out of the dialog's detail view instead of closing. Otherwise it remembers the person's close as /diff's.

ui.scroll of the pane: docked, moves the hunks under the pinned header and list (three rows a wheel tick, a page a page key), or the list when the wheel is over it, and keeps the engine's window still.

ui.focus in the pane: in the dialog's list, selects the file the ring lands on, re-centres the five rows on it, and lands the ring where that row now sits.

tool.call of Edit, Write, NotebookEdit: after an edit that landed (not refused, not failed), refreshes an open pane. The main loop's first such edit opens it, pinning the repository then if the terminal has the room and checkpointing is on.

tool.call of Bash, PowerShell: after a command that was not refused (failed and interrupted ones too), refreshes an open pane.

prompt.submit: adds the armed file's hunks to the prompt's context and disarms.

On $ it calls clock.after, clock.every, clock.now, command.register, env.get (CLAUDE_CODE_DISABLE_FILE_CHECKPOINTING), fs.list, fs.read, fs.stat, process.run (git, read-only), session.id, session.messages, settings.read, store.get, store.set, telemetry.log, telemetry.mark, ui.close, ui.invalidate, ui.log, ui.open, ui.resolve and ui.status. $.telemetry is the telemetry plugin's noun. Where it is absent the rows are dropped and nothing else changes.

Set up

This mod ships inside Claude Code as a built-in. It has no configuration options: its plugin.json declares no userConfig.

To read it running from source, run the command below from the root of a clone of the repository, then use /diff inside a git repository with a modified file. The README says a session where another /diff is listed leaves the plugin idle.

It needs a git repository to show anything. Outside one, /diff says so and does nothing else. For the pane to open by itself on the first edit, file checkpointing must be on, and the layout and terminal width conditions in the overview must hold.

The source does not document how to enable function hooks. The author of the announcement issue (anthropics/claude-code #91870) wrote in its Sep 9, 2026 update that anyone who wants to test can start Claude Code with CLAUDE_CODE_ENABLE_FUNCTION_HOOKS=1. That is a note in an issue, not documentation, and it may change without notice.

claude --plugin-dir mods/diff

Download the source

The source lives in the mods/diff folder of the anthropics/claude-code repository. To fetch only that folder and the mods/types declarations it is typed against, clone the repository sparsely, enter it, and check out those two folders. The clone also brings the files at the top level of the repository.

The repository's LICENSE.md reads: "© Anthropic PBC. All rights reserved. Use is subject to Anthropic's Commercial Terms of Service." The mods README says this folder is the source of the mods, published as it is built into the binary, so that it can be read. This listing does not call it open source.

git clone --depth 1 --filter=blob:none --sparse https://github.com/anthropics/claude-code.git

cd claude-code

git sparse-checkout set mods/diff mods/types

Test it

Run the command below from the root of a clone of the repository. Tests live in the mod's tests/ folder, which holds 27 test files as of the source read for this listing. They are named for what they cover under hooks/: the top level has register.test.ts, git.test.ts and views.test.ts, and folders such as ask, backend, classify, git, pane-state, pane-toggle, todos, turns and views hold the rest, with shared material under fixtures/.

Per the mods README, a test gets the engine's own $ and a plugin's on. Each call on $ is one the engine makes, through every hook of the mod loaded as it ships. The hooks a test registers with on sit beneath the mod, where the rest of the world would be, and a call they leave unanswered throws, naming its event. A test file is named for what it covers under hooks/, and the kit's mock answers the world beneath the mod from memory (mock.env, mock.store, mock.clock).

The mods README also says that tsc -p mods/tsconfig.json typechecks every mod's hooks and tests against types/ and each mod's own types contract.

claude plugin test mods/diff

Using the pane

The header, the file list and its toggles stay put while the wheel moves the hunks under them three rows a tick, or the list a file a tick while the wheel is over a list longer than its eight rows. The plugin answers the pane's ui.scroll itself.

A row's click puts that file's hunks at the top. The list also scrolls under the built-in's list keys (ctrl+up and ctrl+down, opt+up and opt+down), and ctrl+x b moves the comparison base on, as the built-in's chord does. Both work through Buttons that declare the engine's own actions.

Inline, the dialog shows the title, the count, five file rows at a time round the selected one (marked with the ❯ character, where the focus ring starts) and the key hints. Enter shows that file's hunks alone. Escape backs out to the list and then closes, leaving "Diff dialog dismissed". Toasts are held while it is up.

A file's ask button arms that file: its hunks ride the next prompt as context, once.

Hooks it registers

What the badge means

Source verified means the source URL for this entry responded with HTTP 200 on . That is the whole claim. Nobody has read, scanned or run this code on your behalf, and the badge does not mean Anthropic or anyone else endorses it.

Sources change after the check date. Read the code and the publisher page before you install. How to check an extension

  • Mod

    Built inSource verified. Source URL responded on 2026-09-21. Not a security review.

    agents-md

    Reads AGENTS.md as project instructions the way Claude Code reads CLAUDE.md, chosen by one option, instructionFiles, with four values.

    • Workflow
    • Development
  • Plugin

    Source verified. Source URL responded on 2026-09-20. Not a security review.

    feature-dev

    A guided 7-phase feature workflow behind /feature-dev, with code-explorer, code-architect and code-reviewer agents.

    • Development
    • Workflow
  • MCP server

    Source verified. Source URL responded on 2026-09-20. Not a security review.

    Sequential Thinking MCP server

    Reference MCP server with one tool for step-by-step problem solving that supports revising thoughts and branching.

    • Workflow
    • Development