Pretext Skill


An AI agent skill that helps developers use @chenglou/pretext — a TypeScript library that predicts line breaks and heights without DOM reflows.
Uses the open Agent Skills standard. Works with Claude Desktop, Claude Cowork, Claude Code, Codex CLI, Cursor, Windsurf, Manus, ChatGPT, and any other compatible tool.
About @chenglou/pretext
Pretext is a TypeScript library by Cheng Lou that predicts line breaks and heights. It segments text and measures it once with CanvasRenderingContext2D.measureText, using ports of each browser's line breaker, then lays it out at any width with arithmetic alone, cheap enough to call on every animation frame.
Key capabilities:
- Know text dimensions before rendering (virtual scrolling, masonry layouts)
- Auto-fit text to a container (find largest font that fits N lines)
- Flow text around obstacles (magazine-style layouts)
- Render rich inline text — mentions, chips, code spans — via the
@chenglou/pretext/rich-inline subpath
- Measure text in canvas/SVG/WebGL
What This Skill Covers
This skill teaches AI agents how to use pretext correctly. Tracks @chenglou/pretext 1.0.0.
- API usage — all 12 core functions plus the 5 in
@chenglou/pretext/rich-inline, with correct argument order and types
- Critical gotchas — the lineHeight-must-be-pixels bug, text-before-font argument order,
layoutNextLine taking the width before the cursor since 1.0 (the old order loops forever), font loading and invalid font strings, handles tied to the version that made them
- Migration — upgrading from 0.0.x to 1.0: checking the installed version, finding old usage, breaking and silent changes
- Accuracy — painting text so the browser wraps it to the same lines, font and language pitfalls, CSS Pretext doesn't model, running outside the browser
- Integration patterns — wrapper modules, auto-fit font size, height estimation, truncation with an ellipsis, virtualized lists, text around obstacles with and without string allocation, rich inline runs with chips, mentions and images, shrink-wrap chat bubbles
- Creative patterns — editorial layouts, balanced/Knuth-Plass paragraphs, streaming AI chat, text on both sides of moving shapes and masks, per-character positions for letters as particles or game pieces, proportional ASCII art, framework-integration idioms (React/Vue/Svelte)
- When NOT to use Pretext — CSS-only solutions, and mixed HTML content Pretext can't size
Installation
Claude.ai (Web)
- Download
pretext-skill.zip
- Click Customize in the sidebar and go to Skills
- Click +, then Create skill
- Choose Upload a skill and upload the zip file
Skills need code execution turned on: Settings → Capabilities on individual plans, or Organization settings → Plugins & skills on Team and Enterprise.
Claude Desktop

— or install manually —
- Click Customize in the sidebar
- Click Browse Plugins
- Go to the Personal tab and click +
- Choose Add marketplace
- Type
yaniv-golan/pretext-skill and click Sync
Claude Code (CLI)
From your terminal:
claude plugin marketplace add https://github.com/yaniv-golan/pretext-skill
claude plugin install pretext@pretext-marketplace
Or from within a Claude Code session:
/plugin marketplace add yaniv-golan/pretext-skill
/plugin install pretext@pretext-marketplace
Cursor
- Open Cursor Settings
- Paste
https://github.com/yaniv-golan/pretext-skill into the Search or Paste Link box
Manus