thinkhard.SI

Prompt repository Engineering & code

Commit message prompt: written from the diff

You have a diff ready to commit and want a message that says what changed and why, in your repository's own convention.

Registry no.
ENG-030
Collection
Engineering & code
Laid out for
Any chat model
Score
10 out of 10
Blanks to fill
5
Added

Engineering & codeAny chat

The prompt

Score 10 of 10, Excellent

Use it when You have a diff ready to commit and want a message that says what changed and why, in your repository's own convention.

  • {{diff}}
  • {{reason}}
  • {{issue_refs}}
  • {{convention}}
  • {{recent_commits}}
Full prompt and why it works
Prompt
Write a git commit message for the diff below, for the people who will read this project's history later, so that someone running git log or git blame a year from now can tell what changed and, above all, why.

The diff:
"""
{{diff}}
"""

Why this change was made (the problem, the ticket, the decision behind it): {{reason}}
Issue or ticket numbers to reference: {{issue_refs}}
Our commit convention: {{convention}}

Recent commit messages from this repository, to match their style:
"""
{{recent_commits}}
"""

Write the message in this form:
1. A summary line under 72 characters (50 or fewer if it fits), in the imperative mood ("Add", "Fix", "Remove"), with no full stop at the end. If the convention is Conventional Commits, start with the type and optional scope, for example "fix(billing): round tax per line before summing". That example shows the form only.
2. A blank line.
3. A body of 2 to 6 lines, wrapped at 72 characters, that explains why the change was needed and what it does at a high level: the problem, the approach, and any side effect a reader should know about, such as a changed default. Do not list every file or restate the diff line by line.
4. Footer lines for the issue numbers I gave, in the form our convention uses (for example "Refs #123"). Use a closing keyword such as "Fixes" only if I said the change fully resolves the issue, because many hosts close the issue automatically when they see one. If the change breaks a public interface, add a "BREAKING CHANGE:" footer that says what callers must do.

Return the message in a code block, ready for git commit -F. Below it, add at most two short notes, only if needed: changes in the diff that look unrelated to the reason (debug output, formatting, a stray file), with a suggestion to put them in their own commit.

Do not describe anything the diff does not contain, and do not add issue numbers, co-author lines or sign-offs I did not give. Avoid phrases such as "This commit" or "Various fixes".

If the reason is not given and the diff does not make it clear, write the summary line and put [WHY: one line on the reason] in the body instead of inventing one. If the diff mixes several unrelated changes, say so first and suggest how to split it.

Variables

{{diff}}
The staged diff, for example the output of git diff --staged.
{{reason}}
Why you made the change, in a sentence or two. Write "see diff" if it is obvious.
{{issue_refs}}
Issue or ticket numbers, and whether the change fully resolves each, for example "#482, fully fixed". Write "none" if there are none.
{{convention}}
For example "Conventional Commits", "plain imperative summary" or "match the recent commits".
{{recent_commits}}
Five to ten recent messages, for example from git log -10. Write "none" if the repository is new.

Why it works

  • Who it's for. It writes for the person reading git log or git blame a year later, which is why the body explains the reason rather than repeating the diff.
  • What to avoid. Closing keywords appear only when you say the issue is fully resolved, and no issue numbers or co-authors are added beyond the ones you gave.
  • If unsure. A missing reason becomes a [WHY] placeholder in the body instead of an invented motive.

How to use it

  1. Press Fill in blanks and type your details into each blank. What you type stays in this browser.
  2. Copy the filled prompt into the AI tool you already use, such as ChatGPT, Claude or Gemini, or open it in the Grader or the Prompt Tester here.
  3. Before you rely on it, try it on three or four real examples. The Prompt Tester runs them all at once and shows which ones go wrong.
Use it from code

Get this prompt as JSON from the free REST API, with your own text in the blanks, or let an AI assistant fetch it through the MCP server. No key.

curl -s https://thinkhard.si/api/v1/prompts/commit-message-from-diff

With the MCP server added to Claude, ChatGPT, Cursor or VS Code, call get_prompt with {"prompt": "commit-message-from-diff"}, or just ask for it by name.