agentsclimarketplace

Csp

Skill cocart-headless/cocart-skills/skills/csp

A collection of skills for AI coding agents. SDK setup and integration guidance for headless WooCommerce development.

Install
npx -y skills add cocart-headless/cocart-skills --skill csp

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

2 things to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
  • 1 stars1 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

Generate Content-Security-Policy headers for headless storefronts using CoCart. Detects the user's framework, payment gateways, and third-party services to produce a tailored CSP.

The file declares its own license as MIT. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.

SKILL.md

8.2 KB, ~2.1k tokens by cl100k_base, as published. Nobody here has run it

CoCart CSP Generator Skill

You are an expert in Content-Security-Policy headers for headless WooCommerce storefronts built with CoCart. When a user asks for help with CSP, security headers, or uses this skill, analyze their project and generate a tailored Content-Security-Policy.

Workflow

Follow these steps in order:

1. Detect the Framework

Scan the project for framework indicators:

File / PatternFramework
next.config.js, next.config.mjs, next.config.tsNext.js
nuxt.config.ts, nuxt.config.jsNuxt
astro.config.mjs, astro.config.tsAstro
svelte.config.jsSvelteKit
remix.config.js, app/root.tsx with @remix-runRemix
src/index.ts with hono importHono
src/index.ts with elysia importElysia.js
server.js or app.js with express importExpress.js
server.js or app.js with fastify importFastify
vercel.jsonVercel deployment
netlify.tomlNetlify deployment
wrangler.tomlCloudflare Workers / Pages

2. Identify the CoCart API Domain

Search for the CoCart store URL in:

  • Environment files (.env, .env.local, .env.production)
  • Configuration files (look for patterns like COCART_URL, STORE_URL, WP_URL, NEXT_PUBLIC_STORE_URL, NUXT_PUBLIC_STORE_URL)
  • SDK initialization code (new CoCart('https://...'))

This domain must be added to connect-src.

3. Identify Payment Gateways

Search project dependencies (package.json, import statements) and configuration for payment integrations:

ServiceDetectionCSP Directives
Stripe@stripe/stripe-js, stripe in dependenciesscript-src js.stripe.com; frame-src js.stripe.com
PayPal@paypal/react-paypal-js, paypal referencesscript-src www.paypal.com; frame-src www.paypal.com www.sandbox.paypal.com
Square@square/web-sdk, square in dependenciesscript-src js.squareup.com; frame-src connect.squareup.com
Braintreebraintree-web, braintree in dependenciesscript-src js.braintreegateway.com; frame-src assets.braintreegateway.com
Klarna@klarna/klarna-payment referencesscript-src x.klarnacdn.net; frame-src klarna.com *.klarna.com
Mollie@mollie/mollie-api-node referencesframe-src js.mollie.com
Authorize.netauthorizenet, accept.js referencesscript-src jstest.authorize.net js.authorize.net; frame-src jstest.authorize.net js.authorize.net

4. Identify Third-Party Services

Search for imports, script tags, and configuration referencing common services:

ServiceDetectionCSP Directives
Google Fontsfonts.googleapis.com in CSS/HTMLstyle-src fonts.googleapis.com; font-src fonts.gstatic.com
Google Analytics / GTMgtag, GA_MEASUREMENT_ID, GTM- referencesscript-src www.googletagmanager.com; connect-src www.google-analytics.com region1.google-analytics.com
Google Maps@googlemaps, maps.googleapis.comscript-src maps.googleapis.com; img-src maps.gstatic.com maps.googleapis.com
Cloudflare CDNcdnjs.cloudflare.com referencesscript-src cdnjs.cloudflare.com
YouTubeyoutube.com embedsframe-src www.youtube.com
Vimeovimeo.com embedsframe-src player.vimeo.com
Hotjarhotjar referencesscript-src static.hotjar.com; connect-src *.hotjar.com wss://*.hotjar.com
Intercomintercom referencesscript-src widget.intercom.io; connect-src api-iam.intercom.io wss://*.intercom.io
Sentry@sentry/ importsconnect-src *.ingest.sentry.io
Crispcrisp.chat referencesscript-src client.crisp.chat; connect-src client.crisp.chat wss://client.relay.crisp.chat

5. Generate the CSP

Build the policy using these directives:

default-src 'self';
script-src 'self' {detected script sources};
style-src 'self' 'unsafe-inline' {detected style sources};
img-src 'self' data: https: {detected image sources};
connect-src 'self' {cocart-api-domain} {detected connect sources};
font-src 'self' {detected font sources};
frame-src {detected frame sources or 'none'};
object-src 'none';
base-uri 'self';
form-action 'self';

Rules:

  • Always include 'self' in default-src, script-src, style-src, img-src, connect-src, and font-src
  • Always include data: in img-src (common for inline images and SVGs)
  • Always include 'unsafe-inline' in style-src (most frameworks require this for CSS-in-JS or scoped styles)
  • Only add 'unsafe-inline' to script-src if the framework requires it (avoid if possible)
  • Only add 'unsafe-eval' if specifically needed and warn the user about the security implications
  • Set object-src 'none' to block plugins (Flash, Java applets)
  • Set base-uri 'self' to prevent base tag injection
  • Set frame-src 'none' if no iframes are detected; otherwise list only the required frame sources
  • If Next.js is detected and next dev is used, note that development mode may require 'unsafe-eval' in script-src — but this must NOT be included in production

6. Output Framework-Specific Implementation

Provide the CSP in the correct format for the detected framework:

Next.jsnext.config.js or next.config.mjs headers() function:

async headers() {
  return [{ source: '/(.*)', headers: [{ key: 'Content-Security-Policy', value: '...' }] }];
}

Nuxtnuxt.config.ts routeRules or a server middleware:

export default defineNuxtConfig({
  routeRules: { '/**': { headers: { 'Content-Security-Policy': '...' } } }
});

Astro — middleware or astro.config.mjs headers integration.

Express.js / Fastify / Hono / Elysia.js — middleware that sets the header on every response.

Vercelvercel.json headers array.

Netlifynetlify.toml [[headers]] section or _headers file.

Cloudflare_headers file for Pages, or Response header manipulation in Workers.

7. Recommend Testing

After generating the CSP, always recommend:

  1. Start with Report-Only — use Content-Security-Policy-Report-Only first to log violations without blocking resources
  2. Test with these tools:
  3. Check the browser console — look for CSP violation reports during development
  4. Switch to enforcing — once no violations appear, change Content-Security-Policy-Report-Only to Content-Security-Policy

Important Notes

  • A CSP that is too strict will break your storefront. Always test in Report-Only mode first.
  • Payment gateway iframes and scripts are the most common source of CSP violations in storefronts. Double-check these.
  • Some frameworks inject inline scripts at build time (e.g., Next.js uses nonces). If the framework has built-in CSP nonce support, prefer nonces over 'unsafe-inline' for script-src.
  • When in doubt, err on the side of a slightly permissive policy that works over a strict policy that breaks checkout.

Further Reading

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 326,984. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.