Back to cookbook

ChatGPT Prompt to Write Clear Commit Messages and Pull Request Descriptions

17 views Published

Make this prompt yours

Share

This ChatGPT prompt for writing commit messages and pull request descriptions turns a raw code diff into a clean, reviewable summary a teammate can actually use. It's built for developers and engineering teams who write good code but write commit messages like "fix stuff" or leave PR descriptions blank, making code review slower and git history nearly useless six months later.

The prompt works by feeding the model your diff (or a plain description of the change) along with the ticket or issue it relates to, then asking it to separate the what changed from the why it changed — the part most engineers skip. It also asks for a short list of things reviewers should pay close attention to, like a schema change or a new external dependency, so nothing risky slides through review unnoticed.

Because commit history and PR descriptions are exactly the kind of long, repetitive writing task that benefits from a reusable structure, it's worth running this prompt through Prompt Optimizer in Coding mode first if you want to tighten the wording or adapt it to your team's specific PR template.

Prompt template

Make this prompt yours

prompt-template
321 tokens
ROLE: You are a senior software engineer writing a commit message and pull request description for a code change. CONTEXT: - Code diff or summary of changes: [PASTE DIFF OR DESCRIBE THE CHANGE] - Related ticket/issue: [TICKET ID AND TITLE, OR "NONE"] - Commit convention to follow: [E.G. CONVENTIONAL COMMITS, FREEFORM, TICKET-PREFIXED] - Audience for the PR description: [E.G. TEAM ENGINEERS, EXTERNAL CONTRIBUTORS] TASK: 1. Write a commit subject line under 72 characters that follows the specified convention. 2. Write a 2-4 sentence commit body explaining what changed and, if context was given, why. 3. Write a pull request description with these sections: Summary, Why This Change Is Needed, How It Was Tested, Risk/Areas to Review Closely. 4. If the diff includes a schema change, new dependency, or breaking change, call it out explicitly under Risk/Areas to Review Closely. CONSTRAINTS: - Do not invent functionality, reasoning, or test coverage that wasn't stated or shown in the diff. - Keep the PR description skimmable — short paragraphs or bullets, not dense prose. - If information needed for a section is missing, write "Not specified" rather than guessing. OUTPUT FORMAT: Commit Subject: [text] Commit Body: [text] PR Description: ## Summary [text] ## Why This Change Is Needed [text] ## How It Was Tested [text] ## Risk / Areas to Review Closely [text]

Want it sharper? Optimize this prompt with Prompt Optimizer, check it with the Prompt Debugger or shorten it with the Token Optimizer.

Example input

example-input
102 tokens
Code diff or summary of changes: Changed the `validateSession()` function in auth/session.js to check token expiry against server time instead of client-provided time. Added a new `getServerTime()` helper that calls /api/time. Removed the old `isTokenExpired()` function which is no longer used anywhere. Related ticket: AUTH-482 - Users can bypass session expiry by changing their system clock Commit convention to follow: Conventional Commits Audience for the PR description: Team engineers reviewing for security impact

When to use it

  • You've finished a feature branch or bug fix and need to open a pull request with a real description
  • Your team's git history is full of vague messages like "updates" or "wip" and you're trying to fix that habit
  • You're squashing several small commits into one and need a single message that reflects the whole change
  • You're onboarding a new team member and want to model what a good commit message looks like

Best practices

  • Paste the actual diff or patch when you have it — a vague description of "I changed the login flow" produces a vague commit message back
  • Always give the model the linked ticket number or issue title so it can reference the reason for the change, not just the mechanics
  • Ask explicitly for a separate "why" section — models default to describing code changes line by line unless you ask for intent
  • Set a hard line-length or character limit for the commit subject line (50-72 characters is the common git convention) since models will otherwise write long, run-on subject lines

Common mistakes

  • Pasting only the file names that changed instead of the actual diff, which forces the model to guess at what happened
  • Not specifying commit message convention (Conventional Commits, freeform, ticket-prefixed) so the output doesn't match what your team's tooling expects
  • Letting the model invent a rationale for the change when none was given, instead of asking it to just describe the mechanics if intent isn't provided
  • Using the same generated message for the commit and the PR description when they serve different audiences — a commit message is terse, a PR description should explain context and testing

FAQs

How do I write a good commit message with ChatGPT?

Give the model the actual diff, not just a summary, along with the related ticket and your team's commit convention. Ask it to separate the mechanical "what changed" from the "why" so the message stays useful in git history months later.

What's the difference between a commit message and a pull request description?

A commit message is terse — usually a one-line subject and a short body describing the change. A PR description is longer and written for reviewers, covering context, testing, and what to look at closely, since the audience and purpose differ.

Can AI write commit messages directly from a git diff?

Yes — pasting a diff gives the model concrete evidence of what changed, which produces far more accurate messages than describing the change from memory. Most models handle diffs of a few hundred lines well in a single prompt.

Should I use Conventional Commits format for AI-generated messages?

If your team already uses Conventional Commits (feat:, fix:, chore:, etc.) tooling for changelogs or semantic versioning, specify that convention explicitly in the prompt — otherwise the model will default to a freeform style that your tooling can't parse.

Which Cuelara tool can help me refine this prompt for my team's exact PR template?

Prompt Optimizer — its Coding mode is built for exactly this kind of structured, engineering-specific prompt and can adapt the template's sections to match your team's existing PR checklist.

Found this prompt useful? Share it.

Share

More in Code Generation & Software Engineering

Code Generation & Software Engineering

AI Prompt to Write a GitHub Actions CI/CD Workflow from Plain English

This is a prompt for turning a plain English description of your build, test, and deploy process into a working GitHub Actions workflow YAML…

Role: You are a DevOps engineer writing a GitHub Actions workflow file.

Context:
Project type: [LANGUAGE/FRAMEWORK, e.g. Node.js with npm, Python with Poetry]
Repository structure notes: [e.g. monorepo with /api and /web folders, single app at root]
Runner: [e.g. ubuntu-latest]

Task:
Write a GitHub Actions workflow (.github/workflows/[FILENAME].yml) that does the following, in this order:
1. Trigger on: [TRIGGER EVENTS, e.g. pull_request to main, push of tags matching v*]
2. Job 1 - [JOB NAME, e.g. lint]: [WHAT IT DOES]
3. Job 2 - [JOB NAME, e.g. test]: [WHAT IT DOES], must run only after Job 1 succeeds
4. Job 3 - [JOB NAME, e.g. deploy]: [WHAT IT DOES], must run only after Job 2 succeeds and only on [CONDITION, e.g. tag pushes to main]

Secrets/environment variables needed (reference by name only, do not invent values): [SECRET NAMES, e.g. DEPLOY_TOKEN, AWS_ACCESS_KEY_ID]

Constraints:
- Pin third-party actions to a specific major version (e.g. actions/checkout@v4)
- Use caching for dependencies where the ecosystem supports it
- Keep job names and step names descriptive enough to read clearly in the Actions UI

Output format:
Return the complete YAML file in a fenced code block, followed by a short bullet list explaining what each job does and when it runs.

Make this prompt yours

Code Generation & Software Engineering

AI Prompt to Debug a Failed Vercel Deployment Using Vercel's MCP Server

This Vercel MCP prompt helps developers and DevOps engineers figure out why a deployment failed without manually scrolling through build log…

ROLE: You are a deployment troubleshooting assistant with access to Vercel's MCP server.

CONTEXT:
- Project: [PROJECT_NAME]
- Framework: [FRAMEWORK, e.g. Next.js 14]
- Deployment ID or URL: [DEPLOYMENT_ID_OR_URL]
- Last known good deployment: [PREVIOUS_DEPLOYMENT_ID_OR_URL, or 'none']
- What changed since the last successful deploy: [RECENT_CHANGES_SUMMARY]

TASK:
1. Retrieve the build and runtime logs for the failing deployment.
2. Identify the failure category: build error, runtime error, environment/configuration issue, or dependency issue.
3. Quote the specific log lines that show the root cause.
4. If a last known good deployment is provided, compare configuration and environment variables between the two.
5. Propose a ranked list of likely fixes, most probable first.

CONSTRAINTS:
- Do not guess at a cause without quoting supporting log evidence.
- Flag if critical information (e.g. an environment variable value) is missing rather than assuming it.

OUTPUT FORMAT:
- Failure category
- Root cause (with quoted log evidence)
- Ranked fix recommendations
- Any missing information needed to confirm the diagnosis

Make this prompt yours

Code Generation & Software Engineering

ChatGPT Prompt to Generate a Production-Ready Dockerfile for Your App

This Dockerfile generator prompt gives ChatGPT, Claude, or Gemini everything needed to write a secure, production ready Dockerfile for your…

You are an expert DevOps engineer who writes secure, production-ready Dockerfiles.

Context:
- Application language and version: [LANGUAGE AND VERSION, e.g., Node.js 20]
- Framework: [FRAMEWORK, e.g., Express, Django, Spring Boot]
- Package manager: [PACKAGE MANAGER, e.g., npm, pip, Maven]
- Target deployment platform: [PLATFORM, e.g., AWS ECS, Kubernetes, linux/amd64]
- Special requirements: [e.g., private package registry, native dependencies, health checks]

Task:
Write a production-ready Dockerfile for this application. Use a multi-stage build that separates the build/dependency-install stage from the final runtime stage. The final image should:
1. Use the smallest reasonable base image for the runtime.
2. Run as a non-root user.
3. Only copy the files needed to run the application, not build tools or source maps.
4. Include a HEALTHCHECK instruction appropriate for this type of service.
5. Set any necessary environment variables and expose the correct port.

Constraints:
- Do not use the "latest" tag for any base image; pin a specific version.
- Keep the final image size as small as possible.
- Explain, in a short comment above each non-obvious instruction, why it's there.

Output format:
1. The complete Dockerfile in a single code block.
2. A short bullet list explaining the base image choice and any trade-offs.
3. One suggested .dockerignore entry list for this stack.

Make this prompt yours