DEV Community

Cover image for Writing Commit Messages using AI from CLI (no API key)
jnsahaj
jnsahaj

Posted on

Writing Commit Messages using AI from CLI (no API key)

Disclaimer

Commit messages are important pieces of information, and serve as logical checkpoints for your work. I believe in writing informative commit messages that capture both the nuance and scope of the changes. The tool is an experiment to evaluate if AI-generated commit messages can fit in the workflow, if they can make it easier to write better commits.

The tool

I built an open-source CLI tool in Rust.
Check it out: https://github.com/jnsahaj/lumen. GitHub Repo stars

Features

  1. Generate commit message for staged changes
  2. Generate summary for changes in a git commit by providing its SHA-1
  3. Generate summary for changes in git diff (staged/unstaged)
  4. Fuzzy-search for the commit to generate a summary
  5. Free and unlimited - no API key required to work out of the box
  6. Pretty output formatting enabled by Markdown
  7. Supports multiple AI providers

Here's a demo that fuzzy-finds a git commit, and then generates a summary for it
Demo for lumen, generating commit summary

AI is bad at nuance

The LLM is good at capturing the "what" of the change, but it may not understand the "why" of the change. To help the AI, I added a --context flag

lumen draft
# Output: "chore(logs): Rotate log files daily"

lumen draft --context "reduce disk usage"
# Output: "chore(logging): Implement daily log file rotation to optimize storage"
Enter fullscreen mode Exit fullscreen mode

This allows for writing "lazy" commits that only capture the "why" of the change, leaving the "what" of the change to the AI

Conclusion

While I am apprehensive about writing commits using AI, and this tool might not be the most refined version of it, but I do believe it is a step in the right direction

Top comments (0)