Back to list
phamhung075

safe-file-removal

by phamhung075

3🍴 1📅 Dec 29, 2025

SKILL.md


name: safe-file-removal description: Use safe-rm command to safely 'remove' files by renaming them to .obsolete instead of permanent deletion. Reversible, collision-safe, hook-compliant. allowed-tools: Bash, Read, Grep

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 rm is blocked by pre-tool hooks
  • Need reversible "deletion"

Why Not rm

Project setting: .claude/settings.json:132"RM_BASH_BLOCK": "true"

IssueSolution
rm permanently deletessafe-rm renames (reversible)
Blocked by pre-tool hooksWorks within safety constraints
No recoverymv file.obsolete file restores

Command

./.claude/bin/safe-rm [file1] [file2] [dir/]

Path: .claude/bin/safe-rm:1-72

Features

FeatureBenefit
Reversiblemv file.obsolete file recovers
Multi-fileHandle multiple args in one command
Collision safeAdds timestamp if .obsolete exists
Color outputGreen ✓ / Yellow ⚠ / Red ✗
StatisticsReports renamed/failed count

Basic Usage

OperationCommandResult
Single file./.claude/bin/safe-rm file.txtfile.txt.obsolete
Multiple./.claude/bin/safe-rm f1 f2 dir/All get .obsolete suffix
Restoremv file.obsolete fileOriginal restored

Recovery

ScenarioCommand
Singlemv file.obsolete file
With timestampmv file.obsolete.20251109_110500 file
Find allfind . -name "*.obsolete"
Restore allfind . -name "*.obsolete" | while read f; do mv "$f" "${f%.obsolete}"; done

Workflow

  1. Mark obsolete → safe-rm [files]
  2. Verify works → npm test && npm run build
  3. Review periodic → find . -name "*.obsolete"
  4. Permanent delete (when confident) → /bin/rm [file].obsolete

When NOT to Use

ScenarioUse safe-rm?Why
Secrets (.env, keys)Needs secure deletion + git history rewrite
.git folderToo risky
node_modules⚠️rm -rf safe, but safe-rm works
Temp/buildReversible, 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

TaskCommand
Remove single./.claude/bin/safe-rm file.txt
Remove multiple./.claude/bin/safe-rm f1 f2 dir/
Restoremv file.obsolete file
List obsoletefind . -name "*.obsolete"
Countfind . -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.

Score

Total Score

60/100

Based on repository quality metrics

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

+10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

0/5

Reviews

💬

Reviews coming soon