New to Claude Skills? Learn how to install them →

vercel-labs on GitHub

YAML for JSON Render

OfficialFree

Streamline YAML processing with advanced editing capabilities.

Get this skill

Free · Opens the source repo

What YAML for JSON Render does

The @json-render/yaml skill provides a robust solution for working with YAML data formats in conjunction with JSON rendering. This skill is particularly useful for developers and designers who require a seamless way to manage YAML-based specifications, especially when dealing with streaming data. By utilizing a streaming parser, users can incrementally parse YAML and emit JSON Patch operations, allowing for efficient updates and modifications to data structures. This is especially beneficial in scenarios where real-time data processing is essential.

One of the key features of this skill is its support for various edit modes, including patching, merging, and unified diffs. This flexibility enables users to choose the most appropriate method for their specific use case, whether they are making minor adjustments or performing comprehensive updates. The skill also includes a powerful AI SDK transform that can convert YAML fences into JSON-render patches, facilitating integration with AI-driven applications and workflows.

For users looking to generate YAML prompts, the skill offers a straightforward API. Developers can create both standalone and inline prompts, making it easy to incorporate YAML outputs into various applications. The ability to set custom rules and choose edit modes further enhances the versatility of the skill, allowing for tailored interactions based on user needs.

Overall, @json-render/yaml is designed for those who frequently work with YAML in their projects, providing essential tools for parsing, editing, and generating YAML data efficiently. Whether you are developing applications that require dynamic data updates or simply need to manage YAML specifications effectively, this skill offers the necessary capabilities to streamline your workflow.

When to use it

Use this skill when you need to work with YAML specifications in real-time applications or when generating YAML prompts for AI models.

When not to use it

This skill may not be suitable for projects that do not involve YAML data or where JSON is the only required format.

What you can build with it

Real-time Data Processing

Utilize the streaming parser to manage YAML data in applications that require immediate updates.

AI Prompt Generation

Generate YAML prompts for AI models to enhance interaction and data management.

Dynamic YAML Editing

Employ various edit modes to make precise changes to YAML specifications in your projects.

How to install YAML for JSON Render

View source

1. Install with the skills CLI

npx skills add vercel-labs/json-render/yaml --agent claude-code

2. Or install it manually

Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.

Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs

Inside SKILL.md

Written by vercel-labs

@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

Frequently asked questions about YAML for JSON Render

Similar skills