A small npm package that wires Git hooks via core.hooksPath to run checks on commit and push, including lint, tests, and message rules.
Overview
Husky simplifies Git hooks for JavaScript and Node-based repositories by using Git’s core.hooksPath instead of legacy hook installers. Teams add it as a dependency and configure hooks that run automatically before commits or pushes, such as linting commit messages, formatting code, or running tests.
The package stays minimal in size and is designed to run quickly when hooks fire. It supports macOS, Linux, and Windows, works with common Git GUIs and monorepos, and can scope hooks to branches or opt in and out per developer. Hooks can be written with POSIX shell for advanced cases and follow Git’s native hook layout.
Documentation notes alignment with npm prepare scripts for installation, user-facing errors when hooks fail, and the ability to disable hooks globally when needed. The project documents migration from older major versions where configuration format changed.
Key features
- Uses Git core.hooksPath
- All client-side Git hooks supported
- macOS, Linux, and Windows support
- Branch-specific hook configuration
- POSIX shell for custom hooks
- Monorepo and nested project support
- Global opt-out option
- Clear hook failure messages
Use cases
- Run linters before each commit
- Enforce commit message conventions
- Execute tests on push
- Share hook setup across a team