---
title: "CLI"
description: "The qino command, what each subcommand checks, and how to wire it into a build."
canonical: "https://www.qino.works/docs/guide/cli"
---

# CLI

> The qino command, what each subcommand checks, and how to wire it into a build.

`@qino/cms` installs a `qino` binary with three commands. There are no flags.

```txt title="Terminal"
Usage: qino <command>

Commands:
  lint     Validate config, paths, and relations (no content read)
  check    Validate content against schemas and check local media exists
  build    Run lint + check, then generate types, the image manifest, and, if enabled, config.json and the llms.txt files
```

## Discovery

Every command runs from the working directory and expects:

1. A `qino/` folder.
2. `qino/index.ts` that default-exports an `initQino` instance.
3. Definitions exported from any `.ts`, `.tsx`, `.js`, or `.mjs` file under `qino/`, test files aside.

The CLI loads `qino/index.ts`, definitions, and their imports with [jiti](https://github.com/unjs/jiti). TypeScript requires no separate compilation step. See [Project structure](https://www.qino.works/docs/guide/project-structure).

You can reuse your project's import aliases, such as `@/schemas/post`. The CLI reads `compilerOptions.paths` from the nearest `tsconfig.json`, searching upward from the working directory, including paths inherited through `extends`. No qino-specific configuration is needed.

The CLI runs outside your app's bundler. Definitions and shared schemas must not import CSS, images, or Markdown through bundler loaders, including indirectly through other modules.

## qino lint

Reads no content. Checks, in order:

- The entry file exists and default-exports an instance.
- `contentFolder` and `mediaFolder` exist and are directories.
- At least one collection, tree, or item is defined.
- No two primitives own overlapping paths.
- Every primitive and every relation target was created by the same instance.

On success it prints each primitive's path.

Importing definitions never checks path conflicts, so hot reload can recreate definitions freely. Run `lint` or `build` in CI to enforce path ownership.

## qino check

Reads and validates every content file against its schema:

- Collections: every file in the directory.
- Trees: the full walk, including anchor files and `_order.json` consistency.
- Items: the single file.

Views, relation resolution, filter, sort, and augment do not run. Image fields of a primitive's [`media`](https://www.qino.works/docs/concepts/media) are read as getters read them, so an image that's missing or outside `mediaFolder` fails validation. An empty collection or tree logs a warning but does not fail. Validation errors are reported with the primitive and file path.

For primitives with [`media`](https://www.qino.works/docs/concepts/media), `check` then verifies that each media field and body image follows its rules: a file in `mediaFolder`, of an accepted type, under its `maxSize`. See [Checks](https://www.qino.works/docs/concepts/media#checks).

With `cloud` set on [`initQino`](https://www.qino.works/docs/api/init-qino), `check` also verifies that `qino/_generated/config.json` is up to date. See [Config file](#config-file).

### Media

On by default. After schema validation, `check` verifies that every file referenced in content exists in `mediaFolder`. Configure it with `cli.check.localAssetReferences` on [`initQino`](https://www.qino.works/docs/api/init-qino):

```ts title="qino/index.ts"
export default initQino({
  contentFolder: "content",
  mediaFolder: "public",
  cli: {
    check: { localAssetReferences: { exclude: ["/og/**", "/feed.xml"] } },
  },
});
```

Set `cli.check.localAssetReferences` to `false` to skip the check.

`check` scans every `.md`, `.mdx`, `.markdown`, and `.json` file in `contentFolder` and collects root-relative URLs from:

- Markdown images and links: `![Alt](/images/a.png)`, `[Download](/files/b.pdf)`.
- Reference definitions: `[logo]: /images/logo.svg`.
- `src` and `poster` attributes in HTML and MDX: `<video src="/videos/c.mp4" />`, `<Image src={"/images/d.png"} />`. Dynamic values like `src={cover}` are skipped.
- Frontmatter and JSON string values: `cover: /images/e.png`.

The body is parsed as Markdown with GFM (tables, autolinks), plus MDX for `.mdx` files, so code blocks, indented code, and inline code are never scanned. An `.mdx` file that fails to parse fails the check with its path and line.

A URL is a file reference when its last segment has an extension, like `/images/a.png` or `/files/b.pdf`, and it matches no `exclude` glob. It maps to a path inside `mediaFolder`: with `mediaFolder: "public"`, `/images/a.png` must exist at `public/images/a.png`.

Query strings and hashes are stripped, percent-encoded characters like `%20` and `%23` are decoded, and so are HTML character references like `&amp;` in attributes. External URLs, protocol-relative `//` URLs, and relative paths like `./a.png` are ignored. Page links without an extension, like `/blog/post`, are skipped. qino never lists the media folder; files it doesn't reference are left alone. Use `exclude` for files served by routes, such as generated Open Graph images, feeds, or sitemaps.

Every missing file is reported at once:

```txt title="Terminal"
Error: 2 missing media files in "public":
  - content/posts/hello.md:5 → /images/nope.png
  - content/posts/hello.md:9 → /videos/missing.mp4
```

## qino build

Runs `lint`, then `check`, then writes `qino/_generated/types.d.ts`, the [image manifest](#image-manifest), [`config.json`](#config-file) when `cloud` is set, and the [llms.txt files](#llmstxt) when `cli.build.llmsTxt` is on. The types file augments `@qino/cms` with a slug union per collection and tree:

```ts title="qino/_generated/types.d.ts"
// Generated by qino — do not edit. Run `qino build` to regenerate.

export {};

declare module "@qino/cms" {
  export type PostSlug = "hello-world" | "second-post" | (string & {});
  export type DocSlug =
    "introduction" | "guides" | "guides/setup" | (string & {});

  interface QinoSlugRegistry {
    docs: DocSlug;
    posts: PostSlug;
  }
}
```

The write is idempotent: the file is only rewritten when its content changes. Items have no slugs and are skipped. A directory with no entries is omitted so its slug type stays `string`. See [Types](https://www.qino.works/docs/concepts/types).

Set `cli.build.types` to `false` on [`initQino`](https://www.qino.works/docs/api/init-qino) to skip writing the file:

```ts title="qino/index.ts"
export default initQino({
  contentFolder: "content",
  mediaFolder: "public",
  cli: {
    build: { types: false },
  },
});
```

Slug types then fall back to `string`. An existing `types.d.ts` is left in place; delete it to drop its slug unions.

### Image manifest

When a primitive has an [image field](https://www.qino.works/docs/concepts/media#image-fields), `build` also writes `.qino/images.json` inside the content folder. Keyed by URL, it records each image those fields reference: its size and its `QinoImage` data, read when `check` read the entries.

```json title="content/.qino/images.json"
{
  "/images/cover.webp": {
    "size": 48213,
    "width": 1600,
    "height": 900,
    "blurDataURL": "data:image/webp;base64,...",
    "blurWidth": 8,
    "blurHeight": 5
  }
}
```

A server that renders pages on request reads images from it when `mediaFolder` or sharp's native binary didn't ship with it, as on serverless hosts. It ships with the content folder, so [Runtime](https://www.qino.works/docs/guide/installation#runtime) needs no extra step. A `.gitignore` beside it keeps it out of Git: every build writes it again.

### llms.txt

Set `cli.build.llmsTxt` on [`initQino`](https://www.qino.works/docs/api/init-qino), and `build` also writes three files at the root of `mediaFolder`, from the [`llms.txt` template](https://www.qino.works/docs/guide/agent-ready-content#llmstxt):

| File            | Content                                                                                                                     |
| --------------- | --------------------------------------------------------------------------------------------------------------------------- |
| `llms.txt`      | The template, with a section of links for each primitive that declares pages                                                |
| `llms-full.txt` | The template's H1 and summary, then the page Markdown of every entry page, one after another                                |
| `index.md`      | `llms.txt` after a frontmatter block, as the homepage's Markdown. Skipped when a page's Markdown URL is already `/index.md` |

```ts title="qino/index.ts"
export default initQino({
  contentFolder: "content",
  mediaFolder: "public",
  siteUrl: "https://example.com",
  cli: {
    build: { llmsTxt: { template: "agents/llms.md" } },
  },
});
```

The template is `llms.md` in the content folder unless `template` names another file. Its frontmatter is dropped. The sections go before its `## Optional` heading, or at the end when it has none, so optional links stay last, as [llmstxt.org](https://llmstxt.org) expects:

- **Trees** get a section per root node, titled by that node, listing the node and then its descendants in tree order.
- **Collections** get a `## {pages.title}` section, listing the entries the default view keeps, in its order.
- **Items** with a `page` share one `## Pages` section.

Trees come first, then collections, then items, each sorted by directory or file, so every build writes the same file. Each link is `- [title](Markdown URL): description`, without `: description` when there's none:

```md title="public/llms.txt"
# Acme

> Acme is a feature-flag service for JavaScript apps.

## Guide

- [Guide](https://example.com/docs/guide.md): Install Acme and flip a first flag.
- [Installation](https://example.com/docs/guide/installation.md): Add Acme to a project.

## Blog

- [Hello](https://example.com/blog/hello.md): Announcing Acme.

## Optional

- [Changelog](https://example.com/changelog)
```

`llms-full.txt` holds the same entry pages in the same order, each as its Markdown URL serves it but without its frontmatter block, and items' pages last. A collection or tree with `pages.llmsFull: false` stays out of it.

`index.md` opens with a frontmatter block: the template's H1 as `title`, its summary on one line as `description`, with site-relative links made absolute, and `siteUrl` as `canonical`. A template without an H1 gives no block:

```md title="public/index.md"
---
title: "Acme"
description: "Acme is a feature-flag service for JavaScript apps."
canonical: "https://example.com/"
---

# Acme

> Acme is a feature-flag service for JavaScript apps.
```

The files are written only when their content changes, in CI too. Every build writes them again, so keep them out of Git. `build` fails when `siteUrl` is missing or the template doesn't exist. See [Errors](https://www.qino.works/docs/api/errors#cli).

### Section llms.txt

On a large site, `llms.txt` can grow past what agents read well. Set `sections: true`, and `build` also writes a section llms.txt for each collection and tree that declares pages, at its index page's path under `mediaFolder`, such as `public/docs/llms.txt`. An agent working in one area then loads only that area's pages:

```ts title="qino/index.ts"
export default initQino({
  contentFolder: "content",
  mediaFolder: "public",
  siteUrl: "https://example.com",
  cli: { build: { llmsTxt: { sections: true } } },
});
```

A section llms.txt is the index page's Markdown without its frontmatter block, so it lists the same pages as the index page's Markdown URL. `llms.txt` links to each one under a single `## Sections` heading, in place of their sections, and keeps items' `## Pages`:

```md title="public/llms.txt"
# Acme

> Acme is a feature-flag service for JavaScript apps.

## Sections

- [Docs](https://example.com/docs/llms.txt)
- [Blog](https://example.com/blog/llms.txt)

## Optional

- [Changelog](https://example.com/changelog)
```

- A collection or tree with nothing to list still gets one, holding its heading alone, as its index page's Markdown URL does.
- `llms-full.txt` doesn't change.
- An index page at `/` fails the build, since its section llms.txt would replace `llms.txt`. So do two collections or trees with the same index page, since they'd write the same file.
- A section llms.txt that `build` no longer writes, after `sections` is turned off or `pages.index` moves, stays until you delete it.

### Config file

Set [`cloud`](https://www.qino.works/docs/guide/cloud) on [`initQino`](https://www.qino.works/docs/api/init-qino), and `build` also writes `qino/_generated/config.json`: a description of your project that the cloud UI reads without running your code. It lists the config, the cloud config, every primitive keyed by its `directory` (collections, trees) or `file` (items), its body format, its schema as [JSON Schema](https://json-schema.org/draft/2020-12), its relations, its [media](https://www.qino.works/docs/concepts/media), and its cloud config:

```json title="qino/_generated/config.json"
{
  "version": 1,
  "config": {
    "contentFolder": "src/content",
    "mediaFolder": "public"
  },
  "cloud": {
    "publish": {
      "mode": "commit_to_default_branch",
      "reviewBeforePublish": false
    }
  },
  "collections": {
    "posts": {
      "directory": "posts",
      "extension": ".md",
      "body": { "format": "markdown" },
      "schema": {
        "$schema": "https://json-schema.org/draft/2020-12/schema",
        "type": "object",
        "properties": {
          "title": { "type": "string" },
          "author": { "type": "string" }
        },
        "required": ["title", "author"]
      },
      "relations": [
        {
          "path": "author",
          "target": { "kind": "collection", "id": "authors" },
          "cardinality": "one"
        }
      ],
      "media": {},
      "cloud": {
        "searchableBy": [],
        "sortableBy": [],
        "hiddenFields": [],
        "media": { "saveFileAs": "{id}/{name}-{hash}" }
      }
    }
  },
  "items": {},
  "trees": {}
}
```

`body` is `{ "format": "markdown" }` for `.md` and `.markdown` entries, `{ "format": "mdx" }` for `.mdx`, and `null` for `.json`. Every primitive lists `displayAs`, its name in the cloud UI, which defaults to its id. Trees also list `titleField`, `orderFileName`, and `displayEntryAs`, which defaults to `"{<titleField>}"`. Collections list `displayEntryAs` when set. Views, augment, filter, and sort are functions and are left out. See [Cloud](https://www.qino.works/docs/guide/cloud#in-configjson) for the `cloud` fields.

The JSON Schema describes the input side of each schema, the shape of the files on disk, before any transform. It comes from the [Standard JSON Schema](https://standardschema.dev/json-schema) interface, so `cloud` only works with validators that implement it, a subset of Standard Schema validators. Zod 4.2+ and ArkType schemas implement it as is. Others, like Valibot, need their schema wrapped with an adapter. See [the list of implementations](https://standardschema.dev/json-schema). `build` fails when a schema can't be converted, for example when its validator doesn't implement the interface or a field like `z.date()` has no JSON representation.

Relation paths and `titleField` must name fields of that input and pass through the schema unchanged. `build` fails when one of them isn't a field of the input, for example because a transform renames it. `build` and `check` also compare every entry's values on disk with its validated values, and fail when a transform maps another field onto a relation field or the title field, or changes its value, since the file couldn't point to the field on disk.

The comparison runs against existing content, so it can't prove what arbitrary transform code does. A remap passes when a primitive has no entries yet, when the values happen to be equal, or when the transform only remaps under some condition, like `author: post.useRef ? post.authorRef : post.author`. Keep relation fields and `titleField` unchanged by transforms. Every relation target must also be exported from a file under `qino/`, so it's described in the file too.

Commit the file. It's sorted and pretty-printed, so it diffs cleanly, and like `types.d.ts` it's only rewritten when its content changes. Keep the rest of `_generated/` ignored:

```txt title=".gitignore"
qino/_generated/*
!qino/_generated/config.json
```

Exclude `qino/_generated/` from formatters like Prettier or Biome: reformatting `config.json` makes it differ from what `build` writes.

`qino check` fails when the committed file is missing or differs from what `build` would write. So does `build` in CI: when the `CI` environment variable is set, as GitHub Actions, Vercel, and most CI providers do, `build` checks the file instead of rewriting it. A schema change that wasn't rebuilt and committed then fails the CI run or the deploy, rather than going unnoticed. Outside CI, `build` rewrites the file. Set `CI=false` for a CI command that should rewrite it, for example one that commits it back.

## Exit codes

| Code | When                                            |
| ---- | ----------------------------------------------- |
| `0`  | Success                                         |
| `1`  | Unknown or missing command, or any thrown error |

Errors are printed as `Error: <message>`. The messages are listed in [Errors](https://www.qino.works/docs/api/errors).

## Wiring it in

Run `build` before the app builds:

```json title="package.json"
{
  "scripts": {
    "prebuild": "qino build",
    "build": "next build"
  }
}
```

With `cloud` set, this also checks `config.json` in CI and on deploys, with no extra step. See [Config file](#config-file).

In a monorepo, run it in the package that owns `qino/`, since discovery is relative to the working directory. With Turborepo, add `CI` to the build task's [`env`](https://turborepo.dev/docs/reference/configuration#env). Otherwise a build cached outside CI, where it rewrote `config.json`, can be restored in CI and skip the check.
