{"id":46574538,"url":"https://github.com/kayaman/safe-rm","last_synced_at":"2026-03-07T09:23:20.743Z","repository":{"id":335919707,"uuid":"1147503737","full_name":"kayaman/safe-rm","owner":"kayaman","description":"Intelligent file deletion protection for Git projects.  Prevents accidental deletion of unstaged files while allowing  efficient cleanup. Works with AI coding agents (Cursor, Copilot, Claude Code).","archived":false,"fork":false,"pushed_at":"2026-02-01T21:26:25.000Z","size":41,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-02-02T04:43:28.299Z","etag":null,"topics":["ai","copilot","cursor","git","oh-my-zsh","oh-my-zsh-plugin","protection","safe-delete","trash","zsh"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kayaman.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yaml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-02-01T21:02:17.000Z","updated_at":"2026-02-01T21:24:19.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/kayaman/safe-rm","commit_stats":null,"previous_names":["kayaman/safe-rm"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/kayaman/safe-rm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kayaman%2Fsafe-rm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kayaman%2Fsafe-rm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kayaman%2Fsafe-rm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kayaman%2Fsafe-rm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kayaman","download_url":"https://codeload.github.com/kayaman/safe-rm/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kayaman%2Fsafe-rm/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30210746,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-07T09:02:10.694Z","status":"ssl_error","status_checked_at":"2026-03-07T09:02:08.429Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","copilot","cursor","git","oh-my-zsh","oh-my-zsh-plugin","protection","safe-delete","trash","zsh"],"created_at":"2026-03-07T09:23:20.229Z","updated_at":"2026-03-07T09:23:20.714Z","avatar_url":"https://github.com/kayaman.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Safe-RM\n\n**Intelligent file deletion protection for Git projects with AI coding agent support**\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![ZSH](https://img.shields.io/badge/shell-zsh-green.svg)](https://www.zsh.org/)\n[![Oh My Zsh](https://img.shields.io/badge/framework-oh--my--zsh-blue.svg)](https://ohmyz.sh/)\n\nPrevent accidental deletion of unstaged files in Git repositories while allowing efficient cleanup of build artifacts. Works seamlessly with both **human users** and **AI coding agents** (Cursor IDE, VSCode Copilot, Claude Code).\n\n## Why Safe-RM?\n\n- **Protects untracked Git files** - Never lose work-in-progress code again\n- **AI agent compatible** - Works with Cursor, Copilot, Claude Code (non-interactive)\n- **Recoverable deletions** - Move important files to trash instead of permanent deletion\n- **Smart classification** - Automatically knows what's safe to delete\n- **Zero friction** - Drop-in `rm` replacement, no workflow changes\n- **Complete audit trail** - Log every deletion with timestamps\n\n## Quick Start\n\n### One-liner installation\n\n```bash\n# Standalone\ncurl -LsSf https://raw.githubusercontent.com/kayaman/safe-rm/main/get-safe-rm.sh | sh\n\n# Oh-my-zsh plugin\ncurl -LsSf https://raw.githubusercontent.com/kayaman/safe-rm/main/get-safe-rm.sh | sh -s -- --oh-my-zsh\n```\n\n### Installation (oh-my-zsh)\n\n```bash\n# Clone the repository\ngit clone https://github.com/kayaman/safe-rm.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/safe-rm\n\n# Add to your .zshrc plugins\nplugins=(... safe-rm)\n\n# Reload zsh\nsource ~/.zshrc\n```\n\n### Installation (manual)\n\n```bash\n# Clone the repository\ngit clone https://github.com/kayaman/safe-rm.git ~/.safe-rm\n\n# Run installer\ncd ~/.safe-rm\n./install.sh\n\n# Reload shell\nsource ~/.zshrc\n```\n\n### For IDE Skills (Cursor, VSCode)\n\n**Cursor:** Add rule from URL: `https://raw.githubusercontent.com/kayaman/safe-rm/main/skills/safe-rm/SKILL.md`  \n**VSCode / local:** Reference `skills/safe-rm/SKILL.md` or `file:///path/to/safe-rm/skills/safe-rm/SKILL.md`\n\nSee [IDE Integration Guide](docs/IDE_INTEGRATION.md) for detailed setup.\n\n## How It Works\n\n```\nYou type: rm -rf src/\n           ↓\nSafe-RM analyzes and classifies:\n  src/__pycache__/   → DELETE (build artifact)\n  src/draft.py       → TRASH (untracked source - recoverable)\n  src/notes.md       → TRASH (untracked docs - recoverable)\n  .git/              → BLOCKED (protected path)\n```\n\n### Classification System\n\n| Category | Action | Files |\n|----------|--------|-------|\n| **AUTO_ALLOW** | Delete directly (logged) | `node_modules/`, `dist/`, `build/`, `*.pyc`, `*.log` |\n| **AUTO_TRASH** | Move to trash (recoverable) | Untracked `*.py`, `*.js`, `*.md`, config files |\n| **BLOCK** | Refuse (error) | `.git/`, `/`, `/home`, `*important*` |\n\n## Usage Examples\n\n### Basic Commands\n\n```bash\n# Dry run (see what would happen)\nrm -n somefile.txt\n\n# Execute deletion\nrm -f somefile.txt\n\n# Recursive deletion\nrm -rf node_modules/\n\n# View deletion log\nrm-log\n\n# Check status\nsafe-rm-status\n```\n\n### Recovery\n\n```bash\n# List trashed files\ntrash-list\n\n# Restore interactively\ntrash-restore\n\n# View today's trashed items\ntrash-today\n```\n\n### Real-World Examples\n\n**Clean project (mixed content):**\n```bash\n$ rm -rf src/\nDELETED: src/__pycache__/ (build artifact)\nTRASHED: src/draft.py (recoverable)\nTRASHED: src/experimental.js (recoverable)\n```\n\n**Protection in action:**\n```bash\n$ rm -rf .git/\nBLOCKED: Refusing to delete protected path: .git/\n```\n\n## AI Agent Integration\n\nSafe-RM is designed to work seamlessly with AI coding agents:\n\n### Supported Agents\n- **Cursor IDE** – Load Agent Skill from `skills/safe-rm/SKILL.md` or raw URL\n- **VSCode GitHub Copilot** – Reference skill in workspace\n- **Claude Code** – Copy `skills/safe-rm/` to `~/.local/share/claude-skills/safe-rm/`\n- **Continue.dev** – Custom prompt integration\n- **Aider** – Compatible via zsh wrapper\n\n### How Agents Use It\n\n1. **Agent reads skill** from `skills/safe-rm/SKILL.md`\n2. **Learns classification rules** (what's safe to delete)\n3. **Executes safely** (check untracked files, trash source, delete artifacts, log to audit log)\n4. **All operations logged** to `~/.local/state/safe-rm/audit.log` (or `SAFE_RM_AUDIT_LOG`)\n\nSee [IDE Integration](docs/IDE_INTEGRATION.md) for details.\n\n## 🔧 Configuration\n\n### Custom Rules\n\nCreate `~/.config/safe-rm/safe-rm-rules.yaml` (or set `SAFE_RM_CONFIG_DIR`). This project uses the `.yaml` extension for all YAML config files.\n\n```yaml\nauto_trash_patterns:\n  - \"*.secret\"\n  - \"experiments/*\"\n  \nblock_patterns:\n  - \"*CRITICAL*\"\n  - \"production-data/*\"\n\nsettings:\n  recent_hours: 24\n  trash_retention_days: 30\n```\n\n### Environment Variables\n\n```bash\nSAFE_RM_AUDIT_LOG    # Audit log path (default: ~/.local/state/safe-rm/audit.log)\nSAFE_RM_CONFIG_DIR   # Config directory (default: ~/.config/safe-rm)\nSAFE_RM_FORCE=1      # Bypass wrapper temporarily\nSAFE_RM_QUIET=1      # Silent mode\n```\n\n**Migration:** If you used the old `~/.rm-audit.log`, move it to `~/.local/state/safe-rm/audit.log` or set `SAFE_RM_AUDIT_LOG`.\n\n## Features\n\n- **Git-aware** - Detects repositories and untracked files\n- **Non-interactive** - Perfect for AI agents and automation\n- **Audit logging** - Complete deletion history\n- **Trash integration** - Uses FreeDesktop.org trash spec\n- **Btrfs/Snapper** - Additional snapshot protection\n- **Customizable** - YAML-based configuration\n- **Fast** - \u003c 10ms classification overhead\n- **Safe by default** - Dry-run mode\n\n## 🧪 Testing\n\n```bash\n# Create test environment\nmkdir test-project \u0026\u0026 cd test-project\ngit init\necho \"test\" \u003e draft.py\necho \"build\" \u003e file.pyc\n\n# Test safe-rm\nrm -n -rf .           # Dry run - see what would happen\n```\n\n## Documentation\n\n- [Quick Start](docs/QUICKSTART.md)\n- [IDE Setup (Cursor/VSCode)](docs/IDE_INTEGRATION.md)\n\n## Requirements\n\n**Required:**\n- zsh (5.8+)\n- git\n- trash-cli\n\n**Optional:**\n- oh-my-zsh (recommended)\n- snapper (for btrfs snapshots)\n\n**Platform:**\n- Linux (tested on OpenSUSE Tumbleweed)\n- macOS (experimental support)\n\n## Contributing\n\nContributions welcome! Please see [CONTRIBUTING.md](CONTRIBUTING.md).\n\n### Development Setup\n\n```bash\n# Fork and clone\ngit clone https://github.com/kayaman/safe-rm.git\ncd safe-rm\n\n# Lint (optional)\nshellcheck bin/safe-rm safe-rm.plugin.zsh install.sh\n```\n\n## License\n\nMIT License - see [LICENSE](LICENSE) file for details.\n\n## 🙏 Credits\n\nBuilt for developers using:\n- Git for version control\n- zsh and oh-my-zsh for shell\n- AI coding agents (Cursor, Copilot, Claude Code)\n- Linux (OpenSUSE Tumbleweed, Ubuntu, etc.)\n\nInspired by:\n- [trash-cli](https://github.com/andreafrancia/trash-cli)\n- [safe-rm](https://launchpad.net/safe-rm)\n- The need for AI-agent-compatible file protection\n\n## Support\n\n- 📖 [Documentation](docs/)\n- 🐛 [Issue Tracker](https://github.com/kayaman/safe-rm/issues)\n- 💬 [Discussions](https://github.com/kayaman/safe-rm/discussions)\n\n## Star History\n\nIf this project helped you, please consider giving it a star.\n\n---\n\n**Made for safe coding with AI assistants**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkayaman%2Fsafe-rm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkayaman%2Fsafe-rm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkayaman%2Fsafe-rm/lists"}