Live data from Hacker News

If AI writes code, should the session be part of the commit?

github.com

111–120 of 410 posts

Re: If AI writes code, should the session be part of the commit?

#111
post #94

IMO: This might be a contrarian opinion, but I don't think so. Its much the same problem as asking, for example, if every single line you write, or every function, becomes a commit. The answer to this granularity is, much like anything, you have to think of the audience: Who is served by persisting these sessions? I would suspect that there is little reason why future engineers, or future LLMs, would need access to t…

> Its much the same problem as asking, for example, if every single line you write, or every function, becomes a commit.

Hmm, I think that's the wrong comparison? The more useful comparison might be: should all your notes you made and dead ends you tried become part of the commit?

Re: If AI writes code, should the session be part of the commit?

#113
post #94

IMO: This might be a contrarian opinion, but I don't think so. Its much the same problem as asking, for example, if every single line you write, or every function, becomes a commit. The answer to this granularity is, much like anything, you have to think of the audience: Who is served by persisting these sessions? I would suspect that there is little reason why future engineers, or future LLMs, would need access to t…

First N prompts is a good / practical heuristic for something worth storing (whether N = 1 or greater).

Re: If AI writes code, should the session be part of the commit?

#114

A few things really leveled up both my software quality and my productivity in the last few months. It wasn’t session history, memory files, context management or any of that. 1. Writing a spec with clear acceptance criteria. 2. Assigning IDs to my acceptance criteria. Sounds tedious, but actually the idea wasn’t mine, at some point an agent went and did it without me asking. The references proved so useful for guidi…

> Assigning IDs to my acceptance criteria. Sounds tedious, [...]

Might be tedious for a human, but agents should do that just fine?

Re: If AI writes code, should the session be part of the commit?

#115
Yes, it should remain part of the commit, and the work plan too, including judgements/reviews done with other agents. The chat log encodes user intent in raw form, which justifies tasks which in turn justify the code and its tests. Bottom up we say the tests satisfy the code, which satisfies the plan and finally the user intent. You can do the "satisfied/justified" game across the stack.

I only log my own user messages not AI responses in a chat_log.md file, which is created by user message hook in the repo.

Re: If AI writes code, should the session be part of the commit?

#116

Conceptually this is very similar to the question of whether or not you should squash your commits. To the point that it's really the same question. If you think you should squash commits, then you're only really interested in the final code change. The history of how the dev got there can go in the bin. If you don't think you should squash commits then you're interested in being able to look back at the journey that…

I think this is the right analogy, contrary to some other very poor ones in this thread. Yes, it is rare to really look at commit messages, but it can be invaluable in some cases. With vibe-coding, you risk having no documentation at all for the reasoning (AI comments and tests can be degenerate / useless), but the prompts, at bare minimum, reveal something about the reasoning / motivation. Whether this needs to be i…

Depending on the size it might make sense as a kind of commit metadata reference to external, like the signed-off-by field.

Chat-Session-Ref: claude://gjhgdvbnjuteshjoiyew

Perhaps that could also link out to other kinds of meeting transcripts or something too.

Re: If AI writes code, should the session be part of the commit?

#117

Obviously yes, at least if not the prompts in the session, some simple / automated distillation of those prompts. Code generated by AI is already clearly not going to be reviewed as carefully as code produced by humans, and intentions / assumptions will only be documented in AI-generated comments to some limited degree, completely contingent on the prompt(s). Otherwise, when fixing a bug, you just risk starting from…

> Obviously yes

I don't think this is obvious at all. We don't make the keystroke logs part of the commit history. We don't make the menu item selections part of the commit history. We don't make the 20 iterations you do while trying to debug an issue part of the commit history (well, maybe some people do but most people I know re-write the same file multiple times before committing, or rebase/squash intermediate commits into more useful logical commits. We don't make the search history part of the commit history. We don't make the discussion that two devs have about the project part of the commit history either.

Some of these things might be useful to preserve some of the time either in the commit history or along side it. For example, having some documentation for the intent behind a given series of commits and any assumptions made can be quite valuable in the future, but every single discussion between any two devs on a project as part of the commit history would be so much noise for very little gain. AI prompts and sessions seem to me to fall into that same bucket.

Re: If AI writes code, should the session be part of the commit?

#119
post #2

I’ve been thinking about a simple problem: We’re increasingly merging AI-assisted code into production, but we rarely preserve the thing that actually produced it — the session. Six months later, when debugging or reviewing history, the only artifact left is the diff. So I built git-memento. It attaches AI session transcripts to commits using Git notes.

The former GitHub CEO has a startup and this was their first release. They call it checkpoints: https://entire.io/

I copied it for my own tooling to make it work a bit better for my workflows.

Re: If AI writes code, should the session be part of the commit?

#120
post #14

Why should it be? The agent session is a messy intermediate output, not an artifact that should be part of the final product. If the "why" of a code change is important, have your agent write a commit message or a documentation file that is polished and intended for consumption.

It should be a distillation of the session and/or the prompts, at bare minimum. No, it should not include e.g. research-type questions, but it should include prompts that the user wrote after reading the answers to those research-type questions, and perhaps some distillation of the links / references surfaced during the research. Prompts probably should be distilled / summarized, especially if they are research-based…

> It should be a distillation of the session and/or the prompts, at bare minimum.

Huh, I thought that's what commit message is for.

Post reply on HN