⟵ Home

A Better Conventional Commit?

July 07, 2025 ∙ 2 minute read

Today I found a post from Sarah Mathey that makes very good points regarding conventional commits. I’ll quote a few here:

According to the git-commit manpage, it’s “a good idea to begin the commit message with a single short (no more than 50 characters)”. This commit message lands at 71 characters. Personally, I would have put something like “Fix array parsing when input has multiple spaces”. Smaller, and also complies with recommendations from the git documentation.

The type of a commit here is only really useful for automated tools, usually the type can be inferred from the summary of the commit. As such, I think the type would be better off as a field in footer of commit, under a key such as Commit-Type or Type.

But why make an exception for BREAKING CHANGE ? Why not have it as Breaking-Change ? It’s not like it adds or remove any character, all that would change is it would stay consistent with other keys.

That makes so much sense. And folks, we’re just a --trailer away from making this work as it should.

Now for the facts: I do use conventional commits, as it is — as Sarah said — useful for automated tools, and every time I make a commit message larger than it should be, I do feel bad. However, adding --trailer for each commit and for each property would be cumbersome. So why not make a wrapper for git commit to handle that?

The Idea

What if we could do something like git commit --chore --breaking -m "Message here" and get those fancy trailers? Of course, we have some commits like chore(some-component): Some description, so let’s also allow --chore to accept an optional parameter. I’m low on imagination today, so let’s call this “Pretty Commit”, and alias it as pc. Here are some possibilities:

git pc --chore component -m "Commit message"
# or
git pc --spec -m "Commit message"
# or even
git pc --feat "Tokenizer" --breaking -m "Allow tokenizer to do a backflip"

And the result from the last commit:

commit 4decde3d186a834a092676d3143fae6f7a54945a (HEAD -> master)
Author: Vito Sartori <[email protected]>
Date:   Mon Jul 7 10:50:22 2025 -0300

    Allow tokenizer to do a backflip

    Type: feat
    Scope: Tokenizer
    Breaking: true

All parseable! Let’s, for instance, get the meta from this commit:

 λ | git log -1 --pretty=format:"%B" | git interpret-trailers --parse
Type: feat
Scope: Tokenizer
Breaking: true

That’s so much easier to parse than extracting stuff from the commit message alone. Git plumbing has everything everyone ever needed.

I’ll try using this approach and also use it as a reason to bump heyvito/semver-releaser.

Can I use it?

Of course! Git is composable, meaning you just need to have git-pc in your PATH. Then git pc is immediately available. The source is available at github.com/heyvito/git-pc, and is a (very) simple bash script — as far as ‘simple’ and ‘bash’ can go together.

Contributions are welcome!

What else?

If you didn’t, read Sarah’s post. It’s full of insights and was what made me do this. Also, Tyler Cipriani posted about Git Notes, which is another feature that goes unnoticed.

And that’s it for today. Let’s see if we can push this forward!