Working

Undo a change you didn't want

Every turn is a checkpoint. One command puts the files back, committed or not.

/undo

Every file the last turn changed, back the way it was.

/redo

Those changes reapplied.

that broke the build, put it back

The same thing — you don't have to remember the command.

How it works

Before each turn edits anything, ContextCode checkpoints the files it's about to touch. /undo restores that checkpoint.

This is a checkpoint of your working tree, not a git operation. It works whether or not you've committed, it doesn't create a revert commit, and it doesn't care what branch you're on. Your git history is untouched.

/redo reapplies what /undo removed, so bouncing between the two costs nothing.

Seeing what changed before you decide

CtrlL reopens the most recently edited file in the preview pane. Press d there and it toggles the full checkpoint diff — everything the turn changed, not just this file. CtrlL again closes it.

That's usually the fastest way to answer "what did it just do".

Undoing a merged worktree

/undo immediately after /worktree done reverts the merge in one step — the branch comes back and your main branch goes back to where it was. See Working on a branch without leaving your session.

What undo doesn't cover

  • Commands that already ran. If a turn ran npm publish, undoing the file changes doesn't unpublish anything. Checkpoints cover files.
  • Turns before the last one. /undo is the previous turn. To go further back, use git, or /worktree next time so the whole line of work is isolated on a branch you can throw away.
  • Files outside the project. Only the project tree is checkpointed.

If it doesn't work

"Nothing to undo." The last turn didn't change files — it answered a question or ran a command. There's no checkpoint to restore.

It undid less than I expected. /undo is one turn. If the change you're thinking of spanned three turns, run it three times, checking the diff as you go.

I undid, then edited by hand, and now redo won't work. Redo is discarded once the files move on. That's deliberate — reapplying a stale checkpoint over your own edits would lose them.

Next