For most of my life I haven’t been a big believer in version control. It’s certainly useful when working with others but for solo work I mostly just viewed it as backups with extra steps. Now the agentic coding age has turned all of us into collaborators and I’m finding out I have preferences for version control. In particular I am enjoying using jujutsu.
The most important thing with agent coding is making sure you can easily review code and that it’s easy to throw away work. The main problem being that the LLM can regurgitate code way faster than you can read. So we need strategies. In particular I follow the principle that I strive to only review code once: reading over the same code repeatedly is a sure way to slow yourself down.
You give up on the ability to catch the LLM early before it gets too
far off the rails. But now code is cheap VC subsidized (and for work
covered by my employer anyways). Me reviewing everything slows things
down far more than throwing away a bunch of code that’s not quite
right.
Consider this workflow:
- Start with an empty commit
jj describewhat we want to do andjj new - Let the agent do its work in this commit.
- As the agent keeps going make commits in logical chunks
- While the agent is working on the next commit go back and review the older commits.
- Branch off with manually make code changes or just add TODOs for the agent.
- Once you’re happy with the revisions squash back into the original commit. You can try to let the agent handle merge issues (but might need to step in especially if the rest of the code built off a flawed approach). Jujutsu has first-class conflicts so it’s completely fine to have a broken directory that you fix at your leisure.
- If the generated code is garbage
jj abandonthe whole thing and try again.
@ Agent's latest work (rebased and merged)
|
O My manual edits/fixes
/|
O | Agent's checkpoint 2
| |
| O Agent's checkpoint 1
|/
O Start: Empty commit (jj describe)
The flexible ability to manipulate commits distinguishes jj from
git for me. Jujutsu has automatic snapshotting so I don’t have to
mess with a staging area and git add ing or git stash ing for all
of my intermediate work. Commits are mutable (until pushed) so I can
keep agglomerating changes as they occur to me [I have so many git
commits that are 1 line follow-ups for typos; I now just jj absorb
]. Of course the nice thing is that it’s backed by git so it’s fully
compatible with all of my existing repos as well as collaborators
still using =git=/github.
Your agent also probably likes jujutsu: a couple times I’ve seen in
the thread it’s like “jj undo is so helpful” for unwinding things
that didn’t go well.
jj workspace add is helpful for working with multiple agent threads
in parallel. It makes a mirror directory with linked commits so you
can have one agent in each directory and they won’t interfere with
each other. I find this most helpful when exploring speculative
directions: spin off a trio of approaches and see which performs best
and drop the rest.
Agentic coding is making version control a more vital practice than before. We might as well enjoy it with version control tools suited to the moment. If you’re just getting started I recommend this tutorial.