Delete guard
Agents wiping a home directory or a whole drive is no longer hypothetical; people have posted it more than once. When the delete guard is on and an agent runs rm -rf build, rmdir, git clean -fdx, Remove-Item -Recurse or a similar delete, FileTomb stops that execution and tells the agent the equivalent command, such as obit rm -rf build. Once the agent uses it, things go to the graveyard instead of disappearing, and obit resurrect <id> puts them back.
obit init -g --guard-rm # Claude Code; add --agent codex for Codex. Off by defaultThe delete guard recognizes docker volume rm, docker volume remove, docker volume prune, docker compose down -v (or --volumes), the standalone docker-compose down -v, docker rm -v / docker container rm -v (which also delete a container's anonymous volumes) and docker system prune --volumes, including combined short options such as -fv and -vf; the v in a value such as -f v.yml does not count. It suggests obit bury --docker-volume only for a plain docker volume rm with explicit names; it does not guess what a prune would remove. The denial for docker rm -v, docker compose down -v and docker-compose down -v notes that the same command without -v keeps the volumes, and that their data should be backed up by hand first.
The delete guard also stops wsl --unregister (including wsl.exe, full paths, = flags, and invocations through cmd /c or powershell -Command), which permanently destroys an entire WSL distribution and its virtual disk (ext4.vhdx). FileTomb does not bury or resurrect WSL distributions; the denial points to wsl --export <distro> <backup.tar> as the backup step before manual confirmation. Read-only and non-destructive commands such as wsl --list, wsl --status, wsl --export, wsl --terminate and wsl --shutdown pass through.
The delete guard also stops Podman commands that destroy data: podman volume rm (or remove), podman volume prune, podman compose down -v, the standalone podman-compose down -v, podman system prune --volumes, podman rm -v / podman container rm -v, and podman system reset, which deletes every container, image, pod and volume on the machine (including podman.exe, full paths, global options such as --connection, --url and --root, combined short options such as -fv, and invocations through cmd /c or powershell -Command). FileTomb does not bury or resurrect Podman volumes and never rewrites these commands to obit bury --docker-volume; the denial points to podman volume export <name> -o <backup.tar> as the backup step before manual confirmation. podman volume ls, podman compose down without -v, podman rm <container>, podman --version and commands with --help, --dry-run or --volumes=false pass through.
One real run
With the delete guard on, the hook received one Claude Code Bash call, rm -rf build, and replied as follows; rm never ran:
{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"FileTomb's delete guard is on: `'C:/work/obit.exe' rm -rf build` provides restorable deletion; `obit resurrect` restores graveyard entries."}}The agent then switches to FileTomb; the folder goes to the graveyard and one command brings it back:
$ obit rm -rf build
$ obit graveyard --here
ID BURIED PURGE SIZE PATH
#2 2026-11-11 00:36 in 7d 23 B C:\work\build
$ obit resurrect --last
#2 resurrected C:\work\buildPrinciples
- Deny, never rewrite. FileTomb does not rewrite the agent's command: Claude Code checks permissions against the rewritten command, so rewriting would defeat your
denyrules. Denying and letting the agent issue the equivalent command keeps all your permission rules in force. - A literal delete is stopped. When
rm,rmdir,git cleanorRemove-Item(including aliases such asdel,rd,ri) appears at any command position, whether after&&,||,;, in a pipeline,$(…), a subshell, a condition or a loop, that execution is stopped: for examplerm -rf build && npm run build,rm -rf build 2>/dev/nullorgit clean -fdx && npm ci.rminside strings, comments orechoarguments does not count; neither do previews such asrm --help,git clean -nandRemove-Item -WhatIf. - List targets selected at runtime before burying them. Bash
find -delete,find -exec rm(including-execdir) andxargs rm, as well as PowerShellGet-ChildItem … | Remove-Item, are denied without a rewrite. List and review the matches first, then pass the explicit paths toobit rm -- <path>..., individually or as a batch. Afindthat only searches or lists paths still runs. The guard does not inspect arbitrary wrappers such assudo rmorbash -c '…'. - Never falls back to a real delete. Every path given to
obit rm/obit remove-item/obit git-cleanis buried; when one is refused (drive roots, system folders, the user profile itself and so on) the error followsrm's format and the exit code is non-zero. - Afraid the command changes on the way. Between the command an agent means and the one that runs sit shell quoting, escaping and sometimes a proxy that rewrites commands. Lose one character and
rm -rf "$OUT"/becomesrm -rf /. So beforeobit rmtouches anything it checks the real path on disk. - Codex on Windows: substitutions count even inside quotes. Codex on Windows passes the command through another shell, where quoting can fail, so text that Bash would keep literal may run. In a Codex command on Windows, every backtick span and
$(…)is therefore read as Bash and as PowerShell wherever it appears, including quotes, quoted heredocs and comments, and a deletion inside one stops that execution. Text containing backticks passes when an editing tool writes it to a file and the command receives the file path. - Files tracked by Git are buried too, so uncommitted changes can be recovered (this is a deliberate delete by the agent, unlike automatic registration, which never touches tracked files).
obit rm -rfon a folder that contains.gitburies the whole repository: a realrm -rfwould destroy it, and burial can at least be undone. Protections that cannot be forced (system folders, user folders) still apply.- The equivalent command is deliberately narrow. It must never select more than the original, so FileTomb does not translate across shells and only offers one for the forms in the table below. Otherwise the delete is still stopped; the reason says why no equivalent applies and that
obit bury <path>(literal paths) andobit git-cleandelete restorably, and the agent rewrites the command with them.
What is stopped and what passes
| Host | Stopped, with an equivalent command | Stopped, with the reason and general guidance | Passes |
|---|---|---|---|
| Claude Code (Bash tool) | rm, rmdir, git clean, optionally preceded by a literal cd x (joined with &&, ; or a newline); rm -f *.log (when no file in the folder starts with -), rm -rf ../dist, rm -- "$target" (variables after --) | Every other literal delete: other statements before or after (npm …, trap, hash), variables before --, POSIX absolute paths starting with /, redirections, ||, pipelines, $(…), interactive deletes, /usr/bin/rm with a path | Commands that do not delete |
Codex, under WSL's /mnt/<drive> | A single rm / rmdir whose arguments are relative paths without .., ~, wildcards or quotes | Every other literal delete, including git clean and paths into WSL's own file system | A working directory inside WSL's own file system |
| Codex, declared Windows PowerShell | A single Remove-Item or alias with one literal path (-Recurse, -Force allowed) | Every other literal delete: multiple statements, pipelines, other parameters such as -ErrorAction, provider paths, ~, wildcards, backticks | Text inside curly-quoted strings |
| Codex on Windows with an unknown shell | — | Deletion inside raw backtick or $(…) fragments | Other commands |
pwsh on Linux, git rm | — | — | Everything |
For an equivalent command, the delete must be the last segment of the command, joined only with &&, ; or newlines, and file names ending in a dot or space get none (Windows would normalise them into another name). A literal delete in any of these is still stopped.
Use it yourself
obit rm, obit rmdir and obit git-clean accept the common non-interactive options of rm, rmdir and git clean (unsupported ones such as -i or rmdir -p are errors, not silently ignored). obit remove-item takes one literal path and is not a full Remove-Item; for wildcards use obit rm *.log in bash.
Turn it off temporarily with OBIT_GUARD_RM=0. obit stats shows how many deletes were stopped and how much was buried.