Xss Prevention
Practical XSS defense covering input sanitization, output encoding, and Content Security Policy for user-generated content.
- CCM score
- 38 of 100
- skills.sh installs
- 485
- GitHub stars
- 396
- last updated
- Aug 21, 2026
Own this skill? Claim it
What it does
- Covers HTML entity encoding, DOMPurify-based sanitization for rich content, and URL validation for web applications
- Includes Node.js, Python, React, and Content Security Policy reference guides in a
references/directory - Lists explicit do and don't rules, such as avoiding raw
innerHTML,eval(), and inline scripts - Designed for developers handling comment systems, rich text editors, search results, and template rendering
Install
$ npx -y skills add aj-geddes/useful-ai-prompts --skill xss-prevention -yInstalls into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.
Files
XSS Prevention
Table of Contents
Overview
Implement comprehensive Cross-Site Scripting (XSS) prevention using input sanitization, output encoding, CSP headers, and secure coding practices.
When to Use
- User-generated content display
- Rich text editors
- Comment systems
- Search functionality
- Dynamic HTML generation
- Template rendering
Quick Start
Minimal working example:
// xss-prevention.js
const createDOMPurify = require("dompurify");
const { JSDOM } = require("jsdom");
const he = require("he");
const window = new JSDOM("").window;
const DOMPurify = createDOMPurify(window);
class XSSPrevention {
/**
* HTML Entity Encoding - Safest for text content
*/
static encodeHTML(str) {
return he.encode(str, {
useNamedReferences: true,
encodeEverything: false,
});
}
/**
* Sanitize HTML - For rich content
*/
static sanitizeHTML(dirty) {
const config = {
ALLOWED_TAGS: [
// ... (see reference guides for full implementation)
Details
- Repository
- github.com/aj-geddes/useful-ai-prompts
- Categories
- Security, Frontend & UI Code
- First seen
- Jun 3, 2026
Questions
What does the xss-prevention skill do?
The xss-prevention skill prevents Cross-Site Scripting attacks through input sanitization, output encoding, and Content Security Policy headers. It covers HTML entity encoding for text, DOMPurify sanitization for rich content, and guidance to avoid innerHTML and inline scripts.
When should I use the xss-prevention skill?
Use the xss-prevention skill when your web application displays user-generated content, such as comment systems, rich text editors, search results, or dynamic HTML and template rendering. It guides how xss-prevention handles each of these cases safely.
How do I install the xss-prevention skill?
Run npx -y skills add aj-geddes/useful-ai-prompts --skill xss-prevention -y in your project. After that, the xss-prevention skill is available to your agent for handling XSS defenses in that project.
Which category does xss-prevention belong to and what sets it apart?
The xss-prevention skill sits in the Security category, alongside azure-compliance, entra-agent-id, firebase-security-rules-auditor, security-audit, and cloudflare-one. It focuses narrowly on XSS defenses, with reference guides for Node.js, Python, React and Content Security Policy.
More from aj-geddes/useful-ai-prompts
All 258- Dns Management484
- Sentiment Analysis483
- Dependency Management482
- Batch Processing Jobs481
- Circuit Breaker Pattern481
- Aws Cloudfront Cdn480
- Mutation Testing480
- Csrf Protection479
- Developer Onboarding479
- Api Changelog Versioning478
- Deployment Automation478
- Django Application478
- Regression Modeling478
- Concurrency Patterns477
- Gcp Cloud Functions476
- Cloud Security Configuration475
- Aws Ec2 Setup474
- Api Versioning Strategy473
- Email Service Integration472
- Infrastructure Monitoring472
- Angular Module Design471
- Database Monitoring470
- Pull Request Automation470
- Session Management469
Similar to Xss Prevention
More Securityweb-securityacademind/ai-config300 installsSet of security rules that guides code toward safe defaults across XSS, auth, CSP, and data handling.
security-headers-configurationaj-geddes/useful-ai-prompts523 installsConfiguration guide for HTTP security headers covering CSP, HSTS, X-Frame-Options, and MIME-sniffing protection across common web stacks.
wordpress-security-validationbobmatnyc/claude-mpm-skills643 installsSecurity-first WordPress guide covering nonces, sanitization, validation, and escaping against XSS, CSRF, and SQL injection.
xss-cross-site-scriptingyaklang/hack-skills4.4K installsXSS playbook covering injection contexts, multi-reflection, CSP and WAF bypasses, and upload vectors.
frontend-security-codersickn33/agentic-awesome-skills735 installsSecure frontend coding guide covering XSS prevention, CSP, clickjacking, redirects, and browser security features.