SafeSandbox adds automatic git snapshots for AI coding agents

SafeSandbox is a local CLI tool that creates git snapshots while AI coding agents edit a repository. It supports automatic restore points, manual checkpoints, and rollback to earlier states, all on the user’s machine.

SafeSandbox adds automatic git snapshots for AI coding agents

SafeSandbox is a local-first CLI tool that automatically creates git snapshots while AI coding agents edit a repository, giving developers a quick way to roll back when something goes wrong. The project bills itself as “infinite undo” for agent-driven coding and says it works with tools such as Cursor, Claude Code, Codex, and Aider.

The tool was posted on Hacker News under the title “Show HN: Automatic Git snapshots while AI agents edit your repo.” According to the project description, SafeSandbox watches for bursts of file changes and creates restore points without requiring users to manually commit every step of an agent session.

⚡ New to this?

This news is about a tool that acts like an undo button for AI coding sessions. AI agents can make a lot of file changes very quickly, and a git snapshot is a saved point you can roll back to if the code breaks. That matters because it reduces the risk of letting an agent edit a real repository without a clean recovery path.

🦞 OpenClaw angle

If you run self-hosted agents in your own repos, add a snapshot step before any high-risk prompt, especially refactors, dependency changes, and auth work. Use a tool like this to create local restore points automatically, then keep your normal git commits for the parts you actually want to keep long term. Also make sure your agent rules file is present and readable so the agent gets the same guardrails every time it runs.

SafeSandbox is designed to sit between a developer’s normal git commits and the rapid edits an AI agent can make in a short period. The project says it is not a cloud service, not a remote IDE, not a Docker container, and not a replacement for git commit. Instead, it acts as a local safety net while the agent is working.

The workflow starts with initializing the tool in an existing repository. The project says users can install it with npm or pnpm, or run it through npx without a global install. After initialization, SafeSandbox creates a .safesandbox directory, a hidden snapshot branch called safesandbox/snapshots, and an AGENTS.md file with guardrails that major AI agents can read.

Once enabled, SafeSandbox watches the filesystem using chokidar, a file-watching library. It then creates automatic snapshots when it detects a burst of edits, deleted files, or changes to important files such as package.json, lockfiles, Dockerfiles, .env files, and config files, according to the project notes.

Users can also create manual checkpoints before risky work. The project shows an example command such as safesandbox snapshot "before auth refactor," which pins a named snapshot that can be restored later if the next prompt causes problems.

Rollback is a core part of the tool. SafeSandbox says it can restore the full repository, including new files, to any snapshot in seconds, and it also removes files that did not exist at that point in time. If uncommitted changes exist, the tool creates an emergency backup snapshot before rolling back.

The project also includes a human-readable timeline of changes. SafeSandbox says this makes it easier to review what happened during an AI coding session, rather than digging through a long chain of file edits.

Under the hood, SafeSandbox uses git for storage. The project says snapshot commits live on the hidden safesandbox/snapshots branch, while metadata in .safesandbox/meta.json maps snapshot IDs to commit hashes. It does not use Docker or overlay filesystems, and it does not introduce a new storage format.

SafeSandbox requires Node.js 20 or newer and a git repository. The project is released under the MIT license.

Source: HN Show HN ↗

More from OpenClaw News