pretext

pretext is a skill for Claude Code from yaniv-golan/pretext-skill. It costs 182 tokens per session (4,690 once invoked), scanned A, original, MIT.

A guide for using Pretext, a TypeScript library that measures text size with canvas calculations instead of repeatedly reflowing the page.

In plain words
What is it for?
Use it for virtual scrolling, masonry cards, text fitting, text flowing around shapes, canvas or SVG layouts, and rich inline text such as mentions or code spans.
Why use it?
It helps developers estimate text dimensions before displaying it, avoiding layout work that can make interfaces slower or harder to control.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the pretext plugin — 1 skill 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/yaniv-golan/pretext-skill/pretext
Any agent
npx skills add yaniv-golan/pretext-skill --skill pretext
Clone the repo
git clone --depth 1 https://github.com/yaniv-golan/pretext-skill

Made for: Claude Code.

Or install pretext, the plugin that ships this one along with the rest of its 1 skill.

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 pretext

README.md
[![agentmods](https://agentmods.dev/badge/skills/yaniv-golan/pretext-skill/pretext.svg)](https://agentmods.dev/skills/yaniv-golan/pretext-skill/pretext)
Your own site
<a href="https://agentmods.dev/skills/yaniv-golan/pretext-skill/pretext"><img src="https://agentmods.dev/badge/skills/yaniv-golan/pretext-skill/pretext.svg" alt="Measured on agentmods" height="20"></a>
Per session 182 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 4,690 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.1 $0.00182 $0.04690
Opus 5 $0.00091 $0.02345
Sonnet 5 $0.00036 $0.00938
Haiku 4.5 $0.00018 $0.00469

Measured 6d ago against content hash ecc5a89291d3, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-05, from the pricing page.

Security

Grade A, and why

pretext 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 6d 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.

pretext/skills/pretext/SKILL.md · 284 lines

How it starts

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

Pretext Integration Guide

You are helping a developer use @chenglou/pretext — a small, tree-shakable TypeScript library by Cheng Lou that computes exact text metrics using pure math (no DOM reflows). It uses CanvasRenderingContext2D.measureText internally, segments text, measures once, caches, then does arithmetic for all subsequent layouts. The package ships proper ESM with subpath exports (. for core, ./rich-inline for inline rich text) and is sideEffects: false — modern bundlers tree-shake unused entrypoints.

When Pretext Is the Right Tool

Use Pretext when the developer needs to:

  • Know text dimensions before rendering — virtual scrolling, masonry layouts, card height estimation
  • Auto-fit text to a container — find the largest font size that keeps text within N lines (CSS has no equivalent)
  • Flow text around obstacles — magazine-style layouts where text wraps around shapes, images, or interactive elements
  • Measure text in canvas/SVG/WebGL — Pretext's measurements are exact for fillText
  • Render rich inline text — mentions, chips, code spans with browser-like boundary whitespace collapse, via the @chenglou/pretext/rich-inline subpath
  • Measure many text items fast — each layout() call is ~0.0002ms after the first prepare() per font

When NOT to Use Pretext

  • CSS float/flex already handles it — don't reimplement text flow that CSS does natively
  • Content is HTML, not plain text — Pretext measures plain text strings. Tables, code blocks, nested elements need DOM measurement
  • TanStack Virtual + Pretext height estimation — this integration is fragile. Height errors compound over many items, and measureElement correction loops cause desyncing. For <500 items, just render all and use CSS transitions. For 1000+, use Pretext estimates as seeds but rely on DOM correction
  • Accordion content height — if content has HTML structure, use off-screen DOM measurement (visibility: hidden; position: absolute)

Read the full file on GitHub · 284 lines

Files

What ships with it

3 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. 6d ago First seen · 284 lines · 182 tokens per session scan A ecc5a89291d3

Subscribe to this mod's changes

pretext is a skill published in the GitHub repository yaniv-golan/pretext-skill (15 stars, last pushed 1mo ago), licensed MIT. It adds 182 tokens to every session and 4,690 once invoked, about $0.0009 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

fec-typescript-project-standard

用于创建、配置、审查或调试前端应用、库、SDK、CLI、monorepo 包中的 TypeScript 项目规范,包括 tsconfig、strictness、module/moduleResolution、路径别名、project references、声明文件、package exports、公共 API 类型、DTO、高级泛型、判别联合、类型守卫、类型收窄或类型级回归。React/Vue/Next/Nuxt 组件架构优先使用框架项目 skill;中文触发词包括 TypeScript 项目规范、TS 项目规范、TypeScript 类型安全、类型建模、泛型、判别联合、类型收窄、tsconfig、声明文件。.

bovinphang/frontend-craft · 151 tokens

fec-vue3-project-standard

用于设计或审查 Vue 3 + TypeScript 项目结构、SFC/组件边界、composables 组织、路由组合、Pinia 归属、API/错误/样式默认约定、directives 或仓库级 Vue 规范。表单、数据获取、测试、无障碍、虚拟列表、动画或安全深挖优先使用更窄的 skill;中文触发词包括 Vue 3 项目规范、Vue 组件架构。.

bovinphang/frontend-craft · 114 tokens

feathers-service

Scaffold or extend a FeathersJS v5 (Dove) service using the idiomatic four-file pattern ( .ts, .class.ts, .schema.ts, .shared.ts), register it with app.configure, and wire it into the ServiceTypes declaration. Use this whenever the user wants to add a new resource, endpoint, collection, table-backed CRUD service, or…

hassan4702/feathers-plugin · 155 tokens

ultracite

Ultracite is a zero-config linting and formatting preset for JavaScript/TypeScript projects. Use when: (1) Setting up or initializing Ultracite in a project (ultracite init), (2) Running linting or formatting commands (check, fix, doctor), (3) Writing or reviewing JS/TS code in a project that uses Ultracite — to…

haydenbleasel/ultracite · 142 tokens

microsoft-typescript

TypeScript is a language for application scale JavaScript development. ALWAYS use when editing or working with .ts, .tsx, .mts, .cts files or code importing "typescript". Consult for debugging, best practices, or modifying typescript, TypeScript.

skilld-dev/skilld · 57 tokens

better-auth

Skill for integrating Better Auth - comprehensive TypeScript authentication framework for Cloudflare D1, Next.js, Nuxt, and 15+ frameworks. Use when adding auth, encountering D1 adapter errors, or implementing OAuth/2FA/RBAC features.

secondsky/claude-skills · 53 tokens