Skip to main content
hook

conventional-commits — Claude Code hook: what it does, how to install

This hook checks Git commit messages against the Conventional Commits pattern. Use it when commit history needs to support changelogs and semantic versioning.

Install into Claude Code · claude-code-templates All methods and platforms ↓
npx claude-code-templates@latest --hook git/conventional-commits
Open on GitHub

What conventional-commits does

The hook attaches to the PreToolUse event for Bash and runs .claude/hooks/conventional-commits.py. Before a commit is created, it checks the message against type(scope): description.

Accepted types are feat, fix, docs, style, refactor, perf, test, chore, ci, build, and revert. Keeping these labels consistent makes the Git history usable for changelog generation and semantic versioning. The check will not run without python3.

What it helps with

  • validate Git commit messages
  • enforce the type(scope): description pattern
  • reject unsupported commit types
  • keep history ready for changelogs and semantic versioning

Example prompts for the agent

  • Create a commit with the message feat(auth): add GitHub sign-in.
  • Commit the email validation fix as fix(forms): correct email checking.
  • Make a documentation commit using the docs type and a short description.

How to install conventional-commits

1claude-code-templates

npx claude-code-templates@latest --hook git/conventional-commits

2Manually: put the files in place

.claude/settings.json

The hooks block: event (PreToolUse, PostToolUse, Stop…) → command. Personal ones go to ~/.claude/settings.json

Step by step, with commands for each platform: Claude Code hooks: what they are, where to configure them, how to block a risky command

Questions about conventional-commits

How do I install conventional-commits in Claude Code?

Run npx claude-code-templates@latest --hook git/conventional-commits, then open .claude/settings.json.

What does conventional-commits do?

It checks Git commit messages against type(scope): description and accepts the listed Conventional Commits types, including feat, fix, docs, and revert.

What does conventional-commits require to run?

The hook calls python3 to execute .claude/hooks/conventional-commits.py, so that interpreter must be available on the system.

Source text

conventional-commits.json · MIT
{
  "description": "Enforce conventional commit message format for all git commits. Validates commit messages follow the pattern: type(scope): description. Supported types: feat, fix, docs, style, refactor, perf, test, chore, ci, build, revert. Ensures consistent commit history for changelog generation and semantic versioning.",
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Bash",
        "hooks": [
          {
            "type": "command",
            "command": "python3 \"$CLAUDE_PROJECT_DIR\"/.claude/hooks/conventional-commits.py"
          }
        ]
      }
    ]
  }
}

© davila7 · MIT · davila7/claude-code-templates

Similar hooks

All hooks for Git and GitHub →

From the same set740

The whole set →

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor