Skip to content
AI Agent & Markdown Files

Write Commit Messages and PR Descriptions From a Diff

For when AI writes "update files" or a three-paragraph essay for a one-line fix. Paste your diff and tell it why you made the change. It returns a commit message sized to the change, with previous behavior, new behavior and why, plus a PR.md that opens with a short human summary and tucks the long detail into a collapsed block, so reviewers actually read it.

Illustration for the AI prompt: Write Commit Messages and PR Descriptions From a Diff
Chat promptAI Agent & Markdown FilesChatGPTClaudeGemini
The Prompt
You are a senior engineer who writes commit messages and pull request descriptions that other developers actually read. I'll give you a diff (or the output of git diff --staged) and a little context. Your job is to turn it into a commit message and a PR.md I can paste with minimal editing.

Here is what goes wrong when I ask an AI to do this without rules: the message says "update files" or "updated stuff" because it only restates what the diff already shows; a one-line fix like "fixed button color" turns into a three-paragraph corporate announcement; the PR description is a wall of text that reads like a robot justifying the change after the fact, so reviewers skip it and read the diff instead; and the one thing the diff can't show, WHY the change was made, is missing or invented.

HARD RULES:
1. THE WHY COMES FROM ME, NOT FROM YOU. The diff shows what changed. It never shows why. If I haven't told you the reason, ask. Never invent a motive, a bug report, a user complaint or a ticket number. If I still don't know the reason, write the message without one and flag it under GAPS.
2. SIZE MATCHES THE CHANGE. A small change gets a subject line and at most one or two body lines, or no body at all if the subject says everything. Only larger changes get a fuller body. Never pad.
3. SUBJECT LINE: imperative mood ("Fix", "Add", "Remove", not "Fixed" or "This commit fixes"), 50 characters or fewer where possible, hard limit 72, no trailing period, no filler words like "various", "some", "stuff", "misc" or "updates".
4. BODY FORMAT (only when a body is needed): wrap at 72 characters and cover three things in plain sentences: previous behavior, new behavior, why it changed. Mention anything a reviewer could miss: a migration, a config or env var change, a breaking change, a removed feature.
5. CONVENTIONS ARE MINE TO CHOOSE. Use Conventional Commits (feat:, fix:, chore:, refactor: and so on, with an optional scope) only if I say my repo uses it. Otherwise write a plain subject. If I give a ticket or issue number, add it in the format I use (a "Refs #123" footer by default, or a prefix like "ABC-123:" if I say so).
6. ONE COMMIT, ONE PURPOSE. If the diff mixes unrelated changes (a bug fix plus a refactor plus a dependency bump, or dozens of files touching different features), don't force one vague message over all of it. Say so under SPLIT SUGGESTION and propose separate commits, each with its own subject and the files that belong to it.
7. PR DESCRIPTIONS ARE FOR SKIMMING. The top is a short human-readable summary: two or three sentences a reviewer can read in ten seconds. The detail goes below it, and anything long goes inside a collapsed <details><summary>...</summary> block so it doesn't become a wall of text. No marketing tone, no "this PR elegantly introduces", no restating every line of the diff.
8. NEVER CLAIM WHAT YOU CAN'T SEE. Don't say tests pass, performance improved or a bug is fixed in production unless I told you. Testing notes describe what I did or what a reviewer should try, nothing more.

BEFORE WRITING, ask me these in one short batch and STOP (skip any the diff or my notes already answer):
1. Why did you make this change? One or two sentences in your own words is enough, even rough ones.
2. Is there a ticket, issue or PR number to reference, and what format does your team use?
3. Does your repo use Conventional Commits or another commit style? Paste one or two recent commit subjects if you're not sure.
4. Do you need just the commit message, or the PR description too?
5. How did you test it, and is there anything reviewers should look at closely or try themselves?
6. Paste the diff (git diff --staged, or the PR's diff).

Then reply using exactly these sections:
COMMIT MESSAGE: the full message in one plain code block, subject line first, a blank line, then the body if one is needed. If you recommend splitting, give one code block per commit instead.
PR.MD: the complete PR description in one markdown code block, with these parts:
# [PR title, same rules as a commit subject]
A two or three sentence summary: what changes for the user or the codebase, and why.
## Changes: a short bullet list grouped by area, one line each, no file-by-file narration.
## How to test: numbered steps a reviewer can follow.
## Notes for reviewers: risks, migrations, breaking changes or follow-ups, or "None".
<details><summary>Full change details</summary> a longer walkthrough of the diff for anyone who wants it, closed with </details>.
A final line with the ticket reference, if I gave one.
SPLIT SUGGESTION: only if rule 6 applies, otherwise write "None, this is one logical change."
GAPS: anything I should fill in or double-check before I commit, such as a missing reason or an unverified claim.

Plain text outside the code blocks, no intro, no pep talk. Keep the whole reply short enough that I'd rather read it than the diff.

Here are my details (fill in what you can, or leave blank and answer the questions):
Why I made this change: [FILL IN]
Ticket or issue: [FILL IN]
Commit style: [FILL IN]
Diff: [PASTE]

Start with the questions.
Open directly inChatGPTClaudeGemini

How to use this chat prompt

Paste it directly into a new chat, replace anything in [BRACKETS] with your context, and send. Re-use it whenever the task comes up, or save it as a text-expander snippet.

Example output

Staged diff of a React checkout form plus a note: double-clicking Pay created two Stripe charges, ticket SHOP-412, team uses Conventional Commits.

Plain ChatGPT answer

Updated checkout form and payment handling.

This commit improves the checkout experience by making various updates to the payment component, enhancing reliability and ensuring a smoother user flow.

With this prompt

COMMIT MESSAGE: fix(checkout): disable Pay button while charge is pending

Previously a double click on Pay sent two requests and created two Stripe charges. The button now disables on submit and re-enables only on error. Refs SHOP-412

PR.MD: # fix(checkout): prevent duplicate charges on double click

Customers who double-clicked Pay were charged twice. This disables the button until the charge request settles.

## How to test: 1. Double-click Pay in test mode. 2. Confirm one charge in the Stripe dashboard.

SPLIT SUGGESTION: None, this is one logical change.

GAPS: confirm whether existing duplicate charges need refunds.

FAQ

Frequently asked questions

Can AI write good commit messages?

It can, as long as you give it the reason for the change. A diff only shows what changed, so an AI working from the diff alone falls back on vague lines like "update files" or restates the code in words. This prompt asks for your why first, sizes the message to the change, and flags any gap instead of inventing a motive. Treat the output as a starting point you edit, not something to commit blind.

What is the best AI commit message generator?

The model matters less than what you feed it. ChatGPT, Claude and Gemini all write a decent message when they get the diff, the reason and your team's conventions, and all of them write a vague one without. This prompt works in any of the three for free, no signup, and enforces the same rules every time: imperative subject, previous behavior, new behavior, why.

Should I use Conventional Commits?

Developers are split. Fans like that a prefix such as fix: or feat: tells you the type of change at a glance and makes a commit log easy to scan; critics find the chore versus feature labels pointless. Use it if your repo already does or your release tooling depends on it. This prompt asks which style you use and only adds the prefixes if you say yes.

How do I write a PR description reviewers will actually read?

Put a two or three sentence human summary at the top, then short sections for changes, how to test and risks, and fold any long walkthrough into a collapsed details block, which GitHub Markdown supports. Reviewers skip walls of text and go straight to the diff. If the diff itself is AI-written, it also helps to run it through the code review prompt for AI-generated code before you open the PR.

Why does AI give a vague message for a big diff?

Because a diff that touches many unrelated files usually holds several changes, and no single subject line can describe all of them honestly. This prompt checks for that and suggests how to split the work into separate commits, each with its own message. Building in smaller steps from the start, for example with a vibe coding build plan, keeps each diff easy to describe.

Keep going

What's next