SkillAgentSearch skills...

MacCleanCLI

๐Ÿš€ MacCleanCLI is a sleek, powerful, and interactive command-line application designed specifically for macOS, providing efficient disk cleanup, system optimization, and an outstanding user experience directly from your terminal.

Install / Use

/learn @QDenka/MacCleanCLI

README

๐ŸŽ macOS Cleaner

<div align="center"> <img width="1737" alt="macOS Cleaner Interface" src="https://github.com/user-attachments/assets/fdeb8a4e-3d95-4408-9e4b-484ee47000a7" />

A beautiful and powerful console application for cleaning and optimizing macOS systems

Python Version License Platform GitHub Stars GitHub Issues GitHub Forks

Features โ€ข Installation โ€ข Usage โ€ข Documentation โ€ข Contributing

</div>

โœจ Features

๐Ÿ” Smart Scanning

  • Multi-threaded intelligent file scanning across 19+ categories
  • Real-time progress tracking with detailed statistics
  • NEW: Preview detailed file list before cleaning with pagination
  • Pattern-based file identification with safety checks
  • Configurable minimum file size filters

๐Ÿงน Safe Cleaning

  • Priority-based cleaning (HIGH, MEDIUM, LOW, OPTIONAL)
  • Built-in protection for system-critical files
  • Optional backup system with configurable retention
  • NEW: Show exactly what will be deleted with file paths and sizes
  • Batch operations with parallel processing
  • Dry-run mode for safe preview

โšก System Optimization

  • Memory purging for performance boost
  • DNS cache flushing for network optimization
  • Startup items management (LaunchAgents/Daemons/LoginItems)
  • Spotlight index rebuilding
  • Disk verification utilities

๐ŸŽจ Beautiful UI

  • Rich console interface with colors and animations
  • Interactive menu system with keyboard shortcuts
  • Real-time progress bars and status updates
  • Comprehensive scan results visualization
  • User-friendly file detail preview with pagination

๐Ÿ›ก๏ธ Safety First

  • Protected system paths and directories
  • Confirmation prompts for destructive operations
  • Automatic backup before deletion (configurable)
  • Post-cleaning verification
  • Comprehensive error handling and logging

๐Ÿ“‹ Supported Cleaning Categories

System Categories

  • ๐Ÿ—„๏ธ System Cache - System-level cache files (HIGH priority)
  • ๐Ÿ‘ค User Cache - User application cache files (HIGH priority)
  • ๐Ÿ“ Temporary Files - System temporary files (HIGH priority)
  • ๐Ÿ“ Log Files - System and application logs (MEDIUM priority)
  • ๐Ÿ—‘๏ธ Trash - Empty system trash bin (MEDIUM priority)

Browser Data

  • ๐ŸŒ Browser Cache - Safari, Chrome, Firefox, Brave, Edge, Opera, Vivaldi (MEDIUM priority)

Developer Tools โšก NEW

  • ๐Ÿ”จ Xcode Derived Data - Build artifacts and indexes (HIGH priority)
  • ๐Ÿ—๏ธ Xcode Archives - Old app archives (MEDIUM priority)
  • ๐Ÿณ Docker Data - Containers, images, volumes (MEDIUM priority)
  • ๐Ÿบ Homebrew Cache - Package manager cache (MEDIUM priority)
  • ๐ŸŸข Node.js Modules - node_modules directories (LOW priority)
  • ๐Ÿ Python Cache - pycache and .pyc files (LOW priority)

File Management

  • ๐Ÿ“ฅ Downloads - Old downloads folder files (OPTIONAL)
  • ๐Ÿ“‹ Duplicate Files - Identical files detection (OPTIONAL)
  • ๐Ÿ“Š Large Files - Files over 100MB (OPTIONAL)
  • ๐Ÿ•ฐ๏ธ Old Files - Files not accessed in 6+ months (OPTIONAL)
  • ๐Ÿ“ฆ App Leftovers - Files from uninstalled apps (MEDIUM priority)

๐Ÿš€ Installation

Prerequisites

  • macOS 10.15 (Catalina) or later
  • Python 3.10 or higher
  • pip package manager

Quick Install

# Clone the repository
git clone https://github.com/QDenka/MacCleanCLI.git
cd MacCleanCLI

# Install with pip (development mode)
pip install -e .

Verify Installation

# Check if commands are available
macos-cleaner --help
mclean --help

System Permissions

For full functionality, grant Terminal Full Disk Access:

  1. Open System Settings โ†’ Privacy & Security โ†’ Full Disk Access
  2. Click the + button and add your Terminal app
  3. Restart Terminal and rerun the application

๐Ÿ“– Usage

Interactive Mode (Recommended)

# Run with full interface
macos-cleaner

# Or use the short alias
mclean

Interactive Workflow:

  1. Scan System - Choose categories to scan
  2. Review Results - See detailed file list with sizes
  3. Clean Files - Select items to delete
  4. Optimize System - Run system optimizations

Command Line Options

# Scan only (no cleaning)
macos-cleaner --scan-only

# Automatic mode (clean recommended items)
macos-cleaner --auto

# Use custom config file
macos-cleaner --config ~/custom-config.json

# Enable verbose output
macos-cleaner --verbose

# Dry run mode (preview only)
macos-cleaner --dry-run

# Combine options
macos-cleaner --scan-only --verbose

Python Direct Execution

# Run directly with Python
python main.py

# With options
python main.py --scan-only
python main.py --auto --verbose

๐ŸŽฎ Interactive Menu Guide

Main Menu

[1] ๐Ÿ” Scan System      - Scan for cleanable files
[2] ๐Ÿงน Clean Files      - Remove scanned files
[3] โšก Optimize System  - System optimization tasks
[4] โš™๏ธ  Settings        - Configure application
[q] ๐Ÿšช Quit            - Exit application

Scan Menu

[a] All Categories     - Scan everything
[1-9] Specific Category - Select individual category
[q] Back              - Return to main menu

New Feature: File Detail Preview โœจ

When cleaning, you can now preview exactly what will be deleted:

Show detailed file list before cleaning? [Y/n]: y

๐Ÿ“ System Cache Files
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Path: ~/Library/Caches/com.apple.Safari/Cache.db       โ”‚
โ”‚ Size: 45.2 MB                                          โ”‚
โ”‚ Safe: โœ… Yes                                            โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ ... (showing 1-20 of 156 files)                        โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Continue to next page? [Y/n]:

โš™๏ธ Configuration

Config File Location

~/.MacCleanCLI/config.json

Default Configuration

{
  "dry_run": false,
  "enable_backup": true,
  "verify_cleaning": true,
  "remove_empty_dirs": true,
  "max_workers": 4,
  "backup_retention_days": 7,
  "min_file_size_mb": 0.001,
  "scan_hidden_files": false,
  "protected_extensions": [".dmg", ".pkg", ".app"],
  "protected_directories": [
    "/System",
    "/Library/System",
    "/private/var/db"
  ]
}

Configuration Options

| Option | Type | Default | Description | |--------|------|---------|-------------| | dry_run | bool | false | Preview mode without deletion | | enable_backup | bool | true | Backup files before cleaning | | verify_cleaning | bool | true | Verify files are deleted | | remove_empty_dirs | bool | true | Remove empty directories | | max_workers | int | 4 | Parallel processing threads | | backup_retention_days | int | 7 | Days to keep backups | | min_file_size_mb | float | 0.001 | Minimum file size (1KB) | | scan_hidden_files | bool | false | Include hidden files |


๐Ÿ›ก๏ธ Safety Features

Protected Paths

The following paths are never touched:

  • /System/* - System files
  • /Library/System/* - System libraries
  • /private/var/db/* - System databases
  • /usr/bin/*, /usr/sbin/* - System binaries
  • User home directory root files

Safety Mechanisms

  • โœ… Pre-flight safety checks
  • โœ… User confirmation for all destructive operations
  • โœ… Optional automatic backup system
  • โœ… Post-cleaning verification
  • โœ… Dry-run mode for risk-free preview
  • โœ… Comprehensive error handling and logging

Backup System

# Backups stored in
~/.macos-cleaner/backups/

# Structure
backups/
โ”œโ”€โ”€ 2024-10-06_170000/    # Timestamp-based folders
โ”‚   โ”œโ”€โ”€ Caches/
โ”‚   โ””โ”€โ”€ manifest.json      # Backup metadata
โ””โ”€โ”€ 2024-10-05_120000/

๐Ÿ—๏ธ Project Architecture

Directory Structure

MacCleanCLI/
โ”œโ”€โ”€ main.py                 # Application entry point
โ”œโ”€โ”€ core/                   # Core business logic
โ”‚   โ”œโ”€โ”€ scanner.py          # Multi-threaded file scanning
โ”‚   โ”œโ”€โ”€ cleaner.py          # Safe file deletion engine
โ”‚   โ””โ”€โ”€ optimizer.py        # System optimization utilities
โ”œโ”€โ”€ models/                 # Data models and types
โ”‚   โ””โ”€โ”€ scan_result.py      # Result structures and enums
โ”œโ”€โ”€ ui/                     # User interface layer
โ”‚   โ”œโ”€โ”€ interface.py        # Interactive menu system
โ”‚   โ””โ”€โ”€ components.py       # Reusable UI components
โ”œโ”€โ”€ utils/                  # Utility modules
โ”‚   โ”œโ”€โ”€ config.py           # Configuration management
โ”‚   โ”œโ”€โ”€ logger.py           # Logging system
โ”‚   โ”œโ”€โ”€ backup.py           # Backup management
โ”‚   โ””โ”€โ”€ exceptions.py       # Custom exceptions
โ””โ”€โ”€ tests/                  # Test suite (87 tests)
    โ”œโ”€โ”€ test_scanner.py
    โ”œโ”€โ”€ test_cleaner.py
    โ”œโ”€โ”€ test_integration.py
    โ”œโ”€โ”€ test_optimizer.py
    โ””โ”€โ”€ test_new_categories.py

Design Principles

  • SOLID Principles - Clean, maintainable code architecture
  • Type Safety - Full type hints with dataclasses
  • Error Handling - Comprehensive exception handling
  • Testing - 87 tests with 41% coverage
  • Performance - Multi-threaded parallel processing
  • Safety - Multiple layers of protection

๐Ÿ”ง Development

Setup Development Environment

# Clone and navigate
git clone https://github.com/QDenka/MacCleanCLI.git
cd MacCleanCLI

# Create virtual environment (recommended
View on GitHub
GitHub Stars29
CategoryProduct
Updated2d ago
Forks4

Languages

Python

Security Score

95/100

Audited on Mar 29, 2026

No findings