A lightweight CLI tool for generating, linting, and creating commits with enforced formatting. Perfect for teams that want consistent commit messages with JIRA integration.
| Metric | Value |
|---|---|
| Package Size | ~16KB (minified single file) |
| Node.js | >=14.0.0 |
| License | MIT |
| Main File | dist/cli.js |
- π― Generate commit messages with proper formatting
- β Lint commit messages to ensure they follow the format
- π Interactive commit flow with prompts for missing information
- π¨ Category selection with beautiful interactive menu
- π JIRA integration with automatic validation
- π Conventional commit format support
npm install -g commit-forgenpm install --save-dev commit-forgecommit-forge generate --jira TB-123 --category feat --message "add login" --description "Implement login flow"# From a file
commit-forge lint .git/COMMIT_EDITMSG
# From stdin
echo "[TB-123] β¨ feat: add feature" | commit-forge lintcommit-forge commitThis will:
- Check for staged files
- Prompt for missing information (JIRA ID, category, message, description)
- Show an interactive category selector
- Create the commit with the formatted message
commit-forge commit --jira TB-123 --category feat --message "add login" --description "Implement login flow"If you have commit-forge installed locally in your project, you can add a commit script to your package.json:
{
"scripts": {
"commit": "commit-forge commit"
}
}Then use it with:
npm run commit
# or with bun
bun run commitThis will run the interactive commit flow, checking for staged files and prompting for commit details.
Note: The commit script is also available in this package itself. You can use npm run commit or bun run commit in this repository to test the tool.
generate- Format and print a commit messagelint- Validate a commit message file or stdin inputcommit- Prompt for details, ensure staged files, and run git commit
--jira, -j- JIRA issue id (e.g., TB-123)--category, -c- Category keyword (feat, fix, docs, style, refactor, perf, test, chore)--message, -m- Short subject line (<= 72 chars)--description, -d- Longer description (use \n for newlines)--file, -f- Commit message file path (lint command)--json- Output lint result as JSON--output, -o- File path to write generated message--help, -h- Show help
- β¨
feat- New feature - π
fix- Bug fix - π
docs- Documentation change - π¨
style- Code style / formatting - β»οΈ
refactor- Refactoring - β‘
perf- Performance improvement - β
test- Tests - π§Ή
chore- Chores & maintenance
Commit messages follow this format:
[TB-123] β¨ feat: add feature
Optional longer description here
You can customize commit-forge behavior by creating a configuration file in your project root. The tool will automatically look for configuration files in the following order:
.commit-forge.jsoncommit-forge.config.json.commit-forge.tscommit-forge.config.ts.commit-forge.jscommit-forge.config.js
Create a .commit-forge.json file in your project root:
{
"jira": {
"enabled": true,
"required": true,
"allowNoJira": true
},
"emoji": {
"enabled": true
},
"subject": {
"maxLength": 72
},
"description": {
"required": false
}
}jira.enabled(boolean, default:true) - Enable/disable JIRA ID supportjira.required(boolean, default:true) - Require JIRA ID in commitsjira.allowNoJira(boolean, default:true) - Allow "NO-JIRA" as a valid value
Example: Disable JIRA completely
{
"jira": {
"enabled": false
}
}Example: Make JIRA optional (not required)
{
"jira": {
"enabled": true,
"required": false,
"allowNoJira": true
}
}emoji.enabled(boolean, default:true) - Show emojis in category formatting
Example: Disable emojis
{
"emoji": {
"enabled": false
}
}subject.maxLength(number, default:72) - Maximum length for commit message subject line
Example: Change max length to 100 characters
{
"subject": {
"maxLength": 100
}
}description.required(boolean, default:false) - Require description in commits
Example: Require description
{
"description": {
"required": true
}
}You can also use a JavaScript file for more dynamic configuration:
// commit-forge.config.js
module.exports = {
jira: {
enabled: process.env.USE_JIRA !== "false",
required: true,
allowNoJira: true,
},
emoji: {
enabled: true,
},
subject: {
maxLength: 72,
},
description: {
required: false,
},
};TypeScript configuration files are also supported! You'll need one of these packages installed:
ts-node(recommended)tsxesbuild-register
// commit-forge.config.ts
import type { CommitForgeConfig } from "commit-forge";
const config: CommitForgeConfig = {
jira: {
enabled: process.env.USE_JIRA !== "false",
required: true,
allowNoJira: true,
},
emoji: {
enabled: true,
},
subject: {
maxLength: 72,
},
description: {
required: false,
},
};
export default config;Or using CommonJS syntax:
// commit-forge.config.ts
module.exports = {
jira: {
enabled: process.env.USE_JIRA !== "false",
required: true,
allowNoJira: true,
},
emoji: {
enabled: true,
},
subject: {
maxLength: 72,
},
description: {
required: false,
},
};You can use this tool as a git commit-msg hook to automatically validate commit messages:
# Create the hook
echo '#!/bin/sh
commit-forge lint "$1"' > .git/hooks/commit-msg
# Make it executable
chmod +x .git/hooks/commit-msgMIT
- Ayaan Raza - Creator
- Sawan Kumar - Collaborator