# check

Check a React composition against its artifact without rendering a PDF

Canonical URL: https://docs.asterdoc.com/cli/commands/check/

Checks a `@asterdoc/react` composition against the form artifact whose React
layer it renders — the same tree walk the default PDF path runs — and
reports every fault without producing PDF bytes.

## Usage

```bash
asterdoc check <target> [options]
```

## Arguments

| Argument | Description                                                                              |
| -------- | ---------------------------------------------------------------------------------------- |
| `target` | The composition file (`.tsx`/`.jsx`), or the artifact file that declares its React layer |

## Options

| Option                | Description                                                                       |
| --------------------- | --------------------------------------------------------------------------------- |
| `--layer <key>`       | React layer key to check, when the artifact declares more than one                |
| `--data <pathOrJson>` | Complete valid data: a file path or inline JSON, overriding any discovered sample |
| `--adapter <name>`    | Adapter whose class vocabulary to check against: `takumi` (default) or `chromium` |

## Description

`asterdoc check` resolves `target` to one artifact and one React layer, binds the
layer's module to a component, and walks the rendered tree the way the
default PDF path would — without invoking a PDF engine. It reports three
kinds of fault, independently:

* **Unsupported classes** — a Tailwind class outside the default adapter's
  verified vocabulary. Checking against `--adapter chromium` skips this,
  since a real browser accepts whatever CSS the tree produces.
* **Unresolved field paths** — a `Field`/`Table` path, or a `Signature`
  party role, the artifact does not declare.
* **Missing images** — an image `src` that is not a `data:` URI, which a
  render would need bytes for.

Passing the composition file searches the project for the one artifact whose
React layer resolves to it; passing the artifact file reads its declared
layer directly. If more than one artifact points at the composition, or the
artifact declares more than one React layer, pass `--layer` to pick one.

The check runs through `@asterdoc/react-pdf/check` and loads the composition
with `tsx`. Install them in the project:

```bash
npm install @asterdoc/react @asterdoc/react-pdf react react-dom
npm install -D tsx
```

Without `tsx`, the command stops and prints the install line for your package
manager.

Whichever way the artifact is found, from the target, from a layer that
points at the composition, or as a sibling of the same name, it must carry
the current [schema version](/schemas#loading-rules) in `$schema`, as for
`asterdoc dev`. A missing, outdated, or unknown `$schema` exits 1 and points
to [`asterdoc migrate`](/cli/commands/migrate).

Sample data, when `--data` is not given, is discovered **sibling-first** and may be partial: a
`<composition>.sample.{ts,tsx,js,mjs,jsx}` file next to the composition wins
if present; only when none exists does discovery fall back to a named
`sample` export on the composition module itself. Neither found, the check
still runs with empty data — every `Field`/`Table` path is checked against
the artifact's schema regardless of whether data is present.

Both `check` and `dev` search from the nearest project. Outside one, `check`
starts at the composition directory and `dev` at its `[dir]` argument. Pass the
artifact explicitly when it sits above the composition.

The command exits non-zero when it finds any fault. A composition using
`Totals` over a def checks cleanly with no sample data at all: a value with
no data anywhere in it is not treated as a fault, only a value that carries
real data a serializer still rejects is.

## Examples

Check a composition by its own file:

```bash
asterdoc check ./compositions/purchase-order.tsx
```

Check the artifact directly, naming a layer:

```bash
asterdoc check ./artifacts/purchase-order.json --layer composition
```

Check against the Chromium adapter's rules instead of the default:

```bash
asterdoc check ./compositions/purchase-order.tsx --adapter chromium
```

## See also

* [`add`](/cli/commands/add) — install document components from the
  [Asterdoc component registry](/components)
* [Components](/components) — the component vocabulary the check walks

An artifact argument may be a file path or an installed `@namespace/name` reference from `.asterdoc/lock.json`. An uninstalled reference fails with an error.
