Check git commit messages against a few simple rules, in a commit-msg hook and in CI. Zero dependencies.
- Catches AI tool attribution.
Co-Authored-Bytrailers naming Claude, Copilot, Cursor, Codex and other AI tools,Generated with ...lines, and the robot emoji fail by default. - Small, explicit rules. Subject length, line count, banned trailers, emoji, em dashes and your own regexes. Nothing else.
- Checks a whole branch.
commitcheckchecks every commit on your branch that is not on its upstream, or any range you pass. Merge commits are skipped. - Works as a hook.
commitcheck installwrites acommit-msghook that rejects a bad message before the commit is made.
- Node.js 20 or newer
- git
npx @virling/commitcheck # check commits in @{upstream}..HEAD npx @virling/commitcheck origin/main..HEAD # check a range npx @virling/commitcheck --file .git/COMMIT_EDITMSG npx @virling/commitcheck install # write .git/hooks/commit-msg
| Flag | Meaning |
|---|---|
--file <path> |
Check one message file instead of a range. Lines starting with # and everything below git's scissors line (# ---- >8 ----) are ignored, as git does. |
--json |
Machine-readable output. |
--help |
Print usage. |
Each failing commit is printed as <short sha> <subject> followed by its failures:
3f2a9c1 Add the export button
Co-Authored-By trailer is not allowed: Co-Authored-By: Claude <[email protected]>
AI co-author: Co-Authored-By: Claude <[email protected]>
4 commits checked in origin/main..HEAD, 1 failed
It exits 1 if any message fails or git or the config gives an error, and 2 for an unknown flag or too many arguments. With no range and no upstream on the current branch, it asks you to pass one, such as origin/main..HEAD.
Rules come from .commitcheck.json in the repo root, or the "commitcheck" key in package.json when there is no .commitcheck.json. They are merged over the defaults. An unknown key or a wrong type is an error.
| Rule | Default | Fails when |
|---|---|---|
maxSubject |
72 |
the first line is longer than this many characters |
maxLines |
null |
the message has more than this many non-empty lines (null means no limit) |
noTrailers |
[] |
a line is a trailer with one of these keys, for example ["Co-Authored-By"] (case does not matter) |
noAttribution |
true |
a Co-Authored-By trailer names an AI tool, a line starts with Generated with or Generated by, or the message has the robot emoji (U+1F916) |
noEmoji |
false |
the message has any emoji |
noEmDash |
false |
the message has an em dash (U+2014) |
bannedPatterns |
[] |
the message matches one of these regexes (case-sensitive; ^ and $ match at each line) |
noAttribution looks for these names in the Co-Authored-By name or email, as whole words, ignoring case: Claude, Anthropic, Copilot (and GitHub Copilot), Cursor, Codex, OpenAI, ChatGPT, Gemini, Devin, Aider, Windsurf. Co-authors who are people still pass unless you also ban the trailer with noTrailers.
Example .commitcheck.json for short, plain commits: at most 2 lines, a subject under 60 characters, no co-author trailers, no attribution, no emoji, no em dashes, and no conventional-commit prefixes:
{
"maxSubject": 59,
"maxLines": 2,
"noTrailers": ["Co-Authored-By"],
"noAttribution": true,
"noEmoji": true,
"noEmDash": true,
"bannedPatterns": ["^(feat|fix|chore|docs|refactor|test|ci|build|perf|style)(\\(.+\\))?!?: "]
}Leave out bannedPatterns if your repo uses conventional commits. Imperative mood is not checked; no simple rule gets it right.
commitcheck install writes .git/hooks/commit-msg:
#!/bin/sh # written by commitcheck install exec npx --no-install @virling/commitcheck --file "$1"
npx --no-install uses the copy in the project's node_modules (add it with npm install -D @virling/commitcheck) or one npx already has cached, and never downloads. Running install again rewrites a hook it wrote, but it refuses to replace any other commit-msg hook and prints the line to add to it instead.
If git config core.hooksPath is set, git ignores .git/hooks, so install writes nothing, prints the line to add to the commit-msg hook in that folder, and exits 1:
npx --no-install @virling/commitcheck --file "$1" || exit 1
Check every commit in a pull request:
name: commitcheck on: pull_request permissions: contents: read jobs: commitcheck: runs-on: ubuntu-latest steps: - uses: actions/checkout@v7 with: fetch-depth: 0 - uses: actions/setup-node@v7 with: node-version: 24 - run: npx @virling/commitcheck "origin/$BASE_REF..HEAD" env: BASE_REF: ${{ github.base_ref }}
fetch-depth: 0 fetches the base branch so the range resolves. The base ref goes through env: so a branch name is never pasted into the shell script.
commitlint does much more: plugins, shareable configs and a full Conventional Commits parser. commitcheck has a handful of fixed rules, no dependencies, and catches AI tool attribution out of the box. If you want Conventional Commits enforced, use commitlint; if you want short, plain messages without AI trailers, this is less to set up.
- agentmem: project memory for AI coding agents, shared across Claude Code, Cursor, Codex and other MCP clients.
- ccdoctor: checks your Claude Code setup: hooks, MCP servers and plugins that are registered but not working.
- ciwhy: finds the real error in a failed GitHub Actions run and tells you if it is flaky.
- npmship: releases an npm package and verifies it landed on npm, in CI and on GitHub.
- subagents: reviews what Claude Code subagents did in a session and flags repeated or wasted work.