Write a Clear Git Commit Message
Generate a Conventional Commits-compliant git commit message with context and rationale.
This prompt turns a plain-English description of a code change into a clean, Conventional Commits–formatted message, complete with a typed subject line and a body that explains the reasoning. It's structured to enforce the parts developers most often skip: keeping the subject short and explaining WHY rather than restating the diff. Use it when you've made a non-trivial change and want a commit message that will still make sense to a teammate (or future you) six months from now.
You are an expert in software engineering best practices. Write a git commit message for the following change. Follow the Conventional Commits spec: type(scope): subject. Keep the subject under 72 characters. Add a body paragraph if the change is non-obvious, explaining WHY (not what). End with any breaking changes noted as BREAKING CHANGE. CHANGE DESCRIPTION: [DESCRIBE WHAT YOU DID] DIFF SUMMARY: [OPTIONAL: PASTE DIFF]
What you can expect back
fix(auth): store session token in httpOnly cookie The session token was previously kept in localStorage, which is readable by any script running on the page and therefore exposed to XSS attacks. The server now sets and clears the token as an httpOnly, Secure cookie, and the client no longer reads or stores it directly. BREAKING CHANGE: clients that read the token from localStorage will no longer find it; the token is sent automatically with requests via cookie.
Illustrative example — your results will vary by tool and inputs.
Get sharper results
- 01Give it the actual scope (the module or package name) in your description, otherwise it guesses a generic scope like (app) that's less useful in a monorepo.
- 02Paste at least `git diff --stat` so the model picks the right Conventional Commit type — without it, refactors often get mislabeled as feat.
- 03If the change is genuinely trivial, tell it 'no body needed' so you get a one-line message instead of an invented paragraph.
- 04When you have several unrelated changes staged, ask it to split them into multiple commit messages so you can commit them separately and keep history clean.
- 05Add your team's allowed type list (e.g. feat, fix, chore, docs, refactor) if you use commitlint, so the output passes your CI hook on the first try.
Adapt it for your case
Append 'then expand this into a pull request description with a testing-notes section' to generate both at once.
Add 'prefix the subject with the matching gitmoji' if your team uses the gitmoji convention.
Ask it to also produce a one-line user-facing changelog entry derived from the commit.
Common questions
What are the valid Conventional Commit types?
Common ones are feat, fix, chore, docs, style, refactor, perf, test, build, and ci. List the exact set your team uses in the prompt so the output matches your lint rules.
When should it add a BREAKING CHANGE footer?
Only when the change alters a public API, contract, or behavior that other code depends on. Mention in your description whether the change is backward-compatible so it judges this correctly.
Do I have to paste the diff?
No, it's optional. A clear one-sentence description is usually enough, but pasting the diff stat helps it pick the right type and scope.
You may also need
Generate Unit Tests for a Function
Generate comprehensive unit tests with happy path, edge cases, and failure modes.
Write Unit Tests for an Existing Function
Generate a thorough unit test suite covering happy path, branches, edges, and errors.
Perform a Thorough Code Review on a Pull Request
Get a senior-engineer-style code review with categorized, file-referenced feedback.
Refactor Code for Readability and Maintainability
Refactor any code for readability and maintainability without changing its behavior.