patricio0312rev avatar

Secure Headers Csp Builder

Walks you through implementing security headers and Content Security Policy without breaking your app. The smart part is the phased rollout: start with report-only mode to catch violations, analyze what's breaking for a week, then gradually enforce. Includes nonce generation for inline scripts and styles, a violation reporter endpoint, and Helmet.js integration examples. The rollout plan and common CSP issues section are genuinely useful since most teams just flip CSP on and watch everything explode. Code covers both Express middleware and template integration, plus testing examples. If you're adding security headers to an existing app, this approach beats the usual trial and error.

skills.sh installs
318
GitHub stars
63
last updated
Aug 21, 2026

Install

$ npx -y skills add patricio0312rev/skills --skill secure-headers-csp-builder --agent claude-code

Installs into .claude/skills of the current project.

Files

Secure Headers & CSP Builder

Add security headers safely without breaking functionality.

Essential Security Headers

// middleware/security-headers.ts
import { Request, Response, NextFunction } from "express";

export function securityHeaders(
  req: Request,
  res: Response,
  next: NextFunction
) {
  // Prevent clickjacking
  res.setHeader("X-Frame-Options", "DENY");

  // Prevent MIME sniffing
  res.setHeader("X-Content-Type-Options", "nosniff");

  // XSS Protection (legacy browsers)
  res.setHeader("X-XSS-Protection", "1; mode=block");

  // Referrer Policy
  res.setHeader("Referrer-Policy", "strict-origin-when-cross-origin");

  // Permissions Policy (replaces Feature-Policy)
  res.setHeader(
    "Permissions-Policy",
    "camera=(), microphone=(), geolocation=(self), payment=()"
  );

  // HSTS - Force HTTPS (only in production)
  if (process.env.NODE_ENV === "production") {
    res.setHeader(
      "Strict-Transport-Security",
      "max-age=31536000; includeSubDomains; preload"
    );
  }

  next();
}

Content Security Policy (CSP)

Phase 1: Report-Only Mode

Sponsors

Details

Repository
github.com/patricio0312rev/skills
Categories
Testing & QA, Security
First seen
Jun 3, 2026

More from patricio0312rev/skills

All 138
1secondsky avatarcloudflare-workers-ci-cdsecondsky/claude-skillsComplete CI/CD guide for Cloudflare Workers using GitHub Actions and GitLab CI. Use for automated testing, deployment pipelines, preview environments, secrets m318skills.sh installs
2onewave-ai avatarterritory-planning-optimizeronewave-ai/claude-skillsAccount assignment by revenue potential, geography, relationship. Workload balancing, TAM/SAM calculation, coverage models.315skills.sh installs
3jezweb avatarclerk-authjezweb/claude-skillsClerk auth with API Keys beta (Dec 2025), Next.js 16 proxy.ts (March 2025 CVE context), API version 2025-11-10 breaking changes, clerkMiddleware() options, webh310skills.sh installs
4patricio0312rev avatarcurl-command-generatorpatricio0312rev/skillsGenerates ready-to-run cURL commands from Express, Next.js, Fastify, or other API routes. Creates copy-paste commands with proper headers, authentication, and r308skills.sh installs
5payloadcms avatartriage-ci-flakepayloadcms/payloadUse when CI tests fail on main branch after PR merge, when investigating flaky test failures, or when user provides a PR URL/number to aggregate all failing tes307skills.sh installs
6robonet-tech avatartrade-prediction-marketsrobonet-tech/skillsBuild and test Polymarket prediction market trading strategies for YES/NO token trading. Provides 6 tools: get_all_prediction_events (browse markets, $0.001), g305skills.sh installs