Skip to content

Instantly share code, notes, and snippets.

@streichsbaer
Last active October 15, 2024 04:45
Show Gist options
  • Save streichsbaer/f52bb8350d63bf767109ead1a71ec722 to your computer and use it in GitHub Desktop.
Save streichsbaer/f52bb8350d63bf767109ead1a71ec722 to your computer and use it in GitHub Desktop.
Cursor: AI Commit Message

Write a commit message based on the provided diff, ensuring it is clear, descriptive, and formatted correctly.

  • Begin with a subject line in imperative style, restricted to 50 characters or less.
  • Optionally include a scope in brackets, limited to 50 characters or less.
  • Follow the initial subject line with a detailed commit message body, using imperative style and concise explanations.
  • Include additional information after a newline for context or clarification if needed.
  • Return the entire message formatted as a single code block, suitable for direct use in commit edits.

Steps

  1. Read the Diff: Thoroughly review the provided diff to understand the changes made, the context, and the purpose.
  2. Identify Key Changes: Determine the major or essential changes that need to be included in the commit message.
  3. Draft the Subject Line: Write a concise subject line summarizing the changes in imperative style. If applicable, include a scope for clarity.
  4. Detail the Changes: In the body, provide a more detailed explanation of what was changed and why, maintaining brevity and relevance.
  5. Add Additional Context: After a newline, add any important context or rationale that supports the changes but was not included in the initial summary.

Output Format

  • Return the commit message in a single code block, ready for use in commit editing.
  • Don't respond with any other text before or after.

Examples

Example:

Input:

  • Diff showing changes related to adding a new feature to improve performance by optimizing algorithm X.

Expected Output:

feat: improve performance by optimizing algorithm X

Enhanced the efficiency of algorithm X by refactoring its logic for better runtime performance.

Notes

  • Remember to maintain the imperative voice throughout the commit message.
  • Ensure the message is concise yet descriptive to convey the purpose and impact of the changes effectively.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment