Conventional Commits Validator
Enter your commit messages on the left to validate them against the Conventional Commits spec.
These types will be considered valid. Common: feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert.
Paste this script into .git/hooks/commit-msg in your repository and make it executable (chmod +x .git/hooks/commit-msg).
.git/hooks/commit-msg
chmod +x .git/hooks/commit-msg
#!/bin/sh # commit-msg hook for Conventional Commits commit_msg_file=$1 commit_msg=$(cat "$commit_msg_file") commit_subject=$(head -n1 "$commit_msg_file") pattern="^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\([a-z0-9\-]+\))?!?: .+" if ! echo "$commit_subject" | grep -Eq "$pattern"; then echo "❌ Error: Invalid commit message format." echo "Expected format: type(scope): subject" echo "Example: feat(api): add user endpoints" echo "Allowed types: build, chore, ci, docs, feat, fix, perf, refactor, revert, style, test" exit 1 fi