# Using purgeit with AI agents (/docs/guides/ai-agents)

purgeit is designed to be driven by an agent: every command has structured output, deletions are re-verified, and guidance ships with the CLI.

## Get the guide [#get-the-guide]

```bash
purgeit skill
```

Prints a guide **versioned with the installed CLI**, so it always matches the commands that exist. The package also ships a `SKILL.md` stub for agent-skill installers.

This site is agent-friendly too:

- Append `.md` to any docs URL, or send `Accept: text/markdown`, to get the page as Markdown.
- [`/llms.txt`](/llms.txt) lists every page; [`/llms-full.txt`](/llms-full.txt) is the whole site in one file.

## The workflow an agent should follow [#the-workflow-an-agent-should-follow]

<Steps>
<Step>
**Look first.** `purgeit scan <dirs> --format json` lists candidates and deletes nothing. The report has a `projects[]` rollup (dormant projects first) as well as every entry. Narrow with `--stale`, `--min-size`, `--min-age`, `--only`.
</Step>

<Step>
**Show the user** the projects and the total — not hundreds of paths. Entries with a non-null `protection` are never deleted; `purgeit explain <path> --format json` tells you why anything is matched, skipped or protected.
</Step>

<Step>
**Delete only what was approved.** Trim the report to the approved entries and run `purgeit clean --plan plan.json --yes`. Use `--dry-run` to preview.
</Step>
</Steps>

<Callout type="warn" title="Keep the 7-day guard">
Don't lower `--min-age` below its default (`7d`) unless the user asks. It is the guard against deleting something a person is working on.
</Callout>

## Why this is safe to hand to an agent [#why-this-is-safe-to-hand-to-an-agent]

- Every path is **re-verified at deletion time** against the rules, git, deploy keys and recent activity, so a stale or edited plan cannot delete the wrong thing. See the [safety model](/docs/concepts/safety-model).
- Nothing is deleted without `--yes` (or an interactive confirmation), and without a terminal `clean` refuses to guess.
- Output is stable JSON with documented [exit codes](/docs/guides/automation#exit-codes) and [formats](/docs/reference/output-formats). With `--format json`, even **errors** are JSON on stdout (`{"error":{"code","message"}}`), so a parser never has to scrape stderr.
- Everything deleted is recorded: `purgeit history --format json`.

## Other useful commands [#other-useful-commands]

| Command | Use |
| --- | --- |
| `purgeit rules --format json` | What is matched, and the proof gated rules need |
| `purgeit history --format json` | What has been deleted |
| `purgeit scan --format ndjson` | Stream results as they are measured |
| `purgeit explain <path> --format json` | Why a directory is matched, skipped or protected, and what `clean` would do |