← Home

pi-code-rollback

Git-backed restore for Pi that can rewind code, conversation, or both to prompt boundaries


Date

2026

I am someone who likes to explore multiple branches of my conversations with my agents. imagine being dr. strange and having the ability to explore multiple universes chasing a final outcome, the feeling is small albeit similar.

and when claude code introduced checkpoints, i fell in love with it, but i found it lacking. so like always, i made a plugin for pi that gave me the experience i was chasing with claude but couldn't get because the harness is owned by anthropic lmao.

when i built this, pi was still quite new, so it may not work anymore.

Here's what my agent thinks we did

Built a restore system for Pi that makes agent sessions safely reversible. As you work, it automatically captures git-backed snapshots at the boundaries that actually matter — just before a prompt runs and just after a completed run. Later, /restore lets you recover the code, the conversation, or both.

Why this exists

Coding agents can move fast enough that a normal git history is not always the right recovery interface. A single prompt can touch many files, run tools, follow a mistaken assumption, or produce a direction you want to abandon. Manual commits are too coarse, and editor undo only sees the code, not the conversation that led there.

pi-code-rollback treats each agent turn as a recoverable unit. Before a prompt runs, it captures the current code and conversation state. After a successful run, it captures the result. That gives you stable restore points around the moments where intent changes.

What /restore can rewind

The restore flow lets you choose what kind of rollback you actually need:

  • Code only - keep the conversation, but put the workspace back at a previous snapshot
  • Conversation only - keep the current files, but return the chat to an earlier point
  • Code and conversation - fully rewind the session to a prompt boundary

This matters because not every mistake is the same. Sometimes the code is wrong but the reasoning is still useful. Sometimes the files are fine but the chat context has drifted. Sometimes you want the whole branch of work gone.

Implementation

The system is git-backed, but it is not asking the user to manually manage commits while the agent works. It creates internal snapshots at predictable boundaries, tracks the conversation state alongside the code state, and exposes the restore operation as a Pi command.

The important design constraint was making rollback feel native to the agent loop. You should not need to know which files changed, which command caused the bad state, or whether the issue started before or after the last assistant turn. You pick the restore point and the scope, and Pi rewinds the right layer.

Result

The extension makes experimentation much cheaper. You can let the agent attempt a risky refactor, explore an alternate implementation, or recover from a bad prompt without treating the session as disposable. The work becomes reversible at the same granularity that it was created: one prompt at a time.