Mod hooks module (register.js)
The code file a mod's hooks.json points at. register(on) subscribes to events — this one counts tool calls and shows the running total beside the spinner. A plugin that ships a hooks module is a mod; mods require Claude Code v2.1.287+ and are on by default.
// hooks/register.js — a minimal mod
let calls = 0;
export function register(on) {
// Runs each time Claude is about to use a tool
on("tool.call", async ($, e, next) => {
calls += 1;
$.ui.invalidate("ui.render"); // ask Claude Code to redraw
return next(e); // let the tool run as usual
});
// Runs each time Claude Code draws the spinner
on("ui.render", { component: "Spinner" }, async ($, e, next) => {
return next({ ...e, props: { ...e.props, suffix: ` · tool calls: ${calls}…` } });
});
}