@openuidev/cli
API reference for the OpenUI CLI to scaffold apps and generate system prompts.
A command-line tool for scaffolding OpenUI chat apps and generating system prompts or JSON schemas from library definitions.
Installation
# Run without installing
npx @openuidev/cli@latest <command>
# Or install globally
npm install -g @openuidev/cli
pnpm add -g @openuidev/cli
yarn global add @openuidev/cli
bun add -g @openuidev/cliopenui create
Scaffolds a new Next.js app pre-configured with OpenUI Chat.
openui create [options]Options
| Flag | Description |
|---|---|
-n, --name <string> | Project name (directory to create) |
--skill | Install the OpenUI agent skill for AI coding assistants |
--no-skill | Skip installing the OpenUI agent skill |
--no-interactive | Fail instead of prompting for missing input |
When run interactively (default), the CLI prompts for any missing options. Pass --no-interactive in CI or scripted environments to surface missing required flags as errors instead.
What it does
- Copies the bundled
openui-chatNext.js template into<name>/ - Rewrites
workspace:*dependency versions tolatest - Auto-detects your package manager (npm, pnpm, yarn, bun)
- Installs dependencies
- Optionally installs the OpenUI agent skill for AI coding assistants (e.g. Claude, Cursor, Copilot)
The generated project includes a generate:prompt script that runs openui generate as part of dev and build.
Agent skill
When run interactively, openui create asks whether to install the OpenUI agent skill. The skill teaches AI coding assistants how to build with OpenUI Lang — covering component definitions, system prompts, the Renderer, and debugging.
Pass --skill or --no-skill to skip the prompt. In --no-interactive mode the skill is skipped unless --skill is explicitly passed.
Examples
# Interactive — prompts for project name and skill installation
openui create
# Non-interactive
openui create --name my-app
openui create --no-interactive --name my-app
# Explicitly install or skip the agent skill
openui create --name my-app --skill
openui create --name my-app --no-skillopenui generate
Generates a system prompt or JSON schema from a file that exports a createLibrary() result.
openui generate [entry] [options]Arguments
| Argument | Description |
|---|---|
[entry] | Path to a .ts, .tsx, .js, or .jsx file that exports a Library |
Options
| Flag | Description |
|---|---|
-o, --out <file> | Write output to a file instead of stdout |
--json-schema | Output JSON schema instead of a system prompt |
--export <name> | Name of the export to use (auto-detected by default) |
--prompt-options <name> | Name of the PromptOptions export to use (auto-detected by default) |
--no-interactive | Fail instead of prompting for missing entry |
Examples
# Print system prompt to stdout
openui generate ./src/library.ts
# Write system prompt to a file
openui generate ./src/library.ts --out ./src/generated/system-prompt.txt
# Output JSON schema instead
openui generate ./src/library.ts --json-schema
# Explicit export names
openui generate ./src/library.ts --export myLibrary --prompt-options myOptionsExport auto-detection
The CLI bundles the entry file with esbuild before evaluating it. CSS, SVG, image, and font imports are stubbed automatically.
If --export is not provided, the CLI searches the module's exports in this order:
- An export named
library - The
defaultexport - Any export whose value has both a
.prompt()method and a.toJSONSchema()method
If --prompt-options is not provided, the CLI looks for:
- An export named
promptOptions - An export named
options - Any export whose name ends with
PromptOptions(case-insensitive)
A valid PromptOptions value has at least one of: examples (string array), additionalRules (string array), or preamble (string).
PromptOptions type
interface PromptOptions {
preamble?: string;
additionalRules?: string[];
examples?: string[];
toolExamples?: string[];
editMode?: boolean;
inlineMode?: boolean;
/** Enable Query(), Mutation(), @Run, built-in functions. Default: true if tools provided. */
toolCalls?: boolean;
/** Enable $variables, @Set, @Reset, built-in functions. Default: true if toolCalls. */
bindings?: boolean;
}Built-in functions (@Count, @Filter, @Sort, @Each, etc.) are included in the prompt only when toolCalls or bindings is enabled. For static UI examples without data fetching, they are omitted to keep the prompt focused.
Pass this as a named export alongside your library to customise the generated system prompt without hard-coding it into createLibrary.
// src/library.ts
import { createLibrary } from "@openuidev/react-lang";
import type { PromptOptions } from "@openuidev/react-lang";
export const library = createLibrary({ components: [...] });
export const promptOptions: PromptOptions = {
preamble: "You are a dashboard builder...",
additionalRules: ["Always use compact variants for table cells."],
};openui generate ./src/library.ts --out src/generated/system-prompt.txt