SuperAPIAI Directory

stepback

github.com · AI agents

Checkpoint and rewind for any AI coding agent (Claude Code, Codex, aider) via isolated git shadow-refs that never touch your real HEAD, index, or branch, with best-effort conversation resume for Claude Code and Codex.

Open website Alternatives
PricingOpen source开源项目(可免费自部署)
PlatformsmacOS · Linux

About this tool

Purpose

StepBack is a Git time-travel tool for AI coding agents, used to provide checkpoint and rollback capabilities for Claude Code, Codex, aider, or any command. After an AI coding agent produces an erroneous action, the working tree may be full of half-finished edits and extra files; git stash cannot help (because the agent never committed), and the editor's undo also cannot roll back multi-file changes. StepBack sits alongside the agent, snapshots files while it works, and allows precise rollback to any point in time.

Main Capabilities

File Layer (core, stable)

  • A debounced file watcher snapshots the working directory after each burst of edits ends, with snapshots stored as content-addressed git objects under refs/checkpoints/<session>/<n>.
  • Uses git plumbing (hash-object, write-tree, commit-tree, update-ref) with a separate index (via GIT_INDEX_FILE), and never modifies the user's branches, HEAD, index, staging area, or commit history.
  • Exact restore: rollback reproduces the tree state byte for byte, including undoing edits, removing added files, and restoring deleted files, and supports binary files, symbolic links, unicode/space/leading-hyphen filenames, .gitignore, and large trees.
  • Atomicity: restore first stages the target file versions, then renames them into place on the same filesystem, so a crash will not leave half-written files. A write-ahead log records the operation and the ref-protected pre-operation tree before destructive operations, and stepback recover can be used to explicitly recover an interrupted restore operation; a successful rollback can still be reversed with stepback redo.
  • Safety: shows a diff preview before rollback and requires confirmation, pushes the current state onto the redo stack, and --dry-run can show only the plan.
  • Selectivity: stepback restore <id> --path FILE can restore one or more files or subtrees, and verifies that unselected paths have not moved, and the operation can still be redone. When only files are selected, conversation state is not rolled back.
  • Concurrency safety: mutating operations use OS-level cross-process advisory locks (flock on POSIX, LockFileEx on Windows), and during rollback running watchers are notified to ignore restore events.
  • Usable without git: in a git repositoryAdditionally, StepBack creates a private object store at .stepback/shadow.git, using the same mechanism.

Conversation Layer (differentiated, best-effort)

  • After detecting an agent, StepBack also snapshots its on-disk session state at each checkpoint, and restores it on rollback, then outputs a resume hint, thereby making it possible to roll back the conversation and not just the code.
  • This layer depends on each agent's private, undocumented, and version-unstable session format, is best-effort, and is isolated behind a clean adapter interface; if no agent is detected or its format cannot be recognized, it silently degrades to file-only rollback, never crashes, and never blocks the file layer.
  • Adding an agent only requires implementing a small class for detect / session_files / snapshot / restore / resume_hint (see ARCHITECTURE.md).

Usage

(Specific installation commands and CLI usage steps are not provided in the material, so they are not provided for now.)

The commands known from the material include: stepback recover (recover an interrupted recovery operation), stepback redo (reverse rollback), stepback restore <id> --path FILE (selective restore). Exit codes: 0 success, 1 expected failure (no such checkpoint, nothing to redo, aborted), 2 incorrect invocation, 127 agent command not found.

Applicable Scenarios

  • When using any agent in an active repository that edits on-disk files, such as Claude Code, Codex, aider, Cursor's CLI, or ordinary bash scripts, to prevent a single mistaken operation from damaging the working tree.
  • When you need to precisely undo multi-file changes, restore deleted files, or remove newly added files, while keeping git history clean.
  • When you want to roll back the code and also roll back the conversation state, and continue talking with the agent from that point.

Limitations

  • Snapshots respect .gitignore. Ignored files (build artifacts, .env, node_modules) are not captured or restored.
  • The conversation layer format is private to each agent and may break with any update. Codex capture requires that the recognized session metadata exactly match the working tree; unsupported or ambiguous sessions are deliberately degraded to file-only rollback. Conversation rollback should be treated as an additional capability, not a guarantee.
  • Restore overwrites tracked/non-ignored files in the current working tree (after diff preview and user confirmation).
  • Restore is not a filesystem-level atomic system call: individual files are atomically replaced, the final tree is verified, and a write-ahead log makes interrupted file recovery available for explicit recovery with stepback recover; a successful rollback can still be reversed with stepback redo. The conversation adapter and external services are not within that file transaction.
  • Any stepback command resolves storage for the current directory, so running it outside a git repository creates a .stepback/ directory there.
  • The retained integration checks cover the CLI, adapter boundaries, filesystem/Git hardening, and real watcher events; engine/storage internals are not covered by a pure unit test suite.
  • Requires Python 3.11+ and git in PATH, and depends only on typer and watchdog.

Current Release Status

The current version includes selective file/subtree restore, write-ahead logging, new-process recovery, untouched-path verification, atomic promotion, and persistent redo. CI runs the above-named integration checks on Linux, Windows, and macOS for Python 3.11 and 3.12. Conversation-layer rollback still depends on the adapter/platform. The license is MIT (c) 2026 Krishi Attri.

Up/Down to navigate · Enter to open · ESC to closeBrowse all tools