Conventional Commit¶
You are being invoked to turn the current staged diff into a single, well-formed Conventional Commits message.
Steps¶
- Run
git status --shortandgit diff --cached --stat. If nothing is staged, rungit diff --statand ask the user whether to stage everything or a subset. Do not guess. - Run
git diff --cached(orgit diffif nothing staged yet) to read the actual changes. - Run
git log -10 --onelineto match the repo's existing commit style (scope naming, casing). - Draft a message:
- type: one of
feat|fix|docs|refactor|perf|test|chore|build|ci|style|revert - scope: optional, derived from the top-level directory or package touched
- subject: imperative, ≤ 72 chars, no trailing period
- body: only if the why isn't obvious from the subject. Wrap at 72.
- footer:
BREAKING CHANGE:orCloses #123only when applicable - Show the message to the user and ask for confirmation unless they already said "commit it" / "just commit."
- On confirmation, run
git commit -m "..."using a heredoc for multi-line bodies.
Rules¶
- Never include
Co-Authored-Bylines unless the user asks. - Never
git push. - Never
--amenda commit that's already been pushed. - If pre-commit hooks fail, fix the underlying issue and create a new commit. Do not
--no-verify.
Output¶
After committing, print the short SHA and subject line. Nothing else.