Git Commit
Conventions for what goes into one commit and how that commit is described.
These are two concerns decided at two different moments:
- Granularity is decided while working — which changes get staged together.
- Format is decided at commit time — how the staged change is worded.
Granularity comes first. A badly scoped commit cannot be rescued by a well-written subject
line, because the subject is then forced to describe several unrelated things at once.
Choosing the format
Two message formats are in use across projects. They are **not interchangeable within a
repository** — one repository uses one format throughout its history.
Resolve which one applies, in this order.
- The project's
CLAUDE.md. A project declares its format under a
## Commit message format heading:
```markdown
## Commit message format
- Format: imperative
```
The accepted values are imperative and conventional.
- The existing history, when
CLAUDE.mddeclares nothing. Read the recent non-merge
subjects and count how many carry a type prefix:
```bash
git log --no-merges -n 30 --pretty=format:'%s'
```
If most of them begin with a lowercase word and a colon — feat: / fix: /
refactor: / docs: and the rest, optionally with a scope, as in feat(resolver): — the
project uses conventional. Otherwise it uses imperative. The types themselves are listed in
the conventional format file; read the ones named here as examples, not as the whole set.
- Default to imperative when the history is too short to judge, as in a new repository.
- Never mix the two formats within one repository. A history that is genuinely split down the
middle is a defect to raise with the user — it is not a licence to choose per commit.
- When a project's resolved format contradicts what the user asks for in the moment, follow
the user for that commit, but tell them which format the repository otherwise uses.
- Once resolved, follow the matching detail file:
The resolved format governs what to write, never how to read
A history may hold subjects in any other convention — written before the project settled on
one, or by another team, or by hand in a hurry — and those commits are still the record of what
happened. So when searching for where something changed, do not filter on the resolved format
alone.
git log --format='%h %s' <range> # no filter
git log --format='%h %s' <range> | grep -P '^\S+ [a-z-]+(\([^)]*\))?!?: ' # type prefixes
Filter the subject line, as above, rather than reaching for --grep: that searches the whole
message, so it also matches trailers such as Co-Authored-By:. And treat any subject filter as
a shortcut rather than a guarantee — read the range's subjects, or its diff, without one before
concluding that a change is not in the history.
Rules that apply to both formats
Subject line
- The subject is a single line, and carries no trailing period.
- Keep the subject below 72 characters as much as possible. This is a target, not a hard
limit — most subjects should clear it, and a minority legitimately will not.
- When a subject runs long, the usual cause is that the **commit is doing more than one
thing**. Reach for granularity.md first: splitting the
commit shortens both subjects and is the fix that actually improves the history.
- The other legitimate cause is a long but precise identifier. Here the target yields:
naming BaseRestfulApiLauncher#createResponseBodyParser() in full is worth more than
hitting 72. Never truncate, abbreviate, or paraphrase an identifier to fit.
- What the target rules out is padding — the redundant trailing clause that restates
what the identifier already says. Cut the clause, not the identifier.
- Describe the change, not the activity that produced it.
wip,save progress,
Update files, and Address feedback describe a working session; they tell a later reader
nothing about what the tree now does differently. (Two commits are deliberate exceptions: the
branch-opening marker below, which carries no changes at all, and the throwaway save point in
granularity.md, which is deleted before anyone reads it.)
- A subject names the work, never the paths it touched. A path is where the change landed,
and a list of paths is the diff's own table of contents, which the reader already holds.
Add the API reference of AlphaClass says what was done, and Add docs/en/api/AlphaClass.md
says only where it ended up; a subject written that way grows one path for every file the work
reaches. What an Add brings and what a Purge takes away are named by what they are —
Add README, Purge OldValidator, Purge test for OldValidator, Purge /npm-init — never by
the path.
- A path means the folders a file sits in; a file name is not one. A bare file name stays in
the subject wherever it names the thing the commit changes —
Turn on strict-allow-scripts in .npmrc, Use major tags of actions in test.yml,
Update jest version to 30.4.2 in package.json. Leaving it out costs the reader the one fact
the subject was for, which file's setting moved. What stays out is the folder part:
.github/workflows/test.yml says where the file sits, which the diff already shows.
- **A subject that changes something that stands opens with the verb and the thing it changes, and
a phrase after them says what was done.** The thing is whatever the commit acts on — a skill, a
class, a member, a document, a test — written as its own notation says, and the phrase is an
infinitive or a gerund:
Update SessionStore#evictExpired() to skip pinned sessions,
Update test for SessionStore#evictExpired() to cover pinned sessions,
Update /hoc-git-commit to name the work, not the paths, in a subject,
Fix SessionStore#evict() by skipping pinned sessions. A kind of target takes no rule of its own,
and commits on one target open alike, so a reader of the log sees at a glance that a range is
work on that target.
- Do not record how the change came to be asked for: no "as requested", no "per review
comment", no tool attribution. Where the content itself came from is a different matter — that
belongs in the subject wherever it is part of what the work is.
The commits a branch makes about itself
Two commits carry no change of their own: the empty marker that opens a trunk, and the
Merge … commit that closes a sub-branch. Both are specified in full by the git branch
convention — when to make one, and what its subject says — because what they say is
inseparable from what they are for. Here they surface only in the verb table below, where
Start, Release and Merge are reserved for them.
- **A marker made on the wrong branch is taken back with
git reset --soft HEAD~1, while it is
still local.** The marker is empty, so the soft reset leaves the tree exactly as it was. The
two commands that reach the same state are not used for it: git reset --hard takes the
working tree with it, which /hoc-git-prohibit-destructive-commands refuses outright, and
git branch -D takes the branch and everything else standing on it, when what is being taken
back is one empty commit. Once the commit is pushed it stays, and a new commit corrects it.
Verbs
A subject opens with a verb naming what actually happened. The vocabulary is the same in both
message formats — capitalized on the imperative format, lowercase after the type on
Conventional Commits.
**A verb of two words joins into one where it sits in a single-token slot, and takes no hyphen
in its place.** Kick out, Tidy up, Turn on and Turn off stay two words in a subject and
become one before the slash of a branch name — tidyup/environment-files — and the same
holds wherever a project puts this vocabulary in the type: slot of Conventional Commits rather
than the types listed in format-conventional.md. The
slash and the colon already end the token, so a hyphen inside it marks nothing.
The table below lists the verbs whose role is fixed, not the verbs a subject may use. A row
is there because choosing the wrong verb would lose something a later reader needs — whether a
file survived, whether a class or one of its members was written, whether a constraint went one
way or the other. Where a listed verb names what happened, it is the one to use, and no synonym
substitutes for it. Where nothing listed names it, open the subject with the verb that does:
Name, Point, Follow, Keep and their like fix no such distinction and need no row.
The verb is decided by what this commit did, never by what the commit beside it says. Two
commits carrying one change into two files read as a pair, and making their subjects agree looks
like tidiness. But a verb does not describe the change — it describes what the change met, and
where one file already held the rule and the other did not, Update and Add are both the true
answer.
Update /hoc-alpha to replace the rule on H2s in a section a rule was there, and was replaced
Add the rule on H2s in a section to /hoc-beta nothing was there
A matched pair says the two files were in the same state when they were not, and that is the one
thing a later reader cannot recover from the diff: the diff shows what the file holds now, and the
verb is the only record of what it held before.
**The pressure here is symmetry, where in ## The history is a record, never a licence below it
is precedent.** Both end with a subject chosen from something other than what happened, and this
one is the harder to catch — the pair looks more correct after the verbs are matched than it did
before.
| verb | use for |
| :-- | :-- |
| Add | a new file, member, case, or capability that did not exist |
| Declare | a class written for the first time |
| Define | a class member, function, or constant written for the first time |
| Author | an AI element written for the first time — a skill, an agent, a command |
| Build | markup written for the first time — a component, a page, an HTML skeleton |
| Fulfill | a gap filled where something was declared but left short — a TODO, an unset option |
| Purge | a whole file or folder deleted, with nothing replacing it |
| Kick out | a part deleted from what stays — a class member, a section, an entry, a field |
| Tidy up | a place brought into order, where nothing was removed and no behavior changed |
| Update | an existing thing changed in itself, leaving it better than before |
| Retake | an existing thing redone because what was there was poor, hurried, or a stopgap |
| Fix | incorrect behavior corrected |
| Rename | identifier changed, behavior untouched |
| Move | relocation between files or directories, content untouched |
| Rearrange | peers put into a different order — imports, declarations, cases, entries |
| Extract | logic pulled out into its own member or module |
| Unify | two members or modules folded into one |
| Optimize | a change made for speed, behavior untouched |
| Use | switching to a different existing mechanism |
| Allow / Prevent | a constraint loosened or tightened |
| Turn on / Turn off | a switch flipped — a boolean, a lint rule, a feature flag |
| Adjust | a dial moved — a threshold, a limit, the options of a rule that stays on |
| Export | public surface changed |
| Install / Uninstall | a dependency the project takes on, or gives up |
| Start | empty branch-opening marker only — see the git branch convention |
| Release | empty marker opening a release/x.x.x trunk only — see the git branch convention |
| Merge | merge commits only — see the git branch convention |
Declareis for the class itself;Defineis for what is written inside or beside it —
a member, a function, a constant. Both are the specific forms of Add, and where they apply,
Add is the vaguer choice. Add remains correct for everything else that did not exist
before — a test file, a case, a reference document.
```
Declare SkillsInstaller to replace the installed skills
Define SkillsInstaller#replaceInstalledSkills() to swap the tree in one pass
Define SKILL_DOMAIN naming the domains a repository can select
Add test for SkillsInstaller
```
Authoris theDeclareof an AI element. A skill, an agent, a command — whatever is
read by the agent rather than run by the application, and installs under .claude/:
Author scribe skill. Like Declare and Define it is a specific form of Add, and where
it applies Add is the vaguer choice. Editing one that already exists is not Author — that
is Update, Fulfill or Tidy up, whichever names what was done.
Buildis theDeclareof markup. A component, a page, the HTML skeleton of one:
Build TalkroomMessage component, Build HTML skeleton for the security settings page. It
is the fourth of the family — Declare for a class, Define for a member, Author for an
AI element, Build for markup — and each is a specific form of Add. **It never means
running a build.** npm run build produces output, and output is not what a subject
announces; a commit that changed the build's configuration changed a config, and takes the
verb for that.
PurgeandKick outsplit on what survives.Purgeis for a file or a folder that is
gone whole — Purge OldValidator, Purge test for OldValidator, Purge /npm-init. Kick out
takes the shape Kick out <what> from <where>, because the point is that <where> is still there
without <what> — a member of a class, a section of a document, an entry of a manifest:
Kick out main: from package.json. The pair mirrors Declare and Define.
Tidy upis the cleanup that is not a removal. It takes the shapeTidy up <where>—
Tidy up the environment files — and covers stale naming, leftover duplication and disorder,
where naming each micro-change on its own would be noise. When the cleanup is a removal, the
verb is Purge or Kick out, however the branch that carries it happens to be named.
- The test is that no responsibility moves. A typo in a comment or a type, a formatting
correction, a blank line added or taken out, the parameter of every public function renamed
to it — the tree does the same thing before and after, and a reviewer confirms exactly
that. One identifier renamed on its own merits is Rename; a sweep that makes a whole
surface uniform is a tidy-up.
- A type that was wrong over code that was right is a tidy-up, never a
Fix. The
implementation is what the tree runs, and it was doing its job; only the annotation beside
it was mistaken. Fix would say the behavior had been wrong, and a later reader could not
then tell that subject apart from one that repaired a real defect.
- Reordering has its own verb. Putting a set of peers into a different order is
Rearrange, not a tidy-up: Rearrange imports for vue/core alphabetically.
Rearrangemoves peers, and only peers. Imports, declarations, cases, entries — a set
whose members stand at the same level, where the order is a matter of reading and nothing
else. Reordering control flow is not this: two if statements swapped is a behavior change
wearing the clothes of an ordering, and it takes the verb its behavior deserves. Relocating
something to another file is Move; Rearrange never crosses a file.
MovestaysMovewhen the relocation forces an edit inside the moved file. A file
that changes directory takes its own relative paths with it. Those edits are not a second
decision riding along — they are what the move consists of, and a subject naming anything
else would hide the one thing that happened. The row's content untouched means the
substance is untouched: what the file says, not the depth of a path it says it at.
- The test is whether the edit would stand on its own. A path following its file would
not: revert the move and the edit has nothing to do. An edit that still makes sense
with the file where it was is a separate decision, and takes its own commit.
- What pointed at the old place from another file is not part of the move. Each such
file takes a commit of its own, after the move and one file apiece:
```
Move index.js to lib/index.js
Update test for index to follow its move
Update main: in package.json to follow its move
```
Folded into the move, those edits sit under a subject that says nothing of what they
change, and a reviewer can no longer check each reference on its own. Measured: a move
carrying its test's import and the manifest's main: in one commit was asked back as
mixed; split per file, the tree at the tip came out identical.
- The commits in between leave a reference pointing at the old place, until the last of
them lands. The sub-branch carrying them merges as one, so the trunk never holds that
state.
- **A class lives in a file of its own name, so renaming a class always renames its file, and the
file name is changed in commits that carry nothing else.** They come first, the test's file and
then the implementation's, under the Rename verb:
```
Rename filename of test for SampleClass.js to RenamedClass.js
Rename filename of SampleClass.js to RenamedClass.js
```
The renames of the class and of its members follow, one definition at a time. The order keeps
the changes to imports apart from the changes to definition names. Renaming a member leaves the
file name alone, so it has no file-name commit.
- What pointed at the old file name from another file is not part of the file-name commit.
Each such file takes a commit of its own, after the file-name commits and one file apiece, and
it changes the path and nothing else:
```
Update test for SampleAuditor to follow the filename change of RenamedClass
Update SampleAuditor to follow the filename change of RenamedClass
```
The name of the definition inside the same file is a different change and takes a commit
later, with the rename of the definition. A file that imports the class therefore takes two
commits, one for the path and one for the name.
UpdateandRetakesplit on what was there before.Updatecarries a sound
implementation forward and leaves it giving something it did not give before — the gain is the
point. Retake replaces what was poor, hurried or a stopgap with what should have been there,
and claims no gain beyond that. Neither is Fix: that one is for behavior that was wrong,
where Retake is for an implementation that worked and was not good enough.
- A test's subject opens
<Verb> test for <target>, without exception.testis singular and
the target is one definition or one file: Add test for SkillsInstaller, `Update test for
SkillsInstaller#replaceInstalledSkills(), Purge test for OldValidator. Add tests for` and
Update tests for are never written, and neither is a collective target such as `the express
routes`: each says that several tests were committed together, which the one-file-per-commit
rule refuses.
- A test that follows an identifier change is
Update, neverRename.Renameis the
commit that changes the identifier where it is declared. The commit that carries the test along
changes what the test expects, which is an update of the test, so it opens `Update test for
SampleClass#extractValue()`. The two commits sit side by side on one branch and take different
verbs because each met something different, as the paragraph on matched pairs above says.
- A member's inputs and outputs are
Update's ground. A parameter it now takes, a return
value it now gives — the member itself is what changed. That a parameter is something which
appeared does not make it Add: addition takes Add where what appeared stands as an item of
its own, such as a test case or a manifest entry. Whether the change breaks a caller is marked
by the format rather than the verb — Conventional Commits writes ! with a BREAKING CHANGE:
trailer.
Fulfillfills a gap that was already there;Addbrings something that was not. A test
left as a TODO, a JSDoc block without its @returns, an option a rule was never given, a
package.json field left blank — the place existed and was short, and the commit makes it
whole. Where what is covered is itself new, its tests arrive with it and that is Add.
Nothing is replaced either way, which is what separates Fulfill from Update, and nothing
was wrong, which separates it from Fix. An option that was set and then moved is Adjust;
an option that was never set is Fulfill.
Addcovers a whole new thing and a part added to one that stands. A test file that did
not exist and one more case inside a file that did are both Add, so long as what they cover
is itself new — coverage that was owed is Fulfill. Addition is deliberately left unsplit: no
pair divides it the way Purge and Kick out divide deletion, because none is needed — the
subject names the thing added either way, and nothing a later reader wants is hidden by the
choice. Do not invent a verb for the partial case.
Nor reach for Update there. An item added inside something else is still an addition: Add
names what appeared, where Update names only the thing it appeared in. The more telling verb
wins, as Declare and Define win over Add where they apply.
- A word that needs several of these verbs to say what it covered is too vague for a row.
That is the test every exclusion below comes from: name the operations the word spans, and if
the answer is more than one, a reader of the subject cannot tell which happened. It is not
about how the word feels — Refine and Apply feel precise and span four verbs each, where
Purge feels blunt and spans exactly one.
- **
Change,RemoveandCreateare the ambiguous trio, and the table carries none of
them.** Each is broad enough to cover whatever happened, so the subject narrows nothing, and
each has specific verbs here to be narrowed into.
Changefits wherever any of the others would. A subject opening with it has said only
that the tree is not what it was.
Removereads the same whether a whole file went or one line inside it did —Purgeand
Kick out split exactly that, and Delete is Remove's twin in this.
Createleaves open whether a class, one of its members, or something else arrived, which
Declare, Define and Add settle between them.
MakeisCreate's twin, and is barred on wider ground than the trio. Standing for
Create it inherits that fault — Make changes to syntax settles nothing between Declare,
Define and Add. What Create cannot do and Make can is take an outcome as its object:
Make the written conventions reach the writer names the state the tree is meant to be in
once the change is applied, and every verb in the table could have brought that state about.
A word that fits in front of any object marks nothing by standing there, so the subject tells
a reader only that something was done. It is the fault Keep is kept out for and the fault
Put is kept out for, arriving in one word.
- The bar reaches the
-ingform a branch-opening marker takes.Start making xxxx
says no more than Make xxxx does. The marker carries the verb the branch's own commits
would use, and this is not one of them.
- The table carries no
Refineeither. It claims the thing got better without saying what
changed, so the reader is left with the writer's satisfaction and nothing else. Whatever the
improvement was, a listed verb names it: the wording redone is Retake, the formatting
straightened is Tidy up, the order put right is Rearrange, the thing itself carried
forward is Update.
- The table carries no
Migrate. Carrying content in from elsewhere is bracketed by the
branch, not repeated on every commit: the marker names the origin once, as /hoc-git-branch
describes, and each commit inside then says what kind of thing arrived, Declare or
Define or Add. A subject reading Migrate BaseInputValidator
says less than Declare BaseInputValidator does, and the origin it gestures at is nowhere.
- The subject names the thing that changed, not the thing that was brought to it. This is
why the table carries no Apply. Apply flex layout to main-container puts the layout in the
object and leaves main-container — the thing that is now different — in a trailing phrase.
And the word spans four verbs: enabling a module is Install or Turn on, switching to
another mechanism is Use, evening out the spacing is Tidy up, and
Apply respective change to the branch-number usage is the umbrella noun that
granularity.md already turns away.
- The table carries no
Replace. It spansUse, where one mechanism gave way to another,
and Retake or Update, where a passage of prose did. It also invites a subject that names
only what was dropped — Replace SCSS variables says nothing about what stands there now,
where Use CSS custom properties instead of SCSS variables says both and puts the surviving
mechanism first.
- The table carries no
ImplementorEnhance. Both name a whole feature's worth of work,
which is the scale of a Conventional Commits type and of a branch, not of one commit. A
repository on that format writes feat, and a trunk-scale branch is named implement/xxx;
the commits inside are finer than either, and each takes the verb for what it did.
- A verb that names the purpose is not a verb that names the change.
Keep,Telland
Point read as precise and each spans several operations, so a reader is left with the
writer's aim and no way to know what was done.
Keepcovers a requirement the code was short of (Fulfill), a rule that had not existed
before (Prevent), and a passage newly written (Add) — one verb over three commits a
reader needs to tell apart.
Tellcovers the ground ofFulfill, where the reader was short of something, and of
Add, where the statement is new.
PointcoversRetakewhere a passage was replaced,Updatewhere it gained, andUse
where a reference in code moved to another mechanism.
OptimizeandRetakename a motive as well, and keep their rows because the motive
settles which operation it was rather than standing in for it.
Extractleaves the logic in the tree, in a home of its own. The call site stays and
delegates to what was pulled out, which is what separates it from Purge and Kick out —
nothing was deleted. Relocating something intact is Move; Extract makes a new home out of
part of an existing one, and Unify is the same operation run backwards. Cut out is not
in the table for the reason Remove and Delete are not: it reads as excision, so the
subject leaves open whether the logic landed somewhere or went away.
InstallandUninstallname the dependency, not the file that records it. `Install
date-fns 4.1.0 and Uninstall date-fns` say what the project now depends on, or no longer
does. Reaching instead for Add, or for Kick out, would describe an edit to package.json,
which is merely where the fact is written down. A version change to a dependency already
installed is Update.
- **A generated file is committed under its file name and how it was generated, never under
what it contains.** A lock file, generated types, a build output, a snapshot: the subject
names the file and the command that produced it, and lists none of the contents. For
package-lock.json the form is Update package-lock.json after npm <command> —
after npm install, after npm update, after npm audit fix, naming whatever produced the
file.
```
Update package-lock.json after npm install
Update package-lock.json after npm audit fix
```
A generated file is not a decision of its own. It is the recorded outcome of one, and the
command is the only thing about it a reader cannot recover from the diff — the versions are
right there, and which of install, update or audit fix resolved them is not. Naming the
version or the packages instead would restate what the commit before it already said, and
lose the operation.
- **A change to
package.jsonis followed by the commit that moves the lock file, and one lock
commit serves everything that goes out as one pull request.** The shape is the same whether
the version moved is a dependency's or the project's own. Each change moves package.json in
a commit of its own and names the decision — Install date-fns 4.1.0 for a dependency,
Update the package version to 0.8.0 in package.json for the project's own bump. The lock
commit moves the lock file once, after the last of those changes, and names the command that
regenerated it. Neither stands in for the other, and folding them together would hide which
of the two a later revert has to undo.
- The command runs once, when
package.jsonis complete for the pull request. Measured:
a lock file regenerated once at the end came out identical to the one built up change by
change, so a lock commit after each change recorded nothing the last one does not, and
each cost a regeneration.
- The commits between leave
package.jsonand the lock file out of step, until the lock
commit lands, and the branch is not offered for review before it does. Nothing runs an
install from a commit in the middle, which is the test granularity.md sets for what
counts as broken.
- The pair is owed by every field the lock file mirrors, not by versions alone. A lock
file carries the package's own name: as well, in its root object and again in the entry
for the project itself, so renaming a package leaves it stale in two places and the same
two commits are owed: Fulfill name: in package.json, then `Update package-lock.json
after npm install`.
- An install from the lock file does not regenerate it. Measured after a
name:
change: npm ci succeeded and left both copies of the old name where they were, and
npm install then rewrote exactly those two lines and moved no dependency. A working
tree that comes back clean from npm ci is therefore no evidence that the lock file is
in step.
- A subject describes a transition, never a state. `Don't disable the action button when
the competition is completed describes a state the code should hold; Allow the action button
when the competition is completed` says the same change as a transition, and it completes
"Applying this commit will …", which a negative cannot. So a restriction lifted is Allow,
never a negative.
- This is why
Putis not in the table.Put the settings at the bottomnames where
things sit once the commit is applied, not what the commit did. What it did was
Rearrange, or Move, or Add, and one of those three always fits.
Turn onandTurn offname the switch, not what it permits. `Turn off
jsdoc/require-jsdoc for tests in eslint.config.js says which setting moved; Allow` and
Prevent name the behavior that is now open or closed. Where both would be true, the switch
is the more telling of the two, because a reader can go and find it. A value that moved along
a scale is neither: that one is Adjust.
EnableandDisableare not in the table, and for a different reason than the vague
words: each spans exactly one verb, which is Turn on and Turn off. A synonym of a
listed verb costs nothing to write and costs a reader twice — the history splits between
two spellings of one event, and whoever searches it for when a rule went off has to know
both.
- A setting changes in three degrees, and each has its own verb.
Turn onandTurn off
flip the switch. Adjust moves the dial while the switch stays where it is — `Adjust MaxFiles
to 20 in <config>, Adjust max-len to 120 in eslint.config.js. Update` is for the setting
that changed in itself rather than in degree — `Update jest version to 30.4.2 in
package.json. Adjust` carries no direction: a dial is as properly turned down as up, which
is why Update's gain does not apply to it.
Start,ReleaseandMergeare reserved for the commits that carry no change of their
own — the two branch-opening markers and the merge commit, all described by the git branch
convention. A change that
folds two things into one takes Unify, never Merge, so that a merge commit stays
recognizable by its subject alone.
Referring to class members
When a subject or body names a class member, it is written in the notation of
/hoc-classes-member-notation, with the class name attached:
Update BaseRestfulApiLauncher#extendRequestHooks() to return fulfilled hooks
Tidy up the JSDoc of BaseRestfulApiLauncher.get:ResponseBodyParser
A commit that changes a member names that member in its subject. A collective noun in its
place — Update the cache members of SessionStore — is the umbrella the
granularity.md one-line test turns away: it fits the line by
leaving out which members moved. Where the subject cannot name every member it touched, the
commit holds more than one decision, and it is split until each subject can.
Bad: Update the cache members of SessionStore
Good: Update SessionStore#evictExpired() to skip pinned sessions
Good: Update SessionStore.get:defaultTtl to read the environment
The subject says where, and the branch name says why. A commit message is read afterwards,
quickly, by someone looking for where a definition was fixed, so the member it fixed is what the
subject has to carry. What the whole piece of work is for — a rename, a retake — is what the
branch is named for. A test commit names the member it covers in the same notation, and the
prefix tells an instance member from a static one:
Update test for SampleClass#extractValue()
Update test for SampleClass.createValue()
Update test for SampleClass.get:ParserCtor
Rename SampleClass#extractValue() to #pickValue()
This is the same notation used throughout documentation and error messages; see the
documentation convention.
Referring to a config field
A configuration file's own field, named in a subject or body, carries its trailing colon.
Fulfill name: in package.json
Fulfill repository: in package.json
Kick out main: from package.json
The colon is what marks the word as a field rather than a description of one. `Fulfill the
package name in package.json` reads as prose and leaves a reader to work out which key moved;
Fulfill name: in package.json names the key they will search the file for.
- The file is named beside it. One key name recurs across a repository's configuration, and
the field alone does not say which file it sits in.
- What the notation marks is a field of the file's own structure, never an entry inside one.
A lint rule under rules:, a script under scripts:, a package under dependencies: — each
is a value the file holds rather than a key the format defines, and each is named as itself:
Turn off jsdoc/require-jsdoc for tests in eslint.config.js, `Kick out check:levers from
package.json`.
- A key already carrying a colon of its own keeps only that one.
check:leversis written as
it is spelled, because the notation adds a colon to a bare key and there is one there.
Referring to a skill
A skill named in a subject or body carries the leading slash it is invoked with.
Author /hoc-git-branch skill
Fulfill /hoc-git-branch to state the article rule for a branch name
Update /hoc-git-commit to state the notation for a skill name
The slash is what marks the word as a skill. Without it the same string reads as a directory,
a package, or a branch prefix — all of which a repository of skills is full of — and a reader
scanning subjects for where a convention changed has to work out which one each mention was.
Body
- The body is optional. Omit it when the subject already says everything — most small,
well-scoped commits need no body.
- When present, separate it from the subject with one blank line and wrap it at
72 characters.
- The body explains why, not what. The diff already shows what changed; what it cannot
show is the constraint, the rejected alternative, or the non-obvious consequence.
- A ticket or issue identifier may appear in the body, but the body must still explain the
change without it. A reader who cannot open the ticket must still be given the
reason.
Trailers
- Do not add attribution trailers (
Co-authored-by:,Generated-with:, and similar) unless
the project explicitly asks for them.
- A change that forces callers to follow takes a
BREAKING CHANGE:trailer, and there the
body stops being optional: name what a caller relied on, and what it has to do instead. The
test is whether code that passed against the old surface still passes — a parameter added
without a default, a return value narrowed, a member gone. A surface widened compatibly is
not this.
- The trailer carries it in either format. A subject has room for what changed, not for
what it costs, and breakage is found with git log --grep='BREAKING CHANGE' rather than by
scanning subjects. Conventional Commits marks the subject as well, with ! before the
colon; the imperative format adds no mark, and needs none.
A commit is not held to green; the suite is judged where the branch merges
- **Where an implementation and its tests land as separate commits, which side goes first, and
how many commits each side takes, belongs to /hoc-git-commit-order.** Read it before
ordering them. Some of those commits leave the suite red on purpose, so a commit is not held
to green; keeping every commit green would put the claim and its answer back into one commit,
which is the split this convention asks for undone.
- The red has to be gone by the time the branch is offered for merge — when its pull request
is opened, or before it is merged locally into a trunk. That is the one point at which the
whole suite is held to green; a red still standing there is unfinished work, not an ordering.
- What must pass, and when, is not settled here. Which commands run before a commit, and
which before a branch is offered for merge, belongs to the workflows convention. This one
settles what goes into a commit and how it is worded — never whether a command's result permits
the commit.
The history is a record, never a licence
**A commit already in the history is evidence of what happened. It is never permission to write
another one like it.** Conventions arrive after code does, so every repository carries subjects
written before this one was settled, by another team, or by hand in a hurry. Those commits stay,
because a history a reader can trust is worth more than one that is tidy — and not one of them
amends what is written here.
- A violation found in a sibling repository is the weakest ground there is. The search that
turned it up was a search for permission, and what it found was somebody else's mistake. A
subject joining two class declarations with and is wrong in the repository it was copied from
as surely as in the one it was copied to, and citing it names a second offence rather than
excusing the first.
- A precedent may be correct and still not transfer.
Start,ReleaseandMergecarry no
change of their own, so nothing in their subjects answers to granularity — a list in one of
them joins nothing that could have been two commits, though it is still an enumeration that
/hoc-notation refuses. Citing such a subject for one that does
carry changes borrows a licence resting on that exemption, and the commit being written does
not hold it. This is the harder of the two to catch, because nothing in the commit cited is
wrong.
- The reach for a precedent is itself the signal. It happens where the rule would otherwise
cost something — more commits to write, a branch already shaped to rebuild. That pressure is
the moment the rule is doing its work, so a precedent produced under it is being used to buy
the rule off.
- What the history does govern is reading. Search it without filtering on the resolved
convention, as the format section above states: the commits that do not follow it are still the
record of what happened. Reading them is required; imitating them is not permitted.
Granularity in one line
One commit is one decision a reviewer can accept or reject on its own, and the test is
whether one plain subject line states everything it does. Everything — a subject that fits by
leaving something out has failed the test rather than passed it, and "and" joining two
decisions is only the most visible way it fails.
The full heuristic — what to split, what to keep together, and how to stage a mixed working
tree — is in granularity.md.
Detail files
- granularity.md — what belongs in one commit, splitting a mixed working tree
- format-imperative.md — capitalized imperative subject, no type prefix
- format-conventional.md — Conventional Commits (
type: summary)