integrationAdd git-agent as a pre-commit hook in your .pre-commit-config.yaml
The pre-commit framework is a language-agnostic hook manager that runs configured checks before each commit. By wiring git-agent into your pre-commit configuration, you can validate commit messages, check for conventional commit compliance, and take advantage of git-agent's auto-retry logic — all within the same framework that runs your linters and formatters. The pre-commit framework's multi-language hook system supports Go binaries, making git-agent a natural fit.
Benefits
- Manage git-agent alongside existing pre-commit hooks in a single config file
- Validate commit messages before they reach CI, reducing pipeline failures
- Language-agnostic: git-agent's Go binary works with any pre-commit environment
- Automatic corrective retry when the hook rejects a generated commit message
Setup steps
- Create a .pre-commit-config.yaml in your repository root
- Add a repo entry pointing to the git-agent binary or use the local hook system
- Configure git-agent's hook dispatch to conventional mode in .git-agent/config.yml
- Run pre-commit install to register the hooks, then test with a staged change
FAQ
Can pre-commit run git-agent on Windows, macOS, and Linux?Yes. git-agent is a Go binary distributed via Homebrew and GitHub releases. It is cross-platform and works wherever pre-commit runs.
How does git-agent's retry loop interact with pre-commit's hook model?When pre-commit exits non-zero, git-agent's commit flow enters a retry loop: it rewrites the commit message and re-attempts, up to 3 retries and 2 full re-plans before falling back to manual mode.
Do I need to install pre-commit if I already use git-agent?No. git-agent has its own built-in hook system. The pre-commit integration is for teams that already use the pre-commit framework and want to add git-agent to their existing hook pipeline.