Skip to content
cccskills
FreePublished on GitHub

yaml

Helps integrate YAML output into json-render, turning incoming text into incremental UI updates. Covers prompt generation, streaming parsing, and targeted edits to existing UI specifications through merge, patch, or diff formats.

OriginalShow the original description

YAML wire format for json-render with streaming parser, prompt generation, and AI SDK transform. Use when working with @json-render/yaml, YAML-based spec streaming, yaml-spec/yaml-edit fences, or YAML prompt generation.

See how to install

Good for

  • Render UI updates as YAML arrives
  • Generate prompts for YAML output
  • Apply partial edits to existing UI specifications
  • Connect YAML streams to the AI SDK

Files included (1)

  • SKILL.md4.5 KB

SKILL.md (original)

Review the instructions the agent will receive before you install.

@json-render/yaml

YAML wire format for @json-render/core. Progressive rendering and surgical edits via streaming YAML.

Key Concepts

  • YAML wire format: Alternative to JSONL that uses code fences (yaml-spec, yaml-edit, yaml-patch, diff)
  • Streaming parser: Incrementally parses YAML, emits JSON Patch operations via diffing
  • Edit modes: Patch (RFC 6902), merge (RFC 7396), and unified diff
  • AI SDK transform: TransformStream that converts YAML fences into json-render patches

Generating YAML Prompts

import { yamlPrompt } from "@json-render/yaml";
import { catalog } from "./catalog";

// Standalone mode (LLM outputs only YAML)
const systemPrompt = yamlPrompt(catalog, {
  mode: "standalone",
  editModes: ["merge"],
  customRules: ["Always use dark theme"],
});

// Inline mode (LLM responds conversationally, wraps YAML in fences)
const chatPrompt = yamlPrompt(catalog, { mode: "inline" });

Options:

  • system (string) — Custom system message intro
  • mode ("standalone" | "inline") — Output mode, default "standalone"
  • customRules (string[]) — Additional rules appended to prompt
  • editModes (EditMode[]) — Edit modes to document, default ["merge"]

AI SDK Transform

Use pipeYamlRender as a drop-in replacement for pipeJsonRender:

import { pipeYamlRender } from "@json-render/yaml";
import { createUIMessageStream, createUIMessageStreamResponse } from "ai";

const stream = createUIMessageStream({
  execute: async ({ writer }) => {
    writer.merge(pipeYamlRender(result.toUIMessageStream()));
  },
});
return createUIMessageStreamResponse({ stream });

For multi-turn edits, pass the previous spec:

pipeYamlRender(result.toUIMessageStream(), {
  previousSpec: currentSpec,
});

The transform recognizes four fence types:

  • yaml-spec — Full spec, parsed progressively line-by-line
  • yaml-edit — Partial YAML deep-merged with current spec (RFC 7396)
  • yaml-patch — RFC 6902 JSON Patch lines
  • diff — Unified diff applied to serialized spec

Streaming Parser (Low-Level)

import { createYamlStreamCompiler } from "@json-render/yaml";

const compiler = createYamlStreamCompiler<Spec>();

// Feed chunks as they arrive from any source
const { result, newPatches } = compiler.push("root: main\n");
compiler.push("elements:\n  main:\n    type: Card\n");

// Flush remaining data at end of stream
const { result: final } = compiler.flush();

// Reset for next stream (optionally with initial state)
compiler.reset({ root: "main", elements: {} });

Methods: push(chunk), flush(), getResult(), getPatches(), reset(initial?)

Edit Modes (from @json-render/core)

The YAML package uses the universal edit mode system from core:

import { buildEditInstructions, buildEditUserPrompt } from "@json-render/core";
import type { EditMode } from "@json-render/core";

// Generate edit instructions for YAML format
const instructions = buildEditInstructions({ modes: ["merge", "patch"] }, "yaml");

// Build user prompt with current spec context
const userPrompt = buildEditUserPrompt({
  prompt: "Change the title to Dashboard",
  currentSpec: spec,
  config: { modes: ["merge"] },
  format: "yaml",
  serializer: (s) => yamlStringify(s, { indent: 2 }).trimEnd(),
});

Fence Constants

For custom parsing, use the exported constants:

import {
  YAML_SPEC_FENCE,   // "```yaml-spec"
  YAML_EDIT_FENCE,   // "```yaml-edit"
  YAML_PATCH_FENCE,  // "```yaml-patch"
  DIFF_FENCE,        // "```diff"
  FENCE_CLOSE,       // "```"
} from "@json-render/yaml";

Key Exports

ExportDescription
yamlPromptGenerate YAML system prompt from catalog
createYamlTransformAI SDK TransformStream for YAML fences
pipeYamlRenderConvenience pipe wrapper (replaces pipeJsonRender)
createYamlStreamCompilerStreaming YAML parser with patch emission
YAML_SPEC_FENCEFence constant for yaml-spec
YAML_EDIT_FENCEFence constant for yaml-edit
YAML_PATCH_FENCEFence constant for yaml-patch
DIFF_FENCEFence constant for diff
FENCE_CLOSEFence close constant
diffToPatchesRe-export: object diff to JSON Patch
deepMergeSpecRe-export: RFC 7396 deep merge

Reviews

No reviews yet. Tell others what you thought.

Comments

No login needed. Share how it worked for you, ask a question, or note where it did not run.

No comments yet. Be the first to write one.

Comments are published right away. Do not include personal information such as email addresses or phone numbers. Up to 2 URLs.

0 / 1,000 characters

This form is protected by reCAPTCHA, and the Google Privacy Policy and Terms of Service apply.

More skills from this repository

codegen

FreeSummary

Helps build custom code exporters from json-render UI specifications. Covers walking the UI tree, collecting components, state references, and actions, and formatting property values for JSX, the markup syntax used in React.

  • Build a custom exporter for Next.js or Remix
  • List components and actions used in a UI specification
  • Convert property values into JSX attributes
vercel-labs/json-render18.7KUpdated Oct 14, 2026

core

FreeSummary

Define the structure and available components for AI-generated JSON screens or videos. Build generation prompts, process incremental updates, connect values to application state, and validate or repair definitions before passing them to a renderer.

  • Define allowed components for AI-generated screens
  • Build prompts for generating or editing JSON definitions
  • Assemble definitions from streamed AI responses
vercel-labs/json-render18.7KUpdated Oct 14, 2026

devtools

FreeSummary

Debug json-render interfaces with an inspector panel that shows screen specifications, editable runtime state, action history, and streamed updates. Select a rendered page element to locate its definition and investigate display or interaction problems.

  • Investigate missing or incorrectly displayed elements
  • Inspect and edit application state at runtime
  • Review action results and errors
vercel-labs/json-render18.7KUpdated Oct 14, 2026

devtools-react

FreeSummary

Set up an inspection panel in React json-render apps to examine UI definitions, edit state, and review action and stream timelines. The skill also covers opening or toggling the panel and recording events from React code.

  • Adding an inspection panel to a React app
  • Inspecting UI definitions, state, and action history
  • Opening or toggling the panel from React code
vercel-labs/json-render18.7KUpdated Oct 14, 2026

devtools-solid

FreeSummary

Add and troubleshoot the json-render inspection panel in SolidJS applications. This skill covers panel setup for examining specifications, editing state, reviewing action and stream timelines, browsing component catalogs, and selecting page elements for inspection.

  • Add an inspection panel to a SolidJS app
  • Inspect JSON specifications and edit application state
  • Review action and stream timelines
vercel-labs/json-render18.7KUpdated Oct 14, 2026

devtools-svelte

FreeSummary

Add and troubleshoot a developer panel in Svelte 5 json-render apps. Inspect JSON screen definitions, edit application state, review action and streaming timelines, browse component catalogs, and select elements directly from the page.

  • Add a developer panel to a Svelte app
  • Inspect screen definitions and edit application state
  • Review action and streaming timelines
vercel-labs/json-render18.7KUpdated Oct 14, 2026

See all skills by vercel-labs

Report a problem with this skill