Git commit quality CLI for pre-commit hooks, commit-msg validation, staged-file checks, and Husky workflows.
commitiq-engine (cq) is a diff-aware Git commit quality CLI for pre-commit hooks, commit-msg validation, staged-file checks, and Husky git-hook workflows. It automates linting, formatting, quality checks, commit suggestions, and CI-friendly analysis so each staged change lands cleaner.
- Zero Configuration: Auto-detects your package manager (
npm,pnpm,yarn,bun) and common quality scripts. - Git Hooks Ready: Works with Husky pre-commit and commit-msg hooks out of the box.
- Smart Dependency Suggestions: If
eslintorprettierare missing, the tool generates a report with the exact commands needed to install them. - Flexible Commit Validation: Supports both Conventional Commits and Gitmoji (emoji-shortcodes like
:art:) to keep your history clean. - Secret Scanner: Detects API keys, tokens, passwords before they get committed.
- Debug Artifact Scanner: Catches
console.loganddebuggerin staged script files. - Dependencies Vulnerabilities: Runs
npm auditto check for vulnerabilities. - Package Validation: Runs
npm pack --dry-runin full mode to catch packaging issues early. - Diff-aware Risk Signals: Detects removed tests from staged diff content, not only file names.
- Fast Performance: Optimized for staged files to keep your development loop quick.
- Quality Reports: Generates a detailed
quality-report.mdupon failure, explaining exactly what went wrong and how to fix it. - Two Profiles:
fast(default) for staged checks + unit tests,fulladds build, package validation, and Playwright e2e.
Install the tool and enable the hook:
npm install --save-dev commitiq-engine husky
npx cq enableOr with pnpm:
pnpm add -D commitiq-engine husky
pnpm exec cq enableRun npx cq to show interactive menu (arrow keys + enter):
━━━ COMMITIQ ENGINE ━━━
▶ Toggle hook ON
Toggle auto-push OFF
Configure checks
Run single check
Status
Suggest commit
Commit
Staged check
Full check
Quit
↑↓ Select ENTER Confirm Q Quit
Or use direct commands:
| Command | Alias | Description |
|---|---|---|
npx cq |
- | Interactive menu |
npx cq toggle |
t |
Toggle pre-commit and commit-msg hooks |
npx cq auto-push |
p |
Toggle optional post-commit auto-push |
npx cq config |
g |
Open the checker toggle menu |
npx cq single |
r |
Pick and run one checker |
npx cq enable |
e |
Enable auto-check |
npx cq disable |
d |
Disable auto-check |
npx cq status |
s |
Show status |
npx cq suggest |
u |
Show suggested commit header from staged changes |
npx cq json |
j |
Print staged analysis, score, and suggestion as JSON |
npx cq json-check [--full] |
- | Run fast or full checks and print JSON payload with checker results, duration, and optional report path for CI |
npx cq commit |
- | Create git commit from suggested header; in TTY you can accept or edit message |
npx cq staged |
f |
Fast check (staged) |
npx cq check |
c |
Full check + e2e |
npx cq commit-msg <file> |
- | Validate commit message hook file |
After enabling, pre-commit runs staged checks and commit-msg validates commit messages automatically on every git commit. To bypass (if needed):
git commit --no-verify -m "feat: ..."npx cq status shows BROKEN when CQ finds hook files, but the Git hook setup is incomplete or not managed by CQ.
CQ expects all of these to be true:
.husky/pre-commitcontainsnpm exec -- cq staged.husky/commit-msgcontainsnpm exec -- cq commit-msg "$1"git config core.hooksPathpoints to managed Husky hooks path such as.huskyor.husky/_
Common causes:
- hooks were created by an older hook setup version
.husky/pre-commitor.husky/commit-msgwas edited manually- Husky exists, but Git still points to another hooks directory
- only one of the two CQ hooks exists
- another tool owns the same hook file
Check the setup:
npx cq status
git config --get core.hooksPath
cat .husky/pre-commit
cat .husky/commit-msgRepair the CQ hooks:
npx cq enableIf you intentionally use custom hooks, keep the CQ commands inside them instead of replacing them.
When running cq check, the tool runs these checkers:
- Linting (ESLint): Runs
eslint --fixon staged JS/TS files. - Formatting (Prettier): Runs
prettier --writeon staged files. - Secret Scanner: Scans for API keys, tokens, passwords.
- Debug Artifacts: Scans staged JS/TS files for
console.loganddebugger. - Type Check: Runs
typecheck,check-types, ortypesif present. - Dependencies Vulnerabilities: Runs
npm auditto check vulnerabilities. - Test Suite: Runs your test script (jest, vitest, etc.).
- Build (full profile only): Runs
buildorcompileif present. - NPM Pack (full profile only): Runs
npm pack --dry-run. - Playwright Tests (full profile only): Runs e2e tests.
Commit message validation runs in the commit-msg hook via npx cq commit-msg <file>.
If no custom configuration is provided, cq looks for these scripts in your package.json (in order):
linttypecheck|check-types|typestest:unit|unittest|test:cibuild|compiletest:e2e|e2e|playwright|test:playwright
You can override the auto-detection by adding a gitQuality object to your package.json:
{
"gitQuality": {
"skip": ["Secret Scanner", "Dependencies Vulnerabilities"],
"ignore": ["dist/", "src/generated/", "fixtures/example.js"],
"autoPush": false,
"risk": {
"failOn": "HIGH"
},
"staged": {
"prettier": true,
"eslint": true
}
}
}skip: An array of checker names to skip (e.g.,"Secret Scanner","Dependencies Vulnerabilities").ignore: Repo-relative files or folders to ignore during staged-file checks (e.g.,"dist/","src/generated/","fixtures/example.js","*.snap").autoPush: Whentrue, creates an optionalpost-commithook that runs full checks andgit pushafter a successful commit. Defaults tofalse.risk.failOn: Optional risk gate threshold. Use"LOW","MEDIUM", or"HIGH"to fail when computed commit risk reaches that level. Default is advisory-only.staged.prettier: Enable/disable automatic Prettier fixing on staged files.staged.eslint: Enable/disable automatic ESLint fixing on staged files.
Risk analysis is now diff-aware for test removals. Deleting test files or removing describe / it / test / expect lines from staged hunks raises commit risk even when staged file names alone would not show it.
The interactive menu can also toggle each checker on or off and save the result back into gitQuality.skip.
To ignore secrets in specific lines, add a comment:
// cq-disable secret
const mySecret = "sk-123456"; // won't trigger warningTo ignore a console.log or debugger line intentionally:
// cq-disable debug
console.log("intentional debug output");When a check fails or a dependency is missing, a quality-report.md is generated in the project root. This report includes:
- Results Table: A summary of which checks passed, failed, or were skipped.
- Diff Analysis: Staged file counts, line stats, changed areas, and removed-test signals.
- How to Fix: Step-by-step instructions for fixing failed quality checks.
- Setup Suggestions: Direct installation commands if recommended tools (like ESLint) are not found.