Protecting Your Code from AI Mishaps: Why Jujutsu Should Be Your Safety Net
When AI Goes Wrong: A Developer's Nightmare
We've all been there. You're in a coding flow with an AI agent—maybe Claude, Gemini, or another LLM-powered tool—and suddenly something goes sideways. The agent misunderstands your request and runs git clean on untracked files. Your hours of experimental work vanish into the void. Or context gets pruned, the terminal clears, and the AI forgets what it was doing mid-task. When you ask it to undo the damage, you get an apologetic message: "I can't recover those files—they weren't committed to Git."
This scenario is becoming increasingly common as developers adopt AI coding assistants. And here's the uncomfortable truth: traditional Git workflows aren't optimized for the chaotic, iterative nature of AI-assisted development.
The Problem with Traditional Git
Git is a powerful tool, but it requires intentional commits. You have to consciously decide to save your work at meaningful checkpoints. With AI agents running rapid iterations, this creates a dangerous gap. You might get confident mid-session and forget to commit. Or the AI might make several changes, encounter issues, and revert them before you've had a chance to save anything meaningful.
The real nightmare? When an AI agent destructively modifies your repository and you can't recover the work because it was never formally committed.
Enter Jujutsu: The Safety Net for AI-Era Development
Jujutsu (or jj as developers call it) is a version control system designed with a fundamentally different philosophy. Instead of waiting for you to commit, jj automatically snapshots your working directory every time you run a command. This means every change, every experiment, every accidental deletion is preserved in the operation log.
Think of it as Git with an obsessive memory. While Git tracks commits you explicitly make, Jujutsu tracks everything that happens to your repository—whether you intended it or not.
Getting Started: Zero Friction Setup
The best part? You don't have to choose between Git and Jujutsu. They work together beautifully.
Setting up jj in an existing Git repository is trivial:
jj git init --colocate
That's it. Jujutsu now operates alongside your existing Git workflow. Your teammates won't even know you're using it—it's completely transparent to them. When you push to the remote, you're still using Git as normal.
Understanding Jujutsu's Mental Model
Jujutsu uses a slightly different terminology than Git, but the core concepts are intuitive:
@(the working set): Similar to Git's working directory, but automatically snapshotted- Commit identifiers: Uses characters
[g-z]instead of hex, making them distinct from Git hashes - Operation log: A complete history of every change made to the repository
Here's what it looks like in practice:
$ jj
@ lrklqzxy panozzaj@gmail.com 2025-11-22 16:06:25 b76e8471
│ (no description set)
○ qppwxvzp panozzaj@gmail.com 2025-11-06 10:57:53 master
Add site perf audit document
The @ symbol represents your current uncommitted work. Each change gets a unique identifier. Unlike Git's hex-based hashes, jj uses a character set that makes them easy to spot and remember.
The Magic: Recovering Lost Work
Now for the moment where Jujutsu earns its place in your toolkit. Let's say an AI agent makes a destructive change. You can view the complete operation history:
jj obslog --revision @ --patch --limit 5
This command shows you the last 5 operations with full diffs. You can see exactly what changed, when it changed, and recover those changes by checking them out. Even if the AI deleted files, reverted changes, or corrupted your working directory, it's all logged.
Why This Matters for AI-Assisted Development
AI coding agents work differently than human developers. They:
- Make rapid-fire changes without human oversight
- Sometimes misinterpret instructions and make unintended modifications
- Lose context and context-aware state when conversations get long
- Can accidentally use destructive commands without realizing the consequences
Traditional Git workflows assume a human is in control of commits. AI-assisted development breaks that assumption. Jujutsu restores safety by treating every filesystem change as precious and recoverable.
Practical Workflow Integration
You can integrate Jujutsu into your AI coding workflow without changing your existing processes:
- Before starting an AI session: Note that jj is capturing everything
- During the session: Let your AI agent work freely—jj records every change
- If things go wrong: Use
jj obslogto find the exact moment before the problem - After cleanup: Commit your final changes to Git as usual
The beauty is that jj works beneath Git. You still push to GitHub, GitLab, or wherever using Git. But you have a complete safety net underneath.
The Minimal-Friction Approach
One of Jujutsu's biggest advantages is that it adds almost zero overhead:
- Installation is straightforward
- No changes needed to your existing Git workflows
- Teammates don't notice you're using it
- The colocation with Git means zero storage duplication
- Color-coded commit identifiers make them easy to distinguish
There are essentially no downsides to setting it up on projects where you work with AI agents.
Looking Forward
As AI coding assistants become more integrated into development workflows, tools like Jujutsu will become increasingly essential. The question isn't whether you'll lose work to an AI mishap—it's whether you'll have a way to recover it.
For anyone working regularly with Claude Code, Gemini CLI, or similar tools, setting up Jujutsu is insurance against the inevitable moment when AI and unintended consequences collide.
Your future self will thank you when you're able to recover hours of work with a simple command instead of watching it vanish into the Git void.