Checkpoints that never touch your branch

How PaneScale snapshots a working copy byte for byte without moving HEAD, the index or any branch — and why rewinding refuses to overwrite your edits.

“Undo for agents” sounds simple: save the files before the agent runs, put them back if you don’t like the result. In practice there are three traps, and we fell into each of them before getting it right. This article walks through them, shows how to build the same kind of checkpoint with plain Git commands, and ends with what no checkpoint can undo.

Trap 1: using the user’s Git state

The quickest way to snapshot a working copy is git stash or a commit on the current branch. Both change things the user cares about: the stash list, the branch history, the index. A checkpoint tool that rewrites your index while you’re mid-commit is worse than no tool.

Our approach: checkpoints are commits that no branch points to. They live under a private ref, refs/panescale/checkpoints/<id>, which keeps them safe from garbage collection and out of your git log. To build them we use a temporary index file, so the real index is never read or written. HEAD doesn’t move. Your branches don’t move. Nothing is pushed.

Trap 2: “almost” the same bytes

Git is helpful with text: it normalizes line endings and runs filters on the way in and out. For a checkpoint, helpful is wrong. If a file had CRLF line endings before the agent ran, it must have CRLF after a rewind — byte for byte.

Our approach: files are hashed into the checkpoint without filters, so the stored blob is exactly what was on disk. On rewind, every restored file is read back and compared with what was intended.

Trap 3: overwriting the human

This is the important one. An agent finishes a step at 14:05. At 14:07 you fix a typo in one of the files it touched. At 14:10 you decide the agent’s step was a mistake and rewind it.

A naive rewind restores every file from the 14:05 checkpoint and silently deletes your typo fix. You wouldn’t notice until much later.

Our approach: rewinding is refusing. Before writing a file back, PaneScale checks that the file on disk is still exactly what the step left behind. If it isn’t — because you or anyone else changed it since — that file is not restored. The result tells you so: “kept: edited after this step.” Everything else is restored, so you get a partial rewind rather than an all-or-nothing failure.

Redo follows the same rules in reverse.

Checkpoint, stash or commit?

All three save the state of your files. They differ in what else they touch:

git stashCommit on your branchCheckpoint under a private ref
Changes your working copyYes — it removes your changes until you pop themNoNo
Changes the indexYesYesNo — a temporary index is used
Moves HEAD or a branchNoYesNo
Shows up in git log / stash listStash listYesNo
Survives garbage collectionYesYesYes — the ref keeps it reachable

The last column is the only one that leaves everything you can see exactly as it was. That is the property an automatic tool needs: it may run a hundred times a day, and you should never notice it ran.

Building one with plain Git

The idea is not magic, and it helps to see it spelled out. This shell version builds a checkpoint without touching your index, HEAD or any branch:

Terminal
# a private index, so the real one is never read or written
export GIT_INDEX_FILE="$(git rev-parse --git-dir)/checkpoint.index"
git read-tree HEAD      # start from the last commit
git add -A              # record the working copy in the private index
tree=$(git write-tree)

# a commit that no branch points to
commit=$(git commit-tree "$tree" -p HEAD -m "checkpoint before step 3")

# a private ref keeps it safe from garbage collection
git update-ref refs/checkpoints/step-3 "$commit"

unset GIT_INDEX_FILE
rm "$(git rev-parse --git-dir)/checkpoint.index"

To bring a single file back without touching the index, git restore --source=refs/checkpoints/step-3 --worktree -- path/to/file writes the checkpointed version into the working copy only.

This version is useful, but it has the two weaknesses the traps above describe. git add applies Git’s filters and line-ending rules, so the stored bytes are not always the bytes that were on disk, and it skips ignored files. And git restore overwrites whatever is on disk now, including your 14:07 typo fix. A byte-exact checkpoint hashes files without filters — Git has git hash-object --no-filters for that — and a careful rewind compares the current file with the step’s result before it writes anything.

When checkpoints are taken

PaneScale takes a checkpoint whenever it is about to change your workspace on your behalf:

  • before a turn in Agent mode or Chat that may edit files,
  • before a card on the tasks board runs,
  • before applying an autopilot result,
  • before applying a Point & Fix change.

Interactive terminal panes are different: you are driving, and the agent is a tool in your hands. For those, isolation through a lane is the safety net — nothing reaches your branch until you merge.

What a checkpoint can’t undo

A checkpoint restores files in your working copy. Anything an agent did outside those files is out of its reach:

  • Commands with side effects — a database migration against a real database, a message sent to an API, a file written outside the project.
  • Things that left your machine — a push, a published package, a deployment.
  • Installed tools — a global package or a system setting changed by an install script.

That is why checkpoints are one layer, not the whole answer. Actions that leave your machine or change your branch go through signed one-time approvals, and agents that run unattended work in their own worktree, so the worst case of a bad step is a lane you discard.

Cost

Checkpoints are ordinary Git objects. Unchanged files are shared with every other commit, so a checkpoint only costs what actually changed. Git’s housekeeping keeps the rest compact.

Because Git stores content by its hash, a file that is identical in a hundred checkpoints is stored once. In practice a day of checkpoints on a medium-sized project costs about as much disk space as the changes the agents actually made — usually far less than one node_modules folder.

Details are in the Undo & checkpoints docs.

Questions about checkpoints

Do checkpoints replace commits?

No. A checkpoint is a safety net for the minutes between your commits, not a history you share. Commit when a change is finished and reviewed; checkpoints only exist so that an agent’s step can be undone without touching the work around it.

Do checkpoints include files Git ignores?

A checkpoint is built from the files of your working copy, so it is only as complete as what it records. Build output and dependency folders are usually ignored on purpose, and it rarely makes sense to snapshot them — they can be rebuilt. If an agent changes something outside your project, no checkpoint covers it; that is what lanes and approvals are for.

How long are checkpoints kept?

They are ordinary Git objects under a private ref, so they stay until they are cleaned up. Because unchanged files are shared, keeping them is cheap; the Undo & snapshots docs explain where they live and how they are listed.

Checkpoints in a team

Because checkpoints live under a private ref and are never pushed, they stay on the machine where they were taken. Your colleagues never see them, and they never appear in a pull request. That is deliberate: a checkpoint records the state of your working copy at a moment that only matters to you. When work is worth sharing, it becomes a commit on a branch, reviewed like any other.

Sources

More articles

Why the second pane opens instantly

Starting a coding CLI takes seconds. Pre-warmed sessions hide that wait — here is how we do it without eating your memory.

Measured, not estimated

Why the Token Guardian shows “not reported” instead of a guess — and how real budgets stop runs instead of turning numbers red.

Memory is context, not commands

Teammates in PaneScale remember. Here is why everything they remember is passed as context and never as instructions — and why that matters for safety.