
How I use AI, Raycast, and Lazygit to help me write better commit messages
28 May, 2025
0
0
0
Contributors
In this blog post, I will explain how to use the Raycast AI feature to write effective Git commit messages and explore Lazygit to automate this process.
Essentially, the idea is to press one or two keys to commit changes with a generated commit message by AI that has good context about your work.
When I say good context, I mean that it understands the task (we just need to have the task open in a browser tab, whether it's Jira, a GitHub issue, or anything else), the files you changed, and a summary that you provide.
Raycast
Raycast has a nice feature called AI Commands, which allows you to add instructions and placeholders, making it easier to call the command later.
These instructions come with placeholders that make the command highly customizable.
In my case, I use the
{argument name="I did:"}
placeholder. Before Raycast runs the AI command, it asks me, "I did:" so I can write a brief summary of what I did.
I include browser
and web
context since in my prompt I include reference to conventional commits documentation
I added the {browser-tab}
placeholder because before asking the AI to generate the commit message, I open the browser tab containing the issue or ticket I worked on. This allows the AI to access the page and gain more context about the task.
Finally, I added the {clipboard}
placeholder, which will contains the git diff results obtained using git diff --cached -U4
. The -U4
option includes four lines before and after the changes.
Lazygit
Lazygit is not necessary, but it makes my work with Git easier by providing a highly customizable shell interface that I can use.
To make my job easier, I created a custom command for Lazygit to:
- Ask me for a summary of the changes I made.
- Get the diff using the git diff command.
- Open a Raycast deeplink for the AI command I created earlier, with the argument being the summary and the git diff already in the clipboard.
Following the command.
- key: '<c-d>'
context: 'files'
description: 'Copy diff changes'
command: 'git diff --cached -U4 | pbcopy && open "raycast://ai-commands/generates-git-commit?arguments="{{.Form.Explain | quote}}""'
prompts:
- type: 'input'
title: 'Explain the changes'
key: 'Explain'
initialValue: ''
With this configuration, when I press Ctrl + d
in Lazygit, a prompt will open asking me for the summary.
Then it will copy the diff and launch the Raycast AI Command with everything in place.
I just need to copy the generated commit message created by AI based on your summary, the git diff, and the opened webpage.
And paste into Lazygit
Summary
Raycast is ideal for this because we can use these placeholders to dynamically provide context for AI. Additionally, with their extension, the AI utilizes the browser tab containing information about the task, allowing us to focus on writing effective prompts.