Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Sweep?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/nirecom-sweep)
---
name: sweep
description: Periodic maintenance sweep hub. Dispatches to /sweep-worktrees, /sweep-branches, /sweep-plans, /sweep-tests, /sweep-issues, /sweep-shell-snapshots.
user-invocable: true
model: sonnet
---
Hub skill for periodic maintenance sweeps. Dispatches to one or more sub-skills
that each reclaim a specific class of residual state. A flagless run applies
(deletes); `/sweep-plans` deletes only non-plan files and prints a count hint for plan and user-requested files. Pass `--dry-run` to preview without writing.
## Procedure
SW-1. Invoke `/sweep-worktrees` (deletes by default; pass `--dry-run` to preview).
SW-2. Invoke `/sweep-branches` (deletes by default; pass `--dry-run` to preview).
Capture stdout for post-processing (SW-2b/SW-2c).
SW-2a. When SW-2's stdout contains any WORKTREE-LOCKED line, emit
`echo <<WORKFLOW_ENFORCE_WORKTREE_OFF: sweep hub — SW-2b/SW-2c worktree-remove/branch-delete fallback>>`
before SW-2b. Skip SW-2a–SW-2d entirely when no WORKTREE-LOCKED line was produced.
SW-2b. Resolve TARGET_MAIN_ROOT first: run `bash "$AGENTS_MAIN_ROOT/bin/main-worktree-root"` as its own call and copy its stdout literally.
On a non-zero exit, skip the removals, report "SW-2b stopped: main worktree not resolved", and go to SW-2d.
Parse sweep-branches stdout for WORKTREE-LOCKED lines.
Each `WORKTREE-LOCKED: branch=X wt=<path>` line triggers:
`git -C "<TARGET_MAIN_ROOT>" worktree remove --force "<path>"`
Report each path whose removal fails, with git's stderr; continue with the next line.
SW-2b lives in the hub (not sweep-branches.sh) because the hub has
worktree-remove authority; sweep-branches.sh does not.
SW-2c. After worktree removal, retry `git branch -D` for each WORKTREE-LOCKED
branch using the `branch=X` field. SW-2b removes the worktree block, so the
cascade rule no longer prevents deletion. Failures are ignored (reclaimed
next cycle).
SW-2d. Emit `echo <<WORKFLOW_ENFORCE_WORKTREE_ON: sweep hub — SW-2b/SW-2c fallback complete>>` after SW-2c, regardless of outcome.
SW-3. Invoke `/sweep-plans` (deletes non-plan files by default and prints only a count hint for plan and user-requested files; pass `--dry-run` to preview).
SW-4. Invoke `/sweep-tests` (deletes by default; `--dry-run` and `--fix-headers` are forwarded when passed).
SW-5. Invoke `/sweep-issues` (tier-1 meta-parent closes apply by default; `--dry-run` previews).
Tier-2 candidates are human-gated and only surface under `--deep`.
SW-6. Invoke `/sweep-shell-snapshots` (deletes by default; pass `--dry-run` to preview).
SW-7. Future sub-skills to be added in subsequent PRs:
- `/sweep-wip` — stale WIP fingerprints
- `/sweep-logs` — old terminal logs / temp files
Forward `--dry-run` (and any other flags) to each invoked sub-skill verbatim, except `--include-plan-and-user-requested`, which the hub never forwards.
## Rules
- Each sub-skill is independent; one failure does not stop the chain.
- A flagless run deletes; pass `--dry-run` to preview. `--apply` remains accepted as an explicit synonym of the default. For `/sweep-plans` the flagless write scope is non-plan files only.
- Both the nightly cron (`.github/workflows/sweep.yml`) and manual `/sweep` use this hub.
- The nightly cron acts as a workflow health check; zombie reclamation primarily
relies on manual `/sweep` on the developer's machine, since CI runners do not
see local worktrees.
- Never pass `--force` — none of the sub-skills accept it by design.
- Never add `--deep` automatically for `/sweep-issues`; it is for human sessions only, so cron and hub runs never stop at a tier-2 gate.
- Never add or forward `--include-plan-and-user-requested` for `/sweep-plans`; deleting plan and user-requested files is for a direct `/sweep-plans` run only, so hub runs never stop at an approval gate.