clean-disk-space
Version:
๐งน The first comprehensive macOS cleanup tool for npm! No Homebrew or Python needed. Clean disk space with npx - from trash to node_modules, caches to Docker. Safe, interactive, and tracks space freed. System-wide cleanup made simple.
371 lines (260 loc) โข 9.44 kB
Markdown
# ๐งน clean-disk-space
[](https://www.npmjs.com/package/clean-disk-space)
[](https://www.npmjs.com/package/clean-disk-space)
[](https://opensource.org/licenses/MIT)
[](https://nodejs.org)
> **The first comprehensive macOS cleanup tool available as an npm package!** ๐
>
> No Homebrew required. No Python dependencies. Just `npx clean-disk-space` and go.
Clean up **gigabytes** of unnecessary files with confidence. Features **space tracking**, **dry-run mode**, and **two cleanup levels** (safe & aggressive).
```bash
# Install globally
npm install -g clean-disk-space
# Or use instantly with npx (no installation needed!)
npx clean-disk-space
```
## ๐ฏ Why clean-disk-space?
Unlike other macOS cleanup tools, **clean-disk-space** is:
### โ
npm-Native
- **No Homebrew needed** (unlike `mac-cleanup`)
- **No Python required** (unlike `mac-cleanup-py`)
- Works instantly with `npx` - zero setup!
### โ
Comprehensive
- **System-wide cleanup** (not just node_modules like `npkill`)
- Cleans Homebrew, Docker, Xcode, caches, logs, and more
- All in one command
### โ
Developer-Friendly
- Built for the Node.js ecosystem
- Zero external dependencies
- Interactive confirmations for safety
- Tracks exactly how much space you freed
### โ
Safe by Default
- Preview mode with `--dry-run`
- Shows what will be deleted before deletion
- No sudo required
- Never touches system files
## ๐ Comparison with Alternatives
| Feature | clean-disk-space | mac-cleanup | mac-cleanup-py | npkill |
|---------|------------------|-------------|----------------|--------|
| **Installation** | npm/npx | Homebrew | pip | npm |
| **External Dependencies** | โ
None | โ Homebrew | โ Python | โ
None |
| **System-wide Cleanup** | โ
Yes | โ
Yes | โ
Yes | โ No |
| **node_modules Cleanup** | โ
Yes | โ No | โ No | โ
Yes |
| **Docker Cleanup** | โ
Yes | โ
Yes | โ
Yes | โ No |
| **Xcode Cleanup** | โ
Yes | โ
Yes | โ
Yes | โ No |
| **Space Tracking** | โ
Yes | โ No | โ No | โ No |
| **Dry-run Preview** | โ
Yes | โ No | โ
Yes | โ No |
| **Built-in Docs** | โ
Yes | โ No | โ No | โ No |
| **Works with npx** | โ
Yes | โ No | โ No | โ
Yes |
**clean-disk-space is the only npm-native, comprehensive macOS cleanup tool!**
## โจ Features
<table>
<tr>
<td width="33%">
### ๐ก๏ธ Safety First
- **Dry-run mode** to preview
- **Interactive confirmations**
- **Color-coded warnings**
- **No system files touched**
</td>
<td width="33%">
### ๐ Smart Tracking
- **Before/after sizes**
- **Total space freed**
- **Detailed breakdowns**
- **Progress indicators**
</td>
<td width="33%">
### ๐ช Powerful
- **Standard + Deep modes**
- **Built-in documentation**
- **Zero dependencies**
- **Lightning fast**
</td>
</tr>
</table>
## ๐ Quick Start
### Installation
```bash
# Install globally
npm install -g clean-disk-space
# Or use without installing
npx clean-disk-space
```
### Basic Usage
```bash
# Preview what will be cleaned (recommended first run)
clean-disk-space --dry-run
# Run interactive cleanup
clean-disk-space
# Auto-confirm all safe operations
clean-disk-space --yes
```
### Advanced Usage
```bash
# Deep cleanup (node_modules, Docker, etc.) - with confirmations
clean-disk-space deep
# Preview deep cleanup
clean-disk-space deep --dry-run
# View full documentation
clean-disk-space docs
```
## ๐บ Demo
```bash
$ clean-disk-space --dry-run
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๐งน macOS Disk Space Cleaner โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๏ธ DRY RUN MODE - No changes will be made
๐พ Disk Space:
Total: 500GB
Used: 450GB (90%)
Available: 50GB
๐ฆ Emptying Trash...
Current size: 2.3GB
๐พ Would free: 2.3GB
๐บ Cleaning Homebrew cache...
Can free: ~1.2GB
๐๏ธ Cleaning user caches...
Current size: 3.5GB
๐พ Would free: 3.5GB
โจ Cleanup complete!
Run with --deep for aggressive cleanup
```
## ๐งน What Gets Cleaned
### ๐ฆ Standard Cleanup (Safe - Default)
| Item | What It Does | Typical Space Freed | Safe? |
|------|--------------|---------------------|-------|
| ๐๏ธ **Trash** | Empties `~/.Trash` | 0-5GB | โ
Yes |
| ๐บ **Homebrew Cache** | Removes old downloads | 0.5-2GB | โ
Yes |
| ๐ **Browser Caches** | Safari, Chrome caches | 1-5GB | โ
Yes |
| ๐ฆ **npm Cache** | Cached packages | 0.5-2GB | โ
Yes |
| ๐งถ **Yarn Cache** | Cached dependencies | 0.5-2GB | โ
Yes |
| ๐ **Old Logs** | Logs older than 30 days | 0.1-1GB | โ
Yes |
| ๐ฑ **Xcode DerivedData** | Build artifacts (rebuilds automatically) | 5-20GB | โ
Yes* |
*Requires confirmation
**Total Typical Savings: 2-10GB** ๐พ
### ๐ฅ Deep Cleanup (Aggressive)
| Item | What It Does | Typical Space Freed | Requires Confirmation |
|------|--------------|---------------------|----------------------|
| ๐ **node_modules** | Removes all node_modules folders | 5-50GB | โ ๏ธ Yes |
| ๐ณ **Docker** | Unused images/containers | 1-10GB | โ ๏ธ Yes |
| ๐ **CocoaPods** | iOS dependency cache | 0.5-5GB | โ ๏ธ Yes |
| ๐ค **Gradle** | Android build cache | 1-10GB | โ ๏ธ Yes |
| ๐ฆ **Xcode Archives** | App distribution builds | 5-50GB | โ ๏ธ Yes |
**Total Typical Savings: 10-50GB+** ๐พ
## ๐ฏ Commands & Options
### Commands
```bash
clean-disk-space # Standard cleanup (default)
clean-disk-space deep # Aggressive cleanup
clean-disk-space help # Show help
clean-disk-space docs # Show full documentation
```
### Options
| Option | Alias | Description |
|--------|-------|-------------|
| `--dry-run` | `-d` | Preview without making changes |
| `--yes` | `-y` | Auto-confirm all prompts |
| `--verbose` | `-v` | Detailed output |
| `--help` | `-h` | Show help |
## ๐ Common Workflows
### ๐๏ธ Monthly Maintenance
```bash
# Quick monthly cleanup (safe)
clean-disk-space --yes
```
### ๐พ Low Disk Space Emergency
```bash
# Step 1: Preview standard cleanup
clean-disk-space --dry-run
# Step 2: Run standard cleanup
clean-disk-space
# Step 3: Preview deep cleanup
clean-disk-space deep --dry-run
# Step 4: Run deep cleanup (will ask for confirmation)
clean-disk-space deep
```
### ๐ Exploration Mode
```bash
# Learn what it does
clean-disk-space docs
# See what would be cleaned
clean-disk-space --dry-run
clean-disk-space deep --dry-run
```
### ๐ Before Major Updates
```bash
# Free maximum space before macOS update
clean-disk-space deep --dry-run
clean-disk-space deep
```
## ๐ก๏ธ Safety Features
### โ
What's Safe to Delete
- โ
Application caches (rebuilds automatically)
- โ
Package manager caches (re-downloads on demand)
- โ
Old log files (>30 days)
- โ
Trash contents
- โ
Build artifacts (can rebuild)
### โ ๏ธ What Requires Confirmation
- โ ๏ธ **node_modules**: Shows full list before deletion
- โ ๏ธ **Docker images**: May remove images you need
- โ ๏ธ **Xcode Archives**: App distribution builds (backup first!)
- โ ๏ธ **Build caches**: Gradle, CocoaPods
### โ What's NEVER Deleted
- โ System files
- โ Applications
- โ User documents
- โ Active project files
- โ Recent logs (<30 days)
## ๐ก Pro Tips
1. **Always dry-run first**: `clean-disk-space --dry-run`
2. **Start with standard cleanup**: Only use deep mode when necessary
3. **Monthly maintenance**: Run `clean-disk-space --yes` monthly
4. **Before major updates**: Use deep cleanup before macOS upgrades
5. **node_modules cleanup**: Great for freeing 20GB+ for developers
6. **Keep backups**: Especially before cleaning Xcode Archives
## ๐ง Requirements
- **OS**: macOS 10.15 (Catalina) or later
- **Node.js**: v12.0.0 or later
- **Permissions**: Terminal access (no sudo required for most operations)
## ๐ค Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request
## ๐ License
MIT ยฉ [CVSRohit](https://github.com/CVSRohit)
## ๐ Links
- **npm Package**: https://www.npmjs.com/package/clean-disk-space
- **GitHub Repository**: https://github.com/CVSRohit/clean-disk-space
- **Report Issues**: https://github.com/CVSRohit/clean-disk-space/issues
## โญ Show Your Support
If this tool helped you free up disk space, please consider:
- โญ Starring the repository
- ๐ Writing a review
- ๐ค Contributing improvements
- ๐ฌ Sharing with others
<div align="center">
**Made with โค๏ธ for the macOS community**
[](https://github.com/CVSRohit/clean-disk-space)
**Note**: Always have backups of important data before running cleanup tools!
</div>