# Contributing (/docs/community/contributing)

```bash
bun install      # dependencies and git hooks
bun run check    # format, oxlint, typecheck, knip, tests + coverage, build, package checks
```

Node.js 22+ and [Bun](https://bun.sh) are needed. `bun run check` is the same gate CI and releases run, and takes seconds.

## Conventions [#conventions]

- Tests use real temporary directories (`test/tree.ts`). Never scan or delete a shared directory (`/tmp`, `$HOME`). Anything that deletes needs old fixtures: `backdate(root)` or `minAge: 0`.
- Assert paths with `rel()`, never literal `/`, and don't hard-code sizes: allocated sizes depend on the filesystem.
- Only `src/tui/` may import `react` or `ink` (oxlint enforces it); `bun run doctor` must stay clean.
- Deletion goes through `clean()` → `inspect()` only. Never weaken a guard to make a test pass.

## Add an ecosystem [#add-an-ecosystem]

1. Create `src/rules/catalog/<name>.ts` exporting `readonly RuleDefinition[]`.
2. Spread it into `RULE_CATALOG` in `catalog/index.ts`.
3. If it is a new category, add it to `RuleCategory`, `CATEGORY_LABELS` and `CATEGORY_ORDER` in `catalog/types.ts`.
4. Run `bun run generate` — the [rules reference](/docs/reference/rules) is generated from the catalog.

Use `safe` only for names that are unambiguous everywhere. Anything generic (`build`, `out`, `bin`) must be `gated` on a manifest.

## Generated files [#generated-files]

`purgeit.schema.json` and `docs/src/generated/*` are generated from the code: run `bun run generate` after changing `src/config/schema.ts`, the CLI's options, or the rule catalog (tests fail if they are stale).

## The docs site [#the-docs-site]

The site lives in `docs/` — a [Fumadocs](https://fumadocs.dev) app on Next.js with its own dependencies.

```bash
cd docs
npm ci
npm run dev
```

## Releasing [#releasing]

Bump `version`, commit, push `main`, then `git tag vX.Y.Z && git push origin vX.Y.Z`. The tag runs the full `check` gate and publishes to npm with trusted publishing and provenance — no tokens involved.