Skip to main content
Glama

Tests Zero Dependencies Node.js >= 22.5 License MIT

Shadow Git snapshot and checkpoint time-machine for AI coding agents without touching your real .git history.

Works with Claude Code, Cursor, Windsurf, Codex CLI, and Antigravity.

When an autonomous coding agent rewrites ten files on top of your uncommitted changes and breaks the build, git checkout -- . wipes your own unsaved work too, while git reset --hard deletes new untracked files you wanted to keep.

agent-undo keeps an isolated bare Git object store in ~/.agent-undo/<repo-hash>.git outside the workspace. Every checkpoint captures tracked changes and new untracked files (honoring .gitignore) without adding a single commit to your real .git repository. Every restore takes an automatic pre-rewind snapshot first, so even an undo can be undone with redo.

Quick start

Requires Node.js >= 22.5.0 and git.

# Save a shadow checkpoint of your current working tree
npx -y github:keenfolk1-lgtm/agent-undo save "before auth refactor"

# List saved shadow checkpoints
npx -y github:keenfolk1-lgtm/agent-undo log

# Preview what restoring a checkpoint would change or delete
npx -y github:keenfolk1-lgtm/agent-undo undo <id> --dry-run

# Rewind to a checkpoint (saves pre-rewind first) and optionally redo
npx -y github:keenfolk1-lgtm/agent-undo undo <id>
npx -y github:keenfolk1-lgtm/agent-undo redo

MCP server registration

claude mcp add agent-undo -- npx -y github:keenfolk1-lgtm/agent-undo serve

Or add to mcp.json:

{
  "mcpServers": {
    "agent-undo": {
      "command": "npx",
      "args": ["-y", "github:keenfolk1-lgtm/agent-undo", "serve"]
    }
  }
}

Automatic PreToolUse hook

Connect hooks/checkpoint-hook.mjs as a PreToolUse hook in Claude Code or Antigravity so a debounced shadow snapshot runs automatically before edit_file, write_file, Edit, Write, or Bash:

{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "edit_file|write_file|Edit|Write|MultiEdit|Bash",
        "hooks": [{ "type": "command", "command": "node /path/to/agent-undo/hooks/checkpoint-hook.mjs" }]
      }
    ]
  }
}

Related MCP server: statecli-mcp-server

Safety guarantees

agent-undo sets GIT_DIR and GIT_INDEX_FILE to ~/.agent-undo/<hash>.git, leaving <workspace>/.git and its index untouched. .gitignore rules are honored, binary/archive build artifacts (.exe, .apk, .dmg, .zip, .db) and files over 10 MB are skipped automatically, and unsafe targets (home directory, filesystem root, .gemini/config) are blocked.

MCP tools

Tool

Purpose

checkpoint_save

Creates a shadow tree commit if working tree bytes changed since the previous checkpoint.

checkpoint_list

Lists checkpoint IDs, ISO timestamps, and labels.

checkpoint_diff

Shows --stat and unified diff between two checkpoints or against current files.

checkpoint_restore

Rewinds all files or a --file subset after taking a pre-rewind snapshot and prunes emptied folders.

checkpoint_redo

Restores the latest automatic pre-rewind snapshot to reverse a restore.

checkpoint_prune

Keeps the latest N checkpoints and runs git gc --prune=now on the shadow store.

Limitations

Checkpoints store snapshots of non-ignored text and binary files inside ~/.agent-undo/, which consumes local disk space proportional to changed objects until prune runs. Files outside the workspace root or ignored via .gitignore (such as .env or node_modules) are intentionally skipped by snapshots and untouched on restore.

License

MIT

Related tools: mcp-diet · skill-guard · blast-radius-mcp · flight-recorder-mcp · de-slop

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      B
      maintenance
      Provides AI assistants with secure, read-only access to ShadowGit repositories for debugging and code analysis. Enables powerful analysis of fine-grained git history captured automatically by ShadowGit's continuous commit tracking.
      13
      50
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables AI coding agents to checkpoint workspace state, branch parallel attempts, inspect diffs, and roll back to known-good states mid-task through MCP tools, with automatic safety checkpoints to prevent data loss.
      6 npm
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables AI agents to checkpoint, diff, search, branch, merge, and restore intermediate states of pending Perforce changelists without submitting them. Each snapshot is stored as a local Git commit outside the Perforce workspace, so agents can commit milestones automatically and roll files back to earlier revisions.
      MIT