Output Encoding

Implement context-specific output encoding to prevent XSS and injection attacks. Encode HTML, URL, JavaScript, and other contexts appropriately.

48 stars 10 forksSoftware Development Plugin marketplace

Install

Claude Code plugin
/plugin marketplace add sethdford/claude-skills

The repo is a Claude Code plugin marketplace. Run /plugin afterwards to pick the plugin that includes this skill.

skills CLI (Claude Code, Cursor, Codex and more)
npx skills add sethdford/claude-skills --skill output-encoding
Manual install
git clone --depth 1 https://github.com/sethdford/claude-skills.git /tmp/claude-skills
mkdir -p ~/.claude/skills
cp -r /tmp/claude-skills/security/secure-development/skills/output-encoding ~/.claude/skills/output-encoding

Personal skills live in ~/.claude/skills. Use .claude/skills in a project folder to share a skill with your team.

From the SKILL.md

# Output Encoding

Encode output based on context (HTML, URL, JavaScript, etc.) to prevent injection attacks.

## Context

You are a senior security architect designing output encoding for $ARGUMENTS. Output encoding prevents attackers from injecting malicious code through data reflected in the application.

## Domain Context

- **Context Matters**: HTML encoding ≠ URL encoding ≠ JavaScript encoding; use the right encoding for the context
- **Defense in Depth**: Validation prevents bad input; encoding prevents bad output from being executed
- **Double Encoding Risk**: Don't double-encode (encode then encode again); decode once, encode once per context

## Instructions

1. **HTML Context** (most common):
   - `<` → `&lt;`
   - `>` → `&gt;`
   - `&` → `&amp;`
   - `"` → `&quot;`
   - `'` → `&#x27;`
   - Example: `<script>alert('xss')</script>` → `&lt;script&gt;alert(&#x27;xss&#x27;)&lt;/script&gt;`

2. **URL Context**:
   - Encode special characters: space → `%20`, `&` → `%26`, `?` → `%3F`
   - Use URL-safe encoding (percent-encoding/RFC 3986)
   - Example: `redirect=http://evil.com?a=1&b=2` → `redirect=http%3A%2F%2Fevil.com%3Fa%3D1%26b%3D2`

3. **JavaScript Context**:
   - Escape quotes: `'` → `\'`, `"` → `\"`
   - Escape backslashes: `\` → `\\`
   - Avoid dynamic code generation with untrusted input (instead use JSON and JSON.parse)
   - Example: data passed to JavaScript should be JSON-encoded, then parsed safely

4. **CSS Context**:
Read the full skill on GitHub

Details

Skill name
output-encoding
Path
security/secure-development/skills/output-encoding/SKILL.md
License
MIT
Repo updated
11 March 2026

FAQ

What does the Output Encoding skill do?

Implement context-specific output encoding to prevent XSS and injection attacks. Encode HTML, URL, JavaScript, and other contexts appropriately.

How do I install the Output Encoding skill?

Claude Code plugin: /plugin marketplace add sethdford/claude-skills. Skills go in ~/.claude/skills (personal) or .claude/skills (project), and Claude loads them automatically when a task matches the description.

Is Output Encoding popular?

It lives in sethdford/claude-skills, which has 48 GitHub stars and 10 forks.

Related skills

Browse the most popular Claude skills, all software development skills, or write your own with the skills generator.