Vibeleaderboard
← All Intel
Intel / article

Claude Code function hooks, now shipped as Mods

Source
github.com
Author
bcherny
Date

Context

Claude Mods let a plugin change how Claude Code behaves and what it shows by writing TypeScript functions instead of scripts. Boris Cherny of Anthropic asked for feedback on the idea, then called hooks, on September 3, linking to a GitHub proposal by Anthropic's Alice Poteat that said community response would likely decide whether it shipped. A September 9 update committed to shipping within weeks under the product name Claude Mods, a mod being simply a plugin that uses function hooks. An October 1 update said the feature was live, matching Anthropic's launch post, which says mods ship inside plugins and install with /plugin in the terminal or desktop app.

The change is in what a receives. Claude Code's existing hooks include shell commands run at fixed moments, such as before a tool runs; one commenter who maintains security hooks described matching raw Bash command strings with regular expressions, which obfuscated commands can slip past. According to the architecture document, a function hook instead gets the event as structured data, such as the tool name and its arguments, plus a "next" function that runs everything beneath it. As in the Express and Koa web frameworks, the hook can act before or after the action, rewrite the event, or refuse it. Hooks nest by registration order, so a plugin an administrator places first wraps all the others and can veto them, while Claude Code's own default behavior is registered last. The same model reaches the interface: a hook can alter or wrap the components Claude Code draws in the terminal and the desktop app.

The safety argument rests on one engine object, written $, through which every side effect must pass. The document says hook code runs without ambient file system or network access, so what a plugin did is exactly the calls it made on $. An audit log then becomes one hook placed first on every event, and an administrator can remove a capability from $ so that no plugin beneath can use it. The hardest question came from a user who backed the proposal and runs 42 hook scripts. That user counted that more than half touch files outside the project, start other programs, open databases, read credentials or make network calls, and so could not move to function hooks unless $ gained those powers, which would make the audit claim harder to keep. Poteat replied that file, HTTP and process access will very likely exist on $, and that restricting them is the organization administrator's job.

Within weeks of launch, people were posting finished mods in the thread, from a docked table of contents for long conversations to pixel-art companions above the prompt, along with requests for more control over the prompt box. One October 23 report shows a builders should know about: a user said a usage mod disappeared from the desktop app without notice, and Claude Code's own plugin test told them hooks modules were turned off in that process, adding that if the message returned, installed mods were turned off remotely. No response from Anthropic to that report appears in the comments available here.

Terms in this piece · Glossary
  • Terminal and shell — A text interface for navigating files and running programs.
  • Function — A named block of instructions that takes inputs, called arguments, and hands back a result, called its return value.
  • agent hook — A script the harness runs automatically at a fixed point in an agent's loop — before a tool call, after an edit, on session start.
  • Dependency — Anything a program needs to run that its author did not write: the language, its standard library, or a separately installed package.

Get the Brief

A cited digest of what matters for people building with AI, every morning. Unsubscribe anytime. See today’s edition

Tools in this story
More from bcherny
Recommended reads