pretext
What it does
It helps build creative browser demos where text is the main visual element, such as paragraphs that flow around a moving sprite. It is for developers and designers who want unusual, eye-catching web effects.
When to use it
- βWhen you want text to flow around a moving shape or animated element.
- βWhen you want a game or ASCII-style effect built from real words.
- βWhen you want kinetic typography that breaks text into particles.
Skill link
https://github.com/NousResearch/hermes-agent/blob/main/optional-skills/creative/pretext/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agentβs skills folder.
Example of what to ask your AI
βMake a browser demo where a paragraph reflows around a ball bouncing across the page.β
5 new skills a week. 1 minute to read.
How it works
The agent uses the pretext library to measure and lay out text without the browser's usual layout step, so positions can update quickly on each frame. It then builds the visual effect around that layout.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
Pretext Creative Demos
Overview
@chenglou/pretext is a 15KB zero-dependency TypeScript library by Cheng Lou (React core, ReasonML, Midjourney) for DOM-free multiline text measurement and layout. It does one thing: given (text, font, width), return the line breaks, per-line widths, per-grapheme positions, and total height β all via canvas measurement, no reflow.
That sounds like plumbing. It is not. Because it is fast and geometric, it is a creative primitive: you can reflow paragraphs around a moving sprite at 60fps, build games whose level geometry is made of real words, drive ASCII logos through prose, shatter text into particles with exact per-grapheme starting positions, or pack shrink-wrapped multiline UI without any getBoundingClientRect thrash.
This skill exists so Hermes can make cool demos with it β the kind people post to X. See pretext.cool and chenglou.me/pretext for the community demo corpus.
When to Use
Use when the user asks for:
- A "pretext demo" / "cool pretext thing" / "text-as-X"
- Text flowing around a moving shape (hero sections, editorial layouts, animated long-form pages)
- ASCII-art effects using real words or prose, not monospace rasters
- Games where the playfield / obstacles / bricks are made of text (Tetris-from-letters, Breakout-of-prose)
- Kinetic typography with per-glyph physics (shatter, scatter, flock, flow)
- Typographic generative art, especially with non-Latin scripts or mixed scripts
- Multiline "shrink-wrap" UI (smallest container width that still fits the text)
- Anything that would require knowing line breaks before rendering
Don't use for:
- Static SVG/HTML pages where CSS already solves layout β just use CSS
- Rich text editors, general inline formatting engines (pretext is intentionally narrow)
- Image β text (use
ascii-art/ascii-videoskills) - Pure canvas generative art with no text role β use
p5js
Creative Standard
This is visual art rendered in a browser. Pretext returns numbers; you draw the thing.
- Don't ship a "hello world" demo. The
hello-orb-flow.htmltemplate is the starting point. Every delivered demo must add intentional color, motion, composition, and one visual detail the user didn't ask for but will appreciate. - Dark backgrounds, warm cores, considered palette. Classic amber-on-black (CRT / terminal) works, but so do cold-white-on-charcoal (editorial) and desaturated pastels (risograph). Pick one and commit.
- Proportional fonts are the point. Pretext's whole vibe is "not monospaced" β lean into it. Use Iowan Old Style, Inter, JetBrains Mono, Helvetica Neue, or a variable font. Never default sans.
- Real source/text, not lorem ipsum. The corpus should mean something. Short manifestos, poetry, real source code, a found text, the library's own README β never
lorem ipsum. - First-paint excellence. No loading states, no blank frames. The demo must look shippable the instant it opens.
Stack
Single self-contained HTML file per demo. No build step.
| Layer | Tool | Purpose |
|---|---|---|
| Core | @chenglou/pretext via esm.sh CDN |
Text measurement + line layout |
| Render | HTML5 Canvas 2D | Glyph rendering, per-frame composition |
| Segmentation | Intl.Segmenter (built-in) |
Grapheme splitting for emoji / CJK / combining marks |
| Interaction | Raw DOM events | Mouse / touch / wheel β no framework |
<script type="module">
import {
prepare, layout, // use-case 1: simple height
prepareWithSegments, layoutWithLines, // use-case 2a: fixed-width lines
layoutNextLineRange, materializeLineRange, // use-case 2b: streaming / variable width
measureLineStats, walkLineRanges, // stats without string allocation
} from "https://esm.sh/@chenglou/pretext@0.0.6";
</script>
Pin the version. @0.0.6 at time of writing β check npm for the latest if demo behavior is off.
The Two Use Cases
Almost everything reduces to one of these two shapes. Learn both.
Use-case 1 β measure, then render with CSS/DOM
const prepared = prepare(text, "16px Inter");
const { height, lineCount } = layout(prepared, 320, 20);
You still let the browser draw the text. Pretext just tells you how tall the box will be at a given width, without a DOM read. Use for:
- Virtualized lists where rows contain wrapping text
- Masonry with precise card he
FAQ
What is the pretext library?
A small TypeScript library that measures and lays out multiline text without touching the page layout.
Is this for production websites?
The skill is aimed at creative demos, the kind people share online, rather than everyday page layout.
How big is the library?
The skill describes it as about 15KB with no dependencies.
Details
Original description by the author
Build creative browser demos with DOM-free text layout.
Popularity
- GitHub stars
- 260k
- Ranking position
- #474
- License
- MIT
- Updated
- 11/2/2026
Comments
- β¦
More skills from this repository
agent-merge-conflict-arbiter
260kSettles a git merge conflict between two agents' branches as a neutral third party, producing one merged result for the repo.
antigravity-cli
260kGuides you through installing, updating, and troubleshooting the Antigravity command line tool, including its plugins, sign-in, and sandbox.
blackbox
260kLets your agent hand a coding task to the Blackbox AI command line tool, which runs several AI models and picks the best result.
dynamic-workflow
260kTeaches your agent to run large batches of similar work as a saved script, so only verified results return to the main conversation.
Similar skills
angular-developer
280kHelps your agent create Angular code and give project structure advice. Useful for starting new projects, creating code parts, or improving performance and accessibility.
frontend-a11y
280kHelps your agent make web interfaces accessible to everyone. It ensures websites and apps work well with screen readers and keyboard navigation.
frontend-patterns
280kHas your agent apply modern patterns in frontend development. It optimizes performance, manages state, and follows best practices in React and Next.js.