dotfiles / macos_cleanup
AGENTS.md16 starsChanged 48 days agoMITView on GitHub
- Reads credentials
- Deletes or force-pushes
In this repository50 other files it gives its agents.
- ableton/AGENTS.mdAGENTS.md
- AGENTS.mdAGENTS.md
- aichat/AGENTS.mdAGENTS.md
- aider/AGENTS.mdAGENTS.md
- annepro2/AGENTS.mdAGENTS.md
- applesauce/AGENTS.mdAGENTS.md
- atuin/AGENTS.mdAGENTS.md
- btop/AGENTS.mdAGENTS.md
- chromium-vimium-extension/AGENTS.mdAGENTS.md
- claude-code/AGENTS.mdAGENTS.md
- codex/AGENTS.mdAGENTS.md
- constants/AGENTS.mdAGENTS.md
- contextMenu/AGENTS.mdAGENTS.md
- cron/AGENTS.mdAGENTS.md
- docker/AGENTS.mdAGENTS.md
- docker-logger/AGENTS.mdAGENTS.md
- docs/AGENTS.mdAGENTS.md
- dotfiles_tests/AGENTS.mdAGENTS.md
- eza/AGENTS.mdAGENTS.md
- firefox-vimium-addon/AGENTS.mdAGENTS.md
- fork/AGENTS.mdAGENTS.md
- git/AGENTS.mdAGENTS.md
- hammerspoon/AGENTS.mdAGENTS.md
- heroic/AGENTS.mdAGENTS.md
- homebrew/AGENTS.mdAGENTS.md
- iina/AGENTS.mdAGENTS.md
- install/AGENTS.mdAGENTS.md
- iterm/AGENTS.mdAGENTS.md
- jetbrains rider/AGENTS.mdAGENTS.md
- karabiner/AGENTS.mdAGENTS.md
- lazydocker/AGENTS.mdAGENTS.md
- lazygit/AGENTS.mdAGENTS.md
- macos/AGENTS.mdAGENTS.md
- macos_shortcuts/AGENTS.mdAGENTS.md
- macos_update/AGENTS.mdAGENTS.md
- marta/AGENTS.mdAGENTS.md
- noti/AGENTS.mdAGENTS.md
- npm/AGENTS.mdAGENTS.md
- opencode/AGENTS.mdAGENTS.md
- python/AGENTS.mdAGENTS.md
- qdrant/AGENTS.mdAGENTS.md
- rtk/AGENTS.mdAGENTS.md
- tmux/AGENTS.mdAGENTS.md
- uv/AGENTS.mdAGENTS.md
- voiceink/AGENTS.mdAGENTS.md
- vscode/AGENTS.mdAGENTS.md
- xcode/AGENTS.mdAGENTS.md
- zap/AGENTS.mdAGENTS.md
- zsh/AGENTS.mdAGENTS.md
- claude-code/CLAUDE.mdCLAUDE.md
The file
We found no rules to list in this file: it reads as prose or reference rather than instructions.
Files
macos_cleanup — "where_is_my_space" macOS cache/junk cleanup scripts
cleanup_all.shis the entry point: flushes DNS, rebuilds zsh completion cache, sourcescleanup_targets.sh, then prunes Homebrew Caskroom installers, the uv cache, Docker, Trash, Atuin DB (VACUUM), and various app caches (GeForce NOW, Battle.net, Steam, DriveFS, GlobalProtect).deep_clean.sh(aliasdeepclean,-nfor a dry run, optional repo roots as arguments) is the rare, deliberate half and is never run byup. Every step costs a re-download, a rebuild or lost local state, so each prints what it frees and the price, then waits fory+ Enter: NuGet locals, the whole uv cache, npm cache, Go build + module cache, build output in repositories, iOS simulator erase,docker system prune -a, reflog expiry +git gc --aggressive. It replaced theAGGRESSIVE=truesection ofcleanup_all.sh.- Repositories are not cleaned with
git clean -dfx. Measured over~/projects(165 repos, 27 GB), that command would also delete every ignored.env, local SQLite databases, trained models,karabiner.jsonand the Claude Code transcripts underclaude-code/— ignored is not the same as regenerable. A directory goes only if git ignores it and its name is inARTIFACT_NAMES(bin obj node_modules build dist target .venv …); that keeps ~8 GB of the 27 and loses nothing that cannot be rebuilt. A directory some live process was started from is kept and listed as in use. The dotfiles repo itself is skipped entirely:~/.claudeis a symlink into it, so its ignored directories are live tool state.
- Repositories are not cleaned with
- uv keeps the environment of a
uv run script.pyservice inside its cache (environments-v2), so bothuv cache prune --forcehere anduv cache cleanindeep_clean.shdelete it under the live launchd shims; the process survives until its next lazy import and then answers 500 withModuleNotFoundError.restart_services_with_deleted_uv_envinhelpers.shruns after either and kickstarts exactly the launchd jobs whose interpreter path no longer exists. cleanup_targets.shis the declarative target list — mostlytry_clean/try_clean_aged/try_clean_patterncalls grouped (Caches / Gaming / Development / Applications / System / Patterns). The Patterns section deletes.DS_Store(singlefind ~pass, prunes Library/.Trash/node_modules/.git, 30stimeout) and.AppleDoublefiles.try_clean.shdefinestry_clean <dir> <label> [exclude], the two age-gated variants below, andtry_clean_pattern <base> <d|f> <pattern> <label>; all size-measure, skip missing/empty dirs, and report.helpers.shprovides the spinner (spinner_start/spinner_stop) andformat_size.- Age gating protects work in flight: nothing modified within
CLEANUP_KEEP_DAYS(default 2, overridable from the environment) is removed. Which of the two shapes a target gets depends on what a top-level entry means, and picking wrong either corrupts a cache or frees nothing:try_clean_aged <dir> <label> [exclude] [days]— entry is one self-contained unit of work, so it lives or dies whole. Used for the three Caches roots, JetBrains caches, DerivedData, Android SDK/NPX/pre-commit caches, Steam temp+downloads, work bins. The freshness probe is a recursivefind -type f, not a stat of the entry: a directory's own mtime doesn't move when a nested file changes (an in-flight build would read as stale) and does move on every add/remove (a bag of ancient junk would read as fresh) — it lies in both directions. Afindthat exits non-zero (unreadable subtree) is read as "in use" and kept.try_clean_aged_files <dir> <label> [days]— entry is a bag of independently replaceable artifacts, so the unit is the file; empty dirs are pruned afterwards. Used for~/.gradle/caches, the NuGet v3-cache, the/private/var/folders/…/Txdb logs. Whole-unit gating is actively useless here: one warm jar inmodules-2would pin the other several GB forever. Note! -mtime -$DAYS, not-mtime +$DAYS— the latter truncates to whole days and spares an extra day's worth (verified: a 49h-old file is missed by+2).
- Two rules that look like candidates and are not. App caches (
~/Library/Caches/<bundle>, browser/Electron CEF dirs) must never move to the per-file shape — a fresh index referencing stale data files is a state apps handle worse than an absent cache, which is what plaintry_cleangives them. And the hot Electron caches (Discord/Obsidian/Claude/Vivaldi) stay on plaintry_cleanentirely: rewritten constantly, so any gate keeps everything and frees nothing, and they regenerate cheaply. Measured cost of the safety rule on~/Library/Caches: ~270 MB (14%) of stale bytes stay pinned inside live apps' bundles. broken_links.shdefinesreport_broken_links(called from the always-run "Dangling Symlinks" section): scans$HOME(pruningLibrary/node_modules/.git/.Trash/.cache/.npm/dosdevices, plus foreign filesystems mirrored into$HOMEthat only look broken from the host:OrbStackcontainer roots and*/etc/ssl/certsserver-rootfs mirrors) plus/opt/homebrew/{bin,sbin,etc}and/usr/local/binfor dangling symlinks (target deleted/renamed — e.g. a removed app's leftover link, or a renamed dotfiles target), usingfind … -type l ! -exec test -e {} \;. Report-only by default, flagging links into~/projects/dotfileswith[dotfiles]; setPRUNE_BROKEN_LINKS=truetormthem (a dangling symlink is pure junk). NB: "broken hardlinks" don't exist — a hardlink keeps the inode alive — so only symlinks are scanned.- Invariant: cleanup is destructive but conservative — missing/empty/running-app targets are skipped silently, never failed. Safety options:
setopt no_unset pipe_failat the top (a typo'd variable can never expand to "" inside an rm path);err_exitis deliberately NOT set, matching the skip-silently design. - Invoked three ways: locally via
up(alias →macos/update_all_and_cleanup_all.sh, which runsmacos_update/update_all.shthencleanup_all.shas child zsh processes — not sourced, so the safety setopts can't leak into the interactive shell); directly; or remotely viaclean.sh(curl bootstrap that downloads the five sourced scripts to a tmpdir and sourcescleanup_all.shwithCLEANUP_DIRset — safe there because the curl pipe runs in its own zsh process). It does its ownsudo -v. - Relation to
macos_update/:update_all.shdoes package/tool updates (brew, npm, uv, docker, etc.); this dir does only deletion. They are independent —upchains update → cleanup. Files are tracked by the repoMakefile(not symlinked).
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

