Originally published on 2026-01-13
Original article (Japanese): Mole: ターミナルから始めるMac最適化の基本
Mole is a free open-source cleaner for macOS. It is a CLI (Command Line Interface) tool that runs from the terminal, designed to cover the "common use cases" typically handled by tools like CleanMyMac, AppCleaner, DaisyDisk, and iStat Menus all in one command.
I became interested in such tools as parallel development increased, leading to more frequent issues with resource depletion, such as disk space and memory. I wanted a solution that could be run regularly, rather than just a one-time cleanup like a year-end decluttering.
In this article, I will summarize the basic usage of Mole and key points for Mac developers to incorporate "sustainable maintenance" into their routines.
What is Mole?
Mole is a system optimization tool for macOS developed by tw93. He is known for various open-source projects, including Pake (35,000+ ⭐) and MiaoYan.
Main Features
- Lightweight: No GUI, runs from the terminal
- Integrated: Combines features of multiple paid tools into one
- Open Source: MIT License, with over 28,500 stars on GitHub
- Automatable: Can be integrated into shell scripts or cron jobs
Installation
The easiest way to install is using Homebrew (a package manager for macOS):
brew install mole
Alternatively, you can use the official installation script:
curl -fsSL https://raw.githubusercontent.com/tw93/mole/main/install.sh | bash
Basic Usage
Interactive Menu
Running the mo command without arguments will display an interactive menu:
mo
You can choose from the following features:
- Clean - Remove caches and logs
- Uninstall - Completely remove applications
- Optimize - System optimization
- Analyze - Disk usage analysis
- Status - Real-time system monitoring
Direct Command Execution
You can also execute each feature directly:
mo clean # Cache cleaning
mo uninstall # Application uninstallation
mo optimize # System optimization
mo analyze # Disk analysis
mo status # Display system status
Details of Each Feature
1. Clean - Freeing Up Disk Space
mo clean removes the following files:
- User application caches
- Browser caches (Chrome, Safari, Firefox)
- Development tool caches (Xcode, Node.js, npm)
- System logs and temporary files
- Contents of the Trash
Dry Run
If you want to see what will be deleted before actually doing it, use the --dry-run option:
mo clean --dry-run
This will display a list of files to be deleted along with their sizes.
Whitelist Management
If you want to protect specific caches:
mo clean --whitelist
You can add paths that you want to protect.
2. Uninstall - Completely Remove Applications
The standard uninstallation on macOS removes the application itself but leaves behind related files. Mole completely removes:
- The application itself
- Files in Application Support
- Preference files
- Log files
- Launch Agents/Daemons
- Plugins and extensions
mo uninstall
A list of installed applications will be displayed, allowing you to select with the space bar and execute the deletion with Enter.
3. Optimize - Refresh the System
mo optimize performs the following actions:
- Rebuilds system databases
- Resets network services
- Refreshes Finder and Dock
- Cleans up diagnostic logs
- Rebuilds Spotlight index
mo optimize
It's effective to try when your Mac feels sluggish.
4. Analyze - Visualize Disk Usage
mo analyze visually displays usage by directory:
mo analyze
You can navigate with the arrow keys, enter directories with Enter, and check the contents of subdirectories. This is useful for finding large files.
5. Status - System Monitoring Dashboard
mo status displays real-time system information:
- CPU usage (per core)
- Memory usage
- Disk I/O
- Network traffic
- List of processes
mo status
At the top of the screen, there is ASCII art of a walking mole, which is amusing. You can toggle its visibility with the k key.
Developer-Friendly Features
Purge - Delete Build Artifacts
A particularly useful feature for developers is purge. It allows you to bulk delete build artifacts such as node_modules, target (Rust), dist, and build:
mo purge
By default, it automatically scans common development directories (e.g., ~/Projects or ~/GitHub). Since the layout can vary by environment, it's safer to explicitly specify paths with mo purge --paths.
Custom Path Settings
If you want to specify your own project directories:
mo purge --paths
Alternatively, you can directly edit the ~/.config/mole/purge_paths file:
~/Documents/MyProjects
~/Work/ClientA
~/Work/ClientB
Note: Projects modified in the last 7 days are excluded from the default selection, but once deleted, they cannot be restored.
Installer - Delete Installer Files
Find and delete installer files (.dmg, .pkg, etc.) that have accumulated in your Downloads folder:
mo installer
It searches for installer files in the following locations:
- Downloads
- Desktop
- Homebrew cache
- iCloud Drive
- Mail downloads
Touch ID Support
Set up sudo commands to be authenticated with Touch ID:
mo touchid
This replaces password input with Touch ID for system changes.
Shell Completion
Enabling tab completion makes command input easier:
mo completion
It supports Bash, Zsh, and Fish.
Integration into Automation
Mole can be executed from shell scripts, allowing for the automation of regular maintenance.
Example Cron Job
Set up a cron job to perform cleanup every Sunday night. The path may vary depending on whether you're using Apple Silicon (/opt/homebrew/bin) or Intel (/usr/local/bin), so first check the actual path with command -v mo.
command -v mo
# Edit crontab
crontab -e
# Example: Paste the path of mo (replace with your environment's result)
0 2 * * 0 /opt/homebrew/bin/mo clean > /dev/null 2>&1
Example Shell Script
Weekly maintenance script:
#!/bin/bash
# weekly-maintenance.sh
echo "=== Weekly Mac Maintenance ==="
echo ""
echo "1. Cleaning caches..."
mo clean
echo ""
echo "2. Optimizing system..."
mo optimize
echo ""
echo "3. Cleaning old projects..."
mo purge
echo ""
echo "Maintenance complete!"
Turning Year-End Cleaning into "Ongoing Maintenance"
Speaking of which, I wrote an article titled "Engineer Year-End Cleanup 2025 (Part 2)" summarizing reclaiming disk space and auditing Homebrew during the year-end. This article extends that discussion into how to turn a one-time cleanup into regular maintenance.
Even if you clean once at the end of the year, things can get messy quickly when developing. Especially when working on multiple projects in parallel, node_modules, build artifacts, and browser caches can accumulate, leading to a feeling of "my Mac is slow" or "there's no free space."
For me, the key to sustainability is threefold: "preview before deletion," "narrow down the targets," and "decide on the frequency of maintenance."
- First, see what happens with
mo clean --dry-runandmo optimize --dry-run. - Use
purgewith the project root explicitly specified via--pathsto narrow the scan range. - Run it once a week (not daily) to avoid interrupting work.
Even if you start with a "big cleanup" topic, this kind of operation can be effective in daily use.
Differentiating from Existing Tools
Mole is not necessarily the best fit for every use case. Here are some considerations for differentiation:
When Mole is Suitable
- You are comfortable with CLI tools
- You want to automate or script tasks
- You want to use it in server or CI environments
- You are looking for a free and lightweight tool
When a GUI Cleaner is More Suitable
- You want to work visually and confirm actions
- You need detailed disk analysis
- You want support or update guarantees
- You are a Mac beginner
Paid tools like CleanMyMac X offer more detailed analysis features and ongoing support. It's best to choose based on your needs.
Security Considerations
Mole is an open-source project, and the results of security audits are published in SECURITY_AUDIT.md.
Key security measures include:
- Protection of system files (deletion targets are mainly caches and logs)
- Pre-confirmation with dry run mode
- Whitelist functionality
- MIT License allows anyone to audit the code
While there are comments on Reddit about "messy code," the GitHub commit history shows that it is actively maintained. The latest version (V1.20.0, released on January 8, 2026) is also progressing towards a transition to Go, aiming to improve code quality.
Cautions
Terminal Compatibility
Some displays may not work correctly in iTerm2. The following terminals are recommended:
- Alacritty
- kitty
- WezTerm
- Ghostty
- Warp
Irreversibility of Deletion
Files deleted with Mole cannot be restored. Always confirm with --dry-run before executing the following commands:
mo cleanmo purgemo uninstall
Impact on the System
mo optimize makes changes to the system, such as clearing DNS caches and rebuilding the Spotlight index. It is wise to execute it when you are not in the middle of important work and have some time to spare.
Conclusion
Mole is a handy free system maintenance tool for macOS developers. It is particularly recommended for those who:
- Are comfortable with terminal operations
- Want to automate maintenance tasks
- Need to regularly delete build artifacts like
node_modules - Are looking for a free and lightweight tool
On the other hand, those who prefer to work visually and need more detailed analysis features may want to consider paid tools like CleanMyMac X.
If you're interested, start by checking how much space you can save with mo clean --dry-run.

Top comments (0)