Husky & Conventional Commits: A Complete Team Workflow Guide
Learn how to use Husky and Conventional Commits to enforce code quality, maintain clean commit history, and improve team collaboration.
Joy Das
In modern team-based software development, maintaining code quality and a clean commit history is critical. Husky and Conventional Commits help teams automate checks, enforce standards, and keep repositories healthy. This guide explains how Husky works, how to follow commit conventions, and why these tools are essential for professional projects.
Why Husky and Commit Conventions Are Important
Without clear rules, repositories quickly become messy—inconsistent commit messages, broken code pushed accidentally, and poor collaboration. Husky solves this by running automated checks before commits, while Conventional Commits ensure a readable and structured commit history.
- Prevents committing broken or unformatted code
- Keeps commit messages consistent and meaningful
- Improves collaboration in teams
- Makes changelogs and versioning easier
- Encourages professional development practices
Quick Start
Install project dependencies:
npm install
# or
yarn
# or
pnpm installCreate a new feature branch:
git checkout -b feat/your-featureMake changes and commit them:
git add .
git commit -m "feat: add new feature"Commit Message Convention
We follow the Conventional Commits specification to maintain a clear and structured commit history.
Commit Format
<type>(<scope>): <subject>Commit Types
- feat: introducing a new feature
- fix: fixing a bug
- docs: documentation changes
- style: formatting or stylistic changes
- refactor: code restructuring without behavior change
- perf: performance improvements
- test: adding or updating tests
- chore: maintenance tasks
Good vs Bad Examples
# Good
feat: add password reset
fix(api): handle null user response
docs: update setup guide
# Bad
added stuff
WIP
Fix bug.
updated codeCommit Rules
- Use lowercase for type and subject
- Use imperative mood (add, fix, update)
- Do not end the subject with a period
- Keep subject under 50 characters
- Scope is optional but recommended
How Husky Works
Husky uses Git hooks to run scripts automatically at different stages of the Git lifecycle. These hooks run locally before code is committed or pushed.
Pre-Commit Hook
Runs automatically before each commit to ensure code quality.
- Runs ESLint (if installed)
- Runs Prettier (if installed)
- Checks only staged files for better performance
Commit Message Hook
Validates commit messages after you write them and blocks invalid formats.
If ESLint or Prettier Is Not Installed
Husky will skip these checks with a warning. You can install them later when ready.
npm install -D eslint prettierBypassing Husky Hooks
Hooks can be skipped only in emergency situations.
git commit --no-verify -m "emergency fix"Troubleshooting
- Hooks not running: run npm run prepare
- Permission issues: chmod +x .husky/*
- Lint errors: npm run lint -- --fix
- Commit rejected: check commit message format
Branch Naming Convention
- feat/feature-name for new features
- fix/bug-name for bug fixes
- docs/doc-name for documentation
- refactor/refactor-name for refactoring
Code Review Checklist
- All tests pass
- Code is properly formatted
- No lint errors
- Commit messages follow conventions
- Documentation updated if needed
Conclusion
Using Husky with Conventional Commits enforces discipline, improves code quality, and creates a professional development workflow. This setup saves time, reduces errors, and makes collaboration smoother—especially in growing teams.