# visualci.yml

> Keep VisualCI's settings in your repository. Ignore rules scoped to snapshot globs, thresholds, PDF rendering, the CI mode and what to upload, sent with every build.

Source: https://visualci.com/docs/reference/config/
All of VisualCI's documentation: https://visualci.com/llms.txt

`visualci.yml` at the root of your repository holds the project's settings in code. `visualci build create` finds it, checks it and sends it with the build. Each build uses its own commit's file, so a change to it in a pull request applies to that pull request's builds, and reaches the default branch when the pull request merges.

```yaml
# yaml-language-server: $schema=https://visualci.com/visualci.schema.json
project: acme/web
ignore:
  - snapshots: "api/invoices/**"
    json_paths: ["$.generated_at", "$.items[*].id"]
  - snapshots: "api/**/request_log.json"
    json_paths: ["$..request_id"]
  - snapshots: "emails/*.html"
    text_patterns: ['Sent \d{4}-\d{2}-\d{2}']
threshold:
  "screenshots/**": 0.1
  "pdfs/**": 0
pdf:
  engine: pdfbox
  dpi: 140
ci_mode: review
uploads:
  - path: spec/artifacts
  - path: src
    from: auto
```

The CLI looks for `visualci.yml`, `.visualci.yml`, `visualci.yaml` or `.visualci.yaml`, from the working directory up to the repository's root. `VISUALCI_CONFIG` names a file somewhere else. An invalid file stops `build create` with the error, so a build never runs with settings you didn't mean.

## Where settings come from

- A field in the file wins for that build.
- A field the file leaves out comes from the project's **Settings** tab (or `update_project` over MCP).
- A setting on one snapshot (`--threshold`, `--engine`, a test's `ignore`) wins over both.

The build's page shows the file it was sent, and `get_build` returns it as `config`. A text snapshot's page lists the ignore rules applied to it and where each came from.

## Fields

| Field | What it does |
| --- | --- |
| `project` | `organization/project`. The token decides the project; the CLI warns when this names a different one. |
| `ignore` | Values in text snapshots that change on every run. A list of rules; see below. When the file has `ignore`, the project's own rules aren't used. |
| `threshold` | 0 compares exactly; above 0 it's a colour threshold. One number for every snapshot, or a map of snapshot globs to thresholds. When several globs match, the longest glob (by its length in characters) wins. |
| `pdf.engine` | `pdfbox` or `mutool`. |
| `pdf.dpi` | Render resolution, 36 to 600. |
| `ci_mode` | `review`, `wait` or `strict`. The file can only make the project's mode stricter (in that order); a looser value is ignored, with a warning on the build. See [GitLab CI](https://visualci.com/docs/ci/gitlab.md#reviewing-without-a-github-check). |
| `uploads` | What a bare `visualci upload` sends: a list of `path` (relative to the file), with optional `from` (`jest`, `vitest`, `insta`, `syrupy`, `rspec` or `auto`), `prefix` and `format`. |

Unknown fields are errors, so a misspelt field doesn't pass unnoticed.

## Ignore rules

Each rule names the snapshots it applies to with `snapshots`, a glob over snapshot names as VisualCI shows them. Those names leave out the directory you uploaded: `visualci upload api` (or `uploads: [{path: api}]`) sends `api/invoices/show.json` as `invoices/show`, so its rule is `snapshots: "invoices/**"`, not `"api/invoices/**"`. `visualci config check` warns about a rule that matches none of the files under `uploads`, and a build lists any rule that matched none of its snapshots. There are no global rules: a rule without `snapshots` is an error. Use `"**"` when a rule really is for every snapshot.

- `*` matches within one segment of the name and `**` across segments: `api/*/log.json` matches `api/users/log.json`, and `api/**` matches everything under `api/`.
- `json_paths` replace values in JSON snapshots: `$.generated_at`, `$.items[*].id`, `$..request_id` (that key at any depth), `$["odd key"]`.
- `text_patterns` are regular expressions, matched in every text format after normalizing.

Matching values become `[ignored]` on both sides before comparing. A new rule takes effect on the next build, without approving the baseline again.

Rules can also be set next to the assertion, for one snapshot only. The [Ruby helpers](https://visualci.com/docs/screenshots.md#ruby-and-rspec) take `ignore:`, and an upload manifest entry takes `"ignore": {"json_paths": [...], "text_patterns": [...]}`.

## Changes to the file are reviewed

The file can change what counts as a change, so a pull request can't use it to let changes through unseen. When a build's ignore rules or thresholds could hide something its base build's would show (a new or wider rule, a higher threshold), the build gets a `visualci.yml` item next to its snapshots. It shows the rules and thresholds before and after, and it has to be approved like any other change. Removing rules or lowering a threshold needs no review.

## Checking the file

```sh
visualci config check   # exits 1 and prints the problem when the file is invalid
visualci config schema  # prints the JSON Schema
```

The schema is also at [visualci.com/visualci.schema.json](https://visualci.com/visualci.schema.json). Editors with the YAML language server validate the file and complete its fields when it starts with the `# yaml-language-server` comment above.
