A Git hook that uses AI to review and validate commit messages. By default, it checks if messages follow Conventional Commits best practices, but you can completely customize the validation criteria through the system prompt.
The hook will run automatically when you attempt to make a commit. It will:
- Analyze the commit message
- Provide feedback on message quality
- Suggest improvements if necessary
- Allow you to proceed or cancel the commit
- Git
- Bash
makecurljq- OpenAI API key
The hook can be configured through the following environment variables:
COMMIT_REVIEWER_API_KEY: Your OpenAI API key (required)COMMIT_REVIEWER_API_URL: OpenAI API URL (default: "https://api.openai.com/v1/chat/completions")COMMIT_REVIEWER_RESPONSE_LANGUAGE: Language for AI responses (default: "en")COMMIT_REVIEWER_COMMIT_LANGUAGE: Language for Commits (default: "en")COMMIT_REVIEWER_SKIP_AMEND: Whether to skip validation on amend commits (default: "true")COMMIT_REVIEWER_SKIP_WIP: Whether to skip validation on commits containing "wip" or "WIP" (default: "true")COMMIT_REVIEWER_LOG_LEVEL: Log level (debug, info, error) (default: "info")
- Clone this repository:
git clone git@github.com:Tsugami/git-hook-ia-commit-reviewer.git ~/.git-hook-ia-reviewer- Run the installation command:
cd ~/.git-hook-ia-reviewer && make install- Configure your OpenAI API key:
echo 'export COMMIT_REVIEWER_API_KEY="your-api-key"' >> ~/.bashrc
echo 'export COMMIT_REVIEWER_LANGUAGE="en"' >> ~/.zshrc # optional, for English responses
source ~/.bashrcTo remove the hook, run:
cd ~/.git-hook-ia-reviewer && make uninstallTo enable debug mode and see detailed logs:
export COMMIT_REVIEWER_LOG_LEVEL=debugContributions are welcome! Please feel free to open an issue or submit a pull request.
This project is licensed under the MIT License - see the LICENSE file for details.
