I think you can partially accomplish automatic custom commit messages with a button click using the following:
A markdown file describing your commit instructions with a prompt on a repo
The doc crawling feature of cursor
The @Commit (Diff of Working State or @PR (Diff with Main Branch contexts.
You can even support custom flags of your own. Here is what I do which combines some cool tricks I learned in this forum and the things I figured out by myself after spending quite some time with cursor.
Add the URL of the markdown prompt as a doc to cursor (Cursor -> Settings -> Cursor Settings -> Features -> Docs -> Add new doc)
Name it as @create-commit or something similar
When you wanna commit just use cursor chat to call your commit prompt with the diff context.
@create-commit @Commit (Diff of Working State)
or
git diff | pbcopy in your terminal and than @create-commit <paste-with-command-v> in cursor chat (as mentioned above, there is no context for the staged changes in cursor yet)
If you manage the force the prompt to output the git commit under a markdown codeblock with bash as the language in your prompt(claude-3.5-sonnet seems quite consistent for me as well as figuring out the changes the way I want) than this makes it runnable in yor shell creating a run button, on top right corner.
Funny enough, this is exactly what Iâve been doing for the past weeks I even configured it to give me the âgit addâ command and to split the diffs into multiple commits if necessary. Now I almost just need to one click ârunâ
The only (important) downside : the @gitdiff does not return file removals and file additions⌠Always double check !
This looks similar to my workflow. I tend to stage my files regularly and then look at diff --staged. Really wish cursor would have an option for that as I often find myself doing diff --staged > diff.txt and then using @diff.txt to discuss the changes.
BTW I do this for quite a bit more than just commit comments. I have found that when working with Cursor or other ai coding tools it is super helpful to produce design docs that are designed to provide context for the ai. I use cursor to help me write the docsâoften referring to previous commits for contextâand then commit them to my repo and use them as the PR context. This allows the LLM prompts to get way more done correctly with fewer unplanned passes.
Honestly it works great 99% of the time (appart from the missing staged files context of course).
What could be improved is the prioritization of context. It will sometimes assign a âchoreâ type with a simple chore task (which is good) but then in the description will include âCreated NewComponent in layoutâ which should be a âfeatâ commit on itâs own.
Here is what I have added at the end of my prompt template :
You should create different commits if there are multiple changes. Each output should be a valid git commit command. Each output should be a separate executable command. Each output should group changes closely related to each other into a single commit.
Output format (one per commit):
```bash
git add [file1] [file2] ...
git commit -m "<type>[optional scope in lowercase]: <description>
[optional detailed body description]
[optional footer(s)]
"
```_
FYI: the â_â at the end can be removed, itâs only for the quotes to show up in the code snippet