hookset
Every export of hookset, with its signature and doc comment: packageRoot, loadStations, packageVersion, parseRemotes, localRuns, duplicateOf and 5 more, plus 10 types.
import { packageRoot, loadStations, packageVersion, … } from 'hookset';Functions
checkRepo
Everything hookset check reports for the repo at repo, against the presets in pkg.
function checkRepo(repo: string, pkg: string): CheckResult;| Parameter | Type |
|---|---|
repo | string |
pkg | string |
Returns CheckResult
checkText
The text a person reads for a check result.
function checkText(result: CheckResult): string;| Parameter | Type |
|---|---|
result | CheckResult |
Returns string
duplicateOf
True when a hand-written step repeats what a preset station already runs.
function duplicateOf(run: Run, stations: Station[]): Station | undefined;| Parameter | Type |
|---|---|
run | Run |
stations | Station[] |
Returns Station \| undefined
expectedClaudeHooks
The pack's hooks, with stop-after-3 also on PostToolUseFailure (a failed Bash call lands there).
function expectedClaudeHooks(stations: Stations): ClaudeHook[];| Parameter | Type |
|---|---|
stations | Stations |
Returns ClaudeHook[]
initRepo
Write or update the hookset wiring in repo. A lefthook.yml hookset did not write is refused
unless force, which puts the remotes block on top and keeps every hand-written step (check
then names the duplicates to delete). claude also vendors the Claude pack.
function initRepo(repo: string, pkg: string, options?: {
force?: boolean;
claude?: boolean;
}): InitResult;| Parameter | Type |
|---|---|
repo | string |
pkg | string |
options (optional) | { force?: boolean; claude?: boolean; } |
Returns InitResult
lefthookTemplate
The lefthook.yml hookset init writes into a repo with none.
function lefthookTemplate(stations: Stations, ref: string): string;| Parameter | Type |
|---|---|
stations | Stations |
ref | string |
Returns string
loadStations
function loadStations(pkg: string): Stations;| Parameter | Type |
|---|---|
pkg | string |
Returns Stations
localRuns
Every run: a lefthook.yml declares itself, outside remotes:, with its hook and command.
function localRuns(yaml: string): Run[];| Parameter | Type |
|---|---|
yaml | string |
Returns Run[]
packageRoot
The package root: the folder holding stations.json, presets/ and claude/.
function packageRoot(from?: string): string;| Parameter | Type |
|---|---|
from (optional) | string |
Returns string
packageVersion
function packageVersion(pkg: string): string;| Parameter | Type |
|---|---|
pkg | string |
Returns string
parseRemotes
The remotes: entries of a lefthook.yml. Read line by line: hookset writes this block itself,
and a full YAML parser would be this package's only dependency. A remote starts at a list item
whose first word is one of its keys; a configs entry is a list item that is a path.
function parseRemotes(yaml: string): Remote[];| Parameter | Type |
|---|---|
yaml | string |
Returns Remote[]
Interfaces
CheckResult
interface CheckResult {
ok: boolean;
/** The `hookset@…` tag the repo pins, when it pins one. */
pinned: string | undefined;
expected: string;
problems: Problem[];
}ClaudeHook
interface ClaudeHook {
event: string;
matcher: string;
file: string;
}InitResult
interface InitResult {
changed: boolean;
written: string[];
refused?: string;
}Problem
interface Problem {
id: string;
severity: 'error' | 'warning';
message: string;
fix: string;
}Remote
interface Remote {
gitUrl: string;
ref: string | undefined;
configs: string[];
}Run
interface Run {
hook: string;
command: string;
run: string;
}Station
interface Station {
id: string;
hook: Hook;
mode: Mode;
/** The command name the preset gives this station's step. */
command: string;
/** The repo script the step runs, when the repo decides what the station does. */
script?: string;
detail: string;
}Stations
interface Stations {
remote: string;
tagPrefix: string;
presets: Record<Hook, string>;
stations: Station[];
claude: {
files: string[];
hooks: ClaudeHook[];
};
}Types
Hook
type Hook = 'commit-msg' | 'pre-commit' | 'pre-push';Mode
type Mode = 'enforce' | 'optional' | 'observe';Repositories where agents work
Give a repository that Claude Code works in the git hooks and the hook pack in one command, list its deploys under ask and its generated files under generated, and replace the CLAUDE.md sentences the hooks now enforce.
FAQ
Short answers about hookset: whether it runs hooks itself, what a repository must declare, why tags and not branches, how to add a step, what the Claude Code hooks deny, and how to run the check in CI, each with a link to the page that explains it.