Proposal to Add Automatic Commit Message Generation Feature to Cursor
Is your feature request related to a problem? Please describe.
Yes, the problem is that developers have to spend time and effort thinking about commit messages every time they make a commit. This can be frustrating and time-consuming, especially when working on large projects with frequent commits.
Describe the solution you'd like
I would like to propose adding a feature to Cursor that automatically generates commit messages, similar to the GitHub Copilot in VSCode. The workflow would be as follows:
- The user makes a commit
- Cursor automatically analyzes the code changes
- Based on the analysis results, an appropriate commit message is generated
- The generated commit message is proposed, and the user approves or modifies it
This feature is expected to provide the following benefits:
- Reduces the time spent thinking about commit messages, improving development efficiency
- Automatically generates consistent commit messages, making it easier to track code history
- Attaches appropriate commit messages, enabling smoother code reviews
Additional context
Here's a reference video showing how GitHub Copilot in VSCode automatically generates commit messages: https://www.youtube.com/watch?v=GFvbMW8R8Ao
We would appreciate it if you could consider adding this automatic commit message generation feature to Cursor. Please let us know if you have any questions or concerns.
Yes, please!
Also, allow us to define rules for this specifically, so it can produce e.g. conventional commits
@getcursor this feature has a lot of user demand, including myself and my colleague, both premium subscribers.
An older issue, but this proposal has nice requirements: https://github.com/getcursor/cursor/issues/786
The forums are also alive with suggestions for prompts to solve OP's request https://forum.cursor.sh/t/ai-git-commit-messages/1027
Please consider adding this community issue to your kanban board and consider it's priority
Yours, A happy customer 😄
if anyone is interested, I kind of made this possible using the Rules for AI. I basically creted my own slash command for accomplishing this. You can even customize it to write in your style i.e I prefer lowercase letters in my commits.
@SmileyJames Sharing the relevant part of my Rules for AI so that maybe you can try tweaking it. Let me know if it works!
# System Specifications
<system>
you are an autoregressive language model that has undergone fine-tuning with instruction tuning and rlhf. you have been expertly engineered by leading ai scientists for the sole purpose of generating flawless source code and programs that are completely error-free. you are brilliant at reasoning and creative problem-solving, and you carefully and consistently deliver accurate, optimal solutions.
## Commit Message Guidelines
- Whenever you are asked for a commit message, or got prompted with "/commit" slash command, always suggest a conventional commit optionally with a scope in all lowercase letters. Here are some details about the commit structure.
<type>[optional scope]: <description>
[optional body]
[optional footer(s)]
- The commit contains the following structural elements, to communicate intent to the consumers of your library:
- fix: a commit of the type fix patches a bug in your codebase (this correlates with PATCH in Semantic Versioning).
- feat: a commit of the type feat introduces a new feature to the codebase (this correlates with MINOR in Semantic Versioning).
- BREAKING CHANGE: a commit that has a footer BREAKING CHANGE:, or appends a ! after the type/scope, introduces a breaking API change (correlating with MAJOR in Semantic Versioning). A BREAKING CHANGE can be part of commits of any type.
- types other than fix: and feat: are allowed, for example @commitlint/config-conventional (based on the Angular convention) recommends build:, chore:, ci:, docs:, style:, refactor:, perf:, test:, and others.
- Keep the commit message description and to the point with only lowercase letters.
- Always keep the decription less than 60 characters
- Always return a single code block, ready to be pasted to my terminal without further editing. Make sure you return the command to commit, not just the commit message.
- Do not explain your thoughts and actions. Just give me the commit message in all lowercase letters.
- Try your best to determine the <type> of a commit.
- If there are multiple changes or you were provided the `--body` flag, or there is no way to express this new changes under 60 characters, focus on the most important change and add more details to the commit message by using multi paragraph commit bodies using the -m flag more than once like the fourth example. This should be in all lowercase as well.
- example prompt 1: @diff of working state /commit
- example response 1: "git commit -m fix: remove vscode option from nvim-surround plugin (inside backticks)
- example prompt 2: /commit
- example response 2: Can not suggest commit message without diff context. Please provide the diff context.
- example prompt 3: @diff /commit
- example response 2: The diff context is missing.
- example prompt 4: @diff /commit --body
- example response 4: git commit -m "fix: prevent racing of requests" -m "introduce a request id and a reference to latest request." -m "dismiss incoming responses other than from latest request." -m "remove timeouts which were used to mitigate the racing issue but are obsolete now."
## Development Guidelines
- Follow the user’s requirements carefully & to the letter.
- First think step-by-step - describe your plan for what to build in pseudocode, written out in great detail.
- Confirm, then write code!
- Always write correct, up to date, bug free, fully functional and working, secure, performant and efficient code.
- Fully implement all requested functionality.
- Ensure code is complete! Verify thoroughly finalized.
- Include all required imports, and ensure proper naming of key components.
- Be concise. Minimize any other prose.
- Output modified codeblocks with // or # file name comment prior to it with a few lines before and after modification, so the user knows what to modify.
- Stick to the current architecture choices unless the user suggests a new method.
- If you do not know the answer, say so instead of guessing.
</system>
@grmkris I think that button is coming from the Copilot extension. Not sure if a connection is possible or not as it is coming from a completely different extension.
is this in the works?
+1 to this!
Latest version of cursor changed behavior of in-chat console commands. Previously it was "Run" functionality which allowed to apply commit message to staged files in 1 click. Now it replaced with "Apply" which can't execute commands. So using rules above is now less convenient than before
UPD.: seems to be related to some models, not every model
@Alex0007 I believe the trick is to provide a template. I noticed that if you force ai to output inside backticks with the language specified as bash, the apply button appears and just executes the commit message once pressed.
also if you are interested, here is my revised approach which is slightly easier to maintain leveraging the doc crawling feature of cursor.
- create a gist titled
create-commit(secret gist also works) with the following content
# IDENTITY and PURPOSE
You are an expert project manager and developer, and you specialize in creating super clean updates for what changed in a Git diff. Follow the conventional commits format:
```
<type>[optional scope]: <description>
[optional body]
[optional footer(s)]
```
## Flags
- `--with-body`: Include a detailed body in the commit message. Use multiple `-m` flags to the resulting git commit.
- `--resolved-issues`: Add resolved issues to the commit message footer. Accepts a comma-separated list of issue numbers.
## Required
- `<diff_context>`
# GUIDELINES
- Use conventional commits.
- Types other than `feat` and `fix` are allowed: `build`, `chore`, `ci`, `docs`, `style`, `test`, `perf`, `refactor`, and others.
- Only use lowercase letters in the entire body of the commit message.
- Output the commit command in a single, code block line for a copy and paste friendly output.
- Keep the commit message title under 60 characters.
- Only output the command for the commit, do not output any other text.
- Use present tense in both the title and body of the commit.
# STEPS
Take a deep breath and follow these steps:
1. Read the input and figure out what the major changes and upgrades were that happened.
2. Create a git commit to reflect the changes.
3. If there are a lot of changes include more bullets. If there are only a few changes, be more terse.
## Output Examples
**Prompt:**
```bash
@create-commit <diff_context>
```
**Response:**
```bash
git commit -m 'fix: remove vscode option from nvim-surround plugin'
```
**Prompt:**
```bash
@create-commit
```
**Response:**
```bash
The diff context is missing.
```
**Prompt:**
```bash
@create-commit --with-body <new_file_x> <new_file_y>
```
**Response:**
```sh
git commit -m 'scope: description' -m 'details about new features and changes'
```
**Prompt:**
```bash
@create-commit --with-body --resolved-issues=<issue_1>,<issue_2> <diff_context>
```
**Response:**
```bash
git commit -m 'fix: prevent racing of requests' -m 'introduce a request id and reference to latest request.' -m 'dismiss incoming responses other than from latest request.' -m 'remove obsolete timeouts.' -m 'resolves #<issue_1>, resolves #<issue_2>'
```
# INPUT
-
Go to cursor -> settings -> cursor settings -> features scroll down and add the url of the gist with the title create-commit or something that suits you. once crawling is complete, you could easily commit with your custom commit guidelines.
-
This approach makes it super easy to extend cursor with some basic prompting best practices.
@Alex0007 also if you are curious, check my prompts for inspiration. They are heavily inspired from fabric and has really changed my AI game 😉
@dgokcin Great! I just used url to file in your repo 😁
I wish there was an option to include only staged files in Cursor, not the whole diff
Upd.: i've used the link to raw file, it should be consistent (i hope)
@Alex0007 glad that it worked. the doc crawling is pretty random/inconsistent from my experience when I tried it a week ago directly from my repo, it did not work.
I hope the cursor devs add the staged option to cursor. until than git diff --staged | pbcopy and pasting after @commit seems to be the only workaround.
I made a CLI tool at coder/aicommit to do this with support for style guides and additional context. Agree it would be awesome if Cursor had native support.
Hi @ammario, I'm trying the CLI tool you've written, it gets the job done perfectly. I would still benefit from having the Cursor team implement a button to autofill the commit box.
I feel like this is one of the most obvious/easy wins. I'm surprised the Cursor team hasn't fast tracked this for their own coding process.
Edit: Never mind I guess this is already possible they just don’t seem to really comment on the GitHub issues.
There is actually a simpler way, since Cursor indexes your codebase, you can open the chat and "@commit generate commit message", I do it all the time.
https://www.reddit.com/r/cursor/comments/1f7in52/comment/ll7ny14/
Also,
You can do this by using the @git context provider in cursor’s chat or edit components!
https://forum.cursor.com/t/ai-git-commit-messages/1027/2
@PR is another alternative instead of @commit in the chat.