This configuration enables you to generate high-quality, AI-powered commit messages directly from Lazygit, leveraging Raycast’s AI commands. It streamlines the process by copying your staged diff, prompting you for context, and opening Raycast to generate a commit message in your preferred language and style.
-
Trigger the Command in Lazygit
- In the Lazygit
filesview, pressCtrl+D(<c-d>). - This runs a custom command defined in your
lazygit/config.yml.
- In the Lazygit
-
Prompt Sequence
- Explain the changes: You’re prompted to briefly describe what you changed.
- Choose language: Select your preferred language for the commit message (English or Português).
- Choose convention: Select the commit message style (standard
git-commitorgit-conventional-commit).
-
Copy Diff to Clipboard
- The command copies the current staged diff (
git diff --cached -U4) to your clipboard usingpbcopy.
- The command copies the current staged diff (
-
Open Raycast AI Command
- Lazygit opens a Raycast AI Command via a Deeplink, passing your summary, branch name, and language as arguments.
- Raycast receives the clipboard diff and your inputs, then generates a commit message using AI.
git diff --cached -U4 | pbcopy: Copies the staged changes (with context) to your clipboard.- Prompts: Collects your summary, language, and commit style.
- Raycast Deeplink: Opens a Raycast AI Command, passing your inputs as arguments. Raycast then uses the clipboard diff and your context to generate a commit message.
- Lazygit: With custom commands enabled.
- Raycast: With the relevant AI Command set up to accept arguments and generate commit messages.
- macOS: Uses
pbcopyandopencommands.
- Fast: No need to leave Lazygit or manually write commit messages.
- Consistent: Enforces your preferred commit style and language.
- AI-powered: Leverages Raycast’s AI to summarize your changes accurately.
You can find more details on https://ridermansb.dev/article/83307/how-i-use-ai-raycast-and-lazygit-to-help-me-write-better-commit-messages