# Scanning

Include or exclude source files and specific class names.

- ID: directives/scanning
- Type: directive
- Canonical: /reference/directives/scanning
- Version: 2.1.8
- Source revision: 09fc2350ea80ed137ba7ca62c8e5926744b5a5dc (revision)
- Source: site/content/guide/directives/contract.mdx
- Content digest: 144443591a1c6e1de134fd0838e6277f3b99533ed468329d6845c063ef716669
- Semantic digest: 83962260d6d56817dd052d2beebf7999a75804215dac050c47b26353145c099a
- Language: en

<a id="source-boundaries"></a>

File policy chooses where to read candidates; candidate policy chooses which complete class strings remain eligible. These directives do not change the parser or turn arbitrary source text into valid utilities. See [Scanning class names](/guide/scanning-and-pruning) for configuration and troubleshooting, and [Extraction](/reference/rules/extraction) for supported source syntax and lifecycle.

**File selection and candidate selection are different filters**

Excluding draft.html stops its flex candidate from entering this source scope. Blocklisting hidden removes a candidate after collection; safelisting block adds an explicit candidate.

- @source includes the HTML files, and @source not excludes draft.html. Only main.html contributes its grid and hidden class strings.
- @safelist "block" adds a complete candidate independently of a source file.
- @blocklist "hidden" removes that candidate. The resulting eligible set is grid and block; flex never entered this scope.
- File and candidate policies are distinct. Eligibility is not proof that an arbitrary class string is valid; normal matching and diagnostics still apply.

<a id="source"></a>

## `@source`

Ordinary application sources use the integrations' and CLI's default discovery. Add explicit exceptions when needed:

```css
@source "../content/**/*.mdx";
```

<a id="source-not"></a>

## `@source not`

Exclude matching files from the source set:

```css
@source not "../content/drafts/**";
```

Brace groups such as `{a,b}` expand to separate patterns; one pattern may contain at most 64 brace groups and expand to at most 1,024 patterns.

Includes are combined as a union, then all excludes are subtracted. Every relative pattern resolves from the stylesheet that declares it, including bare `src/**`, `./src/**`, imported files, and `@source not`. A reference does not contribute scanning sources.

File-resolving APIs require a declaring file or explicit base file. Source-only directive inspection can return unresolved metadata; it must not invent a filesystem base. The scanner's programmatic `cwd` option retains its existing meaning for scanner options supplied directly through that API.

<a id="candidate-policy"></a>

<a id="safelist"></a>

## `@safelist`

Add complete class candidates that cannot appear literally in scanned source:

```css
@safelist "(opacity:1)";
@safelist "bg-blue-60@dark";
```

Candidates use the same matching and diagnostic policy as discovered classes. Keep dynamic alternatives bounded and explicit.

To retain named animation definitions without generating a class or animation declaration, use the explicit keyframe target:

```css
@safelist keyframes "fade" "pop";
```

Each quoted string is one complete CSS animation name. Names are case-sensitive and support CSS escapes; a space inside a string is part of its name. There is no wildcard expansion or class splitting. Missing names, unquoted names, commas and nested safelist directives are errors. A name absent from the complete import/reference graph produces a warning. Safelists merge within each entry's graph and are withdrawn when their source or directive is removed. `@reference` does not import safelist roots. There is no keyframe blocklist or separate keyframe prune/preserve target.

<a id="blocklist"></a>

## `@blocklist`

Remove unwanted complete candidates with exact strings or `*` and `?` wildcard patterns:

```css
@blocklist "debug-*";
@blocklist "example-token";
```

The stylesheet grammar does not interpret slash-delimited patterns as regular expressions. Wildcard policy belongs in the blocklist; a safelist supplies complete classes.

## Related reference

- [rules/declarations](/reference/rules/declarations.md)
- [rules/conditions](/reference/rules/conditions.md)
