Anthropic shipped "function hooks" for Claude Code, which the presenter calls the best feature yet. Unlike the older shell hooks, function hooks act like Express.js middleware: they can rewrite prompts and tool inputs, short-circuit calls with a cached store, override built-in tools, ask the user questions, add UI rows and panels, and call models or HTTP endpoints. You turn them on with CLAUDE_CODE_ENABLE_FUNCTION_HOOKS=1 claude, which unlocks a built-in plugin-authoring skill that writes the hooks for you from a plain-English description. Demos include automatic secret redaction, a live Vercel deploy status bar, an Exa search override, and a text-to-speech turn summary.
- Hooks exist to add deterministic control because CLAUDE.md rules fade as context fills up, prompts get sloppy, and Claude drifts from defined workflows.
- Old shell hooks couldn't rewrite prompts, append context, draw UI, ask questions, add or edit tools, or remember anything between runs; function hooks address all of these.
- The mental model is Express.js middleware: match a tool call, inspect it, then block, rewrite, short-circuit, or pass it through (e.g. swapping npm for pnpm in Bash commands).
- Function hooks come with a store, so a web fetch can return a cached copy of a URL already fetched, and there's a separate store that persists across sessions and restarts.
- You can override default tools entirely: intercept WebSearch, route to the Exa API if a key exists, fall back to the built-in tool on failure, and uninstall the Exa MCP server.
- A redaction hook strips secrets, emails and IPs from the session transcript by entropy detection, storing the real secret in memory under an ID and substituting it back in only when the request is made.
- Hooks can draw UI: a demo showed a Vercel deploy status row moving through queued/building/ready with elapsed time and a hide/show toggle, plus a per-plugin live data panel.
- Other suggested uses: dry-run gating for data analysis, prompting a refactor when files exceed 1,000 lines, compliance audit logging of every event, confirming newsletter sends, and using $model and $http to pull company knowledge base context or generate a PR comprehension quiz.
Concrete example of replacing a built-in tool's implementation, with fallbacks, letting you drop an MCP server entirely.
So what I can do instead is I can override the web search tool by middlewareing it, whereby it will intercept the tool, see if I have an Exa API key set. If I don't, it will default to the normal web search tool.
A working demo of the most practically useful pattern: Claude uses a real API key without ever seeing or logging it.
You will see it was automatically redacted, the secret, as soon as I pressed enter, and it got replaced with an ID... And when this request is made, then the hook automatically rewrites it to the correct secret.
Function hooks basically take hooks to the next level and make Claude Code even more hackable and customizable.
All the things that you may have been putting in your CLAUDE.md files, you can start removing and putting into really well-defined hooks.json instead.
Claude Code will generate a quiz for you to make sure that you correctly understand the changes that it made before it actually allows you to open up a PR.