ToonUI
API Reference

Prompt API

Reference for ToonUI prompt generation in @toon-ui/core.

Prompt generation belongs to @toon-ui/core.

The recommended API is createToonProtocol because it creates the active catalog, rules, and final prompt together.

import { createToonProtocol } from '@toon-ui/core';

const toon = createToonProtocol({
  components: ['text', 'card', 'form', 'field', 'button'],
});

const system = [toon.prompt, appInstructions].join('\n\n');

Lower-level helpers

HelperPurpose
createRules(catalog)create compact rule lists from an active catalog
createPrompt(rules, catalog)build the full prompt
createComponentPrompt(rules)list enabled components and variants
createCatalogOverviewPrompt(catalog)grouped component summaries
createCatalogCoveragePrompt(catalog)checklist for enabled components
createSyntaxPrompt(catalog)syntax rules for enabled components
createFallbackPrompt()model fallback policy
createSafetyPrompt()hard safety rules
createCompositionPrompt()layout/composition guidance
createFormBestPracticesPrompt()form generation guidance
createDecisionPrompt()when to use ToonUI instead of prose
createSelfCheckPrompt()final syntax self-check
createExamplesPrompt(catalog)valid/invalid examples

Custom composition

Use this only if you understand the tradeoff:

import { createPrompt, createRules, createToonCatalog } from '@toon-ui/core';

const catalog = createToonCatalog({
  components: ['text', 'button'],
});
const rules = createRules(catalog);

const system = [
  createPrompt(rules, catalog),
  'Extra app-specific instructions.',
].join('\n\n');

Most apps should use createToonProtocol instead.

On this page