# Configuration reference (/docs/reference/configuration)

purgeit uses **the nearest config, searching from the working directory upward**: the first of `purgeit.config.ts`, `.mts`, `.js`, `.mjs`, `.cjs`, `.json`, or the `purgeit` key of a `package.json`. If none is found it uses a user-level `config.*` in `~/.config/purgeit/` (the platform's config directory), then the defaults. The nearest config wins outright — configs are not merged. `--config <file>` names one explicitly, `--no-config` ignores all of them, and `purgeit init` writes a starter. TypeScript configs load directly. Unknown keys and bad values are rejected with the file and the problem named. For recipes see [Custom rules](/docs/guides/custom-rules).

<ConfigReference />

## Rule shapes [#rule-shapes]

```ts
gated:   [{ name: 'out', when: { file: 'project.toml' }, description?: string }]
markers: [{ name: 'MYTOOL.TAG', file: '.mytool-cache', signature: 'mytool-cache-v1' }]
```

`when` is one condition, or a list of which any one suffices:

| Condition | Holds when… |
| --- | --- |
| `{ file: 'package.json' }` | that file sits beside the directory |
| `{ glob: '*.xcodeproj' }` | any sibling matches |
| `{ grep: { file, pattern } }` | that sibling's contents match the regex — only the first megabyte is read; unreadable ⇒ no proof |
| `{ inside: 'pyvenv.cfg' }` | that file exists inside the directory itself |

Names are plain file names, never paths. `file` and `glob` are answered from the directory listing the scanner already has, so they cost nothing.

## Schema [#schema]

The JSON Schema ships with the package as `purgeit/schema.json` and is used for editor completion:

```json
{ "$schema": "https://purgeit.nandan.fyi/schema.json" }
```

The same file ships in the package as `purgeit/schema.json` (`./node_modules/purgeit/schema.json`)