mod-builder
Mod builder
A mod is a Claude Code plugin whose hooks/hooks.json names one hooks module under modules. The module exports register(on, options), and each hook is a function ($, e, next). It runs inside Claude Code's own process with the user's reach. Mods need Claude Code 2.1.287 or later, are on by default, and the old early-access flag is ignored. [src: docs overview > Turn mods on or off | checked 2.1.288 | recheck: gate prints a floor line that does not end "met"]
Three facts carry this skill:
claude plugin validate <dir>prints every hooked event, every$call, every env name and every state key before any code runs. [src: docs create > Check what Claude Code reads from your mod | checked 2.1.288 | recheck: footprint.mjs prints a note prefix it does not parse]- Every load from
--plugin-diror the dev-mods folder writes the exact declarations for the running build into<mod>/.claude-plugin/types/; line 1 ofclaude-code/index.d.tsnames the build. Nothing has to be run to get them. [src: docs create > Get type definitions for your version | checked 2.1.288 | recheck: gate cannot locate types after a load] --debug-file <path>logs every module load and, observed, most$calls with the plugin's name;$.statecalls leave no call line, direct or through thereadandupdatehelpers, and neither did$.env.getin the probe run. [src: docs troubleshoot > Read the debug log; observed for the call lines | checked 2.1.288 | recheck: a load log shows a$.statecall line, or a mod's$.ui.logcall leaves no line]
Authority order: the generated types for the build you run, then claude plugin validate, then the docs pages, then the public GitHub copy of the declarations (it can lag), then built-in and sample mod source, then community mods. A page and the types disagree: the types win.
Deferral rule: this skill never restates a shape (fields, signatures, element props, union members, counts). Grep the types the gate printed. It restates decision facts, process facts and limits, each with a stamp.
Where files go
Write the mod in the directory the user names, else ./<name>/ under the current directory. Never write under ~/.claude/dev-mods/ unless the user wants the mod live in this session right now; then say that the first write asks "Enable for this session", that the folder is deleted after cleanupPeriodDays, and copy the mod out at handoff. [src: docs create > Ask Claude for a mod | checked 2.1.288 | recheck: a dev-mods write raises no prompt]
Do not load the built-in plugin-authoring skill for API facts: loading it starts the dev-mods watch and its text tells you to write there. Grep the types instead.