Merge agent changes back into your main branch using Uzi’s checkpoint system
Checkpointing is how you bring an agent’s work from its isolated worktree back into your current branch. This guide explains the process in detail and shares best practices.
Checkpointing rebases an agent’s branch onto your current branch, effectively merging all the agent’s commits and changes into your working directory.What happens during a checkpoint:
All changes in the agent’s worktree are staged (git add .)
A commit is created on the agent’s branch with your message
The commit base is calculated using git merge-base
The agent’s branch is rebased onto your current branch
All changes appear in your current working directory
Checkpointing uses git rebase, not merge. This creates a linear history but means you should understand your current branch state before checkpointing.
uzi checkpoint funny-elephant "feat: add user authentication with JWT"
Output:
Checkpointing 3 commits from agent: funny-elephantSuccessfully checkpointed changes from agent: funny-elephantSuccessfully committed changes with message: feat: add user authentication with JWT
Let’s walk through exactly what happens during a checkpoint.
1
Verify you're on the correct branch
Check your current branch before checkpointing:
git branch --show-current
The agent’s work will be rebased onto this branch.
Most commonly, you’ll be on main or develop when checkpointing. Make sure this is where you want the changes to land.
2
Review the agent's work
Before checkpointing, review what the agent has done:
# Check the diff statsuzi ls# Visit the agent's dev server# (URL shown in uzi ls output)open http://localhost:3000# Or inspect the worktree directlycd ~/.local/share/uzi/worktrees/funny-elephant-myproject-a1b2c3d-1234567890-0git loggit diff HEAD~3 # See last 3 commits worth of changes
3
Run the checkpoint command
Execute the checkpoint with a descriptive commit message:
uzi checkpoint funny-elephant "feat: add user authentication with JWT"
Internal process:
# 1. Stage all changes in agent worktreecd ~/.local/share/uzi/worktrees/funny-elephant-myproject-a1b2c3d-1234567890-0git add .# 2. Commit with your messagegit commit -am "feat: add user authentication with JWT"# 3. Find merge basegit merge-base main funny-elephant-myproject-a1b2c3d-1234567890-0# 4. Rebase onto current branchcd /path/to/your/main/repogit rebase funny-elephant-myproject-a1b2c3d-1234567890-0
4
Verify the changes
After checkpointing, the changes are now in your current branch:
git statusgit log # See the commits from the agentgit diff HEAD~1 # Review the last commit
Test that everything works in your main environment:
npm testnpm run dev
5
Clean up the agent (optional)
Once you’ve checkpointed and verified the work, you can kill the agent:
uzi kill funny-elephant
You can also keep the agent running for further iterations. Checkpointing doesn’t automatically kill the agent.
# Tested the agent's dev server, everything worksuzi checkpoint brave-tiger "feat: add user profile editor"
Before making major changes:
# Save current progress before pivoting approachuzi checkpoint funny-elephant "feat: add basic search functionality"uzi broadcast "Now optimize search using ElasticSearch"
When combining multiple agents’ work:
# Checkpoint different features from different agentsuzi checkpoint agent-1 "feat: add authentication"uzi checkpoint agent-2 "feat: add user profiles"uzi checkpoint agent-3 "test: add integration tests"
You can’t checkpoint part of an agent’s work - it’s all or nothing. If you only want some changes:Option 1: Manual cherry-pick
# In the agent's worktree, find the commit hashcd ~/.local/share/uzi/worktrees/agent-worktree/git log # Copy the commit hash you want# Back in your main repocd /path/to/main/repogit cherry-pick abc123
Option 2: Manual file copy
# Copy specific files from agent worktreecp ~/.local/share/uzi/worktrees/agent-worktree/src/auth.js ./src/git add src/auth.jsgit commit -m "feat: add auth module from agent"
# First checkpointuzi checkpoint agent-name "feat: add basic authentication"# Give more instructionsuzi broadcast "Now add OAuth support"# Wait for agent to implement# Second checkpointuzi checkpoint agent-name "feat: add OAuth authentication"
Each checkpoint creates a new commit with the incremental changes.
Checkpoint different features from different agents in sequence:
# Agent 1 built the backenduzi checkpoint backend-agent "feat(api): add user management endpoints"# Agent 2 built the frontenduzi checkpoint frontend-agent "feat(ui): add user management UI"# Agent 3 wrote testsuzi checkpoint test-agent "test: add user management integration tests"# Now all features are in your main branchgit log --oneline -3
Cause: Git conflicts between agent changes and current branch.Solution:
# Check rebase statusgit status# Resolve conflicts in indicated filesvim conflicted-file.js# Continue rebasegit add .git rebase --continue# Or abort and try manual mergegit rebase --abort
Cause: The agent hasn’t made any changes yet, or changes were already committed.Solution: This is not an error. The checkpoint will still rebase any existing commits from the agent’s branch.
Always review the agent’s work before merging it into your branch:
# Check the diff sizeuzi ls# Test the functionalityopen http://localhost:3000# Review the codecd ~/.local/share/uzi/worktrees/agent-worktree/git diff HEAD~3
Use descriptive commit messages
Your checkpoint commit message becomes part of your project history:Good:
uzi checkpoint agent "feat(auth): add JWT authentication with refresh tokens"
Bad:
uzi checkpoint agent "updates"
Checkpoint incrementally
Don’t wait for everything to be perfect. Checkpoint working increments:
# After basic feature worksuzi checkpoint agent "feat: add basic user search"# After optimizationuzi checkpoint agent "perf: optimize search with indexing"# After polishuzi checkpoint agent "feat: add search filters and pagination"
Test after checkpointing
Always verify that checkpointed code works in your main environment:
uzi checkpoint agent "feat: add feature"# Test immediatelynpm install # In case dependencies changednpm testnpm run dev
Your main environment may differ from the agent’s worktree.
Keep agents after checkpointing for iterations
You don’t have to kill agents after checkpointing:
# Checkpoint current workuzi checkpoint agent "feat: add basic dashboard"# Keep iterating with the same agentuzi broadcast "Add charts and graphs to the dashboard"# Checkpoint again lateruzi checkpoint agent "feat: add dashboard visualizations"