/anglesite:membershipfrom anglesite
Gates premium content behind a newsletter signup (free) or Stripe subscription (paid) using signed cookies verified at the Cloudflare edge. For creator economy paywalls, members-only posts, or free email gates.
Ships in anglesite. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description, though model invocation is off: only you can start it.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Add a paywall to the site. Two tiers, both unlock the same tier: premium pages:
Pages marked tier: premium in frontmatter are gated at the edge by the site Worker entry (worker/site-entry.js), which verifies the signed cookie before serving the response. Public visitors see a teaser (configurable) plus an unlock prompt. Inline <Premium> blocks gate sections within otherwise-public pages.
Read EXPLAIN_STEPS from .site-config. If true or not set, explain before every tool call that triggers a permission prompt. If false, proceed without pre-announcing.
If they only need a one-time purchase (an ebook, a download, a print), route to /anglesite:add-store instead — membership is for recurring access to evolving content.
Read .site-config. The following must be set:
CF_PROJECT_NAME — site has been deployed once (Cloudflare account is bound)SITE_DOMAIN — custom domain configured (cookies are scoped to this domain)CONTACT_EMAIL — a billing/support email on fileIf any are missing, tell the owner: "Membership needs your site deployed on a custom domain first. Run /anglesite:deploy once, then come back."
If MEMBERSHIP_WORKER_URL is already set, the backend exists — skip to Step 5 to gate new pages.
Ask: "Which tiers do you want?"
| Option | Backend | Cost to subscriber | Cost to owner |
|---|---|---|---|
| Free only | Newsletter (Buttondown / Mailchimp) | Free (email opt-in) | Newsletter cost only |
| Paid only | Stripe subscription | Owner sets (e.g., $5/mo) | Stripe fees (2.9% + 30¢) |
| Both | Both — paid is a superset | Tiered | Both |
Save to .site-config:
MEMBERSHIP_TIERS=free (or paid, or free,paid)Free tier piggybacks on the newsletter list. If /anglesite:newsletter has not been run yet, run it first — the membership skill needs NEWSLETTER_API_KEY and NEWSLETTER_PLATFORM already configured.
If newsletter is configured, no extra owner work — the membership Worker reuses the same API key to verify list membership.
Tell the owner: "Free tier unlock works like this: a visitor enters their email, we check it's on your newsletter list, and we set a cookie that unlocks premium pages. If they're not subscribed, they get a one-click subscribe button."
Guide the owner:
price_...)https://buy.stripe.com/...)Save to .site-config:
STRIPE_MEMBERSHIP_LINK=https://buy.stripe.com/...STRIPE_PRICE_ID=price_...https://SITE_DOMAIN/accountThe owner provides their secret key (Stripe Dashboard → Developers → API keys → Secret key, starts with sk_live_ or sk_test_). It's stored as a Cloudflare Worker secret, never in the codebase.
Also generate a webhook signing secret in Step 4c below — the Worker uses it to verify Stripe webhook events that mark a subscription as active or canceled.
Tell the owner: "I'm deploying the server that handles the unlock — it verifies the email or payment, signs a cookie, and sends the visitor back to the page they were trying to read."
Create the KV namespace and bind it to the Worker.
Preferred — Cloudflare MCP (no copy-paste):
${CLAUDE_PLUGIN_ROOT}/docs/cloudflare-mcp.md.kv_namespace_create with title: "MEMBERSHIPS". Read the id from the response.id = "<id>" into the [[kv_namespaces]] block in worker/membership-wrangler.toml (binding name MEMBERSHIPS). Save the value to .site-config as MEMBERSHIP_KV_ID=<id> for future reference.Fallback — wrangler CLI (use only if no kv_namespace_create tool is available):
npx wrangler kv namespace create MEMBERSHIPS
Copy the id value from the output and paste it into worker/membership-wrangler.toml under [[kv_namespaces]].
Confirm worker/membership-wrangler.toml no longer contains REPLACE_WITH_KV_NAMESPACE_ID — the deploy in 4b fails while the placeholder is there.
npx wrangler deploy --config worker/membership-wrangler.toml
Capture the printed Worker URL (e.g., https://anglesite-membership.ACCOUNT.workers.dev). Save it to .site-config as MEMBERSHIP_WORKER_URL=https://....
<MEMBERSHIP_WORKER_URL>/webhook/stripecheckout.session.completed, customer.subscription.deleted, customer.subscription.updatedwhsec_) — it becomes STRIPE_WEBHOOK_SECRET in 4eWebhooks are how the Worker knows when a subscription becomes active. The Worker stores active subscriber identifiers in KV (MEMBERSHIPS namespace).
The Worker signs unlock cookies with HMAC. Generate a 32-byte random key:
node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
The printed hex string is MEMBERSHIP_SIGNING_KEY.
Set secrets by following ${CLAUDE_PLUGIN_ROOT}/docs/worker-secrets.md — wrangler secret put prompts for input the shell can't supply. Two Workers need secrets; run the procedure once per Worker.
Membership Worker (--config worker/membership-wrangler.toml):
| Secret | Value | When |
|---|---|---|
MEMBERSHIP_SIGNING_KEY | hex from 4d | always |
SITE_DOMAIN | SITE_DOMAIN from .site-config | always |
MEMBERSHIP_TIERS | MEMBERSHIP_TIERS from .site-config (e.g., free,paid) | always |
NEWSLETTER_API_KEY, NEWSLETTER_PLATFORM | from the newsletter setup | free tier |
MAILCHIMP_LIST_ID | the Mailchimp audience ID | free tier on Mailchimp |
STRIPE_SECRET_KEY | the key from 3d | paid tier |
STRIPE_WEBHOOK_SECRET | the whsec_ value from 4c | paid tier |
Site Worker (the one in wrangler.jsonc — omit --config):
| Secret | Value | When |
|---|---|---|
MEMBERSHIP_SIGNING_KEY | the same hex from 4d | always |
MEMBERSHIP_PREVIEW_TOKEN | MEMBERSHIP_PREVIEW_TOKEN from .site-config | only if set there |
The site Worker verifies cookies issued by the membership Worker. If it doesn't have MEMBERSHIP_SIGNING_KEY, premium routes are served publicly — the gate silently no-ops. Check npx wrangler secret list (no --config) shows it before continuing.
tier: premiumTwo ways to gate content:
In any src/content/posts/*.mdoc (or other gated collection), set:
---
title: "Premium post"
tier: premium
publicPreview: 2 # optional — number of paragraphs visible to non-members
---
The posts collection schema (and Keystatic) already declares tier and publicPreview. The middleware checks the cookie before serving — non-members get a redirect to /unlock?return=<path>.
For pages that should be partly public, wrap a section in <Premium>:
---
import Premium from "../components/Premium.astro";
---
<p>Free intro paragraph everyone sees.</p>
<p>Another free paragraph.</p>
<Premium teaser="The next 3 sections are for members.">
<h2>Members-only details</h2>
<p>Full content here.</p>
</Premium>
The component renders the children server-side only if a valid signed cookie is present in the request. Public visitors see the teaser text and an unlock button.
Read public/_headers. Update:
form-action — append MEMBERSHIP_WORKER_URLconnect-src — append MEMBERSHIP_WORKER_URLIf paid tier is enabled, ensure form-action already permits https://buy.stripe.com (the Payment Link target). Stripe Payment Links are external redirects, not embeds — no frame-src change needed.
The site Worker entry reads worker/_premium-routes.json to know which paths require a member cookie. Regenerate that index from the current tier: premium frontmatter, then build:
npm run ai-premium-build
npm run build
ai-premium-build is safe to re-run any time content changes — it preserves any glob-style entries (e.g. "/members/*") the owner added by hand. Run it before every deploy that touches premium content, or the new pages will be publicly readable until the next regeneration.
Spot-check that:
__anglesite_member cookie is present/unlock page loads at https://SITE_DOMAIN/unlock/account page loads (paid tier only)Run npx astro check to catch any schema typos.
Tell the owner what's live:
/unlock — visitors enter their email (free) or click subscribe (paid)/account — paid members manage billing via Stripe Customer Portal<Premium> blocks — inline gating within public pagesThe Worker signs a JSON payload { tier, exp, sub } with HMAC-SHA256 using MEMBERSHIP_SIGNING_KEY. Cookie name: __anglesite_member. Attributes: Path=/; Secure; HttpOnly; SameSite=Lax; Max-Age=2592000 (30 days).
sub is a SHA-256 hash of the verified email (no PII at rest), tier is free, exp is 30 dayssub is a hash of the Stripe customer ID, tier is paid, exp is 30 daysThe middleware verifies the HMAC and exp on every request. If invalid or expired, the visitor is redirected to /unlock. The Worker re-checks the source of truth (newsletter list or Stripe subscription) before issuing a fresh cookie — so a canceled subscription stops working when the cookie expires.
For instant revocation, the Worker stores active subscriber hashes in KV (MEMBERSHIPS namespace). The Stripe webhook deletes the entry on cancel, and the Worker's /unlock endpoint refuses to issue a fresh cookie for a hash that's not in KV.
?preview=<MEMBERSHIP_PREVIEW_TOKEN> (set in .site-config); the middleware accepts it as a one-time bypass/anglesite:stats reports unlock events from the Worker logs (issue #194 inbox will surface them long-term)MEMBERSHIP_TIERS=free in .site-config, re-run Step 4e for MEMBERSHIP_TIERS, and redeploy. The middleware will stop expecting tier=paid cookiesWhat SKILL.md sets; muted values are Claude Code's defaults
Use when the owner wants members-only content, paywalled posts, or a free-signup gate on premium pages.
Three short reads, in order
npx claudepluginhub anglesite/anglesite-skills --plugin anglesite56 skills in this plugin
/add-storeAdd ecommerce to the site — picks and sets up a provider for physical goods, digital downloads, services, or software/animateDesign CSS animations: hover effects, scroll reveals, page transitions/backupBack up site changes to GitHub, or restore an earlier snapshot/bookingEmbed appointment scheduling (Cal.com or Calendly) into the site/business-infoCollect and display business hours, address, phone, and LocalBusiness JSON-LD/buy-buttonAdd a buy button to sell a product, service, or digital good (Stripe or Polar)Other plugins' skills for the same job