shtukbasehub

Standard: Conventional Commits

Conventional Commits 1.0.0: commit messages in the form "type(scope)!: description"; three norms, a check of the last commits or a range, and a commit-msg hook that the owner installs themselves.

Packagestd-conventional-commitsv0.1.015 files

Standard: Conventional Commits

What the standard is. Conventional Commits 1.0.0 is a convention for commit messages. The text: https://www.conventionalcommits.org/en/v1.0.0/. The first line of a commit is type(scope)!: description. The type feat is a new feature, fix is a bug fix; the project chooses other types itself. ! or a BREAKING CHANGE: footer means a breaking change. From such messages a machine builds a changelog and picks the next version (the std-keep-a-changelog and std-semver packages).

When to install. The project lives in git, and you want a readable history, a changelog built from commits, or versions by SemVer. If agents write the commits, the standard is especially cheap: an agent follows the form without effort.

How to configure. The page /norms/standards/conventional-commits.md: the list of types (types), the list of scopes (scopes, empty means any), from which day to judge commits (since, by default the install day: old history is not judged), how many of the latest commits to look at (last), a range (range, for example origin/main..HEAD), which headers to skip (ignore, regular expressions: merges, automatic reverts, fixup!, the first commit "Initial commit"), the header length limit (maxHeader). A one-off run with a different scope: shtuk run std-conventional-commits header --range a..b (also --last N, --since DATE, --all).

Hook. shtuk run std-conventional-commits install-hook installs the commit-msg hook in the repository's hooks folder. The package does not install it by itself: the hook changes how the owner commits, so the owner decides. Someone else's hook is not overwritten. To remove it: uninstall-hook. The hook does not let a commit through if a norm in enforce mode is broken; for the others it writes a warning. Without Bun the hook silently skips.

What is checked

  • CC-R01 (MUST, enforce): the header in the form: a type from the list, a non-empty scope (and from the list, if there is one), : and a description. The header check.
  • CC-R02 (MUST, enforce): the body and footers are separated from the header by a blank line; BREAKING CHANGE (or BREAKING-CHANGE) in capitals, followed by a colon, a space and a description. The body check.
  • CC-R03 (SHOULD, observe): the header is no longer than maxHeader (100) and the description has no period at the end. This is commitlint practice, not the text of the standard; so it only observes. The short check.

Merge commits are not checked (--no-merges). A project inside a large repository sees only the commits that touch its folder. If it is not a git repository, there is nothing to check, and the norms hold.

What is not checked

  • Whether the type is chosen right: fix instead of feat, a breaking change without !. That is meaning, and a reviewer sees it.
  • Footers other than BREAKING CHANGE: the standard describes the git trailer format loosely, and a footer cannot be reliably told from a paragraph of the body.
  • Commits before the since day and commits that are not in the chosen scope.

The package only reads git (git log). Only install-hook writes, and only into the hooks folder.