Skip to content

jeremylongshore/tons-of-skills-marketplace / plugins/packages/devops-automation-pack/skills/generating-conventional-commits

generating-conventional-commits

Verified

Execute generates conventional commit messages using AI. It analyzes code changes and suggests a commit message adhering to the conventional commits specification. Use this skill when you need help writing clear, standardized commit messages, especially a... Use when managing version control. Trigger with phrases like 'commit', 'branch', or 'git'.

FileKindSize
SKILL.mdskill md3.3 KB
assets/README.mdmarkdown225 B
assets/commit_message_template.txtmarkdown3.8 KB
assets/example_code_diff.txtmarkdown3.4 KB
references/README.mdmarkdown65 B
scripts/README.mdmarkdown356 B
scripts/generate_commit_message.pyexecutablescript7.3 KB
scripts/suggest_commit_type.pyexecutablescript10.4 KB
scripts/validate_commit_message.pyexecutablescript4.1 KB

scripts/validate_commit_message.py

View on GitHub
#!/usr/bin/env python3
"""
Validate commit messages against the Conventional Commits specification.

This script validates that commit messages follow the conventional commits
standard, which includes type(scope): subject format with proper structure.

The conventional commits specification defines:
- type: feat, fix, docs, style, refactor, perf, test, chore, ci, etc.
- scope: optional area of the codebase
- subject: brief description of the change
"""

import argparse
import sys
import re
from typing import Tuple


def validate_conventional_commit(message: str) -> Tuple[bool, str]:
    """
    Validate a commit message against conventional commits specification.

    Args:
        message: The commit message to validate

    Returns:
        Tuple of (is_valid, error_message)
        - is_valid: True if message is valid, False otherwise
        - error_message: Description of validation error (empty if valid)
    """
    if not message or not message.strip():
        return False, "Commit message cannot be empty"

    message = message.strip()
    lines = message.split("\n")
    subject = lines[0]

    # Validate subject line format
    # Pattern: type(scope)?: subject or type: subject
    # Where type is required, scope is optional, and subject is required
    pattern = r"^(feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert)(\(.+\))?!?: .{1,}$"

    if not re.match(pattern, subject):
        return False, (
            f"Invalid commit message format: '{subject}'\n"
            "Expected format: type(scope): subject\n"
            "Valid types: feat, fix, docs, style, refactor, perf, test, chore, ci, build, revert\n"
            "Example: feat(auth): add login functionality"
        )

    # Validate subject line length (recommended max 50 chars)
    if len(subject) > 72:
        return False, (
            f"Subject line too long ({len(subject)} chars). Recommended maximum is 50 characters, hard limit is 72"
        )

    # Validate subject doesn't end with period
    if subject.endswith("."):
        return False, "Subject line should not end with a period"

    # If there are multiple lines, validate blank line after subject
    if len(lines) > 1:
        if lines[1].strip() != "":
            return False, "Expected blank line between subject and body"

    return True, ""


def main():
    """Main entry point for the validation script."""
    parser = argparse.ArgumentParser(
        description="Validate commit messages against the Conventional Commits specification",
        formatter_class=argparse.RawDescriptionHelpFormatter,
        epilog="""
Examples:
  # Validate a commit message from a file
  %(prog)s --file commit-msg.txt

  # Validate a commit message from command line
  %(prog)s --message "feat(api): add new endpoint"

  # Validate with verbose output
  %(prog)s --message "fix: resolve bug" --verbose
        """,
    )

    # Create mutually exclusive group for input source
    input_group = parser.add_mutually_exclusive_group(required=True)
    input_group.add_argument("-m", "--message", type=str, help="Commit message to validate")
    input_group.add_argument("-f", "--file", type=str, help="Path to file containing commit message")

    parser.add_argument("-v", "--verbose", action="store_true", help="Enable verbose output")

    args = parser.parse_args()

    # Get the commit message
    if args.file:
        try:
            with open(args.file, "r", encoding="utf-8") as f:
                message = f.read()
        except FileNotFoundError:
            print(f"Error: File not found: {args.file}", file=sys.stderr)
            return 1
        except IOError as e:
            print(f"Error reading file: {e}", file=sys.stderr)
            return 1
    else:
        message = args.message

    # Validate the message
    is_valid, error_msg = validate_conventional_commit(message)

    if is_valid:
        if args.verbose:
            print("✓ Commit message is valid")
        return 0
    else:
        print("✗ Validation failed:", file=sys.stderr)
        print(error_msg, file=sys.stderr)
        return 1


if __name__ == "__main__":
    sys.exit(main())
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 323kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 323kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 323kUpdated Claude CodeCodexVerifiedInstall