> For the complete documentation index, see [llms.txt](https://docs.vale.sh/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.vale.sh/topics/filters.md).

# Filters

Learn how to run a subset of the rules a configuration enables.

`--filter` takes an expression over the rules the configuration loaded, and runs only the ones it selects:

```sh
vale --filter='.Level == "error"' docs/
```

A filter narrows a run and never widens it: a rule the configuration did not enable is not there to select. Everything else about the run stays as configured, with one exception. When the expression mentions `.Level`, the minimum alert level drops to include what it selected, so `--filter='.Level == "suggestion"'` shows suggestions even under `MinAlertLevel = warning`.

![Using --filter to limit results to alerts whose scope is a heading.](https://2533404145-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEMH7s0sC5N9L8xSMXGwW%2Fuploads%2Fgit-blob-21a95527c1ac10199ffb8945d5eb778049234875%2Ffilter.svg?alt=media)

## [The expression](#the-expression)

A filter is an [expression](https://expr-lang.org/docs/language-definition), evaluated once per rule against the rule's header. The fields are the ones every rule opens with, capitalized:

| Field          | Type       | Example                                  |
| -------------- | ---------- | ---------------------------------------- |
| `.Name`        | `string`   | `.Name == "Microsoft.Contractions"`      |
| `.Level`       | `string`   | `.Level in ["error", "warning"]`         |
| `.Scope`       | `string[]` | `"heading" in .Scope`                    |
| `.Extends`     | `string`   | `.Extends == "spelling"`                 |
| `.Message`     | `string`   | `.Message contains "instead"`            |
| `.Description` | `string`   | `.Description != ""`                     |
| `.Link`        | `string`   | `.Link startsWith "https://developers."` |

`.Scope` is a list because a rule may name several, so membership is the test. Expressions combine with `and`, `or`, and `not`, and the [operators](https://expr-lang.org/docs/language-definition#operators) include `matches` for a regular expression:

```sh
# Every rule from one style, at any level.
vale --filter='.Name startsWith "Google."' docs/

# Only spelling, and only in headings.
vale --filter='.Extends == "spelling" and "heading" in .Scope' docs/

# Everything except one rule.
vale --filter='.Name != "Vale.Spelling"' docs/
```

## [Saving a filter](#saving-a-filter)

A filter that is typed twice belongs in a file. `--filter` accepts a path, or the name of a file in the `StylesPath`'s `config/filters` directory:

```sh
vale --filter=headings.expr docs/
```

```
# config/filters/headings.expr
"heading" in .Scope
```

The value is tried as a path first, then as a name on the `StylesPath`, and read as an expression only when it is neither, so a file that is not where it was expected is reported as a bad expression rather than silently run as one.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.vale.sh/topics/filters.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
