skills/mdx-sanitizer/SKILL.md
Comprehensive MDX content sanitizer that escapes angle brackets, generics, and other JSX-conflicting patterns to prevent build failures
npx skillsauth add curiositech/windags-skills mdx-sanitizerInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Comprehensive MDX content sanitizer that prevents JSX parsing errors caused by angle brackets, generics, and other conflicting patterns.
When to sanitize vs validate vs wrap:
Content Analysis:
├── Inside code blocks (```, `)
│ └── → Skip sanitization (already protected)
├── Contains TypeScript generics (`Promise<T>`)
│ └── → Sanitize with HTML entities
├── Contains comparisons (`<100ms`, `<=`)
│ └── → Sanitize with HTML entities
├── Contains arrows (`->`, `<--`)
│ └── → Sanitize with HTML entities
├── Valid JSX components (PascalCase)
│ └── → Skip sanitization (preserve functionality)
├── Valid HTML5 elements (`<div>`, `<span>`)
│ └── → Skip sanitization (preserve functionality)
├── Invalid pseudo-tags (`<link>` in prose)
│ └── → Sanitize with HTML entities
└── Documentation examples
├── If showing code syntax → Wrap in code blocks
└── If showing output/prose → Sanitize with HTML entities
Content type decision matrix:
| Pattern | Action | Reason |
|---------|--------|--------|
| Promise<T> | Sanitize | TypeScript generic, not JSX |
| <MyComponent> | Skip | Valid JSX component |
| <div> | Skip | Valid HTML5 element |
| <link> in prose | Sanitize | Invalid context for HTML |
| <100ms | Sanitize | Comparison, not JSX |
| `<T>` | Skip | Already in code block |
Schema Bloat: Over-sanitizing valid JSX
<Button> instead of <Button>)isMdxSafe() firstEscape Cascade: Double-escaping already sanitized content
&lt; instead of < in outputvalidateMdxSafety() before processingCode Block Pollution: Sanitizing content that should stay literal
<T> instead of <T>Context Blindness: Wrong sanitization strategy for content type
Validation Bypass: Files passing validation but failing build
npm run validate:all passes but npm run build fails with JSX errorsScenario 1: TypeScript API Documentation
Input content:
The `createMap` function returns `Promise<Map<string, User>>` where each User has...
Performance is <100ms for datasets <=1000 items.
Decision process:
Promise<Map<string, User>>, <100ms, <=1000Output:
The `createMap` function returns `Promise<Map<string, User>>` where each User has...
Performance is <100ms for datasets <=1000 items.
Expert insight: Novice might wrap entire line in code block, losing prose flow. Expert selectively escapes only the problematic characters while preserving readability.
Scenario 2: Component Usage Guide
Input content:
Use <Button variant="primary"> for main actions.
The <link> tag should be avoided in favor of <Link>.
Decision process:
<Button variant="primary"> has PascalCase, valid JSX<link> in prose context, not valid JSX usageOutput:
Use <Button variant="primary"> for main actions.
The <link> tag should be avoided in favor of <Link>.
Trade-off analysis: Preserving functional JSX while sanitizing prose references maintains both functionality and safety.
< characters outside code blocks are either valid JSX components or HTML-entity escaped&lt; double-escaping patterns in output<MyComponent>) remain unescaped<div>, <span>, <a>) remain unescapedPromise<T>) are escaped to Promise<T><100, <=) are escapedvalidateMdxSafety() returns no issues for processed contentnpm run build completes without JSX parsing errorsThis skill is NOT for:
escape-html or React's built-in escapingDOMPurify or similar XSS protection librariesmarked or remarkisomorphic-dompurify with CSP policies@mdx-js/mdx plugin API insteadDelegation patterns:
xss-security-skillreact-escaping-skilldocusaurus-config-skillregex-patterns-skilldata-ai
license: Apache-2.0 NOT for unrelated tasks outside this domain.
development
Use when designing caching strategies (cache-aside, write-through, write-behind), implementing distributed locks, building rate limiters, leaderboards, real-time streams (XADD/consumer groups), pub/sub, or tuning eviction policies. Triggers: thundering-herd on cache miss, dogpile on key expiry, Redlock vs SET-NX-PX choice, sliding-window rate limiter, hot-key on a single cluster slot, big-key blowup, MULTI/EXEC across slots, KEYS in production. NOT for Redis Cluster operations/admin (different domain), embedded KV (SQLite, leveldb), in-process LRU caches, or Memcached.
tools
Drawing the `'use client'` boundary correctly in React Server Components apps (Next.js App Router, RSC frameworks) — leaf-pushing, slot composition, serialization rules, and environment poisoning prevention. Grounded in react.dev and Next.js 16 docs.
development
Use when designing rate limiting for an API, choosing between token bucket / sliding window / leaky bucket / fixed window, implementing it in Redis, deciding edge (Cloudflare/Upstash) vs origin enforcement, sizing per-user vs per-IP vs per-endpoint quotas, returning the right 429 response with Retry-After, or fixing the boundary-burst bug in fixed-window limiters. Triggers: 429 too many requests, INCR + EXPIRE, ZADD + ZREMRANGEBYSCORE + ZCARD, X-RateLimit-Remaining header, Cloudflare WAF rate limiting rules, Upstash @upstash/ratelimit, leaky bucket shaping vs policing, distributed rate limiter consistency. NOT for DDoS mitigation specifically (different scale), CAPTCHA / bot management, full WAF design, or per-user quota billing.