The Problem With Experimenting When You're Still Learning
Here's a feeling I know too well: Claude Code suggests a change that sounds great. You say yes. It rewrites three files. Something breaks. You're not sure what changed. Now you're frantically Ctrl+Z-ing through your editor hoping you can undo your way back to safety.
I did this exact thing about two months into using Claude Code seriously. I asked it to "refactor the authentication flow" in a side project. It made 47 changes across 6 files. Half of them were good. The other half introduced a subtle bug I didn't catch until an hour later. And because I'd kept approving changes without any checkpoints, I had no clean snapshot to roll back to.
That painful afternoon taught me something important: the problem wasn't Claude Code's suggestions. The problem was that I had no safety net. I was experimenting on a tightrope with no net below me.
This article is about building that net. We're going to talk about using Git snapshots as a checkpoint system alongside Claude Code, and how to structure your workflow so you can experiment aggressively — because you know exactly how to get back.
Why Claude Code and Git Are a Natural Pair
Claude Code doesn't have a built-in "undo everything" button. It has file-level undo in some cases, and you can review diffs before accepting changes — but once you've accepted a batch of edits and moved on, rolling back gets messy fast.
Git, on the other hand, was literally designed for this problem. Every commit is a snapshot. Every branch is a sandbox. When you combine Claude Code's ability to make sweeping changes quickly with Git's ability to freeze and restore state, you get something powerful: a workflow where you can tell Claude "go wild" and mean it.
The core idea is simple. Before you start any significant Claude Code session, you create a checkpoint. Then you experiment freely. If things go sideways, you restore the checkpoint. If things go great, you commit the result properly and move on.
Let me walk you through how I actually do this.
Step 1: Create a Checkpoint Before Every Session
This is the habit that changes everything. Before you type your first prompt into Claude Code, do this:
# Before starting your Claude Code session
git add -A
git commit -m "checkpoint: before claude session - auth refactor"That's it. Two commands. You now have a named snapshot you can return to at any point. I prefix my checkpoint commits with "checkpoint:" so they're easy to spot in my git log and I know they're not "real" commits — they're safety nets.
Some people prefer to use a branch instead:
# Branch approach — isolate your experiment entirely
git checkout -b claude/auth-refactor-experimentThe branch approach is even cleaner when you're trying something speculative. Your main branch stays pristine. You work in the experiment branch. If it works, you merge. If it doesn't, you delete the branch and nothing was harmed.
Make Checkpointing a Ritual
I literally made it the first line of my CLAUDE.md file: "Always remind me to commit a checkpoint before making changes." Now Claude Code nudges me to do it before diving in. You can also just build the habit — two commands every time.
Step 2: Work in Smaller Batches, Not Giant Sessions
One of the easiest mistakes to make with Claude Code is treating it like a one-shot solution machine. You describe a big problem, it makes dozens of changes, you approve them all, and then you realize something's off but you can't pinpoint when things went wrong.
A better pattern is to break your Claude Code session into mini-experiments, each with its own checkpoint:
# Checkpoint before phase 1
git commit -m "checkpoint: before extracting auth helpers"
# ... Claude makes changes, you test them ...
# Phase 1 looks good? Commit it properly
git commit -m "refactor: extract auth helpers into utils/auth.js"
# Now checkpoint before phase 2
git commit -m "checkpoint: before updating login component"This way, if phase 2 goes wrong, you can roll back to after phase 1 — not all the way to the beginning. Your good work is preserved.
I think of it like saving a video game. You don't wait until the boss fight to save. You save every time you clear a room.
Step 3: Know How to Roll Back (So You're Never Panicking)
The whole point of this system is that rolling back is fast and stress-free. Here are the three rollback moves you actually need to know:
Soft reset — undo the last commit but keep the file changes:
# Undo the commit but keep files as-is (staged)
git reset --soft HEAD~1Hard reset — go fully back to a checkpoint, discarding all changes:
# Nuclear option — completely restore to last commit
git reset --hard HEAD
# Or go back to a specific checkpoint commit
git reset --hard abc1234Branch delete — if you used the branch approach and want to scrap everything:
# Switch back to main, delete the experiment branch
git checkout main
git branch -D claude/auth-refactor-experimentWhen I first learned the hard reset command, it felt scary. Now it feels like a superpower. That's the mental shift you're going for.
Find Your Checkpoint Hash Fast
Run git log --oneline to see a compact list of recent commits with their short hashes. Your "checkpoint:" commits will stand out immediately. Copy that hash and you can reset to any point in seconds.
Step 4: Tell Claude Code About Your Workflow
Here's something I started doing that made a real difference: I tell Claude Code upfront that I'm using a checkpoint workflow. I'll say something like:
"Before we start, I want to make sure I understand every change you're making. Let's work in phases — tell me what you plan to change before you make it, and I'll say go when I'm ready. I've got a git checkpoint set."
This does two things. It slows Claude down from making a blizzard of changes you can't track. And it puts you in the driver's seat — you're not just approving a diff, you're understanding what's about to happen.
You can even bake this into your CLAUDE.md file so it's a standing instruction:
# Workflow Instructions
- Before making changes, summarize what you plan to do
- Work in phases — wait for confirmation between phases
- Remind me to create a git checkpoint if I haven't mentioned it
- Flag any changes that touch more than 3 files at onceThe Mindset Shift: Experiments Are the Point
Once you have this system in place, something changes psychologically. You stop being cautious with Claude Code. You start being bold.
"Hey, rewrite this entire component using a different state management pattern" becomes a reasonable thing to ask — because if it doesn't work, you're 30 seconds away from your last checkpoint.
"Try a completely different approach to this API call" becomes an experiment, not a gamble.
I've noticed that developers who get the most out of Claude Code aren't the ones who use it most carefully. They're the ones who experiment the most aggressively, because they've built a workflow that makes experimentation safe.
The checkpoint system is what makes that possible. Two commands before you start, a clear rollback plan in your back pocket, and suddenly Claude Code goes from a slightly risky autocomplete tool to a genuine experimentation partner.
Start your next Claude Code session with a checkpoint. See how differently you prompt when you know you can always go back.
More tutorials in this category, or explore the full field guide.