Set up commitlint for commit message standards
✓Works with OpenClaudeYou are a DevOps/Git workflow specialist. The user wants to set up commitlint to enforce standardized commit messages across their Git repository.
What to check first
- Run
git --versionto confirm Git is installed - Check if
package.jsonexists in your project root (commitlint requires Node.js/npm) - Run
npm list huskyto see if husky is already installed (commonly used alongside commitlint)
Steps
- Install commitlint core and the conventional config:
npm install --save-dev @commitlint/config-conventional @commitlint/cli - Create a
commitlint.config.jsfile in your project root with the conventional config - Install husky to run commitlint as a Git hook:
npm install --save-dev husky - Initialize husky in your project:
npx husky install - Add a commit-msg hook that runs commitlint:
npx husky add .husky/commit-msg 'npx --no -- commitlint --edit "$1"' - Test the setup by making a commit with an invalid message like
git commit -m "bad message"(should be rejected) - Make a valid commit using conventional format:
git commit -m "feat: add new feature" - Verify the commit went through and check
.husky/commit-msgwas created with the hook script
Code
// commitlint.config.js
module.exports = {
extends: ['@commitlint/config-conventional'],
rules: {
'type-enum': [
2,
'always',
[
'feat',
'fix',
'docs',
'style',
'refactor',
'perf',
'test',
'chore',
'ci',
'revert'
]
],
'type-case': [2, 'always', 'lower-case'],
'type-empty': [2, 'never'],
'scope-empty': [2, 'never'],
'subject-empty': [2, 'never'],
'subject-full-stop': [2, 'never', '.'],
'subject-case': [2, 'never', 'upper-case'],
'header-max-length': [2, 'always', 72]
}
};
Pitfalls
- Husky install fails silently in CI/CD: Add
husky installto yourpackage.jsonpostinstallscript, or the.huskydirectory won't exist in CI environments when dependencies are installed - Hook permissions on Linux/Mac: Ensure
.husky/commit-msgis executable; runchmod +x .husky/commit-msgif commits are rejected with "permission denied" - Scope is required by default: The conventional config requires a scope (e.g., `feat(
Common Pitfalls
- Treating this skill as a one-shot solution — most workflows need iteration and verification
- Skipping the verification steps — you don't know it worked until you measure
- Applying this skill without understanding the underlying problem — read the related docs first
When NOT to Use This Skill
- When a simpler manual approach would take less than 10 minutes
- On critical production systems without testing in staging first
- When you don't have permission or authorization to make these changes
How to Verify It Worked
- Run the verification steps documented above
- Compare the output against your expected baseline
- Check logs for any warnings or errors — silent failures are the worst kind
Production Considerations
- Test in staging before deploying to production
- Have a rollback plan — every change should be reversible
- Monitor the affected systems for at least 24 hours after the change
Related Workflow Automation Skills
Other Claude Code skills in the same category — free to download.
Git Workflow
Set up Git branching workflow (GitFlow, trunk-based)
Pre-Commit Hooks
Configure pre-commit hooks (Husky, lint-staged)
Auto Formatter
Set up auto-formatting (Prettier, ESLint)
Issue Template
Create GitHub issue and PR templates
Dependabot Setup
Configure Dependabot/Renovate for auto-updates
Release Workflow
Automate release workflow with changelogs
Code Owner Setup
Configure CODEOWNERS file
Branch Protection
Set up branch protection rules
Want a Workflow Automation skill personalized to YOUR project?
This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.