Introducing Hooknostic

November 14, 2026

Rory Eckel

DeepSeek V4.1 Flash

Hooknostic compiles portable hooks, skills, and MCP servers into native integrations for Claude Code, Codex, Copilot CLI, OpenCode, and Pi, and backs its support claims with recorded evidence, most of it from real harness sessions driven by a scripted model.

Every coding agent has its own idea of a hook. Claude Code fires PreToolUse. Codex borrows Claude's event names and reads the responses its own way. OpenCode loads a plugin. GitHub Copilot CLI reads a hooks file. Pi has another shape again. The guard I want is the same on all five; the code that delivers it is not.

I have written that guard more than once. A shell command that should be blocked, a tool call that should be rewritten, a note that should reach the model — each starts as a small piece of logic and ends up copied into every harness's configuration, in that harness's own protocol, with its own tests. The copies drift. A fix lands in one and misses the others.

Hooknostic is the tool I built to stop doing that. One portable TypeScript source, compiled into native hooks, skills, and MCP servers for Claude Code, Codex CLI, GitHub Copilot CLI, OpenCode, and Pi. Today it is at v0.13.0.

The hard part was not compiling hooks. It was modelling what each harness can actually do at each event.


Events are not capabilities#

Most portability layers assume that because two harnesses both fire a "before tool" event, the same things can happen at that event. They cannot. Every current harness lets a hook block a pending tool call. Only some let it ask the user to approve the call instead, or add context the model sees alongside it. Replacing a tool's output afterward ranges from exact to impossible.

The central design rule in Hooknostic is that being told about an event and being allowed to act on it are two different things. Each action is a named capability: block, input.replace, output.replace, context.add, requestApproval, notify, prevent, and so on. Every adapter ships a versioned capability profile, a table with one cell per event and capability, and the compiler resolves your hook against that table before it writes anything.

If a hook needs a capability the target does not have, check reports the shortfall before you build. Then you choose:

  • raise or lower the minimum support level, globally or per target, up to exact behavior;
  • turn the shortfall into a warning with onBelowMinimum: "warn";
  • mark the capability optional and branch on ctx.capabilities.has();
  • exclude the target from that hook.

What you cannot get is a required capability that quietly falls short. By default it must be at least emulated. An emulated cell is reported in the build. An approximate one fails the build until you change the policy, and is still reported after you do. An unsupported one, which the harness cannot provide at all, fails whatever the policy says.

Blocking is the easy case. The same interface covers the rest of the lifecycle:

  • addContext loads conventions at session start.
  • updateShell rewrites npm test to pnpm test.
  • replaceOutput redacts a tool result: exactly on Copilot today, approximately on OpenCode and Pi.
  • requestApproval escalates a destructive command instead of refusing it, on Claude, Codex, and Copilot.
  • notify says something without changing what happens next.
  • preventStop keeps the turn alive until a check passes. It is a loop, so you write its bound.

Each helper produces an effect that needs a capability: updateShell, for example, needs input.replace. Most of the value is in changing what the model sees and what runs next.


One source, native outputs#

A Hooknostic project is one hooknostic.config.ts:

typescript
import { defineConfig } from "@hooknostic/sdk";

export default defineConfig({
  entry: "./src/hooks.ts",                 // optional
  components: { root: "./portable" },      // plugin.json, skills/, mcp.json
  targets: {
    claude:   { version: ">=2.1 <3",     delivery: "package", output: "./dist/claude" },
    codex:    { version: ">=0.153 <1",   delivery: "package", output: "./dist/codex" },
    copilot:  { version: ">=1.0.101 <2", delivery: "package", output: "./dist/copilot" },
    opencode: { version: ">=2.0.17 <3",  delivery: "package", output: "./dist/opencode" },
    pi:       { version: ">=1 <2",       delivery: "package", output: "./dist/pi" },
  },
});

entry is the portable hook source. components points at an Agent Plugins 1.0 package root — the directory holding plugin.json and usually skills/ and mcp.json — or, with project delivery, at direct components.skills and components.mcp paths for a repository that does not want a manifest. At least one of entry and components is required, so a project can be hooks-only, components-only, or both. When it has both, components.targets can narrow which targets receive the components.

Each target carries a version range, a delivery mode, and an output directory. The range selects adapter behavior at build time, because a harness's hook surface changes between releases; it is not a check of what you have installed — doctor reports that side. The range also picks the OpenCode family, since v1 and v2 load plugins differently. package delivery produces a distributable plugin. project delivery is meant for sync, which writes repository artifacts, records their ownership, and owns the discovery wiring: .claude/settings.json, .codex/hooks.json, .opencode/plugins, the Copilot and Pi equivalents, skill copies, and MCP configuration.

bash
hooknostic init --local       # scaffold a repository integration
hooknostic check              # compile and validate without writing artifacts
hooknostic build              # write native artifacts (project delivery uses sync)
hooknostic sync --dry-run     # preview the complete reconciliation
hooknostic sync               # write artifacts and own project wiring
hooknostic verify             # fail if the integration on disk has drifted
hooknostic doctor             # diagnose installed versions and activation
hooknostic dispatch           # replay portable events through your hooks

check and dispatch work without a model, which matters more than it sounds. Most of the interesting decisions a hook makes can be tested from a file of events — dispatch --target <id> --events <file> replays JSON Lines against one target, or reads them from stdin — and a hook you cannot test is a hook you find out about in production.

Hooks are optional#

Delete entry and the project is still valid, and still useful. A components-only build bundles no hook runtime; it validates the package and projects each component into the target's native layout. For Claude, plugin.json becomes .claude-plugin/plugin.json, the skills/ tree is copied, and mcp.json becomes .mcp.json. Copilot reads the package model natively, so its output keeps plugin.json, skills/, and mcp.json, adding com.github.copilot/hooks/hooks.json only when there are hooks. Codex gets a native manifest that combines skills, MCP declarations, and any hooks into one plugin. OpenCode and Pi get their own package shapes.

The same compiler that maps tool.before onto five harnesses also maps a package onto five native layouts. Hooks are the component that needs a new contract; skills, MCP servers, and the manifest are the components the ecosystem already agreed on.


A standard, and the part it left out#

Hooknostic does not invent a package format for things that already have one. Agent Plugins 1.0 standardizes the portable package: a closed plugin.json manifest, Agent Skills under skills/, MCP servers in mcp.json, and reverse-domain client extensions. It reads a directory such as com.anthropic.claude-code/ as an overlay, which is how a package can carry Claude-specific files without becoming a Claude-only package.

Hooknostic implements that surface rather than paraphrasing it. It ships the specification's JSON Schemas, reports unknown manifest fields the way the spec requires, enforces the plugin-name rules, validates skills against the Agent Skills specification, and reads mcp.json as the spec's closed union of stdio, streamable-http, and the deprecated sse — including the command and cwd rules and HTTPS for non-loopback endpoints.

Variable expansion is where harnesses disagree. The spec has clients replace ${PLUGIN_ROOT} and ${PLUGIN_DATA} in a single pass, only in args, env values, and cwd. For an Agent Plugins package, the launcher Hooknostic generates for stdio servers does exactly that, in repository integrations and in Codex, OpenCode, and Pi packages. A repository's direct MCP source also resolves ${NAME} and ${NAME:-default} from the launch environment, the way Claude does. Claude and Copilot expand more widely wherever they read the configuration themselves, so by default the build warns with HN106 for each server they would read differently. Containment is enforced too: a server whose ./ command or working directory resolves outside the package root fails the build with HN503 by default, as does a ${PLUGIN_DATA} working directory that leaves the data directory. The spec already rejects a symlink that escapes the package root; where Hooknostic is stricter, it says so. Unless the path is listed in components.exclude, an escaping symlink fails the whole package before any component is parsed, because a projector must never read outside its declared input.

And then there is the gap.

Agent Plugins v1 focuses on Agent Skills and MCP because both have established specifications outside this project and meaningful cross-client adoption. Other proposed component types — such as commands, hooks, agents, rules, and LSP servers — remain too client-specific for a stable portable contract and are outside the v1 format until their formats converge.

— Agent Plugins 1.0, Design Decisions

It is the right call for a standard, and it is precisely the hole I needed filled. Hooks are where every harness still disagrees, so a portable hook contract in v1 would have meant standardizing a moving target. Hooknostic takes the stable half as given and owns the unstable half itself: the hook() definition, the capability declarations, one dispatcher, and a versioned capability table per adapter. When a skills or MCP rule changes, the change follows a published specification. When a harness renames an event, the change lands in one adapter's table and every consumer sees it at check.

ConcernAgent Plugins 1.0Hooknostic
Package and manifestClosed plugin.json, $schema versioning, name rulesShips the spec's schemas; validates and inventories offline
Skills and MCPFixed skills/ and mcp.json discoveryThe same components, projected into each harness's native layout
Paths and environmentContainment, ${PLUGIN_ROOT} / ${PLUGIN_DATA} expansionSame rules; warns where a harness expands wider; a symlink escape fails the whole package
Client extensionsReverse-domain namespaces and directoriesConsumed as overlays; never generated beside the source
HooksOut of scope in v1, by designPortable TypeScript hooks, capability declarations, one dispatcher
CompatibilityLeft to each clientA versioned capability cell for every event, resolved before output

Publishing the output#

For package delivery, build stops at the native package. Agent Plugins 1.0 defines no marketplace field, so each ecosystem has its own index or registry that points at the build output. Hooknostic builds the artifact the listing points at; registering a marketplace or submitting to someone else's remains an author step.

HarnessListed inConsumer installAfter a rebuild
Claude Code.claude-plugin/marketplace.jsonclaude plugin install <plugin>@<marketplace>Cached: bump the manifest version and update
Codex CLI.agents/plugins/marketplace.jsoncodex plugin add <plugin>@<marketplace>Cached: bump the manifest and the marketplace entry's version together
Copilot CLI.github/plugin/marketplace.jsoncopilot plugin install <plugin>@<marketplace>Live from a local path; git-hosted needs copilot plugin update
OpenCode v2npmAdd the npm coordinate to plugins in opencode.jsonPublish a new version
OpenCode v1npmopencode plugin <name>Publish; consumers clear OpenCode's cache (--force is not enough)
Pinpmpi install -l npm:<name>@<version>Publish; consumers install the new @<version>

Each marketplace is registered once with claude, codex, or copilot plugin marketplace add .. Point each index's source at the built target — ./dist/claude, ./dist/codex, ./dist/copilot — not at the portable package root, and list the index files in components.exclude so the listing is not baked into the plugin. For Claude that exclusion is required: an unexcluded .claude-plugin/marketplace.json fails the build with HN503.

OpenCode and Pi take the npm route. Their package output is an npm package: run npm publish in dist/opencode or dist/pi, or in the output of a second OpenCode target (any key, with adapter: "opencode") pinned to a v1 range, such as dist/opencode-v1. Set npmName when the published name is scoped, because an Agent Plugins manifest name cannot contain @ or /. Pi's package carries a pi manifest declaring its extension and skills, so the npm coordinate is all a consumer needs. The two OpenCode outputs carry different loaders, so give each its own npmName and install the one that matches the harness family. Either family also loads a local directory without publishing (v2 by absolute path). Bundle its dependencies, because on v1, at least, a local package's declared dependencies are not installed.


A hook you write once#

Here is the shape of a portable hook:

typescript
import { definePlugin, hook, block, updateShell } from "@hooknostic/sdk";

export default definePlugin({
  name: "portable-repo-hooks",
  hooks: [
    hook("tool.before", {
      id: "protect-shell",
      match: { kind: "shell" },
      capabilities: { block: "required", "input.replace": "optional" },
      run({ tool }, ctx) {
        // Normalized across harnesses. Undefined if this tool's shape was never
        // recorded or the input does not fit it; a guard refuses what it cannot read.
        const command = tool.shell?.command;
        if (command === undefined) return block(`Unrecognized ${tool.nativeName} input`);
        if (command.includes("rm -rf /")) return block("Refusing destructive root deletion");
        if (ctx.capabilities.has("input.replace") && command.startsWith("npm ")) {
          // Lands under whichever key this harness uses, siblings preserved.
          return updateShell({ command: command.replace(/^npm /, "pnpm ") });
        }
      },
    }),
  ],
});

The hook reads tool.shell?.command, a normalized field. It does not care whether the harness calls the tool Bash, bash, shell, or powershell; the adapter decodes the native payload into that shape. File tools get the same treatment: for a file tool whose payload shape has been recorded, and an input that fits it, tool.file?.paths lists the files it targets, whatever the harness names the argument. tool.file is undefined for search and listing tools, and for shell commands that touch files.

The block is required; the input.replace is optional. Every current target supports rewriting, so npm becomes pnpm everywhere. On Codex, whose protocol pairs every rewrite with permissionDecision: "allow", the rewrite also settles the hook's permission decision; Codex's sandbox still applies. On a harness that could not rewrite, the hook would still block what it must and do nothing else, and the build report would record the gap. The required block resolves exactly on every target, and the enhancement degrades visibly.

Three runtime facts matter before you ship one:

  • Stateless. On Claude, Codex, and Copilot every hook call is a fresh process; on OpenCode and Pi the hook is a module inside a long-running harness. The portable contract is stateless. Module state may happen to survive on OpenCode and Pi, but nothing promises it, so anything that must persist goes in a file.
  • Fail-open by default. A handler that throws or exceeds its time budget is reported on stderr and dispatch continues, so a guard that times out does not block. runtime.onHookError: "block" turns a failed handler into a block wherever the event can block on that target. Since v0.13.0, on Claude, Codex, and Copilot, a hook source that fails outside any handler, with a stray rejection, a timer that throws, or a process.exit, is reported too, and the hooks still decide the outcome. OpenCode v2 now prints the report too, but the only path measured to show it is opencode run --standalone --print-logs.
  • Start-up allowance. The budget covers only the handler. On Claude, Codex, and Copilot, the timeout Hooknostic writes into the harness configuration is the sum of the budgets of every hook on that event, plus a five-second start-up allowance by default (less where the harness caps that event), so a slow Node start does not read as a hung hook. OpenCode and Pi run hooks in-process, so there is no harness timeout to pad.

The harness is real; the model is a script#

The rule is that every support claim carries its evidence. Each capability profile records dated validation from captured sessions, live probes, router logs, or the harness's own docs, schemas, and type definitions. At least one record per profile is a capture, and every rating below exact carries a written reason.

Two layers run in CI without model credentials. The first replays every captured native input for a harness through the exact bundled artifact a consumer installs, which covers lifecycle events that are hard to induce in a short headless session. The second installs the harness version the adapter pins, loads the generated artifact through that harness's real discovery mechanism, and points the model transport at a loopback-only scripted server. The harness binary is real. The hook payloads are real. Only the model side is scripted — and scripted per request, so a test can prove an injected context arrived in every request instead of merely somewhere in the session. OpenCode v2 has its own playback suite: the same loopback scripted model against the real harness, without the fixture-replay layer.

Effects are asserted by outcome, not by log line. A marker file proves a blocked command never ran and a rewritten command ran as rewritten. A once-only stop prevention forces a second model turn. A real pseudo-terminal drives Claude's interactive permission prompt, because headless sessions decide without asking. On Codex, a test-only preload records each hook process's exit code, wall time, and output without altering them, so a failed run shows what the hook actually did.

Twenty scenarios in a registry cover every capability cell each adapter resolves at the version it pins, and CI fails if a cell is added that no scenario lists. OpenCode v2's cells are listed too, but its own suite, not the registry's drivers, exercises them. Explicitly unsupported cells get scenarios too — inverted watches that fail the day the channel starts working, because "we checked and it does not work" is a claim that can go stale.

What playback cannot decide, it records as inconclusive with a written reason instead of passing:

  • compaction, on every harness except OpenCode v2, whose own suite drives it;
  • Codex subagent lifecycle and its permission-request event;
  • interactive approval on Codex and Copilot.

Those rest on captured live procedures, and an environment flag is not allowed to turn a loopback session into a claimed real-model validation. A paid real-model mode exists, but it runs only on manual dispatch.

dispatch is the same idea pointed at your own code: replay portable events through your hooks with no harness and no model.


Release date and progress#

The first commit is from August 20, 2026. Counting the first npm release, there have been thirteen releases, one of them a patch, in about seven weeks:

DateReleaseMilestone
August 20, 2026—First commit
September 28, 2026v0.2.0First public npm release
October 17, 2026v0.7.0Pi support
October 21, 2026v0.9.0GitHub Copilot CLI support
November 14, 2026v0.12.0Native Zod 4 SDK and a start-up allowance for generated deadlines
November 17, 2026v0.13.0Hook authoring without Zod, and every failure in your code reported

That pace was not a plan. It is what happened once the adapter model was real and each new harness exposed a different set of gaps.

It is still pre-1.0, and the last two releases both broke things for SDK consumers. v0.12.0 made the exported schemas native Zod 4, made Zod a peer dependency, and dropped the V3 error API. v0.13.0 moved those schemas to @hooknostic/sdk/schemas, so hooks and configuration never import Zod; the SDK keeps a required zod@^4.6.7 peer, which npm and pnpm install for you. It also changed exit codes that scripts read: when a config or hook source fails while a command loads it, check, build, sync, and the other commands that load your code now report HN501 and exit 2, instead of crashing, exiting with your code's own status, or hanging, and dispatch gained exit codes of its own. Keep the CLI and SDK on the same release; from v0.13.0 the CLI warns with HN110 when they differ. The v0.13.0 release notes give each break its upgrade step. I would rather make these breaks before 1.0 than freeze a shape I would have to live with. Later releases will break things too, less often, and the release notes will say so.


It maintains itself#

All five harnesses are supported for both package and project delivery today — six playback lanes, because OpenCode's v1 and v2 families are tested separately. Keeping that sentence true is where most of the automation goes.

A weekly harness-watch workflow runs every Monday at 05:23 UTC. It compares each harness's npm latest against the last playback-validated version, installs anything newer with package lifecycle scripts disabled, and runs the model-free playback suite through that harness's own discovery path. A pass opens a pull request that advances a dated validatedOn record in the adapter profile and regenerates the support table; a failure opens a deduplicated issue with a runbook. When playback fails or a harness jumps more than a patch version, a drift lane runs a real harness session (still against the scripted model) with hooks that record every native payload, then diffs those payloads against the fixtures. A changed payload is found before it becomes a bug report.

The automation is deliberately narrow. A pass writes only that record and the generated table; it never widens a version range. A build outside every known range files a range-extension issue instead, because widening a claim is a human decision that needs real captures behind it.

The same idea runs inside a consumer repository: verify rebuilds the integration in isolated storage and exits non-zero if the integration in the working tree has drifted, so CI catches it. In Hooknostic's own repository, Renovate PRs get their regenerated example artifacts pushed as a follow-up commit.

None of this makes the support table true by construction. It makes every validation record dated and attributed to a method, and checks each harness's newest npm release every week, re-running playback whenever it moves, which is as close to true as a moving target allows. The table also records where the evidence stops:

  • macOS has unit and fixture coverage and shell-interpreter captures for every harness except Pi, but end-to-end playback is established only on Windows and Linux.
  • Codex installed-plugin hooks need Codex 0.153 or later, a narrower range than its repository hooks.
  • Copilot loads repository hooks only in a trusted folder, and only from the directory the session starts in.
  • OpenCode v2 injects context at two points only: per model request (approximately) and at compaction. Its stop behavior is approximate too.
  • Pi has no permission event at all.

Those are not footnotes. They are the reason the capability model exists, and the reason the table is generated from each adapter's profiles and the evidence they record instead of written by hand.


How idea genesis uses it#

idea genesis is the first repository I moved onto Hooknostic, and it is still the best example of why the project exists.

Before this, each [hook] was hand-ported into every harness's own config format and the copies drifted.

— idea genesis, .agents/hooknostic/README.md

Today the repository has one portable source in .agents/hooknostic and three project targets — Claude Code, Codex, and OpenCode — with two hooks in src/hooks.ts:

  • block-recursive-grep refuses recursive grep and its PowerShell and findstr equivalents, because a recursive search over this repository is expensive enough to be a mistake.
  • block-misdirected-pyright refuses a pyright run whose import resolution points at the wrong checkout (a worktree versus the primary), which otherwise either floods the run with false import errors or, worse, reports a false clean against the wrong environment.

Both are tool.before hooks matched to shell calls, with block required and a four-second budget each. The matching logic still lives in scripts/block-recursive-grep.mjs and scripts/block-misdirected-pyright.mjs, where it has its own regression tests; the portable hook imports it, and Hooknostic bundles it into each artifact. What Hooknostic owns is the part that used to be duplicated: decoding each harness's payload, classifying the tool, and answering in that harness's protocol.

Skills and MCP are declared once too: canonical skills in .agents/skills, MCP in .agents/mcp.json. Codex and OpenCode read .agents/skills directly; Claude gets a copy Hooknostic manages. MCP entries go into Claude's .mcp.json and Codex's .codex/config.toml, with stdio servers routed through a generated launcher, and a generated OpenCode plugin module registers the same servers. The generated artifacts, the wiring, and .hooknostic/integration.json are committed, and CI runs verify, so a matcher edit that was never synced fails CI instead of rotting. Upgrading to v0.13.0 was the same deliberate step: bump the two pinned Hooknostic packages, sync, and commit a large diff that is almost all regenerated bundles, about 24,000 lines even though the pinned Zod and esbuild versions stayed put. The generated integration is reviewable, and that is the point.

Porting idea genesis also paid for the tool before its first release, surfacing five toolchain defects and two capability gaps. The ones I still think about: a helper module's "am I being run directly?" check is always true once bundled into the hook artifact, so its command-line code ran on every hook call and read the harness's event off stdin before Hooknostic could, leaving the guards blind; the OpenCode plugin imported one function from Hooknostic's core and dragged the esbuild bundler in with it, which OpenCode's Bun runtime tolerated but plain Node refused to load; and hooknostic build failed intermittently on Windows when moving its finished output into place hit EPERM. The first now raises the build warning HN502, the plugin is now a dependency-free module, and the build retries. A tool that has only ever run against fixtures does not find those.

Every agent hook in idea genesis now goes through this path. Adding another supported harness is a target entry, not another copy.


What is next#

The next idea I am exploring is portable agent definitions: define an agent once and carry it to each harness the same way hooks are carried today — not just the hook, but the agent configuration around it. Which harnesses can support that, and how faithfully, is something the capability model will answer, not something I will promise up front. Beyond that: adapter breadth, more captured evidence, and widening a version range only when captures justify it.

Hooknostic is not a sandbox and does not try to become one. Hooks run inside each harness's trust boundary, and Hooknostic never marks a folder trusted or answers a trust prompt for you. It reports differences; it does not hide them.


Try it#

Hooknostic needs Node.js ^22.22.2 || ^24.15.0 || >=26.0.0. Give the project its own package.json first, or npm installs into the nearest parent folder that has one, and make it ESM:

bash
npm init -y
npm pkg set type=module
npm install --save-dev @hooknostic/sdk hooknostic
npx hooknostic --help

With pnpm 12, pnpm init already sets the module type. Allow esbuild's install script when you add the packages, or pnpm exits 1 with ERR_PNPM_IGNORED_BUILDS, and run the CLI with pnpm exec, because npm's npx refuses to run in a project whose devEngines names pnpm:

bash
pnpm init
pnpm add -D --allow-build=esbuild @hooknostic/sdk hooknostic
pnpm exec hooknostic --help

You do not install Zod yourself: hooks and configuration never import it, and both package managers install the SDK's peer. Only code that imports @hooknostic/sdk/schemas should list zod@^4.6.7 in its own dependencies.

Start with the documentation wiki. The getting-started walkthrough takes an empty folder to installed hooks, the project integration guide covers the repository workflow, and the testing guide explains the model-free playback suite. If you maintain hooks for more than one harness, run init --local, sync --dry-run, sync, and verify against a repository you already have. The dry run tells you whether the port is worth it.

Source and docs are at github.com/roryeckel/hooknostic, and the CLI is on npm as hooknostic. Apache-2.0.

The hook is the same. The harness is an implementation detail.

Back to Home