sweep-project
Sweep Project
Periodic cleanup + reorganization + consistency check for one project at a time. Three gated phases: 1) audit (read-only) → 2) plan → 3) execute. Human approves between each.
Covers everything in the project: technical artifacts, deliverables, context files (CONTEXT-*-llm.md),
indexes, manifests, raw inputs, and parking of what's no longer active.
References (read on demand, do NOT inline): references/operating-rules.md (⚠️ hard constraints + AskUserQuestion guard + output style — read first, every run) · references/convention.md (zones + tiers) · references/drift-rules.md (the 5 checks) · references/templates.md (report skeletons).
Auto-invoke: dual-invocable by design. Despite Phase 3 moving/editing files, the three gates (audit → plan → execute, each human-approved) make autonomous misfire safe — so it stays auto-invocable rather than disable-model-invocation.
Phase 0: Resolve Target & Convention
- Resolve project path from
$ARGUMENTS. If empty: glob forCLAUDE.mdunder$COWORK_ROOT/git rev-parse --show-toplevel/ cwd (max depth 3), list candidates, ask which one. One project only. - Read the project's
CLAUDE.md— extract its declared folder structure, mutability table, any tier ontology, and naming rules. This is the authoritative spec for this project. Where it's silent, fall back toreferences/convention.md. Note any file-listing inside CLAUDE.md — that inventory is Axis-0 drift (belongs in INDEX.md). - Detect zones + map roles: detect
in/ src/ ref/ wip/ park/+ satellites (sync/ converted/ .tmp/ .dump/). For semantic-folder projects (own folder names), map each folder to a canonical role perreferences/convention.md§Hybrid role-mapping — keep names, govern by role. Note missing/extra zones and the folder→role map. - Detect traceability artifacts:
INDEX.md,in/MANIFEST.md,wip/00-index.md,sync/**/_manifest.yaml, any project-localSWEEP.md. Note which are missing. - Determine which phase to run (
--phase, else start at audit).--phase plan/executerequire the prior artifact — look for the latestAUDIT-*/PLAN-*in<P>/.tmp/sweep-project/. If the needed artifact is missing (or--phase executehas no approved plan), say so and restart from the earliest phase that has its inputs; never execute moves/edits without an approved plan. Confirm the project + detected convention in one short line before proceeding.