К основному содержанию
скилл CX Codex

markdown — скилл для Claude Code: рендер markdown в assistant-ui

Готовит агенту точную схему подключения markdown-рендера в assistant-ui: какой компонент выбрать, как подсветить код, вывести формулы и диаграммы.

Установить в Claude Code · Через Skills CLI (Vercel) Все способы и платформы ↓
npx skills add assistant-ui/skills --skill markdown -a claude-code
Открыть на GitHub

Что делает markdown

Скилл ведёт агента по двум путям рендера текста ассистента. MarkdownTextPrimitive — лёгкий вариант на react-markdown, а установленный элемент MarkdownText служит его стилизованной реализацией. StreamdownTextPrimitive берут, когда нужен поблочный стриминг и плагины Shiki, KaTeX, Mermaid или CJK. Два рендера на одну часть сообщения ставить нельзя.

Внутри скилла четыре справочника: markdown-text.md, syntax-highlighting.md, latex-mermaid.md и streamdown.md. В них установка через npx assistant-ui@latest add, карта компонентов, подсветка через shiki-highlighter или syntax-highlighter, препроцессинг формул хелперами вроде normalizeMathDelimiters и escapeCurrencyDollars. Разобран и список типичных промахов: markdown выводится как обычный текст, у блоков кода нет цветов, цены в долларах превращаются в формулу.

Для KaTeX нужны remark-math, rehype-katex и стили katex/dist/katex.min.css. Без подключённого подсветчика код останется серым — элемент markdown-text даёт только метку языка и кнопку копирования. Агент читает этот скилл, когда вы просите настроить отображение ответов модели в интерфейсе assistant-ui.

Какие задачи решает

  • выбрать между MarkdownTextPrimitive и StreamdownTextPrimitive для своей задачи
  • встроить MarkdownText в ветку text компонента MessagePrimitive.Parts
  • подключить Shiki или Prism и раскрасить блоки кода по языку
  • вывести формулы KaTeX и не сломать цены со знаком доллара
  • показать Mermaid-диаграмму только после завершения стрима

Примеры запросов агенту

  • Настрой markdown-рендер ответов ассистента через MarkdownText в MessagePrimitive.Parts
  • Добавь подсветку кода через shiki-highlighter для блоков на TypeScript
  • Нужны формулы KaTeX и Mermaid — подключи их по инструкции скилла markdown

Как установить markdown

1Через Skills CLI (Vercel)

npx skills add assistant-ui/skills --skill markdown -a claude-code

2Вручную: положить файлы

~/.claude/skills/markdown/SKILL.md

Папка скилла целиком; для одного проекта — .claude/skills/markdown/

По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов

Вопросы о markdown

Как установить скилл markdown в Claude Code?

Выполните npx skills add assistant-ui/skills --skill markdown -a claude-code. Файл скилла появится по пути ~/.claude/skills/markdown/SKILL.md.

Что делает скилл markdown?

Он даёт агенту инструкцию по рендеру текста сообщений в assistant-ui: какой из двух рендеров взять, как подключить подсветку кода, формулы и диаграммы, какие ошибки обычно всплывают.

Почему код в сообщениях без цветов?

Элемент markdown-text не содержит подсветчика. Установите и зарегистрируйте shiki-highlighter или syntax-highlighter в карте компонентов.

Исходный текст

SKILL.md · MIT
---
name: markdown
description: "Renders assistant message text as markdown in assistant-ui. Use when wiring MarkdownTextPrimitive or the markdown-text element into MessagePrimitive.Parts, installing Shiki or Prism highlighting, adding KaTeX math or Mermaid diagrams, normalizing model-produced math delimiters, or choosing StreamdownTextPrimitive for block-aware streaming with optional code, math, Mermaid, and CJK plugins. Covers defer and smooth parsing behavior, code block overrides, and stream completion. For the surrounding unstyled message composition use primitives, and for installing or editing a styled renderer use elements."
license: MIT
---

# assistant-ui Markdown

**Always consult [assistant-ui.com/llms.txt](https://www.assistant-ui.com/llms.txt) for the latest API.**

Assistant-ui has two renderers for an assistant text part. `MarkdownTextPrimitive` is the lightweight `react-markdown` path and the installed `MarkdownText` element is its styled implementation. `StreamdownTextPrimitive` is the alternative when block-aware streaming and optional Shiki, KaTeX, Mermaid, or CJK support are worth the larger renderer.

## References

- [./references/markdown-text.md](./references/markdown-text.md) -- install and compose `MarkdownText`, customize `MarkdownTextPrimitive`, and distinguish inline from fenced code
- [./references/syntax-highlighting.md](./references/syntax-highlighting.md) -- install the Shiki or Prism renderer and select one per fenced language
- [./references/latex-mermaid.md](./references/latex-mermaid.md) -- configure KaTeX, normalize model math, preserve code spans, and gate Mermaid on stream completion
- [./references/streamdown.md](./references/streamdown.md) -- use the Streamdown alternative, plugins, Tailwind sources, and deferred parsing

## Choose the renderer

Use `markdown-text` when the app needs a small renderer, a custom `react-markdown` component map, or per-language `SyntaxHighlighter` and `CodeHeader` overrides. Add highlighting, math, and Mermaid only when the message format requires them.

Use `StreamdownTextPrimitive` when a text part needs block-based streaming, incomplete markdown repair, or the optional code, math, Mermaid, and CJK plugins. It replaces the markdown renderer for that text part. Do not mount both renderers for the same part.

## Install and wire MarkdownText

Install the renderer, which lands at `components/assistant-ui/elements/markdown-text.tsx`.

```bash
npx assistant-ui@latest add markdown-text
```

`MarkdownText` reads the active message part itself. Render it only in the `text` branch, while other part kinds keep their own renderers.

```tsx
"use client";

import { MessagePrimitive } from "@assistant-ui/react";
import { MarkdownText } from "@/components/assistant-ui/elements/markdown-text";

export function AssistantMessageText() {
  return (
    <MessagePrimitive.Parts>
      {({ part }) => (part.type === "text" ? <MarkdownText /> : null)}
    </MessagePrimitive.Parts>
  );
}
```

The `thread` element already includes this renderer. Compose it directly only when replacing the thread's message layout.

## Customize the primitive

`MarkdownTextPrimitive` reads the surrounding text part through context, so it receives no text child or value prop. Its `components` map controls normal markdown tags plus `SyntaxHighlighter` and `CodeHeader`; `componentsByLanguage` replaces either slot for one fenced language. See [markdown-text.md](./references/markdown-text.md) for a direct primitive implementation.

`preprocess` runs on the full accumulated text before smoothing and parsing. It is the seam for model-specific delimiter repair. `smooth` defaults to `true`; `defer` defaults to `false`. Set `defer` for large, rapidly growing messages when React should prioritize input and scrolling over intermediate parses. Keep its value constant while the renderer is mounted because toggling it remounts the parsed tree.

## Highlight fenced code

`MarkdownText` displays fenced code as plain code until a `SyntaxHighlighter` is registered. Prefer the runtime-aware Shiki element, which waits for its active part to settle before tokenizing.

```bash
npx assistant-ui@latest add shiki-highlighter
```

```tsx
import { SyntaxHighlighter } from "@/components/assistant-ui/elements/shiki-highlighter.aui";

const defaultComponents = memoizeMarkdownComponents({
  SyntaxHighlighter,
});
```

The Prism-based `syntax-highlighter` element remains useful for apps that already depend on `react-syntax-highlighter`.

```bash
npx assistant-ui@latest add syntax-highlighter
```

```tsx
import { SyntaxHighlighter } from "@/components/assistant-ui/elements/syntax-highlighter";
```

Edit the installed `markdown-text` component's default map, or pass a `components` override where the element is rendered. See [syntax-highlighting.md](./references/syntax-highlighting.md) for the exact renderer contracts.

## Render math and diagrams

KaTeX needs `remark-math`, `rehype-katex`, and the KaTeX stylesheet. The markdown package exports `normalizeMathDelimiters`, `rewriteCustomMathTags`, `rewriteLatexBracketDelimiters`, and `escapeCurrencyDollars` for preprocessing model output. The helpers rewrite outside inline code and fenced code, so examples in code stay literal.

Install `mermaid-diagram` and register its `.aui` renderer as the `mermaid` language override. It reads the message part status and shows a skeleton while the stream is running rather than parsing incomplete Mermaid source. See [latex-mermaid.md](./references/latex-mermaid.md).

## Use Streamdown instead

`StreamdownTextPrimitive` reads the same text-part context and can be wired into the same `MessagePrimitive.Parts` branch. It defaults to `mode="streaming"`, which holds completed blocks stable while the final block grows. Supply optional plugins explicitly, and add Tailwind `@source` entries for Streamdown and each installed plugin so its controls and caret receive styles.

Both `defer` and `smooth` are available here. `defer` defaults to `false` and may skip intermediate states under load while still rendering the final text. `smooth` also defaults to `false`; use Streamdown's native `animated` prop for entrance animation unless a typewriter reveal is specifically wanted. The full setup and migration seams are in [streamdown.md](./references/streamdown.md).

## Common Gotchas

**Markdown renders as plain text**

- Render `MarkdownText` or `StreamdownTextPrimitive` in the `text` branch. Rendering `part.text` directly bypasses markdown parsing.

**Fenced code has no syntax colors**

- `markdown-text` includes a label and copy control, but no highlighter. Install and register `shiki-highlighter` or `syntax-highlighter`.

**Math has unstyled output or prices become math**

- Import `katex/dist/katex.min.css` once for KaTeX. Compose `escapeCurrencyDollars(normalizeMathDelimiters(text))` when messages include both single-dollar math and currency.

**Mermaid redraws while a response streams**

- Use `@/components/assistant-ui/elements/mermaid-diagram.aui` in `componentsByLanguage`. Its runtime wrapper holds parsing until the message part completes.

**Deferred parsing causes a visual reset**

- Do not toggle `defer` after mount. Both primitives select a different deferred renderer path when that prop changes.

**Streamdown controls or caret look unstyled**

- Add the required Tailwind `@source` directives for `streamdown` and every installed `@streamdown/*` plugin.

## Related Skills

- [primitives](../primitives/SKILL.md) -- compose `MessagePrimitive.Parts` and the surrounding message UI
- [elements](../elements/SKILL.md) -- install and customize the copied `markdown-text`, highlighter, and Mermaid element sources

© assistant-ui · MIT · assistant-ui/skills

Похожие скиллы

Всё по теме «Фронтенд и UI» →
frontend-design официальный anthropics Скилл задаёт осмысленное визуальное направление для новых интерфейсов и редизайна. Подойдёт, когда стандартный шаблонный UI не устраивает. 1 025 790установок design-taste-frontend Leonxlnx Скилл задаёт арт-дирекцию для публичных страниц и рабочих экранов, а затем проверяет результат в браузере по скриншотам. Нужен, когда интерфейс выглядит шаблонным или недоработанным. CX Codex +1 678 700установок prototype Matt Pocock Создаёт временный прототип, чтобы проверить логику, модель состояния или вид интерфейса до работы над основным кодом. 986 201установок hyperframes heygen-com Скилл задаёт агенту правила рендера HTML-кода в видео через HyperFrames. Помогает собирать проморолики, эксплейнеры и титры прямо в коде проекта. CX Codex +1 1 200 000установок hyperframes-cli heygen-com Управляет проектами HyperFrames через терминал: собирает таймлайн, проверяет контраст кадров, запускает предпросмотр и рендерит видео локально или в облаке. CX Codex +1 1 300 000установок webapp-testing официальный anthropics Скилл запускает проверки локальных веб-приложений через Playwright: помогает отлаживать UI, делать скриншоты и смотреть логи браузера. 186 758установок

Из того же набора16

setup Скилл помогает создать проект assistant-ui, подключить его к существующему приложению и выбрать адаптер для бэкенда. Пригодится и для обновления установки. CX Codex +1 6 100установок thread-list Скилл для assistant-ui: добавляет боковую панель с несколькими диалогами, переключением, переименованием, архивацией и удалением. CX Codex +1 6 200установок update Обновляет существующее приложение на assistant-ui до актуальных версий AI SDK v7 и assistant-ui 0.15.x, применяя нужные миграции. Пригодится, когда после апдейта посыпались ошибки типов или пропали хуки. CX Codex +1 5 900установок cloud Подключает AssistantCloud к приложению на assistant-ui: история тредов между сессиями, обратная связь по сообщениям и загрузка файлов. CX Codex +1 5 000установок react-mcp Скилл для работы с @assistant-ui/react-mcp: подключает MCP-серверы, выбранные пользователем, прямо в браузере и регистрирует их инструменты в чате. CX Codex +1 4 000установок observability Подключает Langfuse, LangSmith или Helicone к бэкенд-роутам assistant-ui на AI SDK и рисует собранные спаны через экспериментальный @assistant-ui/react-o11y. CX Codex +1 4 000установок copilots Скилл для assistant-ui: учит агента читать состояние страницы, кликать по компонентам и менять их состояние через хуки React. CX Codex +1 3 900установок elements Помогает добавлять и настраивать компоненты assistant-ui в проект. Подходит для сборки готовых интерфейсов чатов, карточек рассуждений и планов агентов. CX Codex +1 1 100установок

Спонсоры проекта

Компании, которые помогают держать аналитику открытой