npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

branch-validator-pro

v1.1.1

Published

Professional Git branch and commit validator for consistent naming conventions. Validates format and ensures proper ticket ID patterns without external API dependencies. Perfect for teams worldwide.

Readme

🔍 Branch Validator Pro

A lightweight Node.js package that validates Git branch names and commit messages following consistent conventions and best practices.

🚀 Overview

Branch Validator Pro enforces consistent Git naming conventions across your team, ensuring code quality and maintainability through automated validation of branch names and commit messages.

✨ Features

  • Git branch name validation with proper prefixes (feature/, bugfix/, hotfix/, release/, chore/)
  • Commit message validation following consistent patterns
  • Command-line interface for easy integration
  • Programmatic API for custom implementations
  • Git hook integration for automated validation
  • Zero dependencies for minimal footprint

📦 Installation

Global Installation (Recommended)

npm install -g branch-validator-pro

Local Installation

npm install branch-validator-pro

🎯 Quick Start

Basic Usage

# Validate branch names
validate-git branch feature/TASK-1234-add-user-authentication
validate-git branch bugfix/TASK-5678-fix-login-bug
validate-git branch hotfix/TASK-9012-critical-security-patch

# Validate commit messages
validate-git commit TASK-1234-add-user-authentication
validate-git commit TASK-5678-fix-login-bug

Output

✅ Branch name is valid: feature/TASK-1234-add-user-authentication
✅ Commit message is valid: TASK-1234-fix-login-bug

📖 Programmatic Usage

const { validateBranchName, validateCommitMessage } = require('branch-validator-pro');

// Validate branch name
const branchResult = validateBranchName('feature/TASK-1234-new-feature');
console.log(branchResult.valid); // true/false
console.log(branchResult.message); // validation message

// Validate commit message
const commitResult = validateCommitMessage('TASK-1234-new-feature');
console.log(commitResult.valid); // true/false
console.log(commitResult.message); // validation message

📋 Validation Rules

Branch Names

  • Must start with one of these prefixes:
    • feature/ - for new features
    • bugfix/ - for bug fixes
    • hotfix/ - for critical fixes
    • release/ - for release branches
    • chore/ - for maintenance tasks
  • Must contain a ticket pattern: TASK-XXXX (where XXXX is a number)
  • Description must be lowercase
  • Use dashes (-) only, no spaces or underscores
  • Pattern: ^[a-z]+/TASK-\d+-[a-z0-9-]+$

Valid Examples:

  • feature/TASK-1234-add-payment-gateway
  • bugfix/TASK-5678-fix-validation-error
  • hotfix/TASK-9012-security-patch

Invalid Examples:

  • feature/add-payment (missing ticket)
  • Feature/TASK-1234-payment (uppercase prefix)
  • feature/TASK-1234_payment_gateway (underscores not allowed)
  • feature/TASK-1234-Payment Gateway (spaces not allowed)

Commit Messages

  • Must follow the pattern: TASK-XXXX-description
  • Use lowercase letters, numbers, and dashes only
  • No spaces or underscores allowed
  • Pattern: ^TASK-\d+-[a-z0-9-]+$

Valid Examples:

  • TASK-1234-implement-user-registration
  • TASK-5678-fix-database-connection
  • TASK-9012-update-security-headers

Invalid Examples:

  • TASK-1234 implement user registration (spaces not allowed)
  • TASK-1234_implement_user_registration (underscores not allowed)
  • implement user registration (missing ticket)

🪝 Git Hook Integration

Integrate this validator with Git hooks for automatic validation on every commit.

Pre-commit Hook

Create .git/hooks/pre-commit:

#!/bin/bash
branch_name=$(git symbolic-ref --short HEAD)
validate-git branch "$branch_name"
exit_code=$?
if [ $exit_code -ne 0 ]; then
    echo "Branch name validation failed!"
    exit 1
fi

Commit Message Hook

Create .git/hooks/commit-msg:

#!/bin/bash
commit_msg=$(cat $1)
validate-git commit "$commit_msg"
exit_code=$?
if [ $exit_code -ne 0 ]; then
    echo "Commit message validation failed!"
    exit 1
fi

Make hooks executable:

chmod +x .git/hooks/pre-commit
chmod +x .git/hooks/commit-msg

🔌 API Reference

validateBranchName(branchName)

Validates a Git branch name against the defined rules.

Parameters:

  • branchName (string): The branch name to validate

Returns:

  • valid (boolean): Whether the branch name is valid
  • message (string): Validation result message

validateCommitMessage(commitMessage)

Validates a commit message against the defined rules.

Parameters:

  • commitMessage (string): The commit message to validate

Returns:

  • valid (boolean): Whether the commit message is valid
  • message (string): Validation result message

🚪 Exit Codes

  • 0: Validation successful
  • 1: Validation failed or invalid usage

📝 Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/your-feature
  3. Commit your changes: git commit -m "your-feature-description"
  4. Push to the branch: git push origin feature/your-feature
  5. Submit a pull request

📄 License

MIT License - see LICENSE file for details.

👤 Author

✨ Sanjib Roy

A passionate developer focused on building tools that enhance developer productivity and code quality.

Connect with me:

💬 Support

For issues or questions, please reach out:

📚 Changelog

v1.0.0

  • Initial release
  • Branch name validation
  • Commit message validation
  • CLI interface
  • Programmatic API
  • Git hook integration support