integration

Use git-agent as your commit-msg hook via Husky for zero-config local validation

Husky is a popular Node.js tool that makes managing git hooks simple. By integrating git-agent as a Husky-managed commit-msg hook, you get automatic commit message validation before every commit, with a retry loop that lets git-agent regenerate the message if it fails validation. This combination enforces Conventional Commits locally without any CI round-trip, catching formatting issues before they reach the remote.

  • Fail fast — catch malformed commit messages before they reach the remote repository
  • Automatic retry loop: git-agent re-generates the message if the hook rejects it
  • Zero network dependency: hook validation runs entirely offline with no CI round-trip
  • Works alongside existing Husky hooks (lint-staged, ESLint, Prettier) in a single workflow
  • Install Husky: npx husky init, then add git-agent as a commit-msg hook
  • Configure git-agent's hook dispatch to run validation on commit-msg events
  • Set the hook type to conventional or a custom script path in .git-agent/config.yml
  • Test the integration by handing a completed change to git-agent --intent and verifying the hook fires correctly
Does Husky conflict with git-agent's built-in hook installation?
No. git-agent's init command can install its own hook, or you can point the hook dispatch to a Husky-managed hook script. They are designed to coexist.
Do I need Node.js to use git-agent with Husky?
Husky requires Node.js, but git-agent itself is a standalone Go binary. If you already use Husky for other hooks, adding git-agent as a commit-msg hook adds no extra runtime dependency.
Can I use git-agent's retry loop with custom Husky shell scripts?
Yes. git-agent's hook dispatch supports arbitrary shell scripts. Set the hook path in config.yml to your custom script, and the retry logic still applies.