Languages: English | Português 🇧🇷 | Español
Conventional Commits validator with a friendly CLI, Git hooks, and an internal rule engine — zero runtime dependencies.
- Zero runtime dependencies; lightweight and fast.
- Friendly CLI with interactive commit flow.
- Git hooks install/uninstall with versioned hooks path (
.commitzero/hooks). - Internal rules engine enforcing Conventional Commits.
- Internationalization:
en,pt-BR,es. - Pre-commit commands runner and management.
- Local project (dev dependency):
npm i -D @codemastersolutions/commitzero
# or
pnpm add -D @codemastersolutions/commitzero
# or
yarn add -D @codemastersolutions/commitzero- One-off run (no install):
npx commitzero --help- Initialize configuration:
commitzero init - Install versioned hooks:
commitzero install-hooks - Make an interactive commit:
commitzero commit- Auto stage:
commitzero commit -a - Push after commit:
commitzero commit -p(disable progress with--progress-off) - Use main buffer instead of alternate screen:
commitzero commit --no-alt-screen
- Auto stage:
- Help:
commitzero --help - Initialize config:
commitzero init - Lint a message:
- From file:
commitzero lint --file tmp/commit.txt - From argument:
commitzero lint -m "feat(core): add x"
- From file:
- Validate current commit (hook):
commitzero check - Hooks:
commitzero install-hooks/commitzero uninstall-hooks- Options:
--force: Override existing hooks path configuration--init-git: Initialize git repository if not already initialized
- Options:
- Pre-commit commands management:
- Add:
commitzero pre-commit add "npm run lint" - Remove:
commitzero pre-commit remove "npm run lint"
- Add:
- Interactive commit:
commitzero commit- Auto stage changes:
commitzero commit -aorcommitzero commit --add - Commit and push:
commitzero commit -porcommitzero commit --push - Disable push progress animation:
commitzero commit --progress-off - Disable alternate screen (use main buffer):
commitzero commit --no-alt-screen
- Auto stage changes:
- Navigate with
↑/↓orj/k(wrap-around). - Confirm with
Enter. Cancel withCtrl+C. - Uses the terminal’s alternate screen by default for stable pagination.
- Opt-out via
--no-alt-screenor setuiAltScreen: falsein config.
If command commitzero return not found, use a package manager to run it. This is because it is a development dependency and some package managers do not install the executable globally.
# npm
npm run commitzero --help
# or
# pnpm
pnpm commitzero --help
# or
# yarn
yarn commitzero --help- The hooks must be runnable in Git Bash.
- Pre-commit commands must be runnable in Git Bash.
git initThe hooks are automatically installed in .commitzero/hooks directory and Git is configured to use this path. This ensures hooks are version controlled.
commitzero install-hooks
# or
npm run commitzero install-hooks
# or
pnpm commitzero install-hooks
# or
yarn commitzero install-hooksOptions:
--force: Override existing hooks path configuration without confirmation--init-git: Initialize git repository if not already initialized
Interactive prompts:
- If Git is not initialized, you'll be prompted to initialize it
- If a different hooks path is already configured, you'll be asked to confirm overriding it
ls -l .commitzero/hooks/commit-msg
# Should be executable and include the CommitZero-managed block- Prefer
--filefor messages with body/footers:
printf "feat(core): change\n\nBody text\n\nRefs: 123" > tmp/commit.txt
commitzero lint --file tmp/commit.txt
# or
npm run commitzero lint --file tmp/commit.txt
# or
pnpm commitzero lint --file tmp/commit.txt
# or
yarn commitzero lint --file tmp/commit.txt- Alternative with
$'...'to expand\nin the shell:
commitzero lint -m $'feat(core): change\n\nBody text\n\nRefs: 123'
# or
npm run commitzero lint -m $'feat(core): change\n\nBody text\n\nRefs: 123'
# or
pnpm commitzero lint -m $'feat(core): change\n\nBody text\n\nRefs: 123'
# or
yarn commitzero lint -m $'feat(core): change\n\nBody text\n\nRefs: 123'typemust be valid and lowercase.scopeoptional; when present, must be lowercase and onlya-z,0-9,-, space.subjectmust not end with.and respects a configurable limit.- Blank line required between header and body (if body present).
- Blank line required before footers (if footers present).
feat!/breaking requiresBREAKING CHANGE: ...footer.
commitzero.config.json|js(optional):- Defines rules, language, hooks, and pre-commit commands used by the CLI.
{
"types": [
"feat",
"fix",
"docs",
"style",
"refactor",
"perf",
"test",
"build",
"ci",
"chore",
"revert"
],
"scopes": [],
"requireScope": false,
"maxSubjectLength": 72,
"allowBreaking": true,
"footerKeywords": ["BREAKING CHANGE", "Closes", "Refs"],
"preCommitCommands": [],
"language": "en",
"uiAltScreen": true
}types: Allowed commit types following Conventional Commits.scopes: Allowed scopes. Empty array means any lowercase scope is accepted.requireScope: Whentrue, a scope must be provided.maxSubjectLength: Maximum characters allowed in the commit subject.allowBreaking: Whenfalse, disallowsfeat!and requiresBREAKING CHANGEfooter when breaking changes are present.footerKeywords: Keywords recognized as commit footers (e.g., references, breaking changes).preCommitCommands: Array of shell commands to run before committing.language: CLI and rules output language. Accepted values:en,pt,es. Default:en.uiAltScreen: Whentrue, interactive prompts render in the terminal's alternate screen for stable display. Disable with--no-alt-screenor set tofalse.
COMMITZERO_LANG: Override language (en,pt,es).NO_ALT_SCREEN=1: Disable alternate screen for interactive prompts.
- Respects Git
core.hooksPathif configured. - Defaults to
.git/hookswhencore.hooksPathis not set. commitzero install-hooksconfigurescore.hooksPathto.commitzero/hooksso hooks are version controlled in the repo.
- Add a command:
commitzero pre-commit add "npm run lint"
# or
npm run commitzero pre-commit add "npm run lint"
# or
pnpm commitzero pre-commit add "npm run lint"
# or
yarn commitzero pre-commit add "npm run lint"- Remove a command:
commitzero pre-commit remove "npm run lint"
# or
npm run commitzero pre-commit remove "npm run lint"
# or
pnpm commitzero pre-commit remove "npm run lint"
# or
yarn commitzero pre-commit remove "npm run lint"Tip: keep preCommitCommands as an empty array if you don't need pre-commit checks.
- Node >= 16 (CLI/tests prefer Node >= 18).
- Keep all language READMEs in sync:
- Source:
README.md(English) - Mirrors:
README.pt-BR.md,README.es.md
- Source:
- When updating docs, edit English first and replicate the change:
- Apply the same structure, headings, and examples.
- Keep the language switcher links at the top accurate.
- Prefer small iterative changes to ease translation review.
- Language links present and correct at the top.
- Command examples run as written: paths, quotes,
$'...'expansion, file creation, hook install. - Headings and terminology consistent across all languages.
- Changes replicated to
README.pt-BR.mdandREADME.es.md. - Run
npm run buildandnpm testif CLI examples or syntax changed. - Update integration tests when documented behavior changes.
- Node version notes remain accurate.
- On uninstall, CommitZero attempts to remove its managed block from Git hooks automatically.
- If your package manager does not run
postuninstall, remove lines between# CommitZero managed block STARTand# CommitZero managed block ENDin:.commitzero/hooks/commit-msgor.git/hooks/commit-msg.commitzero/hooks/prepare-commit-msgor.git/hooks/prepare-commit-msg
- Or run manually:
commitzero cleanup
# or
npm run commitzero cleanup
# or
pnpm commitzero cleanup
# or
yarn commitzero cleanupNote: uninstall-hooks and cleanup do not remove package.json scripts. The scripts commitzero, commitzero:install, and commitzero:uninstall are preserved for convenience.
- Hooks print guidance messages in your language when CommitZero is missing.
- Detection order:
commitzero.config.jsonlanguageCOMMITZERO_LANGenvironment variable (en,pt,es)- OS locale (
LANG), mappingpt_BR*→pt,es_*→es, others →en.
- Example override per repo:
export COMMITZERO_LANG=es