json-render
БесплатноБез исполняемых скриптовНе проверенAI chat response rendering guidance — handling UIMessage parts, tool call displays, streaming states, and structured data presentation. Use when building…
от openai★ 8 494 звезды на GitHubОб этом скилле
AI Chat Response Rendering
You are an expert in rendering AI SDK v6 chat responses — UIMessage parts, tool call results, streaming states, and structured data display in React applications.
The Problem
When building chat interfaces with AI SDK v6, the raw message format includes multiple part types (text, tool calls, reasoning, images). Without proper rendering, responses appear as raw JSON or malformed output.
AI SDK v6 Message Format
In v6, messages use the UIMessage type with a parts array:
interface UIMessage {
id: string
role: 'user' | 'assistant'
parts: UIMessagePart[]
}
// Part types:
// - { type: 'text', text: string }
// - { type: 'tool-<toolName>', toolCallId: string, state: string, input?: unknown, output?: unknown }
// state values: 'partial-call' | 'call' | 'output-available' | 'approval-requested' | 'approval-responded' | 'output-denied'
// - { type: 'reasoning', text: string }
// - { type: 'step-start' } // internal, skip in rendering
Recommended: Use AI Elements
The simplest approach is to use AI Elements, which handles all part types automatically:
import { Message } from '@/components/ai-elements/message'
import { Conversation } from '@/components/ai-elements/conversation'
{messages.map((message) => (
<Message key={message.id} message={message} />
))}
⤳ skill: ai-elements — Full component library for AI interfaces
Manual Rendering Pattern
If you need custom rendering without AI Elements, follow this pattern:
'use client'
import { useChat } from '@ai-sdk/react'
import { DefaultChatTransport } from 'ai'
export function Chat() {
const { messages, sendMessage, status } = useChat({
transport: new DefaultChatTransport({ api: '/api/chat' }),
})
const isLoading = status === 'streaming' || status === 'submitted'
return (
<div>
{messages.map((message) => (
<div key={message.id}>
{message.parts?.map((part, i) => {
// 1. Text parts — render as formatted text
if (part.type === 'text' && part.text.trim()) {
return (
<div key={i} className={
message.role === 'user'
? 'bg-primary text-primary-foreground rounded-lg px-3 py-2'
: 'bg-muted rounded-lg px-3 py-2'
}>
{part.text}
</div>
)
}
// 2. Tool parts — type is "tool-<toolName>"
if (part.type.startsWith('tool-')) {
const toolPart = part as {
type: string
toolCallId: string
state: string
input?: unknown
output?: unknown
}
const toolName = toolPart.type.replace('tool-', '')
if (toolPart.state === 'output-available' && toolPart.output) {
return <ToolResultCard key={i} name={toolName} output={toolPart.output} />
}
if (toolPart.state === 'output-denied') {
return (
<div key={i} className="text-sm text-muted-foreground">
{toolName} was denied
</div>
)
}
if (toolPart.state === 'approval-requested') {
return (
<div key={i} className="text-sm text-yellow-500">
{toolName} requires approval
</div>
)
}
return (
<div key={i} className="text-sm text-muted-foreground animate-pulse">
Running {toolName}...
</div>
)
}
// 3. Reasoning parts
if (part.type === 'reasoning') {
return (
<details key={i} className="text-xs text-muted-foreground">
<summary>Thinking...</summary>
<p className="whitespace-pre-wrap">{(part as { text: string }).text}</p>
</details>
)
}
// 4. Skip unknown types (step-start, etc.)
return null
})}
</div>
))}
</div>
)
}
Rendering Tool Results as Cards
Instead of dumping raw JSON, render structured tool output as human-readable cards:
function ToolResultCard({ name, output }: { name: string; output: unknown }) {
const data = output as Record<string, unknown>
// Pattern: Check for known result shapes and render accordingly
if (data?.success && data?.issue) {
const issue = data.issue as { identifier?: string; title?: string }
return (
<div className="rounded border border-border bg-card p-2 text-sm">
<span className="font-medium text-green-400">
{name === 'createIssue' ? 'Created' : 'Updated'} {issue.identifier}
</span>
<p className="text-muted-foreground">{issue.title}</p>
</div>
)
}
Установить json-render в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл json-render?
AI chat response rendering guidance — handling UIMessage parts, tool call displays, streaming states, and structured data presentation. Use when building custom chat UIs, rendering tool results, or troubleshooting AI response display issues.
Как установить скилл json-render?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл json-render запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic