You forget formatting before commit, then lint blocks you right before push. If this repeats, you lose time before review even starts.
Automate formatting and static checks with Git Hooks to reduce manual misses. In this setup, lefthook runs Biome at commit and push time.
Goal
Automatically run Biome formatting and linting at commit and push time.
Prerequisites
bunis available- Work from the repository root
Setup Steps
- Create an ADR in Japanese and document the policy
- Create this procedure memo under
ailog/ - Add
lefthookas a development dependency - Create
lefthook.ymland configure formatting/linting forpre-commitandpre-push - Add the
preparescript (lefthook install) topackage.json - Run
bun run prepareto install Git Hooks - Verify with
lefthook run pre-commitandlefthook run pre-push - If there are issues, fix the configuration
- After setup, create a draft blog post under
ailog/ - Translate the ADR into other languages (en / de / fr / ko)
Verification Checklist
-
lefthook.ymlexists and definespre-commit/pre-push -
bun run preparesucceeds -
lefthook run pre-commitsucceeds -
lefthook run pre-pushsucceeds
Execution Notes
pre-commit targets staged files and runs biome format --write {staged_files} and biome check --write {staged_files}.
pre-push also targets staged files and runs biome format --write {staged_files} and biome check --write {staged_files}.
Keeping Git Hook settings in the repository makes operations consistent across environments. If you want fewer review-noise diffs, locking this down early is the fastest route.
hsb.horse