A Node.js tool for analyzing and cleaning macOS system data storage. This tool helps you identify what's taking up space in your system storage and safely remove unnecessary files.
-
Make sure you have Node.js installed on your Mac
-
Clone the repository:
git clone https://github.com/yourusername/macos-cleaner.git
cd macos-cleaner
- Install dependencies:
npm install
The tool provides three main commands:
Shows all system data locations and their sizes:
sudo node app.mjs scan
This will analyze common system data locations including:
/private/var/db/diagnostics
(System diagnostics)/private/var/folders
(Temporary files)/private/var/log
(System logs)/Library/Caches
(System caches)- And more...
View contents and sizes of a specific directory:
sudo node app.mjs inspect /path/to/directory
Example:
sudo node app.mjs inspect /Library/Caches
Remove specific files or directories:
sudo node app.mjs remove /path/to/item
Example:
sudo node app.mjs remove /Library/Caches/some-folder
The tool includes several safety measures:
- Protected paths list to prevent removal of critical system files
- Recursive size calculation before removal
- Size reporting after successful removal
- Skip handling for inaccessible files
- Error handling for insufficient permissions
The following locations are protected from removal:
/System
/Library/LaunchDaemons
/Library/LaunchAgents
/System/Library/LaunchDaemons
/System/Library/LaunchAgents
- Always run
scan
first to understand your system's storage usage - Use
inspect
to examine contents before removal - Be cautious when removing items - make sure you know what they are
- Run with
sudo
to ensure proper access to system directories - Consider backing up important data before removing large amounts of files
-
"Permission denied" errors:
- Make sure to run the commands with
sudo
- Some system files are protected by SIP (System Integrity Protection)
- Make sure to run the commands with
-
"Cannot remove protected system path":
- The file/directory is in the protected paths list
- This is a safety feature to prevent system damage
While this tool includes safety checks, use it at your own risk. Be especially careful when removing files from system locations. When in doubt:
- Research what the files/directories are used for
- Consider using macOS's built-in storage management tools
- Back up important data before making changes
- Cannot remove SIP-protected files
- Some system files may require additional permissions
- Total sizes may be approximate due to rapidly changing system files
Contributions are welcome! Please feel free to submit a Pull Request.