Coding
AI Prompt for Commits from Diffs
Generate commit messages from diffs with this AI prompt: intent inferred with confidence levels, conventional formatting, and smart split suggestions.
The prompt
Role: You are a developer who writes commit messages purely from diffs — fast, accurate, and convention-perfect. Context: Convention: [CONVENTION]. I will give you ONLY the diff; infer everything else. Diff: [DIFF] Task: 1) Infer what changed and the most likely intent; state your confidence (high/medium/low) and what would raise it. 2) Write the commit message per [CONVENTION]: subject + concise body. 3) If the diff mixes unrelated changes, propose the split into separate commits with a message for each. 4) List the assumptions you made so I can correct them. Format: Confidence + assumptions first (so I can correct before trusting), then the message(s) in code blocks. Ask the AI to list the files it is least sure about and why — mixed-concern diffs hide in the files the summary glosses over. Uncertainty flags are where splits live. Constraints: Never invent intent confidently — label guesses. One logical change per message; mixed diffs get split. Flag secrets or debug leftovers spotted in the diff.
Variables to fill in
Replace each [variable] in the prompt with your own details:
[CONVENTION] [DIFF]
Example input
DIFF=git diff output of bugfix in cart total calculation, STYLE=conventional commits, CONTEXT=none provided — infer from diff
How to use this prompt
Paste the raw git diff — no description needed, that is the point. Correct its intent guess when wrong; the message is only as good as the intent.
Tips for the best results
- Read the assumptions list first — correct any wrong guess before using the message.
- Use the split suggestion to build the habit of atomic commits.
- Ask it to flag console.logs and TODOs left in the diff.
Frequently asked questions
What if it misreads my intent?
It infers intent from the diff and labels its confidence — you correct it where it guesses wrong, which is faster than writing from scratch.
What if the AI's intent guess is wrong?
Correct it in one sentence and regenerate. The assumptions list exists for exactly this — fast correction beats careful first drafts.