Back to the catalog

clean-my-mac

Safe, staged macOS disk cleanup for AI agents & developers. Recovers GBs from Xcode, Docker, node_modules, AI models, and caches with dry-ru

Open source Open in the app JSON README (API)

About

Safe, staged macOS disk cleanup for AI agents & developers. Recovers GBs from Xcode, Docker, node_modules, AI models, and caches with dry-run safety.

Details

Kind
Plugins
Topic
Cloud & DevOps
Publisher
shihabshahrier
Origin
gemini
Category
ferramentas
Version
1.0.0
Last push
2026-06-12T23:45:14Z
Repository state
ativo
Language
Shell
License
MIT
Added
2026-08-30 14:13:39
Updated
2026-08-30 14:13:39
Origin id
shihabshahrier/clean-my-mac

README

# clean-my-mac 🧹

> ⚑ **Safe, staged macOS disk cleanup for developers and AI coding agents.** Recover GBs of storage from Xcode, Docker, node_modules, AI models, and system caches with 100% dry-run safety.

**clean-my-mac** is an intelligent, agent-compatible macOS utility designed to safely reclaim disk space from developer environments (such as Xcode DerivedData, Docker volumes, npm/pnpm/yarn caches, and Hugging Face AI models) and system cache bloat. Every cleanup action is profiled, previewed in a dry-run, and requires explicit per-phase confirmation.

---

## Agent Support

| Agent | Invocation | Install |
|-------|-----------|---------|
| Claude Code | `/clean-my-mac` or natural language | `claude plugin install clean-my-mac` |
| Cursor | `/clean-my-mac` | `.cursor/rules/clean-my-mac.mdc` (included) |
| Windsurf | `/clean-my-mac` | `.windsurf/rules/clean-my-mac.md` (included) |
| Cline | `/clean-my-mac` | `.clinerules/clean-my-mac.md` (included) |
| GitHub Copilot | natural language | `.github/copilot-instructions.md` (included) |
| Codex | `/clean-my-mac` | `.codex/config.toml` (included) |
| Gemini CLI | `/clean-my-mac` | `gemini-extension.json` (included) |
| Amp / Goose / opencode | `/clean-my-mac` | `bash install.sh` |

---

## What It Cleans

| Target | Risk | Notes |
|--------|------|-------|
| User & System Caches | 🟒 Low | Auto-regenerated by macOS |
| Logs & Trash | 🟒 Low | Always regenerated |
| Homebrew cache | 🟒 Low | `brew cleanup` re-downloads on demand |
| npm / pnpm / yarn caches | 🟒 Low | Rebuilt on next install |
| Xcode DerivedData | 🟒 Low | Rebuilt on next build |
| iOS Simulators | 🟑 Medium | Re-downloadable from Xcode |
| Docker images | 🟑 Medium | Re-pullable from registry |
| node_modules | 🟑 Medium | Listed only β€” you choose |
| Time Machine snapshots | 🟑 Medium | Backup confirmation required |
| AI model files | πŸ”΄ High | Listed only β€” you choose |
| Xcode Archives | πŸ”΄ High | Double confirmation required |
| iOS Device Backups | πŸ”΄ High | Guided to Finder only, never scripted |

Typical recovery on a 256 GB M1 Mac:
- Light developer: **5–15 GB**
- Active Xcode dev: **20–60 GB**
- Docker + Xcode + AI models: **30–100+ GB**

---

## Install

### All agents at once
```bash
git clone https://github.com/shihabshahrier/clean-my-mac.git
cd clean-my-mac
bash install.sh
```

### Claude Code (plugin)
```bash
claude plugin install shihabshahrier/clean-my-mac
```

Or from local clone:
```bash
claude plugin marketplace add /path/to/clean-my-mac
claude plugin install clean-my-mac
```

### Manual (any agent)
```bash
git clone https://github.com/shihabshahrier/clean-my-mac.git
mkdir -p ~/.claude/skills/clean-my-mac
cp -r clean-my-mac/skills/clean-my-mac/. ~/.claude/skills/clean-my-mac/
```

---

## Usage

In any supported agent, say:
```
"My Mac only has 20 GB left, help me clean it up"
"Free up disk space"
"Clean my Mac safely"
"What's taking up all my storage?"
```

Or invoke directly: `/clean-my-mac`

---

## How It Works

```
Phase -1  β†’  Profile user (active tools, backup status, what to protect)
Phase  0  β†’  Analyze disk β€” zero deletions, full size breakdown
Phase  1  β†’  Safe caches & logs          [LOW]
Phase  2  β†’  Developer tools             [LOW–MED]
Phase  3  β†’  Docker                      [MEDIUM]
Phase  4  β†’  AI model files              [HIGH β€” list only]
Phase  5  β†’  Time Machine snapshots      [MEDIUM β€” backup confirmed first]
Phase  6  β†’  Large file review           [USER-DECIDES]
Phase  7  β†’  iCloud optimization         [guidance only]
           β†’  Final report
```

Every phase: profile check β†’ dry-run preview β†’ confirmation β†’ execution.

---

## File Structure

```
clean-my-mac/
β”œβ”€β”€ skills/clean-my-mac/
β”‚   β”œβ”€β”€ SKILL.md                     ← Skill definition (source of truth)
β”‚   β”œβ”€β”€ scripts/
β”‚   β”‚   β”œβ”€β”€ analyze_storage.sh       ← Phase 0: disk analysis
β”‚   β”‚   β”œβ”€β”€ cleanup_caches.sh        ← Phase 1: caches, logs, trash
β”‚   β”‚   β”œβ”€β”€ cleanup_homebrew.sh      ← Phase 2: Homebrew
β”‚   β”‚   β”œβ”€β”€ cleanup_xcode.sh         ← Phase 2: Xcode artifacts
β”‚   β”‚   β”œβ”€β”€ cleanup_node.sh          ← Phase 2: Node.js ecosystem
β”‚   β”‚   β”œβ”€β”€ cleanup_docker.sh        ← Phase 3: Docker
β”‚   β”‚   └── cleanup_snapshots.sh     ← Phase 5: Time Machine snapshots
β”‚   β”œβ”€β”€ config/
β”‚   β”‚   β”œβ”€β”€ protected_paths.txt      ← Never-delete list
β”‚   β”‚   └── safe_cleanup_rules.json  ← Rules per category
β”‚   └── reference/
β”‚       β”œβ”€β”€ safe-paths.md
β”‚       β”œβ”€β”€ dangerous-paths.md
β”‚       β”œβ”€β”€ cleanup-strategies.md
β”‚       └── macos-storage-guide.md
β”œβ”€β”€ .claude-plugin/                  ← Claude Code plugin manifest
β”œβ”€β”€ .cursor/rules/                   ← Cursor rules
β”œβ”€β”€ .windsurf/rules/                 ← Windsurf rules
β”œβ”€β”€ .clinerules/                     ← Cline rules
β”œβ”€β”€ .codex/                          ← Codex config
β”œβ”€β”€ agents/openai.yaml               ← Codex display config
β”œβ”€β”€ .github/copilot-instructions.md  ← Copilot instructions
β”œβ”€β”€ AGENTS.md                        ← Codex / Amp / Goose context
β”œβ”€β”€ GEMINI.md                        ← Gemini CLI context
β”œβ”€β”€ gemini-extension.json            ← Gemini CLI extension
└── install.sh                       ← Install to all agent paths
```

---

## Security

- `allowed-tools` restricts Claude to: `Bash`, `Read`, `Glob`, `Grep`, `Write`
- No network access during cleanup
- `config/protected_paths.txt` checked before every deletion
- Scripts use `set -euo pipefail` β€” fail fast on errors
- All operations logged to `~/clean-my-mac-log-<date>.txt`
- Every script supports `--dry-run` mode
- HIGH-risk operations require double confirmation
- iOS Device Backups: guided to Finder only, never scripted

---

## Contributing

See [CONTRIBUTING.md](CONTRIBUTING.md). Read [CLAUDE.md](CLAUDE.md) first.

---

πŸ“– **Project page:** https://shihub.online/projects/clean-my-mac

More