Skip to content
Back to skills

Mac Optimize

BSecurity

Full macOS system check and cleanup. Analyzes memory, CPU, and disk usage, cleans caches/logs/temp files, updates Homebrew packages, stops unneeded background services, and reviews auto-start items. Use when the user mentions 'mac cleanup', 'system optimize', 'mac is slow', 'disk cleanup', 'out of memory', 'clear cache', 'system check', or in Korean '컴퓨터 최적화', '시스템 정리', '맥 느려', '디스크 정리', '메모리 부족', '캐시 정리', '시스템 점검'.

  • 2 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 2, 2026
ai-agentspythonrustgojavabashsqldockergitdatabasesecurity

Works with

  • terminal
  • cli
  • mcp

Security analysis

B85/100
  • highPerforms destructive filesystem operations

Pro scans all 15 files and shows the line behind each finding

Scanned December 2, 2026

npx -y skills add seunggabi/mac-optimize --skill mac-optimize --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Mac Optimize?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Mac Optimize
[![Security: B — Skills Directory](https://www.skillsdirectory.com/api/skills/seunggabi-mac-optimize/badge)](https://www.skillsdirectory.com/skills/seunggabi-mac-optimize)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: mac-optimize
description: "Full macOS system check and cleanup. Analyzes memory, CPU, and disk usage, cleans caches/logs/temp files, updates Homebrew packages, stops unneeded background services, and reviews auto-start items. Use when the user mentions 'mac cleanup', 'system optimize', 'mac is slow', 'disk cleanup', 'out of memory', 'clear cache', 'system check', or in Korean '컴퓨터 최적화', '시스템 정리', '맥 느려', '디스크 정리', '메모리 부족', '캐시 정리', '시스템 점검'."
hooks:
  PreToolUse:
    - matcher: "Bash"
      hooks:
        - type: command
          command: 'g=; for d in "$HOME/.claude/skills/mac-optimize" "${CLAUDE_PROJECT_DIR:-.}/.claude/skills/mac-optimize"; do [ -f "$d/hooks/guard.py" ] && g="$d/hooks/guard.py" && break; done; [ -n "$g" ] && command -v python3 >/dev/null || exit 0; exec python3 "$g"'
---

# macOS System Optimize

A workflow that analyzes resource usage on macOS, cleans up unneeded files and services, and reports the result with before/after numbers.

## Invocation

The text after `/mac-optimize`, or the request that triggered the skill, sets the scope. Decide it before Phase 1 and state it in one line.

- **Nothing**: the full workflow
- **`help` or `usage`** (or the same request in Korean): print the usage summary below and stop. Run nothing that changes the machine
- **A focus word**: Phase 1, then only the matching team, then Phase 3 and Phase 4 for that scope. `disk` is Teams 1 and 4, `memory` and `services` are Team 3, `brew` is Team 2, and `security` or `health` is Team 5. `score` runs Phase 1 and all five teams with every cleanup task removed, then prints only the section 9 score table and what blocks a higher score (format and fixed weights in `references/phase-4-final.md`)
- **`report` or `dry-run`**: Phase 1 and all five teams with every cleanup task removed from their prompts (no purge, move, upgrade, cleanup, or autoremove: they list what they would do), then the Phase 4 report. No Phase 3 picks and no Phase 3 step that changes the machine
- **Anything else**: a free-text request. Say how you read it in one line. If it is a question or asks for documentation rather than a cleanup, answer it and start no cleanup

A second run on the same day follows "Re-measure only when run recently", whatever the arguments.

Usage summary:
```
/mac-optimize              diagnose, five parallel teams, your picks, report with a 100-point score
/mac-optimize <focus>      disk | memory | brew | services | security | health | score
/mac-optimize report       diagnose and report only, change nothing (same: dry-run)
/mac-optimize help         this summary
Asks before: stopping services, Docker cleanup, ending agent sessions, removing build
output or apps, admin actions, emptying what it moved to /tmp
Records: ~/.mac-optimize/rebuild/<YYYYMMDD>/ (moved paths, rebuild recipes)
Unattended hourly cleanup: mac-ops (https://github.com/seunggabi/mac-ops)
```

## Core principles

Short form. The full text, with the reasons and the evidence, is `references/rules.md`: read it before Phase 2 (or before Phase 3 on a run that launches no team), and paste it into every team prompt. Where the two seem to differ, `rules.md` is authoritative.

- **Safety first**: never `rm -rf` an original location. Use a cache manager's own purge/clean command, otherwise move the target to `/tmp/` (recoverable only until `/tmp` is cleaned). The one allowed deletion is emptying paths this run moved under `/tmp`, after the user approves
- **Never touch security software** (keywords at the end of this file). The one exception is a dead leftover the user explicitly picks after being told what it is, acted on only by the main session in Phase 3 after every check in `references/follow-up.md`; an item that fails or cannot complete any check stays untouched; Phase 2 agents only report it
- **Run in parallel**, **measure before and after**, and **verify free space with `df`**, not `du` (moves to `/tmp` and APFS clones free nothing)
- **Report instead of acting** when evidence conflicts about which copy is in use, or when the item is settings or data
- **Compare before restoring** over a live directory, and show the table. When the live copy is newer or more complete, do not swap: clone the trashed copy into the record directory, also before the cleaner is upgraded, reinstalled, or started again. A restore refused because the original exists again is working as intended; never move the live copy aside
- **Re-measure only when run recently**: on a same-day run, do not repeat finished cleanups; re-run Phase 1 and give agents only the areas the day's run records (`run-*.json`) do not list as finished (a `report`, `dry-run` or `score` run, or one that never reached Phase 4, does not count)
- **An old modification time does not mean unused**: leave out any repository with a live process working in it (terminal, IDE, coding agent), or name it and ask again
- **Record how to rebuild before removing**: move a virtualenv only with its Python version and package list recorded; no lock or requirements file and no list means do not move it (an empty list from a non-empty virtualenv means the command failed)
- **Uninstall managed apps through their manager** (JetBrains Toolbox, Homebrew), never by removing the bundle
- **Opening a manager is an action**: read its auto-update setting first (ask if you cannot), tell the user what opening it will do (if they do not want updates, have them turn auto-update off first, or do not open it), record app versions before and after, and report any change
- **Keep the record outside `/tmp`**: moved paths (`moved.txt`), rebuild recipes and the run record (`run-<HHMMSS>.json`) go to `~/.mac-optimize/rebuild/<YYYYMMDD>/` as you go
- **Admin rights only through the password dialog, and only for what the user picked in Phase 3**: show the script first; Phase 2 agents never use it, and the sudo-step commands stay with the user; never two dialogs at once
- **Path traps**: `/tmp` is a symlink (search `/private/tmp`), and APFS is case-insensitive (compare names lowercased)

## Data-loss rules

Short form; the full text is in `references/rules.md`. They apply in every phase and win over any step that seems to say otherwise. `hooks/guard.py` blocks the command-level bans while `~/.mac-optimize/active` exists: a block is a rule hit, never something to rephrase around, and the marker is never removed or aged to switch it off.

- Files and caches: never move anything a running process holds open (`lsof +D`), and move an app cache only when the app is not running. Leave `ms-playwright`, `ms-playwright-mcp`, `JetBrains` (indexes), `~/Library/HTTPStorages` and `~/Library/WebKit`. Never clean `~/Library/Caches/JetBrains/Toolbox/backup` or an older version's IDE cache folders as caches, whenever the update happened; offer them in Phase 3 with the licence caveat. `uv cache prune`, never `uv cache clean`. `find -newermt` only with an absolute time, and keep the stderr of a test that decides a move. The user temp directory is report-only. Never move a data directory; count entries before calling one empty. Under `/tmp`, delete only the exact recorded paths this run moved, one by one, after approval. Never empty the macOS Trash, never delete Time Machine snapshots, never run `softwareupdate --install`
- Homebrew: never bare `brew upgrade` (no casks); upgrade only Team 2's explicit formula list; `brew autoremove` only when its `--dry-run` list holds nothing the user would call directly; no `brew cleanup` while a process runs from an unlinked keg. Never `pkill -f "brew upgrade"`, never kill a brew lock holder, never run the `rm -rf` or `sudo` lines `brew doctor` prints
- Processes: list user processes, end them only when the user asks, after checking their children, with `kill -TERM` (never `-KILL`). Re-check PID and command right before any signal. Match by executable (`ps -eo comm`), not `pgrep -f`. Never end this session or its ancestors; end only root PIDs the user names; leave sessions younger than a day unless named. Quit Docker Desktop only when `docker ps -q` succeeds and is empty; never force-quit an app. `redis-cli save` before stopping Redis; keep databases such as MySQL
- Docker, keychain, secrets: never `--volumes`, never `docker volume prune`; prune images and build cache only with `--filter "until=720h"`. Never `security dump-keychain -d`; delete only picked entries, always with `-a <account>`, and say it cannot be undone. Delete a plaintext secret's line only when the user says it is unused; never print a value (mask it); a backup holds `<removed>`; `zsh -n` before replacing the file
- **mac-ops, never without a pick**: `mac-ops run` without `--dry-run` (it also purges expired trash), `purge`, `restore`, `install`, `uninstall`, `monitor kill`, `monitor setup`, `monitor unsetup`. `monitor kill`, and `purge --all` where `mac-ops help` lists it, are never run from this skill: give the user the line to run in their own terminal (`references/mac-ops.md`), and never work around its refusal. The preview `mac-ops run --dry-run` and the read-only `status`, `config`, `runs`, `list-trash` are allowed, also as tools of the read-only `mac-ops mcp` server where `mac-ops help` lists it. Never delete `~/.mac-ops/.trash` by hand
- Other tools: never run a cleaner's tests or scripts on this machine; `launchctl kickstart` a scheduled job only when picked. `brew trust` only a tap the user owns and picks. Stop a scheduled cleaner with its own command, not `launchctl`. hprof dumps: only what `find ~ -maxdepth 1 -name 'java_error_in_*.hprof'` lists. Keychain leftovers only when the user asks. A dead auto-start item: app absent, nothing running, program path read and missing; a broken symlink only when `-L` and not `-e`

## Companion tool: mac-ops

[mac-ops](https://github.com/seunggabi/mac-ops) does the unattended side of this job: hourly cleanup from launchd into its own trash with a 72-hour restore.
When `command -v mac-ops` succeeds, or Team 3 finds `com.mac-ops.cleanup`, read `references/mac-ops.md` before you summarize Phase 1 and run the Phase 1 commands it lists.

## Workflow

Every reference file named below is under `references/`. If one cannot be read, say which and do not carry out the step that needs it.

### Phase 1: Diagnose system state (do this yourself)

First write the run record and touch the guard marker (`references/recipes.md`, "Run record"). Then read `references/phase-1-diagnose.md`, run its commands in parallel, and summarize the result for the user as the tables it lists.

### Phase 2: Parallel agent teams

Launch the teams of the scope **at the same time** in the background, and set `teams_launched` in the run record. Right before launching, read `references/phase-2-teams.md`: it lists the five teams and how each prompt is built from files (team file, `rules.md`, the keyword list, `recipes.md`, a report limit; for Team 1 also the disk pressure and the mac-ops modules). An agent sees only its prompt; never build one from memory or a summary. If a team file cannot be read, do not launch that team.

### Phase 3: Collect results and follow up

After the agents finish (or at once on a same-day run that launches no team), record in the run record which teams finished. Then read `references/rules.md` (if not read yet), `references/follow-up.md` and `references/recipes.md`, and carry out the nine steps of `follow-up.md` in order, each as written there (step 8 reads `references/post-check.md`). Every move uses the collision-safe pattern in `recipes.md`. Step 4 is one question with every list the agents only reported; act only on the picks.

### Phase 4: Final report

Read `references/phase-4-final.md`: update the run record, remove the guard marker (`rm -f ~/.mac-optimize/active`), and write the report in its format. The section 9 weights are fixed; do not change them between runs.

## Security software keywords

A service whose name contains one of these keywords is likely required by corporate security policy. Never change it:
- fortinet, forticlient (VPN / security)
- ahnlab, astx (antivirus)
- jiran, jkok (DLP / security)
- pnpsecure, pcassist (security)
- wizvera, delfino, veraport (certificate tools)
- iniline, crossex, initech, inisafe (certificate tools)
- nprotect (game / security)
- raon, touchen (certificate tools)

Files in this skill

  • SKILL.md12.1 KB
  • hooks/guard.py11.6 KB
  • references/follow-up.md13.1 KB
  • references/mac-ops.md7.5 KB
  • references/phase-1-diagnose.md2 KB
  • references/phase-2-teams.md2.4 KB
  • references/phase-4-final.md2.6 KB
  • references/post-check.md2.6 KB
  • references/recipes.md3.3 KB
  • references/rules.md16.6 KB
  • references/team-1-cache.md3.2 KB
  • references/team-2-brew.md3.3 KB
  • references/team-3-services.md5.4 KB
  • references/team-4-disk.md2.7 KB
  • references/team-5-health.md2.8 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.