Skip to content
Back to skills

Leftovers

BSecurity

Find what is eating the disk and which git worktrees are safe to remove, then clear only what the user approves. Scans developer caches (npm, pnpm, Yarn, Bun, pip, uv, Poetry, Go, Cargo, Gradle, Xcode, simulators, Homebrew, Docker, Playwright, Hugging Face), Claude Code temp folders, the biggest home folders, stale git worktrees (merged, squash-merged, PR state from GitHub) and leftover dev processes. Everything is re-checked right before deletion.

  • 12 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 3, 2026
developmentpythongobashdockergitdatabase

Works with

  • claude code

Security analysis

B85/100
  • highPerforms destructive filesystem operations

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

Scanned December 3, 2026

npx -y skills add arpwal/leftovers --skill leftovers --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Leftovers?

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

Security grade badge for Leftovers
[![Security: B — Skills Directory](https://www.skillsdirectory.com/api/skills/arpwal-leftovers/badge)](https://www.skillsdirectory.com/skills/arpwal-leftovers)

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: leftovers
description: Find what is eating the disk and which git worktrees are safe to remove, then clear only what the user approves. Scans developer caches (npm, pnpm, Yarn, Bun, pip, uv, Poetry, Go, Cargo, Gradle, Xcode, simulators, Homebrew, Docker, Playwright, Hugging Face), Claude Code temp folders, the biggest home folders, stale git worktrees (merged, squash-merged, PR state from GitHub) and leftover dev processes. Everything is re-checked right before deletion.
when_to_use: Use on "/leftovers", "leftovers", "disk full", "disk is almost full", "out of space", "free up space", "clean up stale worktrees", "remove old worktrees", "what's eating my disk", "where did my disk space go", or when a command fails with "No space left on device".
allowed-tools: Bash(python3 "${CLAUDE_SKILL_DIR}/scripts/disk_scan.py" *) Bash(python3 "${CLAUDE_SKILL_DIR}/scripts/worktree_scan.py" *) Bash(python3 "${CLAUDE_SKILL_DIR}/scripts/procs_scan.py" *) Bash(python3 "${CLAUDE_SKILL_DIR}/scripts/make_plan.py" *)
---

# Leftovers

Clean up what apps and coding agents left behind, from inside Claude Code. Scripts are
python3 stdlib (macOS, Python 3.9+) plus git, du, df, ps, lsof, and gh if present.
The scans only read. Only `clean.py --yes` changes anything.

## Hard rules

1. **Nothing is deleted without the user's yes in this turn.** Show the list first.
   A yes covers only the items shown. Anything new needs a new list.
2. **KEEP is shown, never offered.** REVIEW goes in a plan only when the user picks it.
3. Never `--force` a worktree removal and never delete a branch. Never remove a worktree
   with uncommitted changes, an open PR or a process working in it. clean.py checks all
   of this again right before it acts.
4. Never `poetry env remove`. Never touch `~/Library/Caches/pypoetry/virtualenvs` or any
   shared venv. Never remove Docker volumes.
5. Stop a Postgres cluster (`pg_ctl -D <dir> stop -m fast`) before you delete its data
   folder. Stop local servers before you delete their data.
6. No `sudo` and no `rm -rf` of your own. Every delete goes through `clean.py`.
7. **Shared Mac:** only the current account's files are ever cleaned (clean.py checks the
   owner). Other accounts are shown so the user knows where space went, never offered.
8. **Disk completely full (ENOSPC):** Claude Code may not be able to run anything. Ask
   the user to free a little first with a `!` command, such as `! npm cache clean --force`
   or `! go clean -cache` or `! brew cleanup -s`, then start the scan.

## 1. Scan (read-only)

Make one work folder and reuse its literal path in later commands:

```sh
mktemp -d -t leftovers        # e.g. /var/folders/.../leftovers.Ab12 -> call it W
```

Run these in parallel. Each prints tables and saves JSON for the plan:

```sh
python3 "${CLAUDE_SKILL_DIR}/scripts/disk_scan.py" --save W/disk.json        # ~20-90 s
python3 "${CLAUDE_SKILL_DIR}/scripts/worktree_scan.py" --save W/wt.json      # ~20 s
python3 "${CLAUDE_SKILL_DIR}/scripts/procs_scan.py" --save W/procs.json      # ~1 s; when asked about memory or slowness
```

disk_scan.py also prints **where all the used space goes**, by owner: you (home folder +
your temp area), each other account (or "private" when it can't be read), apps, shared
folders, macOS volumes, and what is left unread. On a shared Mac, say plainly that the
"private accounts" / "can't read" line belongs to other people and only an admin can
measure it (`sudo du -sxh /Users/*`, which the user runs themselves).

Useful flags:
- `disk_scan.py --budget 30`: a shorter home-folder overview. `--no-top` skips it.
- `worktree_scan.py --repo DIR` or `--root DIR`: limit the scan to one repo or folder.
  `--no-size` is faster. `--no-gh` checks with git only.

What the groups mean:

| Group | Worktrees | Disk items | Processes |
|---|---|---|---|
| SAFE | PR merged, or the tip is on the default branch (merged or squash-merged). Clean, no open PR, nothing running in it, quiet for 2+ hours. | A cache that rebuilds itself, with nothing using it. Claude temp folders idle 3+ days. Old Chrome self-copies (`chrome-clones:old`, newest kept). | An orphaned dev process idle 12+ hours, or one whose folder was deleted. |
| REVIEW | PR closed without merging, no PR and not on main, untracked files only, or changed in the last 2 hours. | Costly to get back: Hugging Face models, Xcode archives, Trash, app caches, Docker images or containers. | Orphaned recently or still busy. Test Postgres clusters. |
| KEEP | Uncommitted changes, open PR, a process inside, locked, the main checkout, your current folder, or PR state unreadable. | In use, macOS-owned, Docker volumes, Ollama or LM Studio models, Time Machine snapshots. | Everything else. |

## 2. Show and ask

Show each scan's tables grouped as SAFE, REVIEW and KEEP, with sizes and totals. Say
which tables are biggest. Then ask with **AskUserQuestion**, two questions in one call:

- **SAFE**: "Clear all SAFE items (N items, X GB)?" Options: *Clear all SAFE
  (Recommended)*, *Only worktrees*, *Only caches*, *Nothing*.
- **REVIEW**: list the REVIEW items by name. Options: *None (Recommended)*, *All of
  them*, *I'll pick* (then ask which by number).

Never put KEEP items in the options.

## 3. Plan, dry run, then do it

```sh
python3 "${CLAUDE_SKILL_DIR}/scripts/make_plan.py" --scan W/disk.json --scan W/wt.json \
  --safe [--kinds wt,cache,claude-tmp] [--review ID ...] [--exclude ID ...] -o W/plan.json
python3 "${CLAUDE_SKILL_DIR}/scripts/clean.py" --plan W/plan.json          # dry run: changes nothing
python3 "${CLAUDE_SKILL_DIR}/scripts/clean.py" --plan W/plan.json --yes    # only after the yes
```

- Add `--scan W/procs.json` only if the user approved processes. A process gets SIGTERM
  only, and only the exact PID that was in the plan.
- `make_plan.py` never writes KEEP items. A REVIEW item gets in only by `--review ID` or
  `--review-all`.
- Show the dry run. If clean.py refuses something now (it changed since the scan), say so.
  Do not try to work around it.
- Big runs take time. Removing many worktrees can take 10+ minutes. Run `--yes` with
  `run_in_background`, send stderr (progress lines `[i/n] id: ...`) to `W/progress.log`,
  and tell the user it is running.

## 4. Report

From clean.py's output, give a short table: item, freed, result (*done*, *refused: why*,
or *git kept it*). Then one line: `Free: <before> -> <after> (+<delta>)`.

Then mention:
- **Sizes can differ.** du sizes and freed space can differ. APFS clones share blocks, and
  local Time Machine snapshots keep deleted data until macOS thins them. Freed space can
  show up a few minutes late.
- **Big KEEP or REVIEW items not cleared.** Name the big ones still there, such as open-PR
  worktrees, Docker volumes, Ollama models and the biggest home folders, so the user can
  decide.

Delete the work folder W when done.

## What it never does

- Delete anything outside the catalog paths, a direct child of `~/Library/Caches`, a
  Claude session folder under `/private/tmp/claude-<uid>/`, or an old Chrome copy in your
  own temp area.
- Touch another account's files, folders or databases.
- Follow symlinks. A linked cache path is refused.
- Delete branches.
- Use `git worktree remove --force`.
- Run `docker volume prune`.
- Run `poetry env remove`.
- Kill another user's process or a launchd service.

Files in this skill

  • SKILL.md7.2 KB
  • scripts/catalog.py6.1 KB
  • scripts/chrome_clones.py3 KB
  • scripts/clean.py4.9 KB
  • scripts/clean_actions.py8.5 KB
  • scripts/clean_worktrees.py3.4 KB
  • scripts/common.py6.7 KB
  • scripts/disk_extras.py7.5 KB
  • scripts/disk_scan.py5.9 KB
  • scripts/fsops.py3 KB
  • scripts/git_facts.py8.8 KB
  • scripts/make_plan.py3.7 KB
  • scripts/pr_state.py2.7 KB
  • scripts/proc_rules.py4 KB
  • scripts/proc_table.py4.3 KB
  • scripts/procs_scan.py4.7 KB
  • scripts/system_scan.py6.3 KB
  • scripts/topdirs.py2.5 KB
  • scripts/worktree_inspect.py4.1 KB
  • scripts/worktree_judge.py3.1 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 development →

Comments

Loading comments…

Newsletter

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