ShtukbaseStandard

Repository hooks

hooks · versión 0.1.2
Agentes y automatizaciones3 normas1 comprobación

Connects Git and Claude Code to the repository dispatcher and runs package hooks on their events.

Sobre el paquete

Este texto aún no está traducido. Debajo está el original en inglés.

A package can enforce a norm at a Git or Claude Code event. The norm lists the hook under enforcers and declares enforcerKind: hook.

How it works

  • On install and update, sync finds the repository from the project's nearest ancestor with a .git file or directory. It installs pre-commit and commit-msg in Git's configured hooks folder. Each calls shtuk hook with the event and any commit message path supplied by Git.
  • sync also adds four entries to the repository's .claude/settings.json. They call shtuk hook agent:<Event> on SessionStart, PreToolUse (Bash, Write, Edit, MultiEdit), PostToolUse (Write, Edit, MultiEdit), and Stop.
  • In each project selected by the dispatcher, the runner reads the hooks lists of all installed packages. A declaration has {name, event, tools, run, norm, timeout}. Claude Code hooks receive the original JSON on stdin. Git hooks receive event arguments on the command line.
  • When the dispatcher supplies SHTUK_FILES, the runner uses SHTUK_OWNERS to remove files whose owner appears in the norm's except list. It skips a hook when that list excludes every supplied file.
  • Hook exit code 0 lets the event pass. Code 2 blocks it and reports the finding on stderr. Other exit codes report a broken hook and let the event pass.

Other people's hooks, repeats and updates

  • For an existing shell hook, sync appends one marked block. Git runs the block when the shell reaches it. Keep the dispatcher block reachable when editing the preceding script.
  • In the repository's Claude Code settings, sync replaces its own entries across events, including entries for the older direct runner. It keeps other entries and settings. Invalid JSON stops sync and leaves the settings file untouched.
  • shtuk run hooks remove removes the repository dispatcher entries. shtuk run hooks installed checks for missing, duplicate, or stale entries.

Norms

  • HK-R01: the hook runner is installed once per event. The enforcer is the check installed.
  • HK-R02: a database record that breaks a check does not reach the disk silently. The enforcers are the hooks record-pre (does not let through a record with no header, no title, or an empty required field) and record-post (after a write runs the schema checks s01 to s03 on that record and tells the agent at once what is broken).
  • HK-R03: one commit touches one project. The one-project hook reports staged files owned by multiple projects. Set mode: enforce in the project's copy of the rule to block such commits.

Git and Claude Code need shtuk and bun on their PATH.

Normas 3

IDNormaNivelModoEnforcer
HK-R01
En el .claude/settings.json del proyecto está presente, una vez para cada uno de los eventos SessionStart, PreToolUse, PostToolUse y Stop, el ejecutor de hooks del paquete
MUST bloquea
comprobación
HK-R02
Cuando un agente escribe un registro de colección que rompe una comprobación de esquema, un hook no deja pasar la escritura o le dice al agente, justo después, qué está roto
MUST bloquea
hook
HK-R03
The staged files with an owner belong to at most one project
MUST observa
hook

«Bloquea»: el enforcer detiene la infracción. «Observa»: solo la anota. El nivel MUST es obligatorio; SHOULD significa «sí, salvo que haya motivo».

Acciones 3

NombreQué haceArchivoCuándo
syncInstall the repository dispatcher entries for Git and Claude Codesync.ts
tras instalar tras actualizar
removeRemove the repository dispatcher entries for Git and Claude Coderemove.ts
shtuk run
installedThe repository dispatcher is installed once per event
norma HK-R01
installed.ts
comprobación

shtuk check ejecuta las comprobaciones; shtuk run hooks <nombre> ejecuta cualquier acción. Las acciones «tras instalar» solo se ejecutan solas si el paquete viene de una fuente de confianza.

Hooks de agentes 3

NombreEventoHerramientasArchivoNorma
one-projectpre-commithooks/one-project.tsHK-R03
record-prePreToolUseWrite, Edit, MultiEdithooks/record-pre.tsHK-R02
record-postPostToolUseWrite, Edit, MultiEdithooks/record-post.tsHK-R02

Páginas 3

Se copian al proyecto en estas rutas.

Archivos del paquete 13

Van a .shtukbase/packages/hooks/; las acciones se ejecutan desde ahí.