# CLI reference (/docs/reference/cli)

<Terminal title="purgeit --help">
purgeit [dirs…]            browse and select in the interactive UI (default)
purgeit scan [dirs…]       list projects and artifacts, delete nothing
purgeit clean [dirs…]      delete artifacts
purgeit explain <path>     why a directory is matched, skipped or protected
purgeit rules              list the rules in effect
purgeit history            show what has been deleted
purgeit init               write a starter config
purgeit completion <sh>    shell completions (bash, zsh, fish)
purgeit skill              print the guide for AI agents
</Terminal>

Flags beat the [config file](/docs/reference/configuration). Sizes use binary units (`1KB` = 1024 bytes); durations accept `ms`, `s`, `m`, `h`, `d`, `w`, `y` (and `0`). Output formats are described in [Output formats](/docs/reference/output-formats).

## browse [#browse]

The default command: running `purgeit` with directories (or none) opens this. See the [interactive UI guide](/docs/guides/interactive-ui).

<CliReference command="browse" />

## scan [#scan]

<CliReference command="scan" />

## clean [#clean]

<CliReference command="clean" />

`--min-age` defaults to `7d` for `clean` and doubles as a guard: anything with a change inside that window is skipped at deletion time, whatever the scan said. See [Clean safely](/docs/guides/clean-safely).

## explain [#explain]

Runs the same checks `clean` runs against one directory and reports what it finds — the fastest way to understand a surprising result.

<CliReference command="explain" />

## rules [#rules]

<CliReference command="rules" />

## history [#history]

<CliReference command="history" />

## init [#init]

<CliReference command="init" />

## completion [#completion]

```bash
source <(purgeit completion bash)                                    # ~/.bashrc
source <(purgeit completion zsh)                                     # ~/.zshrc
purgeit completion fish > ~/.config/fish/completions/purgeit.fish
```

<CliReference command="completion" />

## skill [#skill]

<CliReference command="skill" />

## Exit codes [#exit-codes]

| Code | Meaning |
| --- | --- |
| `0` | success |
| `1` | some paths were skipped or failed, or you declined the confirmation |
| `2` | bad arguments, config or plan |
| `70` | internal error |
| `130` | interrupted |

## Environment [#environment]

purgeit honours `NO_COLOR`. History lives in `~/Library/Logs/purgeit/history.jsonl` on macOS, `$XDG_STATE_HOME/purgeit/` (default `~/.local/state/purgeit/`) on Linux and `%LOCALAPPDATA%\purgeit\Log\` on Windows.