# Content security policy

> Content security policy is an open-source agent skill for security. Write, roll out and review CSP, Trusted Types, Permissions Policy and Fetch Metadata. It is available on Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose.

- **Kind:** Skill
- **Pricing:** Open source
- **Platforms:** Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf, Goose
- **Website:** https://github.com/ScaleDockHQ/better-supabase/tree/main/.agents/skills/content-security-policy
- **Repository:** https://github.com/scaledockhq/better-supabase
- **GitHub stars:** 5
- **License:** MIT
- **Skill name:** content-security-policy
- **Collection:** https://github.com/ScaleDockHQ/better-supabase
- **Categories:** [security](https://ai-powered.com/categories/security)
- **Listing updated:** 2026-12-02

## About

This skill guides an agent through writing and reviewing the security headers a server sends to lock down web documents. It covers strict Content Security Policy using nonces, hashes and 'strict-dynamic', plus report-only rollouts that collect violations through report-to and report-uri before enforcement.

The workflow starts by inventorying a page's inline scripts, event handlers, frames and external script origins, then maps each one to the directive that governs it. It adds Trusted Types with named policies, sets a Structured Fields Permissions-Policy header with matching iframe allow attributes, and rejects cross-site requests using Sec-Fetch-* metadata with explicit exceptions. A closing checklist covers every HTML response, including error pages, and includes a test that asserts the headers on each route.

The skill is organized as a main guide with reference files for directives, versions, reporting, Trusted Types, Permissions Policy and Fetch Metadata. It works from the W3C specifications and includes upgrade paths from CSP 1.0, CSP Level 2 and Feature-Policy. It expects a server, middleware, reverse proxy or CDN that controls the response headers, and it includes TypeScript middleware sketches.

## When your agent uses it

> Content Security Policy Level 3: write strict CSP headers, plus the W3C Trusted Types, Permissions Policy and Fetch Metadata Request Headers a server sets and checks to lock down documents. Covers CSP Level 3 (current, Working Draft) with CSP Level 2 supported and CSP 1.0, X-Content-Security-Policy and X-WebKit-CSP legacy: directives, source lists, nonces and hashes, 'strict-dynamic', 'unsafe-hashes', report-to, report-uri, Report-Only, frame-ancestors and upgrade-insecure-requests. Trusted Types: require-trusted-types-for 'script' and the default policy. Permissions Policy: the structured header, allowlists and the iframe allow attribute, with Feature-Policy legacy. Fetch Metadata: Sec-Fetch-Site, -Mode, -Dest and -User for a resource isolation policy. Use when writing or reviewing security headers. Also CSP Embedded Enforcement, Mixed Content, Reporting API and Upgrade Insecure Requests.

## What it can access

From a static check of the files on GitHub; nothing was run.

- [Instructions only, no scripts](https://github.com/ScaleDockHQ/better-supabase/tree/HEAD/.agents/skills/content-security-policy)
- [License: MIT](https://github.com/ScaleDockHQ/better-supabase/tree/HEAD/.agents/skills/content-security-policy)

## Features

- **Strict CSP authoring:** Writes Content Security Policy headers built on nonces or hashes and 'strict-dynamic'.
- **Report-only rollout:** Ships policies in report-only mode with report-to collection before enforcing them.
- **Trusted Types setup:** Covers require-trusted-types-for, the trusted-types directive and named or default policies.
- **Permissions-Policy configuration:** Sets feature allowlists in the Structured Fields header and iframe allow attributes.
- **Fetch Metadata isolation:** Refuses cross-site requests using Sec-Fetch-Site, Mode, Dest and User headers.
- **Legacy header upgrades:** Moves CSP 1.0, CSP Level 2 and Feature-Policy setups to current syntax.

## Good for

- Add a strict Content-Security-Policy with nonces to our HTML responses
- Roll out Trusted Types in report-only mode for our frontend
- Review our existing security headers for weak script-src rules
- Lock down which browser features our iframes can use
- Block cross-site requests to our API using Fetch Metadata

## Install

### Claude Code

This skill ships in the `better-supabase` plugin. In Claude Code, add the marketplace and install the plugin (it may include other skills too):

```sh
/plugin marketplace add ScaleDockHQ/better-supabase
/plugin install better-supabase@better-supabase
```

Or copy only this skill to `~/.claude/skills/content-security-policy`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/ScaleDockHQ/better-supabase.git "$tmp" &&
mkdir -p ~/.claude/skills &&
rm -rf ~/.claude/skills/content-security-policy &&
cp -R "$tmp/.agents/skills/content-security-policy" ~/.claude/skills/content-security-policy &&
rm -rf "$tmp"
```

For one project only, put the folder in `.claude/skills/content-security-policy` inside it instead.

### Codex

Copy the skill folder to `~/.agents/skills/content-security-policy` to use it in every repository:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/ScaleDockHQ/better-supabase.git "$tmp" &&
mkdir -p ~/.agents/skills &&
rm -rf ~/.agents/skills/content-security-policy &&
cp -R "$tmp/.agents/skills/content-security-policy" ~/.agents/skills/content-security-policy &&
rm -rf "$tmp"
```

For one repository only, put the folder in `.agents/skills/content-security-policy` inside it instead.

### Cursor

Copy the skill folder to `~/.cursor/skills/content-security-policy` to use it in every project:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/ScaleDockHQ/better-supabase.git "$tmp" &&
mkdir -p ~/.cursor/skills &&
rm -rf ~/.cursor/skills/content-security-policy &&
cp -R "$tmp/.agents/skills/content-security-policy" ~/.cursor/skills/content-security-policy &&
rm -rf "$tmp"
```

For one project only, put the folder in `.cursor/skills/content-security-policy` inside it instead.

### Gemini CLI

Run in a terminal (add `--scope workspace` to install it for the current workspace only):

```sh
gemini skills install https://github.com/ScaleDockHQ/better-supabase.git --path .agents/skills/content-security-policy
```

Or copy the folder to `~/.gemini/skills/content-security-policy` yourself.

### VS Code

For GitHub Copilot in VS Code, copy the skill folder to `~/.copilot/skills/content-security-policy`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/ScaleDockHQ/better-supabase.git "$tmp" &&
mkdir -p ~/.copilot/skills &&
rm -rf ~/.copilot/skills/content-security-policy &&
cp -R "$tmp/.agents/skills/content-security-policy" ~/.copilot/skills/content-security-policy &&
rm -rf "$tmp"
```

For one project only, put the folder in `.github/skills/content-security-policy` inside it instead.

### Other agents

Get the folder:

```sh
git clone --depth 1 https://github.com/ScaleDockHQ/better-supabase.git
```

Then copy `better-supabase/.agents/skills/content-security-policy` into your agent's skills folder as `content-security-policy`. Agents that support SKILL.md read one folder per skill.

## FAQ

### Does the skill change my server code on its own?

It describes a workflow for the agent to write, deploy and review headers on the server side, following the steps and checks in the skill.

### Which clients does Content security policy support?

It is a plain SKILL.md folder with no client-specific tooling, so it follows the shared agent skills format for all listed clients.

### Are there scripts included?

No scripts are included in the skill folder.

### Which sources does the guidance rely on?

It cites W3C specifications including CSP Level 3, Trusted Types, Permissions Policy, Fetch Metadata and Reporting API, with pinned revisions.

### How do I install Content security policy in Claude Code?

Copy the skill folder from GitHub to ~/.claude/skills/content-security-policy to use it in all your projects, or to .claude/skills/content-security-policy in one project. Or install the better-supabase plugin, which includes it: /plugin marketplace add ScaleDockHQ/better-supabase, then /plugin install better-supabase@better-supabase.

### Does Content security policy run scripts?

No. It is instructions only, with no scripts. This comes from a static check of the files on GitHub; nothing was run. Read the files before you install it.

### Which AI agents can use Content security policy?

Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose. Each reads skills in the SKILL.md format from its own folder; the install steps on this page list them.

### What are the best alternatives to Content security policy?

The closest alternatives to Content security policy are Techstack security, Client side, Security, Security and Security review.

## Where this comes from

- Description: from the skill's own SKILL.md.

## Alternatives

- [Techstack security](https://ai-powered.com/skills/techstack-security): Techstack security is an open-source agent skill for security.
- [Client side](https://ai-powered.com/skills/client-side): Client side is an open-source agent skill for security.
- [Security](https://ai-powered.com/skills/security-jasgujral): Security is an open-source agent skill for security.
- [Security](https://ai-powered.com/skills/security-xiaolai): Security is an open-source agent skill for security.
- [Security review](https://ai-powered.com/skills/security-review-nabwinsaud): Security review is an open-source agent skill for security.
- [Server side](https://ai-powered.com/skills/server-side): Server side is an open-source agent skill for security.
- [Frontend security](https://ai-powered.com/skills/frontend-security): Frontend security is an open-source agent skill for security.
- [Security review](https://ai-powered.com/skills/security-review-getsentry): Security review is an open-source agent skill for security.

---
Source: https://ai-powered.com/skills/content-security-policy
