Output Encoding
Implement context-specific output encoding to prevent XSS and injection attacks. Encode HTML, URL, JavaScript, and other contexts appropriately.
Install
/plugin marketplace add sethdford/claude-skillsThe repo is a Claude Code plugin marketplace. Run /plugin afterwards to pick the plugin that includes this skill.
npx skills add sethdford/claude-skills --skill output-encodinggit 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-encodingPersonal 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):
- `<` → `<`
- `>` → `>`
- `&` → `&`
- `"` → `"`
- `'` → `'`
- Example: `<script>alert('xss')</script>` → `<script>alert('xss')</script>`
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**:Details
- Skill name
output-encoding- Repository
- sethdford/claude-skills
- 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
A B Test Design
48sethdford/claude-skills
Design rigorous A/B tests with hypotheses, variants, metrics, and sample size calculations.
A B Test Design Pm
48sethdford/claude-skills
Analytics and experimentation skill for product managers.
Abuse Case Design
48sethdford/claude-skills
Design abuse cases (negative use cases) showing how attackers misuse system features. Use when identifying attacks that exploit intended functionality or business logic flaws.
Pair Programming Guide
48sethdford/claude-skills
Effective pair programming, driver/navigator roles, tools, and collaboration patterns.
Opportunity Scoring
48sethdford/claude-skills
Apply Gibson Biddle's Importance/Satisfaction/Market Size framework.
Pattern Library
48sethdford/claude-skills
Structure a pattern library entry with problem context, solution pattern, usage examples, and related patterns.
Browse the most popular Claude skills, all software development skills, or write your own with the skills generator.