Contextual commits – An open standard for capturing the why in Git history

(vidimitrov.substack.com)

19 points | by vidimitrov 3 hours ago ago

15 comments

  • teeray an hour ago ago

    It continually amazes me how averse people are to just explaining why a commit exists in the body of the commit. Is all this tagging actually easier to read than written prose? You don’t even have to write it anymore if the sight of your editor opening upon `git commit` causes some instinctual revulsion.

    • vidimitrov 37 minutes ago ago

      The problem is that usually we don't write the WHY in the commits... We tend to always capture the WHAT in the form of prose. And for agents, this is just more noise, since all they need is just the diff to reconstruct the WHAT.

      I've never seen someone write decisions or the intent they started with in commit messages. Even the solutions today that auto-generate commit messages just summarise the diff.

      This was helpful when humans were the only ones reading the history. But for agents its useless.

      • 0x457 9 minutes ago ago

        Because commit history is here to explain WHAT and not WHY. "Why" is explained by a decision log such as ADR which can be store in the same repo and can be mutated in the same commit that has WHAT in its commit body.

        But also, if you look at large projects like Linux or FreeBSD, commits there explain why as well.

      • skydhash 18 minutes ago ago

        > I've never seen someone write decisions or the intent they started with in commit messages

        You may not have seen enough good repos. The following is an example commit from freebsd

        https://cgit.freebsd.org/src/commit/?id=ac5ff2813027c385f903...

        A proper email is like an email. You have the first line as the subject and it may be enough to explain the intent of the diff. But sometimes it’s not enough and you add more details in the body. I strongly believe that people who write the WHAT again don’t know that there’s a diff attached to the commit and think of them a separatete objects. GitHub and VSCode do not really help in that regard.

        • vidimitrov 14 minutes ago ago

          This looks very good. Thanks for sharing. I can only imagine how much discipline it takes to write these kinds of commits manually.

          • skydhash 7 minutes ago ago

            Is it discipline?

            When you think of the patch as an unit of idea and the commit as the means to convey that idea, it takes the same amount of effort to write an email message.

            BTW you do not have to write those for every single commit. You can always rebase interactively and create a final set of commits for sharing. No one cares about what’s in your local copy of the repo.

  • stephbook 18 minutes ago ago

    > intent(auth): users need social login, starting with Google before GitHub and Apple

    Your 'intent' is 'users need social login'? That does not make sense.

    Your intent is 'Getting more users by lowering barriers to sign up', a business goal. That business goal might have hierarchical children – for example, Jira epics – such as 'offer social sign-in', or 'declutter landing page.'

    Also, the commit mentions 'Google before GitHub', but how can a commit (a snapshot of the repository) know the future? What if your product manager decides Google is fine enough and GitHub/Apple aren't needed?

    I wish our profession would stop trying to reinvent issue tracking in git every week.

    • svstoyanovv 8 minutes ago ago

      I understood the example, and it could be a minor hiccup there, but the essence is different:

      By having a structured context of the key session discoveries, decisions, rejected items (if there were past commits with decisions that had been rejected, etc..) you achieve a type of contextual storage of the reason, thus after a month, when a team member wants to start working on a task that you have touched, and now forgot since you are doing ai-assisted coding and pr throughput is to sky right now, your collegue at least will know the rational behind the decission and working with his agent, the agent will produce more reliable code not introducing something for the sake of solving the task.

  • agateau an hour ago ago

    Would be curious to know if it works better than writing the Why as human-friendly paragraphs in the body of the commit message.

    • vidimitrov an hour ago ago

      A few examples are the ability to query historical data and using each action line as a signal for other tooling to build on top but there are many others… you can check what Conventional Commits did in the past and what they unlocked only by introducing structure to commit subjects

  • keybored 42 minutes ago ago

    > an open standard for capturing the WHY in git history

    Agentic coding keeps reinventing coding.

    That was my first thought.

    > And then it hit me - the commit body has always been there. Completely underutilised.

    Wait. What? This is the standard?

    > Here is an example of how a Contextual Commit looks:

    The format is key-value stuff. You can already use trailers for that. The syntax here doesn’t work with that stuff.

    If you have already readh the “conventional commits” (pronounce with a sneer) specification you have already seen them. They’re called footers because they also didn’t know about trailers.

    > No new tools. No infrastructure. Just better commits.

    Okay, let’s cut right to the point..

    • vidimitrov 20 minutes ago ago

      Trailers were not suitable for the use case.

      The scope in parentheses is doing real work. `rejected(oauth-library)` lets you do `git log --grep="rejected(auth"` to find every rejected auth decision across history.

      If you flatten it to a trailer token you either lose the scope or encode it awkwardly as `Rejected-auth-oauth-library: value`, which doesn't grep cleanly and doesn't parse naturally.

      • vidimitrov 19 minutes ago ago

        The format is optimised for agent querying and human readability in `git log`, not for `git interpret-trailers` compatibility. Those are different use cases.

      • skydhash 13 minutes ago ago

        I think those are better suited to an issue tracker. As for changes that affected the source code, you can grep the patch in the git log too.

        • vidimitrov 8 minutes ago ago

          Issue trackers are full of intent and decisions, that's true, but that's not the point here... It's about a storage that agents can use natively without the need of callings external APIs or MCPs.

          And there is a slight difference between what you capture in issue trackers and what happens in reality in coding sessions.