Skip to content

feat(commit): add AI-generated commit message support. (v2)#5395

Open
Blankeos wants to merge 2 commits intojesseduffield:masterfrom
Blankeos:feat/ai-commit-message-cli-2
Open

feat(commit): add AI-generated commit message support. (v2)#5395
Blankeos wants to merge 2 commits intojesseduffield:masterfrom
Blankeos:feat/ai-commit-message-cli-2

Conversation

@Blankeos
Copy link

PR Description

This is a simplified version of this PR #5389. I removed the OpenAI-compatible integration. Instead, it purely relies on a command.

lazygitai-generate-opt.mp4

Adds support for generating commit messages from staged changes using AI, via CLI only.

git:
  commit:
    # Using claude
    aiGenerateCommand: "claude -p 'Generate a conventional commit message for this diff.'"
    # Using opencode
    aiGenerateCommand: "opencode run 'Generate a conventional commit message for this diff.'"
    # Using modelcli
    aiGenerateCommand: 'DIFF=$(git diff --cached) && modelcli "Generate a conventional commit message for this diff. Always provide a bulletpoint body. $DIFF"'

I also made modelcli just for this btw, it has the same exact UX for managing model connections to models.dev as OpenCode... Only simpler, it's not an agent or harness so the start up is faster. (Also in 🦀 rust). This is for people that don't have coding agents installed.

Please check if the PR fulfills these requirements

  • Cheatsheets are up-to-date (run go generate ./...)
  • Code has been formatted (see here)
  • Tests have been added/updated (see here for the integration test guide)
  • Text is internationalised (see here)
  • If a new UserConfig entry was added, make sure it can be hot-reloaded (see here)
  • Docs have been updated if necessary
  • You've read through your own file changes for silly mistakes etc

# stripped automatically).
# Accessible via the commit menu (<c-o> then 'a').
# Example: "claude -p 'Generate a conventional commit message for this diff:'"
aiGenerateCommand: ""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why call this ai, this is a command to generate the commit. Has nothing to do with ai.

Copy link
Author

@Blankeos Blankeos Mar 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call..

Was also thinking of calling it just generateCommand.

Though what do you suggest I hardcode this 'copy' value with?
Generate commit mesage w/ 'generateCommand'?

Or should that copy be configurable? (view here https://github.com/jesseduffield/lazygit/pull/5395/changes#diff-3eb5426752dae525c92f1ecce2f7215d15bfdec91bd459e08f78574876583910)

image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generate commit message

Would be good enough for me or the first version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants