---
title: "CLI"
description: "Scaffold a Next.js backend, ingest knowledge, inspect indexed sources, and run retrieval evaluations."
---

Run the package binary through its package name:

```bash
npx @mordn/chat-widget
```

With no command, or with `init`, the wizard detects `src/app` versus `app` and
creates the catch-all route, auth stub, Drizzle config, and environment template.
Existing files require confirmation before overwrite.

## Scaffold checklist

After generation:

1. Implement `getChatUserId` from a verified server session.
2. Install the provider, database, and optional storage peer dependencies you use.
3. Run `npx drizzle-kit push` for the Drizzle store.
4. Create a private `chat-attachments` bucket when using Supabase storage.
5. Mount `<ChatWidget>` and import the precompiled stylesheet.

## Knowledge commands

Commands load `chat-widget.config.{mjs,js,cjs}`. Override the path with
`--config` or `-c`.

| Command | Purpose |
| --- | --- |
| `init` | Scaffold the backend |
| `ingest [urls...]` | Ingest config sources or ad-hoc URLs |
| `sync` | Re-ingest configured sources idempotently |
| `status` | Show per-source status and chunk counts |
| `list` | List indexed sources |
| `eval --file evals.json` | Run retrieval evaluation cases |

```bash
npx @mordn/chat-widget ingest https://docs.example.com/guide
npx @mordn/chat-widget ingest --llms https://docs.example.com/llms.txt
npx @mordn/chat-widget status -c ./chat-widget.config.mjs
npx @mordn/chat-widget eval --file evals.json
npx @mordn/chat-widget eval -f evals.json --json
```

`--llms` is repeatable. Direct `.md` and `.mdx` URLs use heading-aware Markdown
ingestion. `eval` exits nonzero when any retrieval case fails, so it can gate CI;
`--json` emits machine-readable output.

> **Ingestion is an admin operation**
>
> The CLI uses a write-capable knowledge store. Do not run it through the end-user
> chat request path and never derive namespaces from untrusted request input.

See [Knowledge / RAG](/docs/guides/knowledge) for configuration and source types.
