agentsclimarketplace

Cleanmymac x

Skill evanlong-me/skills/cleanmymac-x

A collection of reusable agent skills for AI coding agents

Install
npx -y skills add evanlong-me/skills --skill cleanmymac-x

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

2 things to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
  • 1 stars1 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

A CLI-based macOS system cleanup, optimization, security, and privacy tool β€” the command-line equivalent of CleanMyMac X. Scan-first, clean-confirmed workflow. Includes the cmx convenience script.

SKILL.md

18.6 KB, ~5.2k tokens by cl100k_base, as published. Nobody here has run it

CleanMyMac X CLI Equivalent

Overview

CleanMyMac X is the best-known system utility for macOS. This skill implements each of its 8 core modules using native CLI tools:

#ModuleCleanMyMac X NameRisk Level
1System JunkSystem Junk🟒 Safe
2PrivacyPrivacy🟒 Safe
3Large FilesLarge & Old Files🟒 Safe
4DuplicatesDuplicates🟒 Safe
5Malware DetectionMalware Removal🟑 Caution
6PerformanceSpeed / Maintenance🟑 Caution
7App UninstallUninstallerπŸ”΄ Irreversible
8Smart ScanSmart Scan🟒 Safe

Core principle:

Scan first β†’ confirm before cleaning. All cleanup operations are dry-run by default; actual execution requires explicit confirmation.

Quick Start

This skill ships with scripts/cmx.sh, a convenience script for all modules:

# System overview (disk/memory/load/security)
bash cmx.sh status

# Smart scan (full module summary)
bash cmx.sh scan

# Clean system junk (preview β†’ confirm)
bash cmx.sh clean system-junk --apply

# Performance optimization
bash cmx.sh optimize --apply

# Uninstall an app
bash cmx.sh uninstall "AppName"

You can also run the individual commands shown in each module below for fine-grained control.


Module 1: System Junk

What it does

CleanMyMac X's System Junk scans these macOS locations:

ItemPathCleanMyMac Logic
User caches~/Library/Caches/Per-app cache directories, safe to delete
System caches/Library/Caches/Same, some require root
User logs~/Library/Logs/Evaluated by file count and age
System logs/Library/Logs/, /private/var/log/Same
Xcode DerivedData~/Library/Developer/Xcode/DerivedData/Build intermediates, safe to delete
Xcode Archives~/Library/Developer/Xcode/Archives/Distributed .xcarchive
iOS Backups~/Library/Application Support/MobileSync/Backup/Old device backups
Language files*.app/Contents/Resources/*.lprojKeep current language, remove extra
Trash~/.Trash/Staging area for deleted files
Temp files/private/tmp/, /private/var/tmp/System temp files
Homebrew cache$(brew --cache)Old formula package cache
npm/pnpm/yarn cache(package manager cache dirs)Node ecosystem dep caches

macOS does not automatically clean app caches and leftover files β€” that's where this tool comes in.

Scan

# ── User caches ──
echo "=== User Caches ===" && du -sh ~/Library/Caches/ 2>/dev/null
echo "Top 10 cache subdirs:" && du -sh ~/Library/Caches/*/ 2>/dev/null | sort -rh | head -10

# ── System caches ──
echo "=== System Caches ===" && du -sh /Library/Caches/ 2>/dev/null

# ── Log files ──
echo "=== User Logs ===" && du -sh ~/Library/Logs/ 2>/dev/null
echo "Logs older than 30 days:" && find ~/Library/Logs -type f -mtime +30 2>/dev/null | wc -l
echo "=== System Logs ===" && du -sh /Library/Logs/ 2>/dev/null
echo "=== var/log ===" && du -sh /private/var/log/ 2>/dev/null

# ── Xcode ──
echo "=== Xcode DerivedData ===" && du -sh ~/Library/Developer/Xcode/DerivedData/ 2>/dev/null
echo "=== Xcode Archives ===" && du -sh ~/Library/Developer/Xcode/Archives/ 2>/dev/null

# ── iOS Backups ──
echo "=== iOS Backups ===" && du -sh ~/Library/Application\ Support/MobileSync/Backup/ 2>/dev/null

# ── Trash ──
echo "=== Trash ===" && du -sh ~/.Trash/ 2>/dev/null

# ── Temp files ──
echo "=== Temp Files ===" && du -sh /private/tmp/ /private/var/tmp/ 2>/dev/null

# ── Homebrew cache (if installed) ──
which brew >/dev/null 2>&1 && echo "=== Homebrew Cache ===" && du -sh $(brew --cache) 2>/dev/null

# ── npm cache (if installed) ──
which npm >/dev/null 2>&1 && echo "=== npm Cache ===" && du -sh $(npm cache dir) 2>/dev/null

Clean

⚠️ Quit running apps before clearing caches. Deleting caches while an app is running may cause unexpected behavior.

# 1. Delete logs older than 30 days (safe)
find ~/Library/Logs -type f -mtime +30 -delete 2>/dev/null && echo "βœ“ Old logs cleaned"

# 2. Clean system logs (needs sudo)
sudo find /private/var/log -type f -mtime +30 -delete 2>/dev/null && echo "βœ“ System logs cleaned"

# 3. Empty trash
rm -rf ~/.Trash/* 2>/dev/null && echo "βœ“ Trash emptied"

# 4. Clean Xcode DerivedData (Xcode will rebuild)
rm -rf ~/Library/Developer/Xcode/DerivedData/* 2>/dev/null && echo "βœ“ DerivedData cleaned"

# 5. Clean Homebrew cache
brew cleanup -s 2>/dev/null && echo "βœ“ Homebrew cache cleaned"

# 6. Clean npm cache
npm cache clean --force 2>/dev/null && echo "βœ“ npm cache cleaned"

# 7. Clean user caches (most aggressive, use with care)
# rm -rf ~/Library/Caches/*

Language file cleanup (advanced)

CleanMyMac X removes unused language packs from apps, keeping only your current language:

# Check which languages an app includes
ls /Applications/Safari.app/Contents/Resources/ | grep lproj

# Keep Chinese and English only, delete the rest (example for one app)
# find /Applications/SomeApp.app -name "*.lproj" ! -name "zh*" ! -name "en*" -exec rm -rf {} +

Do this per-app, not bulk β€” some apps bundle data in unexpected lproj directories.


Module 2: Privacy

What it does

CleanMyMac X cleans three types of privacy traces:

CategoryContentsPath
Browser tracesCache, history, cookies, LocalStorageVaries by browser
System tracesRecent files, clipboard, recent searchesFinder / System services
Communication tracesMessage attachments, call historyMessages / FaceTime

Scan

# ── Safari ──
echo "=== Safari ==="
echo "Cache:" && du -sh ~/Library/Caches/com.apple.Safari/ 2>/dev/null
echo "History:" && ls -lh ~/Library/Safari/History.db 2>/dev/null

# ── Chrome ──
echo "=== Google Chrome ==="
echo "Cache:" && du -sh ~/Library/Caches/Google/Chrome/ 2>/dev/null
echo "History file:" && ls -lh ~/Library/Application\ Support/Google/Chrome/Default/History 2>/dev/null

# ── Firefox ──
echo "=== Firefox ==="
ls ~/Library/Application\ Support/Firefox/Profiles/ 2>/dev/null

# ── Recent files ──
echo "=== Recent Files ==="
mdfind "kMDItemLastUsedDate >= \$time.today(-7)" -onlyin ~/Documents 2>/dev/null | head -20

# ── Clipboard ──
echo "=== Clipboard ==="
pbpaste 2>/dev/null | head -3 || echo "(empty)"

Clean

# Safari cache (safe to clear while browser is running)
rm -rf ~/Library/Caches/com.apple.Safari/* 2>/dev/null

# Chrome cache (clearing while browser is running will force redownload)
rm -rf ~/Library/Caches/Google/Chrome/* 2>/dev/null

# Clear clipboard
pbcopy < /dev/null

# Clear recent files list (takes effect after Finder restart)
osascript -e 'tell application "Finder" to set the name of every item of trash to ""' 2>/dev/null

# Clear Safari browsing history (deletes History.db)
# rm ~/Library/Safari/History.db  # Safari will recreate when launched

After clearing browser caches, resources will redownload on next launch β€” first load may be slower.


Module 3: Large & Old Files

What it does

CleanMyMac X uses the Spotlight index (mdfind) to quickly locate large files instead of traversing the filesystem.

Scan

# Fastest: use Spotlight index to find files > 1GB
mdfind "kMDItemFSSize > 1000000000" 2>/dev/null | head -30

# Show file sizes
mdfind "kMDItemFSSize > 1000000000" 2>/dev/null | while read f; do
  [ -f "$f" ] && echo "$(stat -f%z "$f" 2>/dev/null | xargs -I {} echo "scale=1; {} / 1073741824" | bc 2>/dev/null)GB  $f"
done | sort -rn | head -30

# Fallback: use find (slow, no index needed)
find ~ -type f -size +1G 2>/dev/null -exec ls -lhS {} + | awk '{print $5, $NF}' | head -20

# Find old files (not accessed in over a year)
find ~ -type f -atime +365 2>/dev/null | head -20

# Find large directories
du -sh ~/*/ 2>/dev/null | sort -rh | head -10
du -sh ~/Library/*/ 2>/dev/null | sort -rh | head -10

Clean

Review scan results manually, then rm or move to Trash:

# Safe: move to Trash instead of deleting directly
# osascript -e "tell application \"Finder\" to delete POSIX file \"$PWD/large-file.mp4\""

# Direct delete (after confirmation)
# rm -i /path/to/unwanted/large/file.mkv

Module 4: Duplicates

What it does

CleanMyMac X finds duplicate files by comparing file hashes (MD5/SHA). Same approach using md5 + sort + uniq.

Scan

# Find duplicates in ~/Documents grouped by MD5
echo "Scanning ~/Documents for duplicates (MD5-based)..."
find ~/Documents -type f -size +1k 2>/dev/null \
  -exec md5 -r {} \; \
  | sort \
  | awk '{seen[$1]++; lines[$1]=lines[$1] ? lines[$1]"\n  "$2 : "  "$2} \
         END{for(h in seen) if(seen[h]>1) printf "--- MD5: %s ---\n%s\n\n", h, lines[h]}'

# Same for ~/Downloads
echo "Scanning ~/Downloads..."
find ~/Downloads -type f -size +1k 2>/dev/null \
  -exec md5 -r {} \; \
  | sort \
  | awk '{seen[$1]++; lines[$1]=lines[$1] ? lines[$1]"\n  "$2 : "  "$2} \
         END{for(h in seen) if(seen[h]>1) printf "--- MD5: %s ---\n%s\n\n", h, lines[h]}'

Clean

Review the scan results, then manually delete duplicates β€” keep one copy.


Module 5: Malware Detection

What it does

macOS has multiple built-in security layers:

LayerTechnologyDescription
XProtectSignature scanningApple-maintained malware signature database, auto-updated
GatekeeperApp notarization checkBlocks un-notarized apps from running
NotarizationCode signingDevelopers must pass Apple review

CleanMyMac X's Malware Removal is essentially a wrapper around XProtect + scanning common malware installation paths.

Scan

# 1. XProtect version and status
xprotect version 2>/dev/null || echo "XProtect unavailable (requires macOS 15+)"

# 2. XProtect full scan (needs root, macOS 15+)
sudo xprotect check --json 2>/dev/null || echo "Requires Full Disk Access"

# 3. Check login items (common persistence point for malware)
osascript -e 'tell application "System Events" to get the name of every login item' 2>/dev/null

# 4. Check Launch Agents (user-level auto-start items)
ls ~/Library/LaunchAgents/ 2>/dev/null
# Inspect suspicious plists
for f in ~/Library/LaunchAgents/*.plist; do
  [ -f "$f" ] && echo "--- $(basename $f) ---" && plutil -p "$f" 2>/dev/null | grep -E '"Program|ProgramArguments|Label"' | head -5
done

# 5. Check for suspicious processes
ps aux | grep -iE "(adware|spy|trojan|keylogger|miner|crypto)" | grep -v grep

# 6. Check browser extensions (Chrome)
ls ~/Library/Application\ Support/Google/Chrome/Default/Extensions/ 2>/dev/null

# 7. Check system extensions
systemextensionsctl list 2>/dev/null

Security recommendations

  • macOS built-in protection (XProtect + Gatekeeper + SIP) is already strong
  • Keep the system updated: softwareupdate --list
  • Only download apps from official sources
  • If you suspect infection, try Malwarebytes for Mac (free scan)

Module 6: Performance Optimization

What it does

CleanMyMac X's Speed module covers:

Sub-featureImplementationEffect
Free memorypurge commandClears inactive memory pages
Maintenance scriptsperiodic (removed in macOS 15+)Clean temp files, rotate logs
Flush DNSdscacheutil + killall -HUP mDNSResponderClears DNS cache
Rebuild Spotlightmdutil -EFixes search result issues
Dynamic linker cacheupdate_dyld_shared_cacheSpeeds up app launch

Execute

# 1. Free inactive memory (needs sudo)
echo "=== Memory Status ==="
vm_stat | head -10
sudo purge && echo "βœ“ Memory purged"

# 2. Flush DNS cache
sudo dscacheutil -flushcache && sudo killall -HUP mDNSResponder && echo "βœ“ DNS cache flushed"

# 3. Rebuild Spotlight index (takes a while)
# sudo mdutil -E / && echo "βœ“ Spotlight rebuild triggered"

# 4. Clean system temp files
sudo rm -rf /private/var/tmp/* 2>/dev/null
sudo rm -rf /private/tmp/* 2>/dev/null
echo "βœ“ Temp files cleaned"

# 5. Rebuild dynamic linker cache (recommended after system updates)
# sudo update_dyld_shared_cache -force 2>/dev/null && echo "βœ“ Dyld cache rebuilt"

macOS 15+ notes

macOS Sequoia (15) removed the periodic command. Steps 2 and 4 above cover its core functions β€” just run them directly.


Module 7: App Uninstall

What it does

Dragging .app to Trash leaves config files behind. CleanMyMac X finds and removes:

Leftover TypePath Pattern
Preferences~/Library/Preferences/com.developer.appname.plist
App Support~/Library/Application Support/appname/
Caches~/Library/Caches/com.developer.appname/
Saved State~/Library/Saved Application State/com.developer.appname.savedState/
Containers~/Library/Containers/com.developer.appname/
Group Containers~/Library/Group Containers/*.appname/

Find and uninstall

# Step 1: Locate the app
mdfind "kMDItemKind == 'Application' && kMDItemDisplayName == 'AppName'cw"
# Alternative
find /Applications -iname "*AppName*" -maxdepth 2

# Step 2: List all associated files
# Replace AppName with the actual app name
app="AppName"
echo "=== App Bundle ===" && find /Applications ~/Applications -maxdepth 2 -iname "*${app}*" -type d 2>/dev/null
echo "=== Preferences ===" && find ~/Library/Preferences -maxdepth 2 -iname "*${app}*" 2>/dev/null
echo "=== App Support ===" && find ~/Library/Application\ Support -maxdepth 3 -iname "*${app}*" 2>/dev/null
echo "=== Caches ===" && find ~/Library/Caches -maxdepth 2 -iname "*${app}*" 2>/dev/null
echo "=== Saved State ===" && find ~/Library/Saved\ Application\ State -maxdepth 2 -iname "*${app}*" 2>/dev/null
echo "=== Containers ===" && find ~/Library/Containers -maxdepth 2 -iname "*${app}*" 2>/dev/null

# Step 3: Delete (after confirmation)
app="AppName"
# Remove app bundle
sudo rm -rf "/Applications/${app}.app" 2>/dev/null || rm -rf ~/Applications/"${app}.app" 2>/dev/null
# Remove config files
find ~/Library/Preferences ~/Library/Application\ Support ~/Library/Caches \
  ~/Library/Saved\ Application\ State ~/Library/Containers \
  -maxdepth 3 -iname "*${app}*" -exec rm -rf {} + 2>/dev/null
echo "βœ“ ${app} and related files removed"

Module 8: Smart Scan

What it does

CleanMyMac X's Smart Scan combines System Junk + Malware Detection + Performance Optimization into a single one-click operation.

CLI approach A: Run scan modules together

echo "==============================="
echo "  Smart Scan β€” All Modules"
echo "==============================="
echo ""

echo "=== 1/4 System Junk ==="
du -sh ~/Library/Caches/ ~/Library/Logs/ ~/.Trash/ ~/Library/Developer/Xcode/DerivedData/ 2>/dev/null

echo ""
echo "=== 2/4 Large Files (>1GB) ==="
mdfind "kMDItemFSSize > 1000000000" 2>/dev/null | head -10

echo ""
echo "=== 3/4 Duplicates ==="
find ~/Documents ~/Downloads -type f -size +1k 2>/dev/null \
  -exec md5 -r {} \; | sort | awk '{seen[$1]++; lines[$1]=lines[$1] ? lines[$1]"\n  "$2 : "  "$2} \
  END{for(h in seen) if(seen[h]>1) printf "Duplicates: %s\n%s\n", h, lines[h]}' | head -50

echo ""
echo "=== 4/4 System Status ==="
echo "Disk free:" && df -h / | tail -1 | awk '{print $4}'
echo "XProtect:" && xprotect version 2>/dev/null

Approach B: Use cmx.sh script

bash /path/to/scripts/cmx.sh scan

Safety Notes

Risk levels

LevelMeaningExamples
🟒 SafeFiles auto-generated by system/apps, safe to removeCaches, logs, DerivedData
🟑 CautionAffects system behavior but is recoverableFlush DNS, purge memory
πŸ”΄ RiskyIrreversible β€” double-check before deletingUninstall app, delete files

Best practices

  1. Scan first, clean second β€” never skip the scan step
  2. Quit apps before clearing cache β€” avoids issues with running processes
  3. Keep recent logs β€” only delete logs older than 30 days
  4. Check large files manually β€” some large files are work-critical (VMs, asset libraries)
  5. Don't blindly delete system caches β€” /Library/Caches/ may include system-required items

Recovery

If you accidentally delete something important:

  • App caches: restart the app β€” they'll be recreated
  • System caches: restart your Mac β€” they'll be recreated
  • Xcode DerivedData: auto-rebuilt on next build
  • Spotlight index: rebuild with mdutil -E /

Appendix: cmx.sh Reference

This skill ships with scripts/cmx.sh, a one-stop script wrapping all the above functionality.

Installation

Via skills.sh (recommended)

npx skills add evanlong-me/skills --skill cleanmymac-x

Manual cmx alias

# Add alias to your shell config
# Replace /path/to with the actual path
echo 'alias cmx="bash /path/to/cleanmymac-x/scripts/cmx.sh"' >> ~/.zshrc
source ~/.zshrc

Commands

cmx status                # System status (disk/memory/load)
cmx scan                  # Smart scan (all modules)
cmx scan system-junk      # Scan system junk only
cmx scan privacy          # Scan privacy traces only
cmx scan large-files      # Scan large files only (default >3GB)
cmx scan duplicates       # Scan duplicates only
cmx scan malware          # Malware detection only
cmx clean system-junk     # Clean system junk (dry-run)
cmx clean system-junk --apply   # Confirm and clean
cmx clean privacy --apply       # Clean privacy traces
cmx optimize --apply      # Performance optimization
cmx uninstall "AppName"   # Preview uninstall
cmx uninstall "AppName" --apply # Actually uninstall

Options

OptionDescriptionDefault
--applyActually execute clean (default: preview)dry-run
--size 500MLarge file threshold3GB
--days 30Log retention days365

References

What ships with it: 2 files

29.4 KB alongside SKILL.md, 1 of them executable

scripts/

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.