Checkpoints and Branching Strategies
You asked Agent to refactor your authentication module. It rewrote six files, reorganized imports, and updated three test files. Then you noticed it also changed your database connection pooling logic — something you never asked for. You press undo a few times, but the changes are interleaved across files and you cannot get back to a clean state. You close Cursor, run git checkout ., and lose the authentication changes you actually wanted.
This scenario is entirely preventable. Cursor’s checkpoint system, combined with disciplined git branching, gives you a safety net that lets you experiment aggressively without risking your working code.
What You’ll Walk Away With
Section titled “What You’ll Walk Away With”- A workflow for using Cursor’s automatic checkpoints to roll back unwanted AI changes
- A git branching strategy designed specifically for AI-assisted development
- Techniques for combining checkpoints with git commits for multi-layer safety
- Copy-paste prompts for safe experimentation patterns
How Cursor Checkpoints Work
Section titled “How Cursor Checkpoints Work”Every time Agent makes a set of changes, Cursor automatically creates a checkpoint. This checkpoint captures the state of all modified files before the changes were applied. You can restore any checkpoint to undo a specific set of AI changes without affecting other work.
Checkpoints are visible in the chat history. Each Agent response that modified files has a “Restore” option that reverts the codebase to the state before those changes.
Checkpoint Limitations
Section titled “Checkpoint Limitations”Checkpoints are local to your Cursor session. They are not persisted across IDE restarts. They do not capture terminal side effects (if Agent ran a database migration, restoring the checkpoint does not undo the migration). And they track file changes only — if Agent deleted a file, restoring brings it back, but if Agent created new files that you then manually edited, things get complicated.
This is why checkpoints alone are not enough. You need git as your primary safety net.
The Two-Layer Safety Strategy
Section titled “The Two-Layer Safety Strategy”Layer 1 is git commits. Layer 2 is Cursor checkpoints. Use them together:
- Create a feature branch before starting any AI-assisted work
- Commit your current clean state (even if it is just the branch creation)
- Let Agent make changes — Cursor automatically creates checkpoints
- Review the changes. If they look good, commit them with a descriptive message
- If the changes are partially good, use the checkpoint to restore, then re-prompt with more specific instructions
- If everything went wrong,
git checkout .to return to your last commit
Git Branching for AI-Assisted Development
Section titled “Git Branching for AI-Assisted Development”Standard git branching works for AI development, but the cadence is different. With AI, you generate more speculative changes that may or may not pan out. This calls for more frequent, smaller commits and a willingness to throw away branches entirely.
The Micro-Branch Pattern
Section titled “The Micro-Branch Pattern”Instead of one feature branch with many commits, create micro-branches for each AI experiment:
# Main feature branchgit checkout -b feature/payment-system
# Micro-branch for the first AI experimentgit checkout -b feature/payment-system/stripe-approach
# If it works, merge backgit checkout feature/payment-systemgit merge feature/payment-system/stripe-approach
# If it does not, discardgit checkout feature/payment-systemgit branch -D feature/payment-system/stripe-approachThis pattern works well when you want Agent to try different approaches to the same problem. Spin up a branch, let Agent work, evaluate the result, and either merge or discard.
Commit Cadence for AI Work
Section titled “Commit Cadence for AI Work”Commit more frequently than you would with manual coding:
- Before each Agent prompt — So you have a clean restore point
- After each successful Agent change — Lock in good work immediately
- After manual tweaks to AI output — Keep your refinements separate from the AI’s work
Parallel Agents and Worktrees
Section titled “Parallel Agents and Worktrees”Cursor supports parallel agents that run in isolated git worktrees. You can run the same prompt against multiple models simultaneously, compare the results, and apply the best one.
Setting Up Worktrees
Section titled “Setting Up Worktrees”Cursor automatically creates and manages worktrees for parallel agents. When you launch a parallel agent, it gets its own copy of your codebase. Your main working tree is unaffected until you choose to apply changes.
Configure worktree initialization in .cursor/worktrees.json:
{ "setup-worktree": [ "npm ci", "cp $ROOT_WORKTREE_PATH/.env .env" ]}For Python projects:
{ "setup-worktree": [ "python -m venv venv", "source venv/bin/activate && pip install -r requirements.txt", "cp $ROOT_WORKTREE_PATH/.env .env" ]}Best-of-N: Multiple Models, One Prompt
Section titled “Best-of-N: Multiple Models, One Prompt”Send the same prompt to two or more models and compare their approaches:
- Select multiple models in the parallel agent dropdown
- Submit your prompt
- Each model works independently in its own worktree
- Compare the results side by side
- Click “Apply” on the one you prefer
This is powerful for hard problems where different models take different approaches. You can also use it to benchmark which model works best for your codebase.
Advanced Checkpoint Patterns
Section titled “Advanced Checkpoint Patterns”The Incremental Commit Pattern
Section titled “The Incremental Commit Pattern”For large, multi-step features:
- Ask Agent to implement step 1 of your plan
- Review the changes, commit if good
- Ask Agent to implement step 2, building on committed step 1
- Review, commit
- Continue until complete
If step 3 goes wrong, you only lose step 3’s work. Steps 1 and 2 are safely committed.
The Selective Accept Pattern
Section titled “The Selective Accept Pattern”Agent often generates changes that are 80% correct. Instead of accepting or rejecting everything:
- Review the diff in Cursor’s change view
- Accept the changes you want (click the checkmark on individual files)
- Reject the changes you do not want
- Commit the accepted changes
- Re-prompt Agent for just the rejected parts, being more specific
When This Breaks
Section titled “When This Breaks”Checkpoints disappear after restarting Cursor. They are session-local. Always commit important work to git. Never rely on checkpoints as your only safety net.
Agent modifies files you already committed. Start a new chat for each distinct task. Long conversations cause the agent to lose track of what has been committed versus what is still in progress.
Worktree setup fails. Check .cursor/worktrees.json for syntax errors. Debug the setup script via the Output panel, selecting “Worktrees Setup” from the dropdown. Use pnpm or bun instead of npm install for faster worktree initialization.
Merge conflicts when applying worktree changes. Cursor offers “Full Overwrite” or native conflict resolution. For complex conflicts, apply worktree changes to a new branch and resolve there.
What’s Next
Section titled “What’s Next”- Large Codebase Strategies — Branching strategies matter more at scale
- Agent Modes Deep Dive — Plan mode creates structured plans before Agent executes
- Token Management — Parallel agents consume more tokens; manage costs effectively