ADR-0050: Husky for Git Hooks
Status
Accepted - 2025-01-26
Context
Enforce code quality checks before commits and pushes to prevent broken code.
Decision
Husky 9.x for Git hooks management.
Rationale
- Simple: Easy setup with pnpm exec husky init
- Fast: Runs only on staged files (lint-staged)
- Enforced: Pre-commit hook prevents bad commits
- CI Alignment: Same checks as CI
Setup
# Install
pnpm add -D husky lint-staged
# Initialize
pnpm exec husky init
Pre-Commit Hook
# .husky/pre-commit
pnpm lint-staged
Lint-Staged Config
// package.json
{
  "lint-staged": {
    "*.{ts,tsx}": [
      "eslint --fix",
      "prettier --write"
    ],
    "*.{json,md,yaml}": [
      "prettier --write"
    ]
  }
}
Hooks
- pre-commit - Lint + format staged files
- pre-push - Run tests
- commit-msg - Validate commit message format