From e91dcb3f12cc3aad3e94a0af1104a6fdba6d81fe Mon Sep 17 00:00:00 2001 From: bchanot Date: Fri, 16 Oct 2026 11:49:26 +0200 Subject: [PATCH] feat(commits): follow project convention, else short messages New lib/commit-message.md looks for a documented convention first. Without one, messages stay under 50 words at medium technical level. --- .claude/tasks/TODO.md | 5 +++++ CLAUDE.global.md | 1 + agents/client-handover-writer.md | 4 ++-- agents/commit-changer.md | 15 +++---------- lib/commit-message.md | 38 ++++++++++++++++++++++++++++++++ skills/bugfix/SKILL.md | 10 +++------ skills/feat/SKILL.md | 9 +++----- skills/hotfix/SKILL.md | 7 +++--- 8 files changed, 58 insertions(+), 31 deletions(-) create mode 100644 lib/commit-message.md diff --git a/.claude/tasks/TODO.md b/.claude/tasks/TODO.md index 2d21e73..8bcfe22 100644 --- a/.claude/tasks/TODO.md +++ b/.claude/tasks/TODO.md @@ -1,5 +1,10 @@ # TODO +## 2026-10-15 — short commit messages (feature/short-commit-messages) +- [x] `lib/commit-message.md`: lookup of a documented convention (README, CONTRIBUTING, CLAUDE.md, `.claude/` rules, commitlint, template), else 50 words max, medium technical level. Git log is not a convention. +- [x] Citers patched: commit-changer, bugfix STEP 6, feat STEP 5, hotfix STEP 4, client-handover-writer, CLAUDE.global.md (1 line, 320-line budget). +- [ ] Residual: `chore(memory)` / `docs:` helper commits untouched (already one line). release-executor prep message untouched (fixed one-liner). + ## 2026-10-15 — model-router: probe a move target before routing main to it (bugfix/router-probe-before-route) Contract `.claude/tasks/contracts/2026-10-14-router-probe-before-route-0005.md`, plan r3 `.claude/tasks/plans/2026-10-14-router-probe-before-route-0005.md`. - [x] /bugfix run: Fable out of credits routed (BLK-030, LRN-218); r1 → r3; 497 tests, verifier CONFORME 11/11, security PASS; commit 2cccc43 + docs. diff --git a/CLAUDE.global.md b/CLAUDE.global.md index 25a230e..97e58ed 100644 --- a/CLAUDE.global.md +++ b/CLAUDE.global.md @@ -193,6 +193,7 @@ when asked: the user runs `! git push`. An invalid value counts as manual, nothing pushes and the stop is named. `GITFLOW_NO_PUSH=1` only for throwaway test repos. Outside manual mode a branch ahead of its upstream is a defect, not a state. +Commit messages: project convention, else 50 words max (lib/commit-message.md). ## Security — non-negotiable defaults Apply at every step: design, scaffolding, implementation, review. diff --git a/agents/client-handover-writer.md b/agents/client-handover-writer.md index c444a2f..80948b3 100644 --- a/agents/client-handover-writer.md +++ b/agents/client-handover-writer.md @@ -564,8 +564,8 @@ If `PENDING_CHANGES` non-empty → invoke /commit-change skill via subagent: > auto-fix iterations of /seo, /harden (web) or /cso (non-web). Group into > atomic logical commits (e.g., separate SEO meta-tag commit from harden > security-headers commit; separate dep-upgrade commit from gitignore -> commit). Use Conventional Commits format. After committing, return the -> SHA list." +> commit). Message per `~/.claude/lib/commit-message.md`. After committing, +> return the SHA list." **PUSH STATE READ.** Three separate Bash calls, never combined, read-only: `git branch --show-current` → `
`; diff --git a/agents/commit-changer.md b/agents/commit-changer.md index af624a0..e193191 100644 --- a/agents/commit-changer.md +++ b/agents/commit-changer.md @@ -123,18 +123,9 @@ artificially split what was done as one action. ### Commit message format -Follow Conventional Commits and match the repo's existing style: - -``` -(): - - -``` - -Types: `feat`, `fix`, `refactor`, `chore`, `docs`, `test`, `style`, `perf` - -Keep the first line under 72 characters. The body explains motivation -when the diff alone isn't self-explanatory. +Follow `$HOME/.claude/lib/commit-message.md`: the project's documented +convention if there is one, else a short message (50 words max, medium +technical level). Run its lookup once for the whole plan. ### Capitalize candidates (draft only — decided later, written in `MODE: apply`) diff --git a/lib/commit-message.md b/lib/commit-message.md new file mode 100644 index 0000000..bf8e262 --- /dev/null +++ b/lib/commit-message.md @@ -0,0 +1,38 @@ +# Commit message: project convention first, else short + +Run before composing ANY commit message (flow or ad-hoc). Read-only lookup: + +```bash +git config --get commit.template +ls CONTRIBUTING* commitlint.config.* .commitlintrc* .gitmessage 2>/dev/null +grep -n -i -m3 -E "commit (message|convention)|conventional commit" \ + README* CONTRIBUTING* CLAUDE.md .claude/rules/* docs/* 2>/dev/null +``` + +## 1. A convention is documented + +Hit in the project's own files (README, CONTRIBUTING, project `CLAUDE.md`, +`.claude/` rules, commitlint config, commit template) → follow it to the +letter: format, language, length, scope list. Nothing below applies. + +Read each grep hit before trusting it. The git log is NOT a convention: it +can carry the verbosity this file removes. + +## 2. No convention: short + +- Subject `(): `, 72 chars max. Types: feat, fix, + refactor, chore, docs, test, perf, style. +- Optional body: one or two sentences on why. Whole message 50 words max. +- Medium technical level: say the behavior and its cause. No file lists, + line numbers, step-by-step of the diff or internal identifiers. A reader + who knows the stack follows without opening the diff. + +``` +fix(auth): reject expired refresh tokens + +The refresh check compared the expiry in seconds against milliseconds, so +expired tokens passed. Both sides now use seconds. +``` + +Out of scope: `chore(memory)` and `docs:` commits made by +`memory-commit.sh` / `doc-commit.sh`, already one line by their own style. diff --git a/skills/bugfix/SKILL.md b/skills/bugfix/SKILL.md index 25f3f3f..4b6f95b 100644 --- a/skills/bugfix/SKILL.md +++ b/skills/bugfix/SKILL.md @@ -223,13 +223,9 @@ Parse the `BUGFIX-EXEC REPORT`: - `skip` → leave changes uncommitted, exit cleanly. - `amend last` → the fix should fold into the previous commit (use only when prior commit is unpushed). -3. Commit using conventional format (after approval): - ``` - fix(): - - - - ``` +3. Commit after approval, message per `$HOME/.claude/lib/commit-message.md` + (project convention first, else short: root cause in the subject, at most + two sentences of body). 4. Print summary: ``` BUGFIX COMPLETE diff --git a/skills/feat/SKILL.md b/skills/feat/SKILL.md index aecbde7..e5a2a6c 100644 --- a/skills/feat/SKILL.md +++ b/skills/feat/SKILL.md @@ -191,12 +191,9 @@ run + one verifier + one security dispatch. ## STEP 5 — COMMIT -Commit using conventional format: -``` -feat(): - - -``` +Commit with the message per `$HOME/.claude/lib/commit-message.md` +(project convention first, else short: what was added, at most two +sentences of body). If the feature touched multiple concerns (e.g., feature + config + test), consider splitting into 2-3 atomic commits grouped by logical diff --git a/skills/hotfix/SKILL.md b/skills/hotfix/SKILL.md index 9ed5296..be0f3a3 100644 --- a/skills/hotfix/SKILL.md +++ b/skills/hotfix/SKILL.md @@ -190,10 +190,9 @@ Parse the `HOTFIX-EXEC REPORT`: - Structural failure (mute / unparsable / no VERDICT line) → treat as a failed gate: retry ONCE fresh; a 2nd structural failure → revert + escalate. A mute auditor is never a PASS. -3. Commit using conventional format (only after smoke AND security pass): - ``` - fix(): - ``` +3. Commit only after smoke AND security pass, message per + `$HOME/.claude/lib/commit-message.md` (no convention: one subject line, + `fix(): `). 4. Print summary: ``` HOTFIX APPLIED