Agent skill
safe-file-removal
Use safe-rm command to safely 'remove' files by renaming them to .obsolete instead of permanent deletion. Reversible, collision-safe, hook-compliant.
Install this agent skill to your Project
npx add-skill https://github.com/phamhung075/4genthub-hooks/tree/main/skills/safe-file-removal
SKILL.md
Safe File Removal
Rename files to .obsolete instead of permanent deletion via safe-rm command.
When to Use
- Removing temp files, build artifacts, old code, deprecated tests
- After refactoring (keep backup during testing)
- Any situation where
rmis blocked by pre-tool hooks - Need reversible "deletion"
Why Not rm
Project setting: .claude/settings.json:132 → "RM_BASH_BLOCK": "true"
| Issue | Solution |
|---|---|
rm permanently deletes |
safe-rm renames (reversible) |
| Blocked by pre-tool hooks | Works within safety constraints |
| No recovery | mv file.obsolete file restores |
Command
./.claude/bin/safe-rm [file1] [file2] [dir/]
Path: .claude/bin/safe-rm:1-72
Features
| Feature | Benefit |
|---|---|
| Reversible | mv file.obsolete file recovers |
| Multi-file | Handle multiple args in one command |
| Collision safe | Adds timestamp if .obsolete exists |
| Color output | Green ✓ / Yellow ⚠ / Red ✗ |
| Statistics | Reports renamed/failed count |
Basic Usage
| Operation | Command | Result |
|---|---|---|
| Single file | ./.claude/bin/safe-rm file.txt |
file.txt.obsolete |
| Multiple | ./.claude/bin/safe-rm f1 f2 dir/ |
All get .obsolete suffix |
| Restore | mv file.obsolete file |
Original restored |
Recovery
| Scenario | Command |
|---|---|
| Single | mv file.obsolete file |
| With timestamp | mv file.obsolete.20251109_110500 file |
| Find all | find . -name "*.obsolete" |
| Restore all | find . -name "*.obsolete" | while read f; do mv "$f" "${f%.obsolete}"; done |
Workflow
- Mark obsolete →
safe-rm [files] - Verify works →
npm test && npm run build - Review periodic →
find . -name "*.obsolete" - Permanent delete (when confident) →
/bin/rm [file].obsolete
When NOT to Use
| Scenario | Use safe-rm? | Why |
|---|---|---|
| Secrets (.env, keys) | ❌ | Needs secure deletion + git history rewrite |
| .git folder | ❌ | Too risky |
| node_modules | ⚠️ | rm -rf safe, but safe-rm works |
| Temp/build | ✅ | Reversible, safe |
Output Examples
Success:
✓ Renamed: file.txt → file.txt.obsolete
─────────────────────────────────────
Renamed: 1
Collision (timestamp fallback):
⚠ Already exists: file.obsolete
Using: file.obsolete.20251109_110500
✓ Renamed: file → file.obsolete.20251109_110500
Error:
✗ Not found: missing.txt
─────────────────────────────────────
Failed: 1
Quick Reference
| Task | Command |
|---|---|
| Remove single | ./.claude/bin/safe-rm file.txt |
| Remove multiple | ./.claude/bin/safe-rm f1 f2 dir/ |
| Restore | mv file.obsolete file |
| List obsolete | find . -name "*.obsolete" |
| Count | find . -name "*.obsolete" | wc -l |
Supporting Files
- EXAMPLES.md - 10 scenarios: temp files, refactoring, tests, collisions, assets, docs, batch ops, scripting, git, hooks
- TEMPLATES.md - Copy-paste commands for all operations
- VALIDATION.md - Safety checklists, verification commands
Key Insight
Safety by design: No permanent deletion → collision protection → hook compliance → audit trail. Development workflow: Refactor → safe-rm → Test → Review period → Permanent delete after confidence.
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
unused-code-cleanup
Systematically identify and remove unused imports, variables, and dead code from TypeScript/React projects using --noUnusedLocals and --noUnusedParameters compiler flags
spawn-team
Spawn an agent team using the Proxy Pattern. Team lead fetches agent configs from MCP and injects them into teammate prompts (since team agents cannot access MCP tools).
token-economy
Apply token optimization when writing docs, changelogs, MCP tasks. Quality
changelog-updater
Update CHANGELOG.md and TEST-CHANGELOG.md with new entries following Keep a Changelog format and token optimization principles. Use when adding changes to the changelog, documenting new features, fixes, or optimizations.
handoff
Compact the current conversation into a handoff document for another agent to pick up.
obsidian-vault
Search, create, and manage notes in the Obsidian vault with wikilinks and index notes. Use when user wants to find, create, or organize notes in Obsidian.
Didn't find tool you were looking for?