The Git Workflow I Use on Every Claude Code Build

David IyaDavid Iya July 31, 2026 7 min read
A dark plugin panel with glowing connectors on a developer workstation
Original image, Claude Code Club

Why Claude Code and git need a system

Claude Code can write more code in ten minutes than most developers produce in a morning. That speed is the whole point, but it creates a real problem: if you do not have a commit rhythm, you end up with a working directory full of changes you have never checkpointed. One failed experiment, one wrong undo, one accidental overwrite, and the session is gone. Git is the safety net, and without a system for using it alongside Claude, you are flying without one.

I learned this the hard way on an early build. I had Claude add a feature over about forty minutes of back-and-forth, it was working, and then I asked it to refactor something unrelated. The refactor broke the feature. I typed undo, Claude rewrote the file, and the working version I had never committed was gone. Forty minutes, gone. After that I built a simple git system and I have used it on every build since.

The commit-often rule

The core rule is this: commit every time something works. Not just when a feature is done, not just at the end of a session - every time you have a version you would be upset to lose. With Claude, that moment comes more often than you expect. A working route, a passing test, a component that renders correctly - each of those is worth a commit.

The commit message does not have to be elaborate. One line that names what this version does is enough: 'add contact form route', 'fix login redirect', 'wire up Stripe webhook'. The point is that future you can read the history and understand what each checkpoint represents. Claude Code generates a lot of commits in a short window, so a readable history is genuinely useful, not just tidy.

  • Commit before you explain a new problem to Claude. Starting a new task on a clean commit means you can always roll back to the last working state if the new task breaks something.
  • Commit after each meaningful unit of work: a working route, a resolved bug, a connected integration. Do not wait for the whole feature.
  • Commit before any refactor. Refactors have a way of touching more than you expect. A clean checkpoint before you ask Claude to reorganize anything is protection against scope creep in both directions.
  • Commit before you deploy. Never push uncommitted work. What lands in the repo is what Vercel or your host builds from, and silent WIP that never gets committed never goes live.

Branch per task: the clean-room approach

The branch-per-task pattern is simple: every new task that Claude works on gets its own branch. Claude builds in it, you review the diff, and merging to main is a decision you make once the task is done and the diff looks right. The branch is a clean room for one piece of work.

This pattern matters especially when Claude is in auto mode or working through a longer task. If the work drifts in an unexpected direction, you can see the full diff in one place before anything touches main. You can also run parallel builds - a subagent working on the payment page and another working on the dashboard - without the two sets of changes colliding in a shared main branch.

When the task is done and you are happy with the diff, merge into main and delete the branch. If the task went sideways and you want to start over, delete the branch and open a new one. Nothing on main was touched. That is the clean-room property, and it is worth building the habit even on solo projects.

How to review the diff before you merge

The diff review step is the one most builders skip, and it is the most important one. Before you merge any branch, look at what actually changed. Not the description Claude gave you - the actual file-by-file changes. Claude does not always touch only the files it said it would, and a ten-second diff review catches that.

What you are looking for: files that should not have been touched, logic that looks different from what you discussed, any change that was not in scope for the task. You do not need to read every line. You are looking for surprises. Most of the time there are none. But the times there are, you will be glad you looked.

  • In GitHub Desktop: click 'Changes' in the left panel to see every modified file. Click each file to see the line-by-line diff.
  • In the terminal: 'git diff main..your-branch' shows you every line that differs from main.
  • In VS Code: the Source Control panel shows changed files with a diff view for each.
  • In the Claude Code desktop app: the file change indicator next to each session shows you what was touched in the current conversation.

The four rules on every build

These four rules came from the mistakes I made on early builds. They are simple enough to remember without a checklist, and they prevent the specific kinds of pain I ran into.

  1. Commit before you hand Claude a new problem. Every new task starts on a clean checkpoint. If the task breaks something, you can roll back without losing the work that came before.
  2. Review the diff before you merge. Spend ten seconds looking at what actually changed, not just what Claude said it changed. Surprises are rare and catching them is free.
  3. Never git add -A on a dirty tree. If your working directory has files from other tasks or experiments, staging everything at once risks committing unrelated WIP. Add specific files by name.
  4. Write a one-line commit message that names the intent. 'Add contact form' is useful. 'Updates' is not. Your future self reads the history when something breaks; give it something to work with.

None of these rules are complicated, and none of them slow the build down in any meaningful way. What they do is make the build recoverable. That is the whole point of git alongside Claude: you get the speed, and you get a safety net.

Build without fear inside Claude Code Club

Inside Claude Code Club we go deeper on this - looking at git worktrees for parallel builds, rebase strategies for AI-heavy histories, and the exact setup I use when Claude Code is running unattended overnight. If you want to build faster without the recovery panic, join us at [https://www.skool.com/claudecodeclub/about](https://www.skool.com/claudecodeclub/about) and bring your current build.

Free Claude Code drops, straight to your inbox

Short, practical drops on skills, MCP, agents, prompts, and more. No spam, unsubscribe anytime.

Frequently asked questions

Should I commit every single change Claude Code makes?

Not every individual change - every meaningful checkpoint. A working route, a passing test, a resolved bug: those are worth committing. A half-finished attempt or a file Claude touched on the way to something else is not. The question to ask is: would I be upset if I lost this right now? If yes, commit it.

What if Claude Code breaks something and I want to undo it?

If you committed before handing Claude the new task, you can roll back to that commit and the broken work is gone. This is the main reason to commit before every new task - it makes rollback a simple one-step action instead of a manual file-by-file recovery. In GitHub Desktop that is right-click on the commit and 'Revert'. In the terminal it is 'git revert' or 'git reset --hard' to the commit hash.

Can I use a GUI like GitHub Desktop instead of the terminal?

Absolutely. GitHub Desktop, Tower, and the VS Code source control panel all surface the same git operations as the terminal, just visually. The Claude Code desktop app works alongside any of them. The workflow above describes the logic - commit often, branch per task, review the diff - and you can implement all of it without opening a terminal.

How do I handle merge conflicts when Claude Code changes the same files I did?

The branch-per-task approach keeps this from happening on most projects, because each branch touches one set of files. If a conflict does come up - say you and Claude both touched the same component - resolve it like any merge conflict: open the conflicted file, read both versions, pick or combine the right lines, and commit the resolution. In GitHub Desktop the conflict resolution UI walks you through it. The key is that a conflict is a normal git event, not a crisis - the branch pattern just makes it rare.

Last reviewed by David Iya on July 31, 2026

David Iya

Written by

David Iya

Forbes 30 Under 30 · Y Combinator

Keep reading

Claude CodeWorkflows

Why Is Claude Code Slow? The Real Causes and How to Speed It Up

Claude Code is usually slow for one of three reasons: the context you are sending is too big, the tools it is running are the actual bottleneck, or you picked a heavier model than the task needs. Here is the Slow Loop Audit I run to find which one it is in about five minutes.

David Iya 9 min
Read article

Ready to build it yourself?

Join Claude Code Club, the #1 community for learning claude code, for $9/month.

← Back to the blog