Skip to content

init

bunx @pivanov/agent-hooks-bridge init [<path>] [options]

Scaffold a starter hook script and wire it into all three host configs in one step. Useful for the first-time setup; after that, edit the generated script and re-run install if you change paths or scope.

Usage

bash
# default: writes ./.hooks/format.ts and runs install
bunx @pivanov/agent-hooks-bridge init

# custom path
bunx @pivanov/agent-hooks-bridge init ./hooks/guard.ts

# scaffold only; do not run install
bunx @pivanov/agent-hooks-bridge init --no-install

# overwrite an existing file
bunx @pivanov/agent-hooks-bridge init --force

# preview the template + the would-be install plan; touches no files
bunx @pivanov/agent-hooks-bridge init --dry-run

Options

FlagDefaultNotes
<path> (positional)./.hooks/format.tsWhere to write the starter hook (relative to --cwd).
--forceoffOverwrite the file if it already exists.
--dry-runoffPrint the template + the install plan; nothing is written.
--no-installoffScaffold only; skip the install step.
--cwd <path>process.cwd()Run relative to this directory.
--help, -hPrint usage.

What gets scaffolded

A no-op hook script with handlers for all five unified events, the rm -rf deny example from the README, and a #!/usr/bin/env bun shebang. The file is created with mode 0o755 so the host can spawn it directly.

After scaffolding

Edit the generated script. If you change the file path or which events you want it wired to, re-run install to update the host configs:

bash
bunx @pivanov/agent-hooks-bridge install ./.hooks/format.ts --events PreToolUse,PostToolUse

init always writes to all three hosts in project-local mode. To wire only to hosts you actually have installed, or to install into a user-level (global) config, run init --no-install first and then drive install with the flags you want:

bash
bunx @pivanov/agent-hooks-bridge init --no-install
bunx @pivanov/agent-hooks-bridge install ./.hooks/format.ts --hosts auto
# or:
bunx @pivanov/agent-hooks-bridge install ~/scripts/format.ts --global

Or run doctor to verify the install picked up your edits:

bash
bunx @pivanov/agent-hooks-bridge doctor

Programmatic API

ts
import { runInit } from "@pivanov/agent-hooks-bridge";

const exitCode = await runInit({ argv: ["./.hooks/format.ts"] });

The CLI is a thin wrapper around runInit. The fs and log options follow the same shape as runInstall, plus a fileExists and chmod for the scaffold step.

Not affiliated with Anthropic, Anysphere, or OpenAI. Supported by LogicStar AI.