A CLI tool to generate standardized Git commit messages with ease.
- 🚀 Interactive prompt for commit messages
- 🔍 Commitlint integration for validation
- 🛡️ Husky hooks for automatic commit message validation
- 📋 Smart staging area management
- 🎨 Colorful terminal output with chalk
- ⚡ Fast and lightweight
- 🔧 Works with any Git repository
- ✅ Conventional Commits standard compliance
npm install -g @hamzarafique964/git-commit-gen # Install as dev dependency
npm install --save-dev @hamzarafique964/git-commit-gen
# Set up commitlint and husky (optional)
npx commitlint --installnpm install -g @hamzarafique964/git-commit-gengit-commit-genThe tool automatically detects unstaged changes and lets you:
- Stage all changes at once
- Select specific files to stage
- Skip staging if needed
- Stage your changes:
# Make some changes to your files
echo "console.log('new feature');" >> feature.js
# Run the commit wizard
git-commit-gen
# Follow the interactive prompts:
? Select commit type: (Use arrow keys)
❯ feat: A new feature
fix: A bug fix
docs: Documentation changes
chore: Maintenance tasks
style: Code style changes
refactor: Code refactoring
test: Adding tests
? Enter commit message: add new authentication system
🔍 Validating commit message...
✓ Commit message validated!
📝 Generated: "feat: add new authentication system"
? Proceed with commit? Yes
✔ Committed successfully!- feat - A new feature
- fix - A bug fix
- docs - Documentation changes
- chore - Maintenance tasks
- style - Code style changes (formatting, etc.)
- refactor - Code refactoring
- test - Adding or updating tests
The package includes built-in support for commit message validation:
# Test a commit message
echo "feat: add new feature" | npx commitlintWhen installed in a project, it sets up Husky hooks to automatically validate commit messages.
Create a commitlint.config.js file in your project root:
module.exports = {
extends: ['@commitlint/config-conventional'],
rules: {
'type-enum': [2, 'always', [
'feat', 'fix', 'docs', 'chore', 'style', 'refactor', 'test'
]]
}
};✅ Valid:
- feat: add user authentication
- fix: resolve login timeout issue
- docs: update API documentation
❌ Invalid:
- added new stuff (missing type)
- fix: (missing description)
- FEAT: add feature (uppercase type)
# Add a test script to package.json
npm pkg set scripts.test="echo 'No tests'"
# Or skip hooks temporarily
git commit --no-verifynpm install --save-dev @commitlint/cli @commitlint/config-conventionalContributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'feat: add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
MIT © Hamza Rafique