Git Hook Automation with lefthook
Decision
- Adopt
lefthookfor Git Hook management. - Run
biome format --writeand thenbiome check --writeon staged files inpre-commit. - Run
biome format --writeand thenbiome check --writeon the files included in the push (committed changes) inpre-pushas well. - Centralize hook definitions in
lefthook.ymlat the repository root.
Context
When formatting or linting is skipped locally, reviews include noisy non-essential diffs and comments. There was also inconsistency in per-developer hook setups, so we needed a version-controlled and reproducible approach.
Alternatives
- Native Git hooks in
.git/hooksconfigured manually: low reproducibility and hard to share. - Husky: proven option, but
lefthookwas preferred this time for lighter and simpler configuration. - CI-only validation: slower feedback and no early local detection.
Consequences
- Quality checks are automated before commit and before push.
- Formatting issues are detected early, reducing style inconsistency.
- On failure, commit/push is blocked until fixes are applied and checks are rerun.
hsb.horse