Inputs
--message, --edit (the commit-msg hook file), --file, --stdin, or a git range --from/--to. Merge, revert and release commits are skipped. An all-zero --from (a new branch push) lints just the head commit.
GitHub Packages · MIT · Node ≥ 18
A lightweight Conventional Commits linter for git hooks and CI, with clear fix-up suggestions.
Lightweight Conventional Commits linter for git hooks and CI: lints a message, a file, stdin or a commit range, explains every problem and suggests a corrected header. Configurable types/scopes, sign-off and issue rules, hook installer. Text/JSON/SARIF/Markdown, allowlist with expiry, GitHub Action. Zero deps.
1 Point the @mrlouiswright scope at GitHub Packages in .npmrc
@mrlouiswright:registry=https://npm.pkg.github.com2 Install
npm i -D @mrlouiswright/commit-gaugePublished to GitHub Packages, not npmjs.com. GitHub Packages needs a GitHub token with read:packages to install, even for public packages: add //npm.pkg.github.com/:_authToken=${GITHUB_TOKEN} to .npmrc or run npm login --registry=https://npm.pkg.github.com.
$ npx commit-gauge -m "feature(API): Added new endpoint."commit-gauge — commit message1 commit(s) linted, 1 with problems HIGH type "feature" is not one of: feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert [type-unknown] ↳ fix: Use "feat". Suggested header: "feat(api): add new endpoint"LOW scope "API" should be lowercase [scope-case] ↳ fix: Use "api".LOW subject ends with a full stop [subject-full-stop] ↳ fix: Remove the trailing ".".LOW subject starts with an uppercase letter ("Added") [subject-case] ↳ fix: Use "added". 1 high, 3 low, 1 info✖ Failing (fail-on: high).
commit-gauge checks commit messages against Conventional Commits. It tells you what's wrong and also what to write instead. “Fixed the Login bug.” gets the suggestion “fix: fix the Login bug”, and “feature(API): Added new endpoint.” gets “feat(api): add new endpoint”. Use it as a commit-msg hook, on a single message, or on every commit in a pull request.
CLI, library and GitHub Action. Node.js 18+, zero runtime dependencies (commitlint needs dozens). By Louis Wright.
--message, --edit (the commit-msg hook file), --file, --stdin, or a git range --from/--to. Merge, revert and release commits are skipped. An all-zero --from (a new branch push) lints just the head commit.
format, allowed types (with the closest match: feature → feat, bugfix → fix), lowercase type and scope, empty and allowed scopes, empty subject, trailing full stop, sentence case, imperative mood (added → add), and max length.
blank lines before body and footer, BREAKING CHANGE: spelling, line length (URLs exempt), optional Signed-off-by and issue-reference requirements.
fixup!/squash!/amend! and WIP commits are caught before merge.
commit-gauge --install-hook writes .husky/commit-msg if Husky is set up, otherwise .git/hooks/commit-msg.
text, JSON, SARIF 2.1.0 and Markdown; --fail-on; exit codes 0/1/2; allowlist entries with expiry dates.
# lint every commit message locally
npx commit-gauge --install-hook# Example
npx commit-gauge -m "feature(API): Added new endpoint."# every commit on this branch
npx commit-gauge --from origin/main --to HEAD# Example
git log -1 --format=%B | npx commit-gauge --stdinpermissions:
contents: read
security-events: write # only needed for the SARIF upload
jobs:
commit-gauge:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with: { persist-credentials: false, fetch-depth: 0 }
- uses: MrLouisWright/commit-gauge@v1
with:
fail-on: high
sarif: commit-gauge.sarif
- uses: github/codeql-action/upload-sarif@v3
if: always()
with: { sarif_file: commit-gauge.sarif }
| Flag | Description |
|---|---|
-m, --message <msg> | Lint this message |
-e, --edit [file] | Lint the commit-msg hook file (default: .git/COMMIT_EDITMSG) |
--file <file> | Lint a message stored in a file |
--stdin | Read the message from stdin |
--from <ref> | Lint every commit in <from>..<to> (all-zero SHA = only <to>) |
--to <ref> | End of the range (default: HEAD) |
| Rules | |
--types <list> | Allowed types (default: feat,fix,docs,style,refactor,perf,test,build,ci,chore,revert) |
--scopes <list> | Allowed scopes (default: any) |
--require-scope | A scope is mandatory |
--max-length <n> | Header max length (default: 100) |
--require-signoff | Require a Signed-off-by trailer |
--issue-pattern <re> | Require an issue reference matching this regex |
--no-merges-ignored | Also lint merge commits |
| Hooks | |
--install-hook | Write a commit-msg hook (.husky/commit-msg if husky is set up, else .git/hooks) |
| Common | |
-c, --config <file> | JSON config (default: .commit-gauge.json or "commitGauge" in package.json) |
-f, --format <fmt> | text (default) | json | sarif | markdown |
--json <file> | Also write a JSON report |
--sarif <file> | Also write SARIF 2.1.0 |
--markdown <file> | Also write Markdown (e.g. for a job summary) |
--fail-on <sev> | critical | high | medium | low | info | none (default: high) |
--list-rules | Print rules and default severities |
--no-fixes | Hide fix suggestions in text output |
--no-color | Disable colours |
Full reference, config file format and API in the README.
Support this project
I build free, open-source tools that help developers ship safer websites. Every coffee helps keep them maintained, documented and free for everyone.
Buy me a coffee (opens Stripe in a new tab)Secure checkout by Stripe