skillissue.sh

house / Clerk + Cloudflare Auth

✓ hosted skill bundleauthv1.1.0MIT3.8 KB
skills/clerk-cloudflare-auth/SKILL.md

A public integration guide for adding Clerk identity to Cloudflare Pages or Workers without leaking deployment credentials.

InstallCLI + MCP
CLIRun from your local shell.
$autovault add jack-arturo/skillissue@775e1e1620d2730c8a67e8b7958448e3e888dfc2:skills/clerk-cloudflare-auth/SKILL.md --sync-profiles
MCPPaste into an agent MCP tool call.
>add_skill({ source: "github", identifier: "jack-arturo/skillissue@775e1e1620d2730c8a67e8b7958448e3e888dfc2:skills/clerk-cloudflare-auth/SKILL.md" })
Choose CLI for a shell install or MCP for an agent tool call.
Source
Example type
bundle
hosted skill bundle
Bundle files
1
SKILL.md + resources
Resources
0
inspectable source files
Declared agents
3
from frontmatter
Source
house
pinned GitHub bundle
SKILL.mdview raw →
---
name: clerk-cloudflare-auth
description: Add Clerk authentication to Cloudflare Pages or Workers apps with protected APIs, session-aware UI, and optional application-side user mapping.
license: MIT
tags: [clerk, cloudflare, auth, pages, workers, vite, d1]
agents: [claude-code, codex, autojack]
category: auth
metadata:
  version: "1.1.0"
capabilities:
  network: true
  filesystem: readwrite
  tools: [Bash, Read, Edit]
requires-secrets:
  - name: CLERK_SECRET_KEY
    description: Server-side Clerk credential, configured through the deployment platform.
    required: true
resources:
  - path: story.md
    type: file
---

Clerk + Cloudflare Auth

Use this skill when a Cloudflare Pages or Workers application needs Clerk login,

session-aware UI, protected API routes, account records, or billing-linked user

mapping. Clerk should own identity; the application should own its domain data

and any billing records.

Secret boundary

Keep provider values in the platform's environment-variable or secret manager.

Do not commit them, paste them into chat, or invent a local credential-store

format. A typical deployment needs these names:

CLERK_SECRET_KEY=<managed server secret>
VITE_CLERK_PUBLISHABLE_KEY=<managed build variable>

The publishable key is intended for the browser but should still be supplied by

the build environment. CLERK_SECRET_KEY belongs only in server-side runtime

configuration. For local development, use ignored environment files and do not

read or print their contents unless the user explicitly asks.

Integration shape

  1. Inspect the application: framework, Pages Functions or Workers entry point, existing session model, public/protected routes, and application records keyed to users or accounts.
  2. Add Clerk's framework package in the client and Clerk's server package where the edge runtime verifies tokens. Follow current official Clerk and Cloudflare documentation for the package-specific initialization API.
  3. Initialize the client from VITE_CLERK_PUBLISHABLE_KEY. Render a clear signed-out fallback if it is absent in a local build.
  4. Verify the session token at every protected Pages Function or Worker route; never treat client-side visibility as authorization.
  5. Map the verified Clerk user or organization ID to D1/application records only where the product needs internal data. Keep Stripe customer and subscription truth in the billing layer rather than duplicating it in identity claims.

Frontend rules

  • Prefer the framework's reactive Clerk APIs over polling global state.
  • Request a fresh token immediately before authenticated API calls.
  • Guard against a late anonymous response replacing a newer signed-in state.
  • Configure Clerk appearance through its supported configuration object, not brittle global CSS overrides.
  • Keep static marketing pages static; add identity only where it is needed.

Edge authorization

At the server boundary, extract and verify the Clerk session token using the

official backend SDK. Return 401 for a missing/invalid session and 403 for

an authenticated user without the required application entitlement. Make route

policy explicit so public webhooks and health endpoints do not accidentally

inherit account-only checks.

Verification

Before deployment, test:

  • Signed-out visitors can reach public pages and cannot call protected APIs.
  • A signed-in test user receives the expected account data.
  • Expired or malformed tokens are rejected by the edge route.
  • Local and preview builds receive the appropriate Clerk environment values.
  • Any D1 user mapping is idempotent and uses the verified Clerk identifier.

Use Cloudflare Commerce Deploy for

provider configuration and Stripe Commerce Checkout

when authentication gates paid product access.

story.md

Why

Identity code gets tangled quickly when frontend state, edge verification, and billing records each invent their own user model.

How

Keep Clerk responsible for identity, verify sessions at the edge, and keep provider values in environment variables managed outside the repository.

Related

Use Cloudflare Commerce Deploy for deployment wiring and Stripe Commerce Checkout for billing.

Bundle contents

Every file declared by this skill is inspectable here. Static resources are previewed from same-origin hosted files; script-like files are shown as text only.

1files
markdownSKILL.md
view raw →

SKILL.md

Primary agent instructions, frontmatter, workflow, and declared resource manifest.

Select a package file to inspect it.

Declared capabilities

network
true
filesystem
readwrite
tools
[Bash, Read, Edit]

Requires: CLERK_SECRET_KEY

Public, pinned, and inspectable

This house package is installed from the pinned Git commit shown here. Inspect the source and every bundled file before you run it.

package pin775e1e1sourceGitHub packagecompatibilityclaude-code, codex, autojack
VersionBundleSourcePinRaw
v1.1.0latest1 files · 3.8 KBhouse775e1e1SKILL.md