Git pre-commit hook for AI agent code review against project guidelines
npm install @jaleeson11/commitguardA git pre-commit hook that enables AI agents to review code changes against project guidelines before committing.
- Automated code review — Blocks commits and presents staged changes for AI agent review against your project's coding standards.
- Zero configuration — Installs automatically via npm postinstall. Just add your COMMITGUARD.md and you're ready to go.
- Framework agnostic — Works with any project that uses git. No API calls or external services required.
- Non-intrusive workflow — Agents can bypass the hook with --no-verify after reviewing, or fix issues and re-commit.
- Node.js 18+
- Git
1. Install the package as a dev dependency:
``bash`
npm install @jaleeson11/commitguard --save-dev
2. Create a COMMITGUARD.md in your project root with your coding standards:
`bash`
touch COMMITGUARD.md
The hook will automatically be installed to .git/hooks/pre-commit.
When an AI agent (or developer) attempts to commit:
`bash`
git commit -m "add new feature"
The hook will:
1. Display the project's COMMITGUARD.md
2. Show the staged diff
3. Block the commit with review instructions
After reviewing, the agent can either:
- Approve and commit:
`bash`
git commit --no-verify -m "add new feature"
- Fix issues and retry:
`bash`
# Make fixes
git add .
git commit -m "add new feature"
The hook searches for COMMITGUARD.md in these locations (in order):./COMMITGUARD.md
- ./.github/COMMITGUARD.md
- ./docs/COMMITGUARD.md`
-
This project is licensed under the MIT License.