Bugs I didn't expect while building a zsh cleanup script for macOS dev machines

milizc1 pts0 comments

GitHub - milyzc/clean-mac · GitHub

/" data-turbo-transient="true" />

Skip to content

Search or jump to...

Search code, repositories, users, issues, pull requests...

-->

Search

Clear

Search syntax tips

Provide feedback

--><br>We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Cancel

Submit feedback

Saved searches

Use saved searches to filter your results more quickly

-->

Name

Query

To see all available qualifiers, see our documentation.

Cancel

Create saved search

Sign in

/;ref_cta:Sign up;ref_loc:header logged out"}"<br>Sign up

Appearance settings

Resetting focus

You signed in with another tab or window. Reload to refresh your session.<br>You signed out in another tab or window. Reload to refresh your session.<br>You switched accounts on another tab or window. Reload to refresh your session.

Dismiss alert

{{ message }}

milyzc

clean-mac

Public

Notifications<br>You must be signed in to change notification settings

Fork

Star

main

BranchesTags

Go to file

CodeOpen more actions menu

Folders and files<br>NameNameLast commit message<br>Last commit date<br>Latest commit

History<br>10 Commits<br>10 Commits

.github/workflows

.github/workflows

.gitignore

.gitignore

LICENSE

LICENSE

README.md

README.md

clean.sh

clean.sh

View all files

Repository files navigation

clean.sh — macOS disk space cleanup

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<br>Description

npm cache<br>npm cache clean --force

Homebrew<br>Old package versions (brew cleanup --prune=all) and orphan dependencies (brew autoremove)

Gradle cache<br>~/.gradle/caches — generated by Android builds

CocoaPods cache<br>pod cache clean --all

Xcode DerivedData<br>~/Library/Developer/Xcode/DerivedData — intermediate build artifacts

Unavailable iOS simulators<br>xcrun simctl delete unavailable — simulators with no associated runtime

iOS DeviceSupport<br>~/Library/Developer/Xcode/iOS DeviceSupport — keeps only the 2 most recent versions

Android SDK build-tools<br>Uninstalls versions sdkmanager

Android SDK cmdline-tools<br>Uninstalls old versions (1.0 → 11.0), keeps latest

10<br>System<br>Empties the Trash (~/.Trash) and clears VS Code cache

11<br>node_modules<br>Removes folders not accessed in +60 days

12<br>iOS simulator data<br>xcrun simctl erase all — wipes app data, keeps devices

13<br>Android AVD snapshots<br>Removes snapshot directories from each AVD

14<br>yarn / pnpm cache<br>yarn cache clean and pnpm store prune

15<br>Swift PM cache<br>~/Library/Caches/org.swift.swiftpm

16<br>Diagnostic Reports<br>Removes .crash and .ips files older than 30 days

17<br>Git gc<br>Runs git gc --prune=now on all local repositories

18<br>Docker<br>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:<br>Used: 234G Available: 28G Total: 460G

Size by category:<br>iOS Simulators: 11G<br>iOS DeviceSupport: 5.4G<br>Xcode Archives: 468M<br>Android SDK: 9.6G<br>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

About

No description or website provided.

Topics

android

macos

shell

zsh

ios

xcode

disk-space

developer-tools

cleanup

mobile-development

Resources

Readme

License

GPL-3.0 license

Uh oh!

There was an error while loading. Please reload this page.

Activity

Stars

stars

Watchers

watching

Forks

forks

Report repository

Releases

No releases published

Packages

Uh oh!

There was an error while loading. Please reload this page.

Contributors

Uh oh!

There was an error while loading. Please reload this page.

Languages

Shell<br>100.0%

You can’t perform that action at this time.

clean android cache xcode reload tools

Related Articles