# Clean safely (/docs/guides/clean-safely)

Deleting is the one thing purgeit does that you cannot undo, so it gives you several ways to look before you leap.

## 1. Preview with a dry run [#1-preview-with-a-dry-run]

```bash
purgeit clean ~/dev --dry-run
```

Runs *every* check — rules, protection, recent activity — and reports what would be deleted and what would be skipped, deleting nothing. Skipped paths come with the reason.

## 2. Narrow it down [#2-narrow-it-down]

| You want | Use |
| --- | --- |
| Only the big wins | `--min-size 100MB` |
| Only projects you have abandoned | `--stale` (not worked on for 30 days — change it with `dormantAfter`) |
| Only artifacts untouched for a while | `--min-age 30d` |
| Only certain tools' output | `--only node_modules,target` or a [group](/docs/reference/configuration) |
| Only proven-safe names | `--safe-only` (skips rules that need a manifest as proof) |
| Keep some folders out | `--exclude 'legacy/**'` |

## Ask why [#ask-why]

When something is matched, skipped or protected and you wonder why:

```bash
purgeit explain ~/dev/app/node_modules
```

```text
~/dev/app/node_modules
  rule       ✓ node_modules — npm / yarn / pnpm dependencies (safe wherever it appears)
  project    ✓ app (repo, ~/dev/app) · last git activity 5mo ago
  size       ✓ 979.6 MB in 41,230 files · last changed 5mo ago
  protection ✓ nothing marks it as authored
  git        ✓ ignored by git — evidence it is not authored
  synced     ✓ not in a cloud-synced folder
  verdict    ✓ clean would delete it
```

It runs the **same checks `clean` runs**, so the verdict can never disagree with what would happen.

## 3. Review, then apply a plan [#3-review-then-apply-a-plan]

For anything a human should approve, split *finding* from *deleting*:

```bash
purgeit scan ~/dev --format json > plan.json   # delete the entries you want to keep
purgeit clean --plan plan.json
```

A plan only *proposes*. At deletion time every entry is re-checked against the rules, protection and "changed since the scan", so a stale or hand-edited plan cannot delete something that is no longer an artifact.

## The 7-day guard [#the-7-day-guard]

`clean` skips anything with a change inside the last **7 days** (`--min-age`, or `minAge` in config; `0` disables). The interactive UI doesn't apply it by default, because you are choosing each row yourself, but passing `--min-age` there enforces it too.

## When something is skipped [#when-something-is-skipped]

| Reason | Meaning |
| --- | --- |
| `recently-active` | something inside changed within `--min-age` |
| `changed-since-scan` | it changed after the scan (or after the plan was written) |
| `protected` | nested `.git`, a `*-keypair.json`, or git-tracked files |
| `no-longer-matches` | no rule claims it any more (renamed, replaced, or its proof file is gone) |
| `outside-roots` | it resolves outside the folders you scanned (a symlink was involved) |
| `missing` | it was already gone |
| `unverifiable` | something couldn't be read, so it wasn't safe to proceed |

Details and the full list of checks: [Safety model](/docs/concepts/safety-model).

## Audit trail [#audit-trail]

Every deletion and failure is appended to a history file. `purgeit history` shows it, newest first. Dry runs write nothing.