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-skilltools
Building resilient distributed systems with circuit breakers, retries with full-jitter exponential backoff, retry budgets (per-request 3-attempt + per-client 10% ratio per Google SRE), deadline propagation, and the cascading-failure math (4 layers × 3 retries = 64x amplification). Grounded in Resilience4j, Microsoft Cloud Patterns, AWS Architecture Blog (Marc Brooker), and Google SRE Book.
testing
Designing HTTP cache headers that work correctly across browsers, CDNs, and shared proxies — `Cache-Control` directives per RFC 9111, `stale-while-revalidate` and `stale-if-error` per RFC 5861, the Vary header for varying responses, and surrogate keys for tag-based purging. Grounded in IETF RFCs and Cloudflare/Fastly docs.
development
Use when designing or fixing a Content Security Policy on a real site, choosing between nonce-based and hash-based CSP, adding strict-dynamic, debugging "Refused to execute inline script" errors, deploying CSP in report-only mode first, configuring report-to / report-uri, or auditing an existing policy for unsafe-inline / unsafe-eval / wildcards. Triggers: "CSP blocks legitimate inline script", strict-dynamic, nonce-{RANDOM}, sha256-{HASH}, object-src none, base-uri none, frame-ancestors, Trusted Types, X-Content-Security-Policy obsolete, report-only vs enforced. NOT for general HTTP security headers (HSTS, COOP/COEP), Trusted Types deep dive, CORS configuration, or building a WAF.
tools
Choosing and operating an HTTP API versioning strategy that doesn't break clients — Stripe's date-based pinned versions, the Deprecation/Sunset header pair (RFC 9745 + RFC 8594), URI vs header vs media-type approaches, and the version-transformer pattern. Grounded in Stripe's published architecture and IETF RFCs.