[Sprint 3] feat: Implement commit message enforcement hook for git-flow #225

Closed
opened 2026-01-27 21:51:25 +00:00 by lmiranda · 0 comments
Owner

Description

Implement a PreToolUse hook that validates all git commit messages follow the conventional commit format before they are executed. This ensures commit message consistency regardless of whether the user uses the /commit command or raw git commands.

Implementation

Wiki: Sprint 3: Hooks Implementation

Plugin: plugins/git-flow/

Technical Details

Hook Configuration

  • Event: PreToolUse
  • Tool Filter: Bash (detect git commit commands)
  • Behavior: Block if commit message is invalid

Commit Format (Conventional Commits)

type(scope): description

[optional body]

[optional footer]

Valid types: feat, fix, docs, style, refactor, test, chore, perf, ci, build

Files to Create/Modify

plugins/git-flow/
  hooks/
    hooks.json              # Add PreToolUse hook definition
    validate-commit-msg.sh  # Shell script for validation

Acceptance Criteria

  • Hook defined in hooks/hooks.json (NOT plugin.json)
  • Shell script validates conventional commit format
  • Blocks invalid commit messages with clear error message
  • Allows valid commit messages to proceed
  • Handles edge cases (amend commits, merge commits)
  • README updated with hook documentation

Technical Notes

CRITICAL: Hooks must be in hooks/hooks.json, NOT inline in plugin.json.

## Description Implement a `PreToolUse` hook that validates all git commit messages follow the conventional commit format before they are executed. This ensures commit message consistency regardless of whether the user uses the `/commit` command or raw git commands. ## Implementation **Wiki:** [Sprint 3: Hooks Implementation](https://gitea.hotserv.cloud/personal-projects/leo-claude-mktplace/wiki/Change-V5.2.0%3A-Plugin-Enhancements-Proposal-%28Sprint-3-Hooks%29) **Plugin:** `plugins/git-flow/` ## Technical Details ### Hook Configuration - **Event:** `PreToolUse` - **Tool Filter:** `Bash` (detect `git commit` commands) - **Behavior:** Block if commit message is invalid ### Commit Format (Conventional Commits) ``` type(scope): description [optional body] [optional footer] ``` **Valid types:** `feat`, `fix`, `docs`, `style`, `refactor`, `test`, `chore`, `perf`, `ci`, `build` ### Files to Create/Modify ``` plugins/git-flow/ hooks/ hooks.json # Add PreToolUse hook definition validate-commit-msg.sh # Shell script for validation ``` ## Acceptance Criteria - [ ] Hook defined in `hooks/hooks.json` (NOT plugin.json) - [ ] Shell script validates conventional commit format - [ ] Blocks invalid commit messages with clear error message - [ ] Allows valid commit messages to proceed - [ ] Handles edge cases (amend commits, merge commits) - [ ] README updated with hook documentation ## Technical Notes **CRITICAL:** Hooks must be in `hooks/hooks.json`, NOT inline in plugin.json.
lmiranda added the Type/FeatureEffort/MPriority/HighComplexity/Medium labels 2026-01-27 21:51:25 +00:00
lmiranda added this to the Sprint 3 - Hooks milestone 2026-01-27 21:55:28 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: personal-projects/leo-claude-mktplace#225