Automatically generate commit messages with OpenCode
AI is fine for vibe-coding, but I prefer to introduce my own “checkpoints” via commits.
I like to make a working, logical “chunk” of changes, and commit that atomic unit.
When Claude Code automatically generates commits, it’s basically per-prompt. But with all of the back-and-forth, I’d need to rebase or squash them.
prepare-commit-msg
Git has several hooks available.
When you run git commit WITHOUT a message, I’m using prepare-commit-msg hook to generate one for your using opencode.
$ git commit
🤖 Generating default commit message (model: opencode/grok-code)…
Then, your default $EDITOR opens per usual with a message you can customize:
Update opencode permission key from edit to write
- Change "edit" to "write" in the OPENCODE_PERMISSION_JSON
- Ensures consistency with updated permission naming
🤖 Generated by opencode/grok-code
Finally, your git commit completes as usual:
$ git commit
🤖 Generating default commit message (model: opencode/grok-code)…
[eric 7c280ef] Update opencode permission key from edit to write
1 file changed, 1 insertion(+), 1 deletion(-)
Installation
With husky in your project, create .husky/prepare-commit-msg with the following content: