---
name: multi-agent-prune-logs
description: "Delete per-task project logs under ~/.claude/logs/multi-agent (filter by age/project/task). Audit trail + metrics are preserved. Dry-run first; confirms before deleting. Invoked only when the user types it."
user-invocable: true
argument-hint: "[--older-than=<days>] [--project=<name>] [--task=<id>] [--yes]"
metadata:
  language: en
---

# multi-agent prune-logs  -  Clear Per-Task Project Logs

Every run persists a task log dir at
`~/.claude/logs/multi-agent/<project>/<task>/` (agent-state.json, agent-log.md,
tracker-state.json, otel-spans.jsonl). These accumulate forever. This prunes
whole task dirs, with optional age / project / task filters.

Backed by `$HOME/.claude/scripts/prune-logs.sh`. Safe by default: it previews
and deletes nothing until you confirm. The audit trail (`audit.jsonl` +
rotations) and the metrics corpus (`metrics.jsonl`, `metrics-summary.md`) live
at the log-root top level and are never removed; `.counter` files survive too. A run that can still be resumed (its `agent-state.json` status is not
finished, abandoned or cancelled) keeps its log however old it is, and
so does a folder written in the last 10 minutes; `--task` names one dir and
bypasses both.

Unlike `/multi-agent:purge` (which wipes worktrees, branches, logs, and state
together), this only removes log dirs and leaves your worktrees and branches
untouched.

## Steps

1. **Preview (dry-run)**  -  run the pruner with no `--yes`, forwarding any
   `--older-than=<days>`, `--project=<name>`, or `--task=<id>` the user gave:

   ```bash
   bash $HOME/.claude/scripts/prune-logs.sh ${ARGUMENTS}
   ```

   It lists each task log dir that matches and the space it would free.

2. **Nothing to do**  -  if the output says `nothing matched`, stop and report
   there is nothing to prune.

3. **Confirm**  -  surface a native `AskUserQuestion` picker (no typed keyword),
   in `outputLanguage`:
   - `question`: "Delete the listed task log dirs now?" (include the count and
     freed-size estimate, and note audit + metrics are preserved)
   - `header`: "Prune logs" (English, <=12 chars)
   - `options`: `{ label: "Delete logs", description: "Remove the listed task log dirs" }`,
     `{ label: "Cancel", description: "Keep everything, change nothing" }`
   - Anything other than **Delete logs** -> cancel and change nothing.

4. **Delete**  -  on confirm, re-run with `--yes` plus the same filters:

   ```bash
   bash $HOME/.claude/scripts/prune-logs.sh --yes ${ARGUMENTS}
   ```

5. **Report**  -  echo the `══ prune-logs: removed N task log dir(s), freed ~X ══`
   summary line.

## Notes

- Pruning a log dir does not affect the run's git history or its commit/PR;
  it only removes the local state + log artifacts.
- To also reclaim `/tmp` scratch, use `/multi-agent:garbage-collect`.
- For a full reset (worktrees + branches + logs + state), use
  `/multi-agent:purge`.
