# clean/

The `clean` skill: documentation cleanup orchestrator. Loads the machine report
from `/os-doc-hygiene:check`, gates confirm-tier entries, applies deterministic ops
via the patch applier, delegates generative distillation to a Sonnet subagent,
produces exactly one cleanup commit, and stamps `last_clean`.

## Contents

| File | Purpose |
|------|---------|
| `SKILL.md` | The complete `clean` workflow. Orchestrates 11 steps: load report → re-validate → filter by scope/category → detect incompatible-ops → partition by safety_tier/op_type → confirm gate (BEFORE mutation) → git preflight (baseline + WIP checkpoint) → apply deterministic ops via `patch_applier.py` → apply generative ops via Sonnet subagent → produce cleanup commit via `git-context` → stamp `last_clean`. Rollback on hard failures; commit what applied on partial success. Invariants #4, #5, #6, #7 (confirm precedes mutation), #8 (mtime guard). LOOP-GUARD: subagent prompt points only to `workflows/distill.md`. |
| `workflows/distill.md` | Self-contained generative workflow for distillation subagent. Defines ops: `distill` (condense, preserve frontmatter, ~40–60% target), `split` (extract to archive), prose-rewrite (`provisional`, `contradicted`). Receives live file contents (no disk I/O), performs the rewrite, returns structured output (`DISTILL_RESULT_START`/`END`, `SPLIT_PRIMARY_START`/`END`, `SPLIT_ARCHIVE_DEST`, `SPLIT_ARCHIVE_START`/`END`, or `DISTILL_ERROR`). No file writes, no git calls, no re-reads. Conservative: prefers keeping content when uncertain. |
