Skip to content
This repository was archived by the owner on Sep 26, 2025. It is now read-only.

Tsugami/git-hook-ia-commit-reviewer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Git Hook AI Commit Reviewer

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.

Usage

The hook will run automatically when you attempt to make a commit. It will:

  1. Analyze the commit message
  2. Provide feedback on message quality
  3. Suggest improvements if necessary
  4. Allow you to proceed or cancel the commit

Git Hook AI Commit Reviewer in action

Requirements

  • Git
  • Bash
  • make
  • curl
  • jq
  • OpenAI API key

Configuration

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")

Installation

  1. Clone this repository:
git clone git@github.com:Tsugami/git-hook-ia-commit-reviewer.git ~/.git-hook-ia-reviewer
  1. Run the installation command:
cd ~/.git-hook-ia-reviewer && make install
  1. 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 ~/.bashrc

Uninstallation

To remove the hook, run:

cd ~/.git-hook-ia-reviewer && make uninstall

Troubleshooting

To enable debug mode and see detailed logs:

export COMMIT_REVIEWER_LOG_LEVEL=debug

Contributing

Contributions are welcome! Please feel free to open an issue or submit a pull request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

A Git hook that uses AI to review and validate commit messages

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published