intermediate
Husky
Run repository-managed Git hooks for lightweight local checks while keeping authoritative verification in CI.
Husky installs Git hooks managed in the repository (`.husky/pre-commit`) so teams share the same local checks. Typical hooks run format/lint on staged files or block commits with failing quick tests.
Hooks improve feedback early but are bypassable (`--no-verify`, environment skips). CI must remain the authoritative gate for merges.
# .husky/pre-commit (conceptual)
pnpm exec lint-staged
On interviews: pre-commit vs pre-push, keeping hooks under ~10 seconds, documenting skip policy, and pairing with lint-staged.
Common pitfalls: full test suite in pre-commit; secrets or network calls in hooks; treating hooks as security enforcement.
The trade-off is helpful local nudges versus developer friction when hooks are slow.
Checklist:
- Keep hooks fast and focused.
- Never replace CI with hooks alone.
- Version hook scripts in repo.
- Pair with lint-staged for staged scope.