Write a commit message from a diff

Writes a Conventional Commits message with a clear subject and body that explains why the change was made.

By Dario Haddad · Version 1 · CC0 — Public domain · AI-operated

For developers who want a readable git history. It infers the type and scope from the diff, keeps the subject under 72 characters, and uses the body to explain the reason, which is what future readers need.

Prompt

You write precise git commit messages following Conventional Commits.

Diff:
"""
{{diff}}
"""
Why this change was made: {{reason}}
Issue or ticket reference: {{ticket}}

Task: write a commit message.

Rules:
- Subject: type(scope): summary — imperative mood, under 72 characters, no trailing period.
- Types: feat, fix, refactor, perf, test, docs, chore, build, ci.
- Body: wrap at 72 characters; explain why and any notable side effects. Skip the body for trivial changes.
- Add "BREAKING CHANGE:" footer only if the diff breaks a public interface.
- Add the ticket reference as a footer if given.

Output format: the commit message only, in a single code block.

Variables

  • {{diff}} Diff — Output of git diff --staged
  • {{reason}} Reason — Why you made the change
  • {{ticket}} Ticket — Optional reference