---
name: multi-agent-garbage-collect
description: "Sweep leftover /tmp scratch (picker state, review diffs, channel payloads, analysis drafts) from past runs. Dry-run first; confirms before deleting. Invoked only when the user types it."
user-invocable: true
argument-hint: "[--older-than=<minutes>] [--yes]  -  dry-run unless confirmed"
metadata:
  language: en
---

# multi-agent garbage-collect  -  Sweep /tmp Scratch

Each run writes ephemeral scratch under `/tmp`: picker state
(`multi-agent-picker-*`), PR/review diffs (`multi-agent-review-*`), issue
progress bodies (`issue-progress-*`), channel payloads (`channels-*`),
external-context bundles (`context-links-*` / `context-by-type-*`), and analysis
drafts (`analysis-*`). Most are never cleaned up, so a long-lived machine
accumulates them. This sweeps the known prefixes only.

Backed by `$HOME/.claude/scripts/gc-tmp.sh`. Safe by default: it previews and
deletes nothing until you confirm.

## Steps

1. **Preview (dry-run)**  -  run the sweeper with no `--yes`, forwarding an
   `--older-than=<minutes>` argument if the user supplied one:

   ```bash
   bash $HOME/.claude/scripts/gc-tmp.sh ${ARGUMENTS}
   ```

   It prints each matching item and the space it would free.

2. **Nothing to do**  -  if the output says `nothing to do`, stop and report
   that there is no scratch to clean.

3. **Confirm**  -  surface a native `AskUserQuestion` picker (no typed keyword),
   in `outputLanguage`:
   - `question`: "Delete the listed /tmp scratch items now?" (include the count
     and freed-size estimate from step 1)
   - `header`: "Sweep" (English, <=12 chars)
   - `options`: `{ label: "Delete scratch", description: "Remove the listed /tmp items" }`,
     `{ label: "Cancel", description: "Keep everything, change nothing" }`
   - Anything other than **Delete scratch** -> cancel and change nothing.

4. **Delete**  -  on confirm, re-run with `--yes` (and the same
   `--older-than` if given):

   ```bash
   bash $HOME/.claude/scripts/gc-tmp.sh --yes ${ARGUMENTS}
   ```

5. **Report**  -  echo the `══ garbage-collect: removed N item(s), freed ~X ══`
   summary line.

## Notes

- An in-flight analysis keeps its drafts in `/tmp/analysis-<slug>-<timestamp>/`
  and `/multi-agent:resume` re-uses them. If a run is paused at
  `awaiting_output_decision`, pass `--older-than=<minutes>` so fresh drafts are
  spared, or finish the run first.
- This only touches `/tmp` scratch. Persistent per-task logs live under
  `~/.claude/logs/multi-agent/` and are cleaned by `/multi-agent:prune-logs`.
