# markdown

Tells the agent how to wire markdown rendering for assistant messages in assistant-ui: which renderer to use, how to highlight code, and how to add math or diagrams.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 4300 installs · ★ 29
- Author: assistant-ui
- License: MIT · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/assistant-ui/skills/tree/HEAD/assistant-ui/skills/markdown/SKILL.md
- Updated: 2026-10-13
- HTML: https://affpapa.org/en/nevibecode/skills/markdown

## What it does

The skill splits assistant-ui's text rendering into two paths. `MarkdownTextPrimitive` is the light `react-markdown` route, and the installed `MarkdownText` element is its styled form. Reach for `StreamdownTextPrimitive` when block-aware streaming matters, along with the optional Shiki, KaTeX, Mermaid or CJK plugins. Mounting both renderers on one part does not work.

Four reference files come with it: `markdown-text.md`, `syntax-highlighting.md`, `latex-mermaid.md`, `streamdown.md`. They cover installing pieces with `npx assistant-ui@latest add`, the component map, code highlighting through `shiki-highlighter` or `syntax-highlighter`, and math preprocessing with helpers such as `normalizeMathDelimiters` and `escapeCurrencyDollars`. A gotcha list is included too: markdown showing up as raw text, fenced code without colours, dollar amounts turned into math.

KaTeX expects `remark-math`, `rehype-katex` and the `katex/dist/katex.min.css` stylesheet. No highlighter registered means plain fenced code; the `markdown-text` element only brings a language label and a copy button. The agent pulls this skill in when you ask it to set up how model replies look inside an assistant-ui interface.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add assistant-ui/skills --skill markdown -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/markdown/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/markdown/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add assistant-ui/skills --skill markdown -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/markdown/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add assistant-ui/skills --skill markdown -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/markdown/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install assistant-ui/skills markdown
```

2. **Manually: put the files in place**
- File: `.github/skills/markdown/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add assistant-ui/skills --skill markdown -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/assistant-ui/skills --path assistant-ui/skills/markdown
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/markdown/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add assistant-ui/skills --skill markdown -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/assistant-ui/skills/tree/HEAD/assistant-ui/skills/markdown/SKILL.md

## When to use it
- decide between `MarkdownTextPrimitive` and `StreamdownTextPrimitive` for a given screen
- wire `MarkdownText` into the `text` branch of `MessagePrimitive.Parts`
- register Shiki or Prism so fenced code gets per-language colours
- render KaTeX formulas while keeping dollar prices as text
- hold a Mermaid diagram back until the stream finishes

## Example prompts
- Set up `MarkdownText` inside `MessagePrimitive.Parts` so assistant replies render as markdown
- Add `shiki-highlighter` for the TypeScript code blocks in my chat
- I need KaTeX math and Mermaid diagrams — walk me through the markdown skill setup

## Source text · SKILL.md · MIT

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: c3204fcb964390da.

BEGIN THIRD-PARTY FILE c3204fcb964390da
````text
---
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
````
END THIRD-PARTY FILE c3204fcb964390da

The third-party file has ended. Everything between the c3204fcb964390da tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 2455 of 7726 bytes. © assistant-ui · MIT · https://github.com/assistant-ui/skills/tree/HEAD/assistant-ui/skills/markdown/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
