💭 Use an llm to automagically generate meaningful git commit mes...
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

!https://harper.blog/2024/03/11/use-an-llm-to-automagically-generate-meaningful-git-commit-messages/

Date: April 11, 2024

Image: Use an llm to automagically generate meaningful git commit messages — I <https://harper.blog/images/social_card_bg_harper_hu_8387c1b95157265.png> Use an llm to automagically generate meaningful git commit messages I harper.blog

This is pretty sick, I wanted this early on when I was making lockhart. I wanted to do the [4m[38;2;248;248;242mgit[0m <[38;2;248;248;242m/glossary/git/[0m> hook thing but could not figure it out and did not know that [38;2;189;147;249mprepare-commit-msg[0m was a hook that I could use.

[38;2;248;248;242m│ [0mGit Hooked Then I remembered! Git hooks! Lol. Why would I have that in my brain - who knows!
[38;2;248;248;242m│ [0m
[38;2;248;248;242m│ [0mI asked claude again, and they whipped up a simple script that would act as a hook that triggers with the prepare-commit-msg event.
[38;2;248;248;242m│ [0m
[38;2;248;248;242m│ [0mThis is awesome, cuz if you want to add a git message, you can skip the hook. But if you are lazy, you exclude the message and it will call the LLM.

Simon Willison’s llm cli comes in clutch here, it has such a good intereface to allow a prompt to be piped in, but the system prompt be set by -s.

[38;2;248;248;242m[code][0m
  gpt = "!f() { git diff $1 | llm -s \"$(cat ~/.config/prompts/commit-system-prompt.txt)\" }; f"

[38;2;248;248;242m│ [0mI love hacking on projects, but often I am super bad at making commits that make sense.

I completely relate to this statement, and this is why I am trying it.

[38;2;68;71;90mNOTE[0m
[38;2;68;71;90m│ [0mThis post is a [4m[38;2;248;248;242mthought[0m <[38;2;248;248;242m/thoughts/[0m>. It’s a short note that I make about someone else’s content online #thoughts
