Skip to main content

Prompt: add security headers without breaking your site

Paste this into Claude Code, Cursor or Codex inside your repo. The agent lists every third-party origin your site loads, builds a Content-Security-Policy from that list, ships it in report-only mode first, and sets the other headers in one place.


Copy prompt

The prompt

Paste it into an agent that has your repo open. It plans first and waits for your OK before writing code.

56 lines · ~1,134 tokens

Or paste one line

Fetch https://www.scrolllaunch.com/prompts/security-headers.md and carry out the prompt in its "Prompt" section on this repo. Show me your plan before writing code.

For agents that can fetch URLs. The agent pulls the full prompt from this page's markdown version, which includes the last step above.

What you get

What your repo has when the agent is done

  • A list of every third-party origin the site loads, grouped by type
  • HSTS, nosniff, Referrer-Policy, Permissions-Policy and frame protection on every response
  • A Content-Security-Policy shipped as Report-Only, with a violation report endpoint
  • A one-line switch to enforce the CSP once reports are clean
  • Cookie flags and CORS checked, with anything loose listed
  • Headers set in one place, not scattered across pages

The result

ScrollLaunch ships the same setup

These are live on this site. Open them to see what a passing result looks like.

Check your result

Deployed? Score your site

Runs your live URL through the free HTTP Header Checker. Free HTTP header checker - inspect status, security headers, caching, and X-Robots-Tag.

While your CSP is in report-only mode the checker shows CSP as missing. That's expected until you flip the switch to enforce it.

How to use

4 steps from paste to deploy

  1. 1

    Open your repo in a coding agent

    Claude Code, Cursor (agent mode), Codex or Windsurf.

  2. 2

    Paste the prompt and review the origin list

    Check that every analytics, payment, font and embed origin you use is on it. Anything missing there will be blocked once CSP is enforced.

  3. 3

    Say OK and test locally

    The agent sets the headers, then opens key pages in a production build and reports CSP violations.

  4. 4

    Deploy, watch reports, then enforce

    Leave CSP in report-only for a few days. When the reports are clean, flip the switch.

Next

Shipped it? Put it in front of people

Launch on ScrollLaunch

A week on the leaderboard and a permanent product page with a markdown version that AI agents can read. Free launches get a dofollow backlink while the badge stays on your site.

Questions

Security headers prompt FAQ

Why report-only first?

A CSP that's too strict silently breaks payments, analytics or embeds for real users. Report-only logs what would have been blocked without blocking it, so you can fix the policy before it bites.

Will the result be a perfect A+?

Often not on day one. Many frameworks still need 'unsafe-inline' for scripts or styles. The prompt tells the agent to say so plainly and explain what it would take to remove it, rather than claim a stricter policy than you have.

More prompts

Other prompts