ai-trash
Stop AI coding tools from permanently deleting your files. A transparent rm replacement that moves deleted files to recoverable trash.
curl -fsSL https://raw.githubusercontent.com/forethought-studio/ai-trash/main/install.sh | bash
ai deleted my files. now what?
AI coding assistants like Claude Code, Cursor, Copilot, and Codex routinely run rm to clean up files. Usually that's fine. Sometimes they delete something important and there's no undo.
ai-trash sits between your AI tools and /bin/rm. Every file deletion is intercepted and moved to a recoverable trash folder instead of being permanently destroyed. Your workflow doesn't change. rm still works exactly as before.
Without ai-trash
AI runs rm config.json
File is gone forever.
With ai-trash
AI runs rm config.json
ai-trash restore config.json brings it back.
works with every ai coding tool
ai-trash detects AI processes by walking the full process tree. No configuration needed for supported tools.
how it works
- Installs a wrapper at
/usr/local/bin/rmthat runs before/bin/rmin your PATH. - Detects whether the caller is an AI tool by checking environment variables and the process tree.
- AI-initiated deletions are moved to trash with full recovery metadata (original path, timestamp, who deleted it).
- Your own
rmcalls pass through unchanged (in selective mode) or go to system Trash (in safe mode). - Also intercepts
find -delete,git clean,git checkout, andgit reset --hard.
cross-platform
macOS
Uses FSMoveObjectToTrashSync for native Finder Put Back support. Files appear in your Trash with full metadata.
Linux
Routes to ~/.local/share/Trash/ai-trash/ with sidecar metadata files. Per-volume trash on external drives.
Windows
PowerShell Remove-Item wrapper sends files to the Recycle Bin via .NET. Explorer's native Restore works.
Zero config
One-line install. No shell aliases, no config files to edit. Works immediately with all supported AI tools.
get it
MIT License. Free and open source.