Pi Rewind Hook banner
badlogic badlogic

Pi Rewind Hook

Development community

Description

Pi agent hook for rewinding file changes during coding sessions

Installation

This entry records only its repository, not the path inside it, so there is no exact command to give. Open the source below and copy the folder into ~/.claude/skills/, or the file into ~/.claude/agents/.

README

Rewind Hook

A Pi agent hook that enables rewinding file changes during coding sessions. Creates automatic checkpoints using git refs, allowing you to restore files to previous states while optionally preserving conversation history.

Screenshots

![Selecting a message to branch from](rewind1.png)

![Choosing a restore option](rewind2.png)

Requirements

  • Pi agent v0.18.0+
  • Node.js (for installation)
  • Git repository (checkpoints are stored as git refs)

Installation

npx pi-rewind-hook

This will:

  1. Create ~/.pi/agent/hooks/rewind/
  2. Download the hook files
  3. Add the hook to your ~/.pi/agent/settings.json

Alternative Installation

Using curl:

curl -fsSL https://raw.githubusercontent.com/nicobailon/pi-rewind-hook/main/install.js | node

Or clone the repo and configure manually:

git clone https://github.com/nicobailon/pi-rewind-hook ~/.pi/agent/hooks/rewind

Then add to `~/.pi/agent/settings.json`:

{
  "hooks": ["~/.pi/agent/hooks/rewind/index.ts"]
}

Platform Notes

**Windows:** The `npx` command works in PowerShell, Command Prompt, and WSL. If you prefer curl on Windows without WSL:

Invoke-WebRequest -Uri "https://raw.githubusercontent.com/nicobailon/pi-rewind-hook/main/install.js" -OutFile install.js; node install.js; Remove-Item install.js

How It Works

Checkpoints

The hook creates git refs at two points:

  1. Session start - When pi starts, creates a "resume checkpoint" of the current file state
  2. Each turn - Before the agent processes each message, creates a checkpoint

Checkpoints are stored as git refs under `refs/pi-checkpoints/` and are pruned to keep the last 100.

Rewinding

To rewind:

  1. Type /branch in pi
  2. Select a message to branch from
  3. Choose a restore option:

**For messages from the current session:**

Option Files Conversation
Restore all (files + conversation) Restored R