π¨ PROJECT ORIGIN
This project originated from: Setup-Mac
GitHub Issue: Setup-Mac #111
Clean Wizard

A comprehensive system cleanup tool for macOS with type-safe architecture and interactive TUI.
Clean Wizard cleans old caches, temporary files, and unused data across 11 different cleanup targets β from Nix generations to Homebrew, Docker containers to Go build caches, npm packages to language version managers.
β¨ Features
11 Specialized Cleaners
| Cleaner |
Target |
Status |
| Nix |
Nix store and generations |
β
Production Ready |
| Homebrew |
Homebrew cache and autoremove |
β
Production Ready |
| Docker |
Containers, images, volumes, builds |
β
Production Ready |
| Cargo |
Rust Cargo cache and registries |
β
Production Ready |
| Go |
Go module, test, and build cache |
β
Production Ready |
| Node |
npm, pnpm, yarn, bun package caches |
β
Production Ready |
| BuildCache |
Gradle, Maven, SBT build caches |
β
Production Ready |
| SystemCache |
macOS Spotlight, Xcode, CocoaPods |
β
Production Ready |
| TempFiles |
Age-based temporary files |
β
Production Ready |
| LangVersion |
NVM, Pyenv, Rbenv version managers |
π§ NO-OP (Planned) |
| Projects |
Project automation (development) |
π§ In Progress |
Preset Modes
| Mode |
Purpose |
What's Cleaned |
| Quick |
Daily cleanup |
Homebrew, Go, Node, TempFiles, BuildCache |
| Standard |
Full cleanup |
All available cleaners including Nix and Docker |
| Aggressive |
Nuclear cleanup |
All cleaners including language versions |
Interactive TUI
- Beautiful Forms - Powered by Charm Bracelet's Huh library
- Multi-Select - Choose which cleaners to run
- Progress Tracking - See each cleaner execute in real-time
- Size Estimates - See freed space before confirming
Safety Features
- Dry-Run Mode - Preview what would be cleaned without making changes
- Confirmation Dialog - Explicit Yes/No before any deletion
- Protected Generations - Current Nix generation is never deleted
- Availability Detection - Only shows cleaners for available tools
Output Options
| Flag |
Output |
| (default) |
Interactive TUI with forms |
--json |
Machine-readable JSON output |
--dry-run |
Preview mode (no changes) |
--verbose |
Detailed logging |
π¬ Quick Start
Installation
# Install from source
go install github.com/LarsArtmann/clean-wizard@latest
# Or build locally
git clone https://github.com/LarsArtmann/clean-wizard.git
cd clean-wizard
go build -o clean-wizard ./cmd/clean-wizard/
Basic Usage
# Standard mode - interactively select what to clean
clean-wizard clean
# Quick mode - daily cleanup without system changes
clean-wizard clean --mode quick
# Aggressive mode - all cleaners including dangerous ones
clean-wizard clean --mode aggressive
# Dry-run - preview without making changes
clean-wizard clean --dry-run
# JSON output for automation
clean-wizard clean --json
# With verbose logging
clean-wizard clean --verbose
The tool will:
- Scan for all available cleaners (based on installed tools)
- Show you which ones can be run
- Let you select which ones to execute (or use preset modes)
- Confirm before making any changes
- Clean the selected targets and show results
πΈ Demo
Interactive TUI
$ clean-wizard clean
π Scanning for available cleaners...
β Found 9 available cleaners
# TUI interface appears - multi-select form
# Select which cleaners to run
β
Running cleaners...
β Homebrew: Freed 245 MB
β Docker: Freed 1.2 GB
β Go: Freed 512 MB
β Node: Freed 128 MB
β
Cleanup completed in 2.3s
β’ Freed 2.1 GB total
Quick Mode
$ clean-wizard clean --mode quick --dry-run
π Quick mode - excludes Nix, Docker, System
Would clean:
β’ Homebrew cache
β’ Go module cache
β’ npm/pnpm/yarn/bun caches
β’ Temporary files (>7 days)
β’ Build caches (Gradle, Maven, SBT)
Estimated space: 500 MB
JSON Output
$ clean-wizard clean --json
{
"success": true,
"freed_bytes": 2147483648,
"duration_ms": 2300,
"cleaners": {
"homebrew": {"freed_bytes": 245000000, "success": true},
"docker": {"freed_bytes": 1200000000, "success": true},
"go": {"freed_bytes": 512000000, "success": true},
"node": {"freed_bytes": 128000000, "success": true}
}
}
π οΈ Commands
clean-wizard clean (Main Command)
Synopsis:
clean-wizard clean [flags]
Flags:
| Flag |
Description |
Default |
--mode, -m |
Preset mode: quick, standard, aggressive |
standard |
--config, -c |
Path to config file |
~/.config/clean-wizard/config.yaml |
--dry-run |
Preview without making changes |
false |
--json |
Output as JSON |
false |
--verbose |
Enable verbose logging |
false |
--dry-run |
Simulate deletion |
false |
Examples:
# Normal mode - select cleaners interactively
clean-wizard clean
# Quick daily cleanup
clean-wizard clean --mode quick
# Aggressive cleanup (requires confirmation)
clean-wizard clean --mode aggressive
# Preview what would be cleaned
clean-wizard clean --dry-run
# Automation-friendly output
clean-wizard clean --json
# With verbose logging
clean-wizard clean --verbose
# Dry-run in quick mode
clean-wizard clean --mode quick --dry-run
# Combined flags
clean-wizard clean --mode standard --dry-run --json
Preset Modes
Quick Mode (--mode quick)
Daily cleanup that excludes system-critical paths:
# What's included
clean-wizard clean --mode quick
# Cleaners active in quick mode:
# - Homebrew (brew cleanup + autoremove)
# - Go (go clean -cache -testcache -modcache)
# - Node (npm, pnpm, yarn, bun caches)
# - TempFiles (age-based, excludes system)
# - BuildCache (Gradle, Maven, SBT)
# What's excluded in quick mode:
# - Nix store (never touch current gen)
# - Docker (requires explicit selection)
# - SystemCache (Xcode, Spotlight, etc.)
# - Language Versions (requires aggressive)
Standard Mode (--mode standard)
Full cleanup with all available cleaners:
# What's included
clean-wizard clean
# Cleaners active in standard mode:
# - All from quick mode
# - Nix (gc --delete-older-than 1d or keep N gens)
# - Docker (system prune -af --volumes)
# - Cargo (cargo cache --autoclean)
# - SystemCache (Spotlight, Xcode, CocoaPods)
Aggressive Mode (--mode aggressive)
Nuclear cleanup including dangerous operations:
# What's included
clean-wizard clean --mode aggressive
# Additional cleaners in aggressive mode:
# - All from standard mode
# - Language Version Managers (NVM, Pyenv, Rbenv)
# - All Nix generations (no keep count)
# - iOS Simulators (xcrun simctl delete all)
# - Full Docker with volumes
β οΈ Warning: Aggressive mode includes destructive operations. Always use --dry-run first to preview.
π Safety Features
Protected Operations
Current Generation Protection:
- Nix current generation is never shown for deletion
- System always keeps at least the active profile
Confirmation Requirements:
- Explicit Yes/No dialog before any deletion
- Lists exactly what will be removed
- Shows estimated space to be freed
- Can be bypassed with
--yes flag (not recommended)
Dry-Run Mode:
# Safe preview - shows what would happen
clean-wizard clean --dry-run
# In dry-run mode:
# - No files are actually deleted
# - Shows estimate of freed space
# - Lists what would be cleaned
# - No confirmation required
What Each Cleaner Cleans
| Cleaner |
Target |
Risk Level |
| Nix |
/nix/store/*-generation |
Low |
| Homebrew |
~/Library/Caches/Homebrew |
Low |
| Docker |
Containers, images, volumes |
Medium |
| Cargo |
~/.cargo/registry, ~/.cargo/git |
Low |
| Go |
go build cache, go mod cache |
Low |
| Node |
~/.npm, ~/.pnpm, ~/.cache/yarn, ~/.bun |
Low |
| BuildCache |
~/.gradle, ~/.m2, ~/.sbt |
Low |
| SystemCache |
~/Library/Caches/*, Xcode DerivedData |
Medium |
| TempFiles |
/tmp/* (age-based) |
Low |
| LangVersion |
~/.nvm/versions, ~/.pyenv/versions |
High |
| Projects |
Project-specific cleanup |
Medium |
π Configuration
YAML Configuration File
Clean Wizard supports a YAML configuration file for customization:
# ~/.config/clean-wizard/config.yaml
# Preset definitions
presets:
quick:
cleaners:
- homebrew
- go
- node
- tempfiles
- buildcache
standard:
cleaners:
- homebrew
- go
- node
- cargo
- tempfiles
- buildcache
- systemcache
- docker
- nix
aggressive:
cleaners:
- all
include_dangerous: true
confirm: true
# Cleaner-specific settings
nix:
keep_generations: 5
optimization: true
docker:
timeout: 2m
include_volumes: true
tempfiles:
older_than: 7d
exclude_paths:
- /tmp/important-*
# Output settings
output:
json: false
verbose: false
Environment Variables
| Variable |
Description |
CLEAN_WIZARD_CONFIG |
Path to config file |
CLEAN_WIZARD_DRY_RUN |
Default dry-run mode |
CLEAN_WIZARD_VERBOSE |
Default verbose mode |
ποΈ Architecture
Clean Wizard is built with a focus on type safety and extensibility:
clean-wizard/
βββ cmd/
β βββ clean-wizard/ # CLI entry point
βββ internal/
β βββ cleaner/ # Cleaner implementations
β β βββ registry.go # Thread-safe cleaner registry
β β βββ registry_factory.go # Default cleaner setup
β β βββ nix.go # Nix store cleanup
β β βββ homebrew.go # Homebrew cleanup
β β βββ docker.go # Docker cleanup
β β βββ golang_*.go # Go cache cleanup
β β βββ node_*.go # Node package managers
β β βββ ...
β βββ domain/ # Type-safe enums and constants
β βββ config/ # YAML configuration
β βββ adapters/ # External tool adapters
βββ api/ # REST API layer
βββ schemas/ # JSON schemas
βββ tests/
βββ unit/ # Unit tests (200+)
βββ integration/ # BDD tests with Godog
Key Design Principles
- Type-Safe Enums - Compile-time safety for all constants
- Registry Pattern - Centralized cleaner management with thread-safety
- Result Types - Explicit success/failure with error handling
- Interface-Based - All cleaners implement common
Cleaner interface
- Testable - 200+ tests with BDD scenarios
Domain Enums
// Example: Type-safe strategy constants
type CleanStrategyType int
const (
StrategyDryRunType CleanStrategyType = iota
StrategyConservativeType
StrategyAggressiveType
)
// Example: Risk level with explicit values
type RiskLevelType int
const (
RiskLowType RiskLevelType = iota
RiskMediumType
RiskHighType
RiskCriticalType
)
π§ͺ Testing
Run All Tests
# Run all tests
go test ./...
# Run with coverage
go test -cover ./...
# Run specific test
go test -run TestDockerCleaner ./internal/cleaner/
# Run with verbose output
go test -v ./...
# Run benchmarks
go test -bench=. ./...
# BDD tests
go test -tags=bdd ./tests/integration/...
Test Coverage
| Test Type |
Count |
Status |
| Unit Tests |
200+ |
β
All Passing |
| Integration Tests |
10+ |
β
Passing |
| BDD Tests (Godog) |
5 |
β
Passing |
| Benchmark Tests |
15 |
β
Passing |
Test Categories
- Unit Tests - Individual cleaner functionality
- Integration Tests - Clean command and registry
- BDD Tests - User scenarios with Godog
- Benchmark Tests - Performance measurement
π§ Development
Building
# Build for current platform
go build -o clean-wizard ./cmd/clean-wizard/
# Build with optimization
go build -ldflags="-s -w" -o clean-wizard ./cmd/clean-wizard/
# Cross-compile for macOS ARM64
GOOS=darwin GOARCH=arm64 go build -o clean-wizard-darwin-arm64 ./cmd/clean-wizard/
# Run locally
./clean-wizard clean
Linting
# Run golangci-lint
golangci-lint run ./...
# Run with specific linters
golangci-lint run --enable=staticcheck,gosimple ./...
Adding a New Cleaner
// 1. Implement the Cleaner interface
type MyCleaner struct {
verbose bool
dryRun bool
}
func (mc *MyCleaner) Clean(ctx context.Context) result.Result[domain.CleanResult] {
// Implementation
return result.Result[domain.CleanResult]{
FreedBytes: 1024,
Success: true,
}
}
func (mc *MyCleaner) IsAvailable(ctx context.Context) bool {
// Check if tool is installed
return true
}
// 2. Register in registry_factory.go
func DefaultRegistry() *Registry {
registry := NewRegistry()
registry.Register("mycleaner", NewMyCleaner(false, false))
// ...
return registry
}
// 3. Add domain enum if needed
// 4. Add tests
// 5. Update configuration schema
π Comparison with SystemNix
Clean Wizard and SystemNix serve similar purposes but with different approaches:
| Feature |
SystemNix (justfile) |
Clean Wizard (Go) |
| Language |
POSIX shell |
Type-safe Go |
| Type Safety |
β Shell strings |
β
Compile-time enums |
| Dry-Run Mode |
β Not available |
β
Preview mode |
| Interactive TUI |
β CLI only |
β
Beautiful forms |
| JSON Output |
β Not available |
β
Machine-readable |
| Registry Pattern |
β Manual |
β
Thread-safe registry |
| Test Coverage |
β Manual |
β
200+ tests |
| Configuration |
β Hardcoded |
β
YAML profiles |
Feature Parity
| Mode |
SystemNix |
Clean Wizard |
Parity |
| Quick Mode |
β
|
~85% |
π‘ Partial |
| Standard Mode |
β
|
~75% |
π‘ Partial |
| Aggressive Mode |
β
|
~60% |
π΄ Poor |
Missing in Clean Wizard
- Language Version Manager (NO-OP, needs implementation)
- Docker light prune (quick mode)
- Nix store optimization
- Nix profile management
- iOS simulator cleanup
- Size before/after display
π€ Contributing
Ways to Contribute
- Fix Language Version Manager - Currently NO-OP, needs actual deletion logic
- Implement Docker light prune - For quick mode parity
- Add Nix store optimization -
nix-store --optimize
- Implement iOS simulator cleanup -
xcrun simctl delete
- Write BDD tests - Expand test coverage
- Improve documentation - README, examples, guides
- Report issues - Bug reports and feature requests
Development Workflow
# Fork the repository
# Clone your fork
git clone https://github.com/YOUR-USERNAME/clean-wizard.git
# Create feature branch
git checkout -b feature/new-cleaner
# Make changes
# ...
# Run tests
go test ./...
# Commit with descriptive message
git commit -m "feat(cleaner): add new cleaner implementation"
# Push to your fork
git push origin feature/new-cleaner
# Create Pull Request
π Roadmap
- Update README documentation
- Fix Go build cache location gap
- Implement Docker light prune
- Add Nix temp files cleanup
Short-Term (This Month)
- Fix Language Version Manager NO-OP
- Implement Nix store optimization
- Implement Nix profile management
- Add iOS simulator cleanup
- Complete quick mode parity
Long-Term (This Quarter)
- Complete standard mode parity
- Complete aggressive mode parity
- Write comprehensive BDD tests
- Create complete documentation
- Add performance benchmarks
π Links
Dependencies
π License
MIT License - See LICENSE for details.
Built with β€οΈ for a cleaner macOS experience
The ultimate tool for keeping your MacBook clean and fast