Skip to content
itzjkPublic

About

Ctrl+Z for every AI coding agent. Each agent turn becomes a checkpoint you can undo, without touching your git history.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

8 Commits

Folders and files

Repository files navigation

turnback

Ctrl+Z for AI coding agents.

CI MIT license

turnback undoing a broken agent turn

Quick start

Install with Node.js 22+ on macOS or Linux:

npm install --global --install-links github:itzjk/turnback

Inside the project you want to protect, wrap your terminal agent:

turnback watch -- codex

Replace codex with claude, gemini, opencode, aider, or another terminal command. When a turn goes wrong, stop the agent and run turnback undo. Edited files, deleted files and git-ignored files return to their checkpoint; unwanted new files disappear. Run turnback redo to bring the saved work back.

Features

  • Recover edits, deletions and unwanted new files with one undo.
  • Protect git-ignored files, including .env, alongside your source.
  • Keep your git history, branches and staging area untouched.
  • Wrap terminal agents without configuring plugins or hooks.
  • Inspect changes and restore any retained checkpoint by ID.

Why

An agent can rewrite a working project in one turn; making a commit before every prompt gets old. On October 27, 2026, Codex's request to bring back /undo was open with 490 thumbs-up reactions. turnback gives file recovery its own history, covering files git ignores too; research notes compare the neighboring tools.

How it works

turnback saves a checkpoint before launching the agent and before forwarding each interactive Enter. A separate .turnback/ directory holds its history, reusing unchanged file contents. Before restoring, it saves your current files for redo. It works inside or outside a git repository. Storage and recovery details.

Node.js makes installation one npm command; a prebuilt terminal dependency preserves the agent's interactive terminal.

Usage

Command What it does
turnback watch -- <command> [args] Checkpoint before launch and terminal submissions
turnback checkpoint [label] Save manually or from an agent hook
turnback undo Save current work and go back
turnback redo Reapply an undo
turnback list Show checkpoint IDs, labels and times
turnback diff [id] Compare your files with a checkpoint
turnback restore <id> Restore a checkpoint, saving current work first

Options go before the command, for example turnback --cwd ./project undo. On first use, the current directory becomes the project boundary. Later invocations find an existing store in parent directories. Navigation rules and options.

FAQ

Does it work with my agent? watch wraps terminal commands without an agent plugin. It checkpoints on Enter; optional Claude Code and Codex integrations use agent events instead. See the guide for integration setup and tested coverage.

Does it touch my git repository? No. turnback never reads or writes .git, and works outside git repositories. Add .turnback/ to your .gitignore to keep local checkpoints out of commits.

What happens to secrets and dependencies? .env is included. Dependencies, build output and files over 10 MiB are excluded. Add literal paths or basenames to .turnbackignore for extra exclusions. The store contains plaintext copies of secrets; keep it local. Diff output can contain them too.

Can I undo an undo? Yes, with turnback redo. New edits after an undo block redo until you checkpoint or undo those edits. Saving a checkpoint keeps pending redo steps; undoing that redo brings your saved edits back. Numbered restores are also undoable.

Limitations

  • Enter is a submission boundary. Approval prompts may add checkpoints; autonomous background turns need hooks. Piped input gets one checkpoint before launch.
  • Stop agents, autosaving editors and other writers before restoring. Multi-file restores use a recovery journal, rather than a filesystem-wide atomic operation.
  • History retains up to 200 checkpoints, with a 250 MiB limit per snapshot. Scanning large trees adds latency; exclude generated output.
  • Recovery covers files inside the project. External services, git operations and agent conversation memory cannot be rewound. Full limits.

Contributing

From a clone, run npm ci then npm test; include a reproducer with bug reports. Development, local installation and demo recording.

License

MIT.

About

Ctrl+Z for every AI coding agent. Each agent turn becomes a checkpoint you can undo, without touching your git history.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages