Mac Cleaner
Scan and clean junk files on macOS systems to help free up disk space.
Quick Start
Use the following commands to scan different types of junk files:
bash
# Scan system cache and temporary files
bash .claude/skills/mac-cleaner/scripts/scan_cache.sh
# Scan development temporary files and build artifacts (node_modules, .next, dist, etc.)
bash .claude/skills/mac-cleaner/scripts/scan_dev_files.sh /path/to/scan
# Scan duplicate files (requires fdupes to be installed first: brew install fdupes)
bash .claude/skills/mac-cleaner/scripts/scan_duplicates.sh /path/to/scan
# Scan large files (default > 100MB)
bash .claude/skills/mac-cleaner/scripts/scan_large_files.sh /path/to/scan 100M 20
Scan Types
1. System Cache Files
Scans include:
- - User cache
- - System cache
- - User logs
- - System logs
- - Trash
- - Temporary files
Usage Scenarios:
- Slow system performance
- Application exceptions
- Regular system maintenance
Notes:
- Deleting system cache requires sudo privileges
- Applications may run slowly the first time after deletion (cache needs to be rebuilt)
- It is recommended to back up important data first
2. Development Temporary Files
Scans include:
- - Node.js dependencies
- - Next.js build artifacts
- / - Frontend build artifacts
- - Java/Scala compilation artifacts
- / - Python cache
- - macOS system files
- - Log files
Parameters:
- First parameter: Scan directory (default current directory)
- Second parameter: Maximum depth (default 3 levels)
Usage Scenarios:
- Development projects taking up too much space
- Clean up build artifacts before switching branches
- Clean up unused project dependencies
Examples:
bash
# Scan current directory
bash .claude/skills/mac-cleaner/scripts/scan_dev_files.sh
# Scan specified directory with depth 2
bash .claude/skills/mac-cleaner/scripts/scan_dev_files.sh ~/projects 2
3. Duplicate Files
Use the
tool to find duplicate files.
Prerequisites:
Parameters:
- First parameter: Scan directory (default current directory)
- Second parameter: Minimum file size (default 1M)
Usage Scenarios:
- Duplicate backup files
- Duplicate downloaded files
- Duplicate project resource files
Examples:
bash
# Scan duplicate files larger than 1MB in current directory
bash .claude/skills/mac-cleaner/scripts/scan_duplicates.sh
# Scan duplicate files larger than 10MB in specified directory
bash .claude/skills/mac-cleaner/scripts/scan_duplicates.sh ~/Documents 10M
Cleanup Commands:
bash
# Interactive deletion (keep the first file in each duplicate group)
fdupes -r -d -N /path/to/scan
4. Large Files
Locate files that take up a lot of space.
Parameters:
- First parameter: Scan directory (default current directory)
- Second parameter: Minimum file size (default 100M)
- Third parameter: Show top N files (default 20)
Usage Scenarios:
- Insufficient disk space
- Find large files that can be deleted
- Analyze disk space usage
Examples:
bash
# Find files larger than 100MB, show top 20
bash .claude/skills/mac-cleaner/scripts/scan_large_files.sh
# Find files larger than 1GB, show top 10
bash .claude/skills/mac-cleaner/scripts/scan_large_files.sh ~/Documents 1G 10
Cleanup Process
All scan scripts will provide cleanup command recommendations. Follow this safe process:
Step 1: Scan
First use the corresponding script to scan the target directory and identify junk files.
Step 2: Review Results
Carefully review the scan results and confirm the files to delete:
- Confirm the files are no longer needed
- Check for important data
- Verify deletion will not affect other programs
Step 3: Backup (Optional)
For important files, it is recommended to back up first:
bash
# Create backup
cp -r /path/to/important/file ~/backup/
# Or use tar to package
tar -czf backup_$(date +%Y%m%d).tar.gz /path/to/file
Step 4: Delete
Use the cleanup commands provided by the script, or delete manually:
bash
# Delete single file/directory
rm -rf /path/to/file
# Delete multiple files
rm -rf file1 file2 file3
# Use find to delete in batches
find . -name "node_modules" -type d -prune -exec rm -rf {} +
Best Practices
Development Project Cleanup
For development projects, it is recommended to use
to prevent committing temporary files:
gitignore
node_modules/
.next/
dist/
build/
__pycache__/
*.pyc
.DS_Store
*.log
Before cleaning up the project, you can use:
bash
# Save dependency list
npm list > dependencies.txt
# Delete node_modules
rm -rf node_modules
# Restore when needed
npm install
Regular Cleanup
It is recommended to run cleanup regularly (monthly or quarterly):
- Empty Trash
- Clear browser cache
- Delete development build artifacts
- Find and delete duplicate files
System Cache Cleanup
System cache cleanup requires caution:
- Only delete known safe caches
- Avoid deleting caches that are in use
- Applications may need to be restarted after deletion
Safety Warnings
⚠️ Important Notes:
- Deletion operations are irreversible, please confirm carefully
- Deleting system files and caches requires sudo privileges, extra caution is needed
- It is recommended to back up important data before deletion
- If you are unsure about the purpose of a file, please query or consult first
- Some applications may run slowly the first time after cache deletion
Troubleshooting
fdupes Not Installed
If you get a prompt that fdupes is not installed when using duplicate file scanning:
Insufficient Permissions
Some system directories require sudo privileges:
bash
sudo bash .claude/skills/mac-cleaner/scripts/scan_cache.sh
Slow Scanning
For large directories:
- Limit scan depth
- Increase minimum file size limit
- Scan directories separately
Resources
scripts/
- - Scan system cache and temporary files
- - Scan development temporary files and build artifacts
- - Scan duplicate files
- - Scan large files
generate_cleanup_commands.sh
- Generate safe deletion scripts with confirmation