agentleFS
PradnyeshpPradnyeshp/Claude-Skills/.claude/skills/security-headers/SKILL.md

security-headers

Skill2 starsChanged 4 months agoMITView on GitHub

Add or harden HTTP security headers on a web app or API — Content-Security-Policy, HSTS, X-Frame-Options, X-Content-Type-Options, Referrer-Policy, and CORS — using the project's framework, to defend against XSS, clickjacking, and MIME sniffing. Use when the user says "add security headers", "set up CSP", "add HSTS", "configure CORS", "fix clickjacking", "harden the HTTP headers", or "pass a security headers scan".

7 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use accessibility.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • ElasticSkill

    accessibility

    Accessibility guidance for Kibana. Use this skill when working with or reviewing EUI components, resolving a11y-related (@elastic/eui) ESLint issues, and ensuring proper use of ARIA attributes, focus management, keyboard interactions, and accessible naming conventions.

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

6 rules. 0 are common, 3 are distinctive, and 3 are very specific to this project.

  • 0

    Common

    Most of the 6 edited versions we read keep these.

  • 3

    Distinctive

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Lock down CORS to an allowlist: Never reflect arbitrary origins or pair Access-Control-Allow-Origin: * with credentials.

    line 22
  2. Distinctive:

    Don't break the running app: CSP and CORS misconfigured will block legitimate assets or requests — prefer CSP report-only first and an …

    line 27
  3. Very specific:

    Never set Access-Control-Allow-Origin: * together with credentials, and never reflect the request origin without validating it against an …

    line 28
  4. Very specific:

    Avoid unsafe-inline/unsafe-eval in CSP.

    line 29
  5. Distinctive:

    Only enable HSTS once HTTPS is fully working (it's hard to roll back), and extend the project's existing header mechanism instead of adding …

    line 30
  6. Distinctive:

    After applying, summarize each header set, the CSP/CORS policy, whether CSP is report-only, and how to verify the headers and that nothing …

    line 31

“Common” is measured: kept by at least 6 in 10 of the 6 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Framework & header signals

!grep -rilE "express|fastify|koa|nestjs|next\\.config|helmet|flask|fastapi|django|secure\\.py|rails|spring|nginx|cors|csp|content-security-policy|strict-transport" --include='*.*' package.json pyproject.toml go.mod Gemfile next.config.* nginx.conf 2>/dev/null | grep -vE 'node_modules|\.git|dist|build' | head -10

Instructions

Add or harden security headers for the app in $ARGUMENTS (or the whole app if unspecified). Match the project's framework and where it currently sets headers. CSP and CORS can break a working app if set wrong, so apply them carefully and explain what each does.

Method

  1. Find where headers are set today. Look for an existing middleware (helmet, django-csp, Rails default_headers, a reverse-proxy config) and extend it rather than adding a second, conflicting source. Prefer the idiomatic library (helmet for Express/Fastify, secure for FastAPI/Flask, Spring Security headers) over hand-setting strings.
  2. Set the low-risk headers first. X-Content-Type-Options: nosniff, X-Frame-Options: DENY (or a frame-ancestors CSP), Referrer-Policy: strict-origin-when-cross-origin, and Strict-Transport-Security with a sane max-age (only once HTTPS is fully in place — HSTS is sticky and hard to undo). These rarely break anything.
  3. Build a Content-Security-Policy deliberately. This is the highest-value and highest-risk header. Start from default-src 'self', then add only the origins the app genuinely loads from (scripts, styles, images, fonts, connect/XHR). Avoid unsafe-inline/unsafe-eval — prefer nonces/hashes. Offer to deploy it as Content-Security-Policy-Report-Only first so violations are reported without breaking the page.
  4. Lock down CORS to an allowlist. Never reflect arbitrary origins or pair Access-Control-Allow-Origin: * with credentials. Allow only the specific trusted origins, the methods/headers actually used, and set Allow-Credentials only when cookies/auth truly cross origins.
  5. Verify before declaring done. Note how to check (curl -I, a securityheaders.com-style scan, browser console for CSP violations) and confirm the app still loads — no blocked scripts/styles, no CORS errors in the console.

Rules

  1. Don't break the running app: CSP and CORS misconfigured will block legitimate assets or requests — prefer CSP report-only first and an explicit CORS allowlist, and verify the app still works.
  2. Never set Access-Control-Allow-Origin: * together with credentials, and never reflect the request origin without validating it against an allowlist.
  3. Avoid unsafe-inline/unsafe-eval in CSP; use 'self', nonces, or hashes, and scope each directive to the origins actually used.
  4. Only enable HSTS once HTTPS is fully working (it's hard to roll back), and extend the project's existing header mechanism instead of adding a conflicting second one.
  5. After applying, summarize each header set, the CSP/CORS policy, whether CSP is report-only, and how to verify the headers and that nothing broke.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.