GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - virling/commitcheck: Check git commit messages against simple rules, including AI tool attribution, in a commit-msg hook and in CI

BranchesTags
Open more actions menu

Latest commit

 

History

9 Commits
9 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
bin
bin
 
 
src
src
 
 
test
test
 
 
.commitcheck.json
.commitcheck.json
 
 
.gitignore
.gitignore
 
 
CHANGELOG.md
CHANGELOG.md
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
package.json
package.json
 
 

Repository files navigation

commitcheck

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-By trailers 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. commitcheck checks 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 install writes a commit-msg hook that rejects a bad message before the commit is made.

Requirements

  • Node.js 20 or newer
  • git

Usage

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

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.

The commit-msg hook

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

In CI

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.

Compared with commitlint

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.

More tools from Virling

  • 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.

License

PolyForm Noncommercial 1.0.0.

About

Check git commit messages against simple rules, including AI tool attribution, in a commit-msg hook and in CI

Resources

Readme
License
Activity
Custom properties

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.