portable-text-serialization

portable-text-serialization is a skill for Claude Code, Codex from sanity-io/agent-toolkit. It costs 85 tokens per session (1,140 once invoked), scanned A, original, MIT.

A set of instructions for turning Portable Text—a structured format for rich text—into content displayed by React, Svelte, Vue, Astro, HTML, Markdown, or plain text.

In plain words
What is it for?
Use it to display Portable Text in a website or app, create custom renderers for special blocks, or convert the content into HTML, Markdown, or plain text.
Why use it?
It avoids writing separate conversion logic for each frontend framework or output format. It also helps handle custom content blocks, links, lists, and text styling consistently.

Skill for Claude CodeCodex

Part of the sanity plugin — 7 skills, 4 commands, 1 MCP server shipped together

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/sanity-io/agent-toolkit/portable-text-serialization
Any agent
npx skills add sanity-io/agent-toolkit --skill portable-text-serialization
Clone the repo
git clone --depth 1 https://github.com/sanity-io/agent-toolkit

Made for: Claude Code, Codex.

Or install sanity, the plugin that ships this one along with the rest of its 7 skills, 4 commands, 1 MCP server.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for portable-text-serialization

README.md
[![agentmods](https://agentmods.dev/badge/skills/sanity-io/agent-toolkit/portable-text-serialization.svg)](https://agentmods.dev/skills/sanity-io/agent-toolkit/portable-text-serialization)
Your own site
<a href="https://agentmods.dev/skills/sanity-io/agent-toolkit/portable-text-serialization"><img src="https://agentmods.dev/badge/skills/sanity-io/agent-toolkit/portable-text-serialization.svg" alt="Measured on agentmods" height="20"></a>
Per session 85 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,140 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00085 $0.01140
Opus 5 $0.00043 $0.00570
Sonnet 5 $0.00017 $0.00228
Haiku 4.5 $0.00009 $0.00114

Measured 5d ago against content hash 082c107c6e82, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

portable-text-serialization scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 5d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

Origin

Copies of this mod

3 near-identical copies found in the catalogue:

skills/portable-text-serialization/SKILL.md · 112 lines

How it starts

The opening of the file, as written. The whole thing — 112 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Portable Text Serialization

Render Portable Text content across frameworks using the @portabletext/* library family. Each library follows the same component-mapping pattern: you provide a components object that maps PT node types to framework-specific renderers.

Portable Text Structure (Quick Reference)

PT is an array of blocks. Each block has _type, optional style, children (spans), markDefs, listItem, and level.

Root array
├── block (_type: "block")
│   ├── style: "normal" | "h1" | "h2" | "blockquote" | ...
│   ├── children: [span, span, ...]
│   │   └── span: { _type: "span", text: "...", marks: ["strong", "<markDefKey>"] }
│   ├── markDefs: [{ _key, _type: "link", href: "..." }, ...]
│   ├── listItem: "bullet" | "number" (optional)
│   └── level: 1, 2, 3... (optional, for nested lists)
├── custom block (_type: "image" | "code" | any custom type)
└── ...more blocks

Marks come in two forms:

  • Decorators: string values in marks[] like "strong", "em", "underline", "code"
  • Annotations: keys in marks[] referencing entries in markDefs[] (e.g., links, internal references)

Component Mapping Pattern (All Frameworks)

Every @portabletext/* library accepts a components object with these keys:

Key Renders Props/Data
types Custom block/inline types (image, code, CTA) value (the block data)
marks Decorators + annotations children + value (mark data)
block Block styles (h1, normal, blockquote) children
list List wrappers (ul, ol) children
listItem List items children
hardBreak Line breaks within a block

Framework-Specific Rules

Read the rule file matching your framework:

  • React / Next.js: rules/react.md@portabletext/react or next-sanity
  • Svelte / SvelteKit: rules/svelte.md@portabletext/svelte
  • Vue / Nuxt: rules/vue.md@portabletext/vue
  • Astro: rules/astro.mdastro-portabletext
  • HTML (server-side): rules/html.md@portabletext/to-html
  • Markdown: rules/markdown.md@portabletext/markdown
  • Plain text extraction: rules/plain-text.md@portabletext/toolkit

Read the full file on GitHub · 112 lines

Files

What ships with it

7 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 5d ago First seen · 112 lines · 85 tokens per session scan A 082c107c6e82

Subscribe to this mod's changes

portable-text-serialization is a skill published in the GitHub repository sanity-io/agent-toolkit (181 stars, last pushed today), licensed MIT. It adds 85 tokens to every session and 1,140 once invoked, about $0.0004 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

create-site

Creates a new Power Pages code site (SPA) using React, Angular, Vue, or Astro. Guides through the full process from initial concept to deployed site: requirements discovery, scaffolding, component planning, design, implementation, validation, and deployment. Use when the user wants to create, build, or scaffold a new…

microsoft/power-platform-skills · 73 tokens

ui-development

Build UI pages and extensions for Falcon Foundry apps using React or Vue with the Shoelace design system and Foundry-JS. TRIGGER when user asks to "create a UI page", "build a UI extension", "add a Shoelace component", "call an API from the UI", runs foundry ui pages create or foundry ui run, or needs help with Vite…

CrowdStrike/foundry-skills · 113 tokens

astro-integrations

Use when adding React, Vue, Svelte, Solid, Preact, or another UI framework to an Astro project via @astrojs/ integrations.

fusengine/agents · 34 tokens

ui-ux-pro-max

UI/UX design intelligence. 67 styles, 96 palettes, 57 font pairings, 25 charts, 13 stacks (React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Tailwind, shadcn/ui). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, check UI/UX code. Projects: website, landing…

the-hugin/RSIm · 221 tokens

markstream-nuxt

Integrate markstream-vue into a Nuxt 3 or Nuxt 4 app. Use when Codex needs client-only boundaries, SSR-safe setup, browser-only peer gating, worker-aware initialization, renderer mode selection, or a safe MarkdownRender integration inside pages, components, or Nuxt plugins.

Simon-He95/markstream-vue · 71 tokens

markstream-vue2-cli

Integrate markstream-vue2 into a Vue 2 Vue CLI or Webpack 4 app. Use when Codex needs Webpack 4-friendly setup, CDN worker fallbacks for Mermaid or KaTeX, dist/index.css imports, Vue 2 composition-api shims, or code block choices limited to stream-diffs or plain .

Simon-He95/markstream-vue · 83 tokens