Husky Git Hooks Config Builder

Set up Husky pre-commit and commit-msg hooks for code quality gates

Generates Husky v9 hook scripts for pre-commit running lint-staged, commit-msg running commitlint, and pre-push running tests, plus the matching lint-staged configuration and setup commands for your repo.

What is Husky and why use it?

Husky manages Git hooks so quality checks run automatically at commit and push time. It lets your whole team share the same pre-commit linting and commit-message rules without anyone remembering to run them manually.

Add quality gates to every commit

Husky runs Git hooks for you, so linting, commit-message validation, and tests fire automatically at the right moment instead of relying on memory. This builder generates the three most useful hooks — pre-commit, commit-msg, and pre-push — along with the matching lint-staged config and the exact setup commands.

How it works

Husky installs a Git core.hooksPath pointing at a .husky folder. In Husky v9 each hook is a plain shell script containing just the command to run.

  • pre-commit runs lint-staged, which lints and formats only the files you staged. The lint-staged config maps a glob like *.{js,jsx,ts,tsx} to commands such as eslint --fix and prettier --write; matched files are auto-fixed and re-staged.
  • commit-msg runs commitlint --edit "$1", where $1 is the path to the file holding the in-progress commit message. If the message violates your convention, the commit aborts.
  • pre-push runs your test command so broken code never reaches the remote.

The setup commands install husky, lint-staged, and commitlint, run npx husky init, and write each hook file.

Tips and notes

  • lint-staged keeps pre-commit fast by only touching staged files.
  • Hooks can be bypassed with --no-verify, so re-run the same checks in CI.
  • Use npx --no-install in the commit-msg hook so it fails loudly if commitlint is missing rather than fetching it silently.
  • Keep the pre-push command lightweight; a full slow test suite belongs in CI.