Skip to content

milyzc/clean-mac

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

clean.sh — macOS disk space cleanup

Lint

Script for cleaning up development environments (iOS + Android) with Node.js, Xcode and Android Studio.

Install & run

One-liner (download, inspect, execute):

curl -fsSL https://raw.githubusercontent.com/milyzc/clean-mac/main/clean.sh -o clean.sh && chmod +x clean.sh

Dry-run first (recommended — shows what would be deleted without touching anything):

./clean.sh --dry-run

Run the actual cleanup:

./clean.sh

Always run --dry-run before the real thing so you know exactly what will be removed.

What it cleans

# Category Description
1 npm cache npm cache clean --force
2 Homebrew Old package versions (brew cleanup --prune=all) and orphan dependencies (brew autoremove)
3 Gradle cache ~/.gradle/caches — generated by Android builds
4 CocoaPods cache pod cache clean --all
5 Xcode DerivedData ~/Library/Developer/Xcode/DerivedData — intermediate build artifacts
6 Unavailable iOS simulators xcrun simctl delete unavailable — simulators with no associated runtime
7 iOS DeviceSupport ~/Library/Developer/Xcode/iOS DeviceSupport — keeps only the 2 most recent versions
8 Android SDK build-tools Uninstalls versions < 34 and all RCs using sdkmanager
9 Android SDK cmdline-tools Uninstalls old versions (1.0 → 11.0), keeps latest
10 System Empties the Trash (~/.Trash) and clears VS Code cache
11 node_modules Removes folders not accessed in +60 days
12 iOS simulator data xcrun simctl erase all — wipes app data, keeps devices
13 Android AVD snapshots Removes snapshot directories from each AVD
14 yarn / pnpm cache yarn cache clean and pnpm store prune
15 Swift PM cache ~/Library/Caches/org.swift.swiftpm
16 Diagnostic Reports Removes .crash and .ips files older than 30 days
17 Git gc Runs git gc --prune=now on all local repositories
18 Docker docker system prune -f — dangling images and stopped containers only

What it does NOT touch

  • Active project node_modules (accessed within the last 60 days)
  • Recent Xcode Archives (2025+)
  • Active Android SDK platforms, system images and platform-tools
  • Available simulators (only removes unavailable ones)
  • Docker named volumes and reusable images
  • User data in ~/Documents, ~/Desktop, etc.

Output

The script prints a disk usage summary before and after for each category:

Current disk usage:
  Used: 234G  Available: 28G  Total: 460G

Size by category:
  iOS Simulators:          11G
  iOS DeviceSupport:       5.4G
  Xcode Archives:          468M
  Android SDK:             9.6G
  Gradle cache:            4.0G

Requirements

  • macOS with zsh
  • xcrun / Xcode Command Line Tools (for simulators and DeviceSupport)
  • sdkmanager at ~/Library/Android/sdk/cmdline-tools/latest/bin/ (for Android SDK)
  • brew, pod, yarn, pnpm, docker optional — skipped if not installed

Releases

No releases published

Packages

 
 
 

Contributors

Languages