Someone in the Indy Hackers Slack shared the following post:
I had also run into this problem while coding with AI agents. This seemed like an opportune time to write up some thoughts to hopefully save others some time and agony.
Sometimes this issue happens to me because I get too confident in the current work direction and have not committed in a while. And then one or two prompts later, I have a broken or confusing set of changes.
Or, as Rands's post mentions, sometimes the AI agent purposely or accidentally reverts some changes and can't recover them. Several versions ago, when Claude Code compacted context, it would also clear the terminal, so if it couldn't remember the changes, then I would be unlikely to recover.
Enter jj
To try to combat this problem, I've been setting up and using Jujutsu (henceforth jj) instances for the repos that I have. jj keeps track of every filesystem change in your repo. So you can use its history to see and restore changes that might have otherwise gotten lost. It also works fairly seamlessly with git, which basically all of my projects use at this point. It also doesn't affect other users of your projects. So in my mind there are basically no downsides to setting it up.