Skip to content

sickagents/commit-msg-lint

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

commit-msg-lint

A fast, zero-dependency CLI tool to lint git commit messages against Conventional Commits and custom rules.

Features

  • ✅ Validates Conventional Commits format (type(scope): subject)
  • ✅ Configurable rules via .commit-lint.json
  • ✅ Supports custom types, scopes, and length limits
  • ✅ Works as a git hook or standalone CLI
  • ✅ Zero dependencies - single Python file
  • ✅ Fast and lightweight

Installation

# Download the script
curl -o commit-msg-lint https://raw.githubusercontent.com/sickagents/commit-msg-lint/main/commit-msg-lint
chmod +x commit-msg-lint

# Move to PATH
sudo mv commit-msg-lint /usr/local/bin/

Usage

As a git hook

# In your git repository
commit-msg-lint install

This creates a .git/hooks/commit-msg hook that validates every commit.

Standalone validation

# Validate a commit message
commit-msg-lint check "feat(api): add user authentication"

# Validate from file
commit-msg-lint check-file .git/COMMIT_EDITMSG

Configuration

Create .commit-lint.json in your repository root:

{
  "types": ["feat", "fix", "docs", "style", "refactor", "test", "chore"],
  "scopes": ["api", "ui", "db", "auth"],
  "subject_max_length": 72,
  "subject_min_length": 10,
  "require_scope": false,
  "allow_empty_scope": true
}

Commit Message Format

<type>(<scope>): <subject>

<body>

<footer>

Examples

✅ Valid:

feat(api): add user authentication
fix: resolve memory leak in parser
docs(readme): update installation steps

❌ Invalid:

added new feature          # Missing type
feat add feature           # Missing colon
feat(api) add feature      # Missing colon after scope
FEAT(api): add feature     # Type must be lowercase

Rules

  1. Type: Must be one of the configured types (default: feat, fix, docs, style, refactor, test, chore)
  2. Scope: Optional, must be alphanumeric with hyphens/underscores
  3. Subject:
    • Must start with lowercase letter
    • No period at the end
    • Length between min and max (default: 10-72 chars)
  4. Format: type(scope): subject or type: subject

License

MIT

About

A fast CLI tool to lint git commit messages against Conventional Commits and custom rules

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages