CLI Tools bash Intermediate

Git Commit Message Enforcer

commit-msg hook that enforces Conventional Commits format.

bash
#!/bin/bash
# .git/hooks/commit-msg
COMMIT_MSG=$(cat "$1")
PATTERN='^(feat|fix|docs|style|refactor|test|chore)(\(.+\))?: .{1,72}'
if ! echo "$COMMIT_MSG" | grep -qP "$PATTERN"; then
  echo 'ERROR: Commit must follow Conventional Commits format.'
  echo 'Example: feat(auth): add JWT refresh endpoint'
  exit 1
fi

Prerequisites

  • bash
  • git

Pro Tips

  • → Use commitlint for team-wide enforcement via CI.

Was this module useful?

Share your experience — it helps the team improve.

Leave Feedback

Commercial Licensing

Acquire a production access token or template license for enterprise deployment.

Module Info

Language
bash
Level
Intermediate
Read time
2 min
Published
Sep 2026
License
Commercial License

Newsletter

New modules every week, directly to your inbox.