Safe disk clean
Confirmation-first disk cleanup for a shared multi-agent Linux computer. Overrides any “auto-clean temp / package caches without approval” guidance elsewhere.
Absolute rules
- Survey never deletes. Flow: diagnose → limited scan → classify → approval → re-check → delete → audit.
- Never scan all of
/. Discover narrow roots at runtime; do not hardcode a specific machine’s tree. - Failures: count, prune, continue — do not abort the whole job after one miss.
- Approvals are directory summaries, not huge file lists.
- Do not trust atime alone. Activity T = max(mtime, ctime).
Discover roots (every run)
Resolve once, then use only these variables:
HOME— login home ($HOME)WORKSPACE— shared scratch/work root (first existing among envWORKSPACEif set,$HOME/workspace, and other account-documented scratch roots; do not invent)TMP—$TMPDIRif set, else the system temp dirAGENT_DATA—$HOME/agent-datawhen presentREFERENCE—$HOME/referencewhen present
If a root is missing, skip it and note under D.
Review-resilient Shell
Sequential only (one Shell at a time). Prefer ls -ld over stat.
Canonical survey sequence
du -xhd1 "$WORKSPACE"(if set)du -xhd1 "$TMP"du -xhd1 --exclude=agent-data --exclude=reference "$HOME"
Never baredu -xhd1 "$HOME"whenagent-data/referencelive under it — Auto-review may reject unprotected home scans. Prefer the exclude form.df -h /- Shortlist ≤6 candidates:
ls -ldone path per call; optionaldu -shone path per call - If
AGENT_DATA/agentsexists:ls -1 "$AGENT_DATA/agents"
Classifying / binding errors
- Do not parallelize alternatives.
- Retry the identical command once.
- Success → continue. Failure → mark missing / prune.
- Never invent sizes or dates.
Forbidden Shell shapes
Multi-line scripts, many paths in one command, bare stat, deep walks into venv / node_modules / browser profile contents, Python per-file os.stat, parallel Shell storms.
Default roots / bans
Survey: discovered WORKSPACE, TMP, HOME (with excludes), trash-like dirs, package/user caches, clearly orphaned empty browser profiles.
Never candidate without an explicitly named approval: agent-data, reference, /proc /sys /dev /run, OS system trees, live repos / manuscripts / TEAM.md trees. Never wipe all of temp.
Time box
Aim for a short survey (about half a minute) when commands pass. Cap shortlist ~6.
Classification A / B / C / D
- A safe (still needs approval): trash dirs, unreferenced deleted-agent remnants, tiny orphan browser profiles, reclaimable caches, old unused temp regular files (not live desktop/session sockets).
- B judgment: work trees, venvs, large browser profiles, tool state dirs.
- C idle ≥ ~30 days (info only): T = max(mtime,ctime) on work areas; note atime unreliable.
- D uninspected: review failures after retry, permission, timeout, missing roots.
Delete after approval
Re-check each approved path; prefer move-to-dated-trash under WORKSPACE when unsure; log results; prove with df -h /.
Related
Fast disk survey, Shared computer maintenance, Cheap routines.