Skip to content
Back to skills

Security Headers Csp

ASecurity

Adds a Content Security Policy and the other protective HTTP headers, starting in report-only mode so nothing breaks before you tighten it.

  • 3 stars
  • 0 votes
  • 0 copies
  • 4 views
  • Added November 15, 2026
ai-agentsgitsecurity

Security analysis

A100/100

Scanned November 15, 2026

npx -y skills add workspace-templates/ai-agent-templates --skill security-headers-csp --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Security Headers Csp?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Security Headers Csp
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/workspace-templates-security-headers-csp/badge)](https://www.skillsdirectory.com/skills/workspace-templates-security-headers-csp)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: security-headers-csp
description: Adds a Content Security Policy and the other protective HTTP headers, starting in report-only mode so nothing breaks before you tighten it.
---

# Security headers and CSP

Roll out in stages. Never enforce a new CSP before you have seen its reports.

## Steps

1. Inventory what the pages load: scripts, styles, fonts, images, frames, fetch and websocket targets, analytics and widgets. Note every inline script and style.
2. Remove inline code where it is cheap. For what remains, use a per-response nonce (`script-src 'nonce-...' 'strict-dynamic'`) or hashes. Do not rely on `'unsafe-inline'` or `'unsafe-eval'` for scripts.
3. Draft the policy: `default-src 'self'`, then explicit `script-src`, `style-src`, `img-src`, `connect-src`, `font-src`, plus `object-src 'none'`, `base-uri 'none'`, `frame-ancestors 'self'` and `form-action 'self'`.
4. Ship it as `Content-Security-Policy-Report-Only` with a `report-to` endpoint or a log of violations. Run through the main user journeys and read the reports. Fix or allow each legitimate source narrowly. Wait for a representative period.
5. Switch to enforcing `Content-Security-Policy` only when reports are clean. Keep a report-only copy of the next stricter version.
6. Add the companions through the framework's middleware or server config:
   - `Strict-Transport-Security: max-age=31536000; includeSubDomains` (add `preload` only after confirming every subdomain serves HTTPS)
   - `X-Content-Type-Options: nosniff`
   - `Referrer-Policy: strict-origin-when-cross-origin`
   - `Permissions-Policy` turning off unused features
7. Test with a header scanner and a browser console check.

## Rules

- Do not paste a policy found online; build it from what the pages actually load.
- Keep policy in one place, in config.

## Report

The policy, the sources allowed and why, where it is set, and the steps remaining to enforce it.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.