---
name: auto-hapus-sampah
description: "Scan dan hapus file tidak penting — temp, junk, cache, log, kosong, duplikat — dari folder tertentu."
---

# Auto Hapus Sampah

Hapus file tidak penting dari folder. Selalu dry-run dulu, konfirmasi sebelum hapus beneran.

## Cara Pakai

```
/run hapus : /path/to/folder
```

Prompt: `hapus : [folder]`

## Alur Kerja

```
START
  ↓
1. Terima path folder dari BOSS
  ↓
2. Jalankan scan (dry-run mode)
  ↓
3. Tampilkan preview file yang akan dihapus
  ↓
4. Tanya konfirmasi ke BOSS
  ↓
5. BOSS confirm → jalankan ulang dengan --confirm
  ↓
6. Laporkan hasil
```

## Yang Dideteksi

| Kategori | Pola |
|----------|------|
| Temporary | `.tmp`, `.temp`, `.bak`, `.swp`, `.old`, `.orig` |
| OS junk | `Thumbs.db`, `.DS_Store`, `desktop.ini` |
| Cache | `.pyc`, `.pyo`, `.class`, `.o`, `.obj` |
| Log | `.log` |
| Junk prefix/suffix | `~file`, `file~` |
| File kosong | Size = 0 byte |
| Duplikat | Hash MD5 sama (keep 1, hapus sisanya) |

## Keamanan

- **Selalu dry-run dulu** — tanpa `--confirm`, script hanya preview
- Skip folder: `node_modules`, `.git`, `venv`, `.venv`, hidden dirs
- Duplikat: keep file pertama, hapus yang lain
- Output progress ke stderr, hasil ke stdout

## Script

```bash
# Preview (dry-run)
python3 scripts/hapus_sampah.py /path/to/folder

# Hapus beneran (BOSS confirm)
python3 scripts/hapus_sampah.py /path/to/folder --confirm
```

## Output Contoh

```
🗑️  HAPUS SAMPAH — DRY-RUN (tidak ada file dihapus)
📂 Folder: /home/boss/Documents
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  Temporary (2):
    ├── /home/boss/Documents/backup.bak  [1.2 MB]
    ├── /home/boss/Documents/temp.tmp   [45 KB]

  File Kosong (3):
    ├── /home/boss/Documents/empty.txt
    ├── /home/boss/Documents/kosong.csv
    └── /home/boss/Documents/nothing.md

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📊 Total ditemukan: 5 file (1.3 MB)
💡 Ini dry-run. Tambah --confirm untuk hapus beneran.
```
