Get started
Install
shell
npm install --save-dev huskyshell
pnpm add --save-dev huskyshell
yarn add --dev husky
# Add pinst ONLY if your package is not private
yarn add --dev pinstshell
bun add --dev huskyhusky init (recommended)
The init command simplifies setting up husky in a project. It creates a pre-commit script in .husky/ and updates the prepare script in package.json. Modifications can be made later to suit your workflow.
shell
npx husky initshell
pnpm exec husky initshell
# Due to specific caveats and differences with other package managers,
# refer to the How To section.shell
bunx husky initTry it
Congratulations! You've successfully set up your first Git hook with just one command 🎉. Let's test it:
shell
git commit -m "Keep calm and commit"
# test script will run every time you commitFor manual setup and more information, see the How To section.