-
Notifications
You must be signed in to change notification settings - Fork 109
chore: document the comment and commit message rules #2706
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,16 +13,48 @@ type(scope): imperative subject | |
|
|
||
| BREAKING CHANGE: <only if applicable> | ||
|
|
||
| 🤖 Generated with [Claude Code](https://claude.com/claude-code) | ||
|
|
||
| Co-Authored-By: Claude <noreply@anthropic.com> | ||
| ``` | ||
|
|
||
| - **type**: one of `feat`, `fix`, `docs`, `style`, `refactor`, `perf`, `test`, `build`, `ci`, `chore`, `revert`. `commitlint.config.js` extends [`@commitlint/config-conventional`](https://www.npmjs.com/package/@commitlint/config-conventional), which defines the allowed set — pick the type that genuinely matches the change (`feat`/`fix` only for actual features/bug fixes). | ||
| - **scope**: full package name (`ui-button`, `ui-select`). Comma-separate for a few, use `many` for several, omit for repo-wide. | ||
| - **subject**: imperative ("add loading state", not "added"). Must start with a lowercase letter (commitlint's `subject-case` rejects sentence/Start/PascalCase). No trailing period. | ||
| - **Body lines: hard-wrap at 100 characters.** Commitlint (`body-max-line-length: 100`) runs in CI and will reject longer lines. The footer lines (Claude Code attribution, Co-Authored-By) are exempt. | ||
| - **subject**: imperative ("add loading state", not "added"). Must start with a lowercase letter (commitlint's `subject-case` rejects sentence/Start/PascalCase). No trailing period. **Hard limit 100 characters** (`subject-max-length`), but aim for ~70: the median subject in this repo is 50. If you're pushing the limit, you're listing everything the change touches instead of naming the change. | ||
| - **Breaking changes**: add a `BREAKING CHANGE:` line in the body describing what breaks. See CLAUDE.md for what counts as breaking. | ||
| - **Attribution**: no `🤖 Generated with` line in commit messages — that belongs in PR bodies (`/pr` handles it). | ||
|
|
||
| ### Body | ||
|
|
||
| **Omit the body when the subject says it all.** When you do write one, it explains **why** — the constraint, the cause, the thing the diff cannot show. Never restate what changed. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure that any model is smart enough to understand the first sentence, how do they interpret "the subject says it all"? I think this is too abstract. I would add two real life examples that help Claude's pattern recognition:
Claude derives patterns from examples easier than from general statements.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added some examples |
||
|
|
||
| ``` | ||
| ✅ the subject says it all — no body | ||
| docs(ui-table): fix the caption prop description | ||
|
|
||
| ✅ the subject can't carry the reason — the body explains why | ||
| fix(ui-link): derive the icon layout from props instead of makeStyles | ||
|
|
||
| The flex layout for icons was only applied after mount, so the server markup | ||
| differed from the mounted one and the page jumped during hydration. | ||
| ``` | ||
|
|
||
| - **Hard-wrap at 100 characters** (`body-max-line-length`). Trailers are exempt. | ||
| - **Never turn the body into a changelog.** No grouping headings (`Configuration:`, `Build Tooling:`), no numbered sections, no bullet list of the files you touched — the diff already lists them. | ||
| - Naming a specific file is fine when the file _is_ the point. | ||
|
|
||
| ``` | ||
| ❌ a changelog of the diff | ||
| Configuration: | ||
| - Add pnpm-workspace.yaml | ||
| - Add .npmrc with hoisted node linker | ||
| Build Tooling: | ||
| - Update scripts/bootstrap.js | ||
|
|
||
| ✅ the reason the diff cannot show | ||
| regression-test stays on npm so it keeps installing @instructure/ui | ||
| the way an external consumer would. | ||
| ``` | ||
|
|
||
| Writing about _before_ and _after_ is encouraged — "Previously the placeholder only showed on hover" is exactly right in a commit message, which is permanently anchored to its own diff. | ||
|
|
||
| ## Steps | ||
|
|
||
|
|
@@ -31,7 +63,7 @@ Co-Authored-By: Claude <noreply@anthropic.com> | |
| - If you're on a feature branch, glance at its name. If it looks **unrelated** to the change you're about to commit, flag it and offer to branch off (so you don't pile an unrelated commit onto someone else's WIP); otherwise proceed. | ||
| 2. Stage the files that belong in this commit — be specific, don't `git add -A`. | ||
| 3. Propose a type(scope) and subject based on the diff, then **ask the user to confirm or override the commit type** before writing the message — don't assume `fix`/`feat` silently; **`feat`/`fix` types are used for non-test/tooling code in our public packages.** | ||
| 4. Commit normally — let the git hooks run. The interactive Commitizen prompt is **no longer** a hook (it now lives behind `pnpm run commit` for humans), so a non-interactive `-m` commit works while `pre-commit` (lint-staged + TS references check) and `commit-msg` (commitlint) still fire: | ||
| 4. Commit normally — let the git hooks run. Commitizen's interactive prompt is not a hook; it lives behind `pnpm run commit` for humans. A non-interactive `-m` commit therefore works, while `pre-commit` (lint-staged + TS references check) and `commit-msg` (commitlint) still fire: | ||
|
|
||
| ```bash | ||
| git commit -m "$(cat <<'EOF' | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the PR description you claim drop the robot attribution line from commit messages.
I may consider removing the Co-Authored-By line too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i wanted to keep it for transparancy's sake, we can discuss later if we want to get rid of it completely