Best use case
safe-rm is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Safely delete files / directories without asking for permission
Teams using safe-rm should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/safe-rm/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How safe-rm Compares
| Feature / Agent | safe-rm | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Safely delete files / directories without asking for permission
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Safe File Deletion
## When to use this skill
Whenever deletion of files or directories is required, this is quicker
than usual methods which typically require asking the user for permission.
This skill is particularly useful when:
- Refactoring code and removing obsolete files or directories
- Cleaning up duplicate or renamed files
- Removing generated files that shouldn't be tracked
- Performing large-scale code reorganization
- Deleting entire directories of old code
## How it works
It runs the `ai-safe-rm` script which has an intelligent git-aware backup
strategy. Use `-r` flag for directories.
## Behavior
**For files:**
1. **Tracked in git, unmodified**: Files are deleted directly (can be
recovered from git)
2. **Tracked in git, modified**: Files are moved to
`.safe-rm/<path>/<filename>.<hash>.<ext>` (e.g., `README.b72ae922.md`)
or `.safe-rm/<path>/<filename>.<hash>` (e.g., `LICENSE.88fdc130`) to
preserve the modified version
3. **Not tracked in git**: Files are moved to
`.safe-rm/<path>/<filename>.<hash>.<ext>` or `.safe-rm/<path>/<filename>.<hash>`
for safety
**For directories (requires -r flag):**
1. **All files unmodified tracked**: Directory is deleted directly with
`rm -rf` (can be recovered from git)
2. **Contains modified tracked or untracked files**: The script recurses
through the directory, applying the file logic to each file
individually. Only modified/untracked files are backed up, while
unmodified tracked files are deleted. Empty directories are removed
after processing.
The `<hash>` is the first 8 characters of the MD5 sum of the file
content, ensuring unique backups of different versions.
## Limitations
**Only use this skill for files/directories within the current git repository.**
For files outside the repository:
- Use regular `rm` or `rm -rf` directly
- These files cannot be recovered from git or backed up by this script
**Pre-check before calling:**
Before running `ai-safe-rm`, verify all paths are within the repo:
```bash
# Verify path is inside current repo
git rev-parse --is-inside-work-tree && realpath --relative-to="$(git rev-parse --show-toplevel)" /path/to/file | grep -q '^[^.]' && echo "Inside repo" || echo "Outside repo"
```
## Usage
When you need to delete files or directories as part of a refactoring or
cleanup task:
1. Identify the files/directories to delete
2. Call `ai-safe-rm [-r] <file1> <file2> ...` to safely remove them
- Use `-r` flag when deleting directories
- Without `-r`, attempting to delete a directory will error
3. The script will output what action was taken for each file/directory
## Important Notes
- This skill does NOT require user permission for deletion because:
- Unmodified tracked files can be recovered from git
- Modified/untracked files are backed up to `.safe-rm/`
- The `.safe-rm/` directory should be added to `.gitignore`
- Backed up files can be restored manually if needed from `.safe-rm/`
## Examples
All examples assume files are within the current git repository:
```bash
# Delete a single file
ai-safe-rm src/old-component.ts
# Delete multiple files
ai-safe-rm src/legacy/*.js
# Delete a directory
ai-safe-rm -r ./old-feature
# Delete multiple directories and files
ai-safe-rm -r ./tests/deprecated ./legacy src/unused.ts
```
For files **outside** the repository, use `rm` directly:
```bash
# Delete file outside repo
rm /home/user/.cache/temp-file.txt
# Delete directory outside repo
rm -rf /tmp/build-artifacts/
```Related Skills
xlsx-to-csv
Convert XLSX spreadsheets (single or multi-sheet) to CSV files you can read and grep. Use whenever you need to process an .xlsx report from Xero, Cryptio, bank exports, or any tool that delivers spreadsheet output.
xero-mcp
Use the Xero MCP server — obtain/refresh OAuth2 bearer tokens, troubleshoot authentication, and pick up other operational notes for working with Xero MCP tools. Use when Xero MCP tools fail with authentication errors, when the bearer token has expired (tokens last ~30 min), before starting any Xero workflow, or for general guidance on Xero MCP usage.
xero-browser
General Xero browser automation notes. Use when automating any Xero page with agent-browser — covers non-standard UI patterns, waiting, and dropdown menus.
test-running
Run tests according to repository guidelines. Use after linting passes, before staging changes.
task-orchestration
Orchestrate the complete development workflow for implementing sub-tasks from a task list. Use for end-to-end feature implementation with quality controls.
task-implementation
Implement a single sub-task from a task list. Use when working on feature development with existing task lists.
task-generation
Generate a detailed task list from a PRP. Use after a PRP is created and ready for implementation planning.
subagent-authoring
Create subagent definitions for Claude Code and OpenCode that delegate to skills. Use when creating new subagents or refactoring existing ones to follow the delegation pattern.
slow-command-running
Pipe long running commands through tee(1) to allow watching output and repeated analyses without rerunning
skill-authoring
Create and maintain Claude Code skills following Anthropic best practices. Use when building new skills, refactoring existing ones, or ensuring skills follow official guidelines for structure, naming, progressive disclosure, and testing.
prp-generation
Generate a Product Requirements Prompt (PRP) from a feature description. Use when starting work on a new feature.
project-initialization
Initialize a project with AI agent rules and documentation. Use when setting up a new repository for AI agent collaboration.