Skip to content

Husky

Husky connects Git hooks to versioned repository scripts. In a repoctl workspace it is only a trigger: the actual verification lives in repo verify so people, CI, and hooks use the same contract.

sh
# .husky/pre-commit
pnpm exec repo verify pre-commit

# .husky/commit-msg
pnpm exec repo verify commit-msg "$1"

# .husky/pre-push
pnpm exec repo verify pre-push

Keep hooks small. A hook should select a repository task, not duplicate lint, typecheck, or build commands that will drift from CI.

What each hook protects

HookPurposeUsual scope
pre-commitFast feedback before a commit existsStaged formatting, lint, and typecheck
commit-msgEnforce the commit message contractThe pending commit message file
pre-pushCatch broader integration failuresRoot checks and affected build, test, and tsd tasks

repo doctor reports incomplete Husky and lint-staged configuration. Use repo upgrade --no-overwrite to preview managed hook changes before accepting them.

Install and initialize

bash
pnpm add -D husky
pnpm exec husky init

The initializer creates .husky/pre-commit. Replace its generated command with the repository task instead of adding a second tool-specific pipeline.

Troubleshooting

  • Confirm the hook file is executable after a fresh clone.
  • Run the command from the hook directly before debugging Git.
  • Do not use interactive prompts in a hook.
  • Keep network calls and release work out of pre-commit.

Keep Reading