Protect files with sandbox, hooks and checkpoints

Turn on /sandbox, block destructive commands with hooks, and keep git checkpoints so one bad command is a one-step rollback.

by anassBld8 Oct 2026

Prompt for your agent

Goal: Let Claude Code run real commands without risking my files.
Setup: agents used in source: Claude; tools/MCPs stated: Seatbelt, bubblewrap, git.
Steps:
1. Layer 1: run /sandbox in a session; writes are confined to the project at OS level (Seatbelt on macOS, bubblewrap on Linux/WSL2). Not on native Windows.
2. Layer 2: add hooks that stop destructive commands (force-push to main, DROP TABLE, reset --hard) or make Claude ask first.
3. Layer 3: keep git checkpoints so you can roll back in one command if something slips through.
Rules: ask me before anything irreversible (sending, posting, paying, deleting); don’t invent data, results or tools I haven’t given you; tell me what you couldn’t verify.
Based on: anassBld — https://dev.to/anasbuilds997/claude-code-can-delete-your-files-the-3-layer-setup-i-run-sandbox-hooks-git-checkpoints-188h

Steps are from the source. Includes a “Based on” credit line.

I tried this

Tell the next builder. One anonymous answer each; click again to undo.

Agents, models and tools only what the source states

Agents
Claude
Tools
  • Seatbelt
  • bubblewrap
  • git

Sources & credit