plugins/clerk-auth-master/skills/clerk-environments-deployment/SKILL.md
Use for Clerk dev/prod readiness, deployment, and multi-language implementation planning. PROACTIVELY activate for environment variables, pk_test/sk_test vs pk_live/sk_live, local dev, preview/staging/prod instances, domains/DNS, redirects, OAuth credentials, custom domains/proxy, authorizedParties, CSP, CORS/cookies, webhooks/tunnels, Vercel/Netlify/Cloudflare/API gateways, monitoring/troubleshooting, and backends in Node/Express/Fastify, Python/FastAPI/Django/Flask, Go, Ruby/Rails, Java/Spring, .NET, PHP/Laravel. Provides checklists, rollout plans, and language-portable patterns.
npx skillsauth add JosiahSiegel/claude-plugin-marketplace clerk-environments-deploymentInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Use this skill when the task is broader than a single framework: development vs production setup, deployment readiness, custom domains, DNS, redirects, CORS/cookies, webhooks, CSP, monitoring, incident response, or multi-language backend architecture.
Clerk integrations often work locally and fail in production because keys, domains, redirects, OAuth credentials, webhook secrets, proxy headers, or CSP are environment-specific. Treat environment design as part of the auth implementation, not a deployment afterthought.
Use separate Clerk instances for development and production. For staging/preview, decide explicitly whether to use a separate staging Clerk instance or a constrained development instance. Avoid sharing a production instance with untrusted preview URLs unless there is a strong reason and hardened allowlists.
Key prefixes are a fast sanity check:
| Key type | Development | Production | Exposure |
|---|---|---|---|
| Publishable key | pk_test_... | pk_live_... | Client-safe |
| Secret key | sk_test_... | sk_live_... | Server-only |
| Webhook signing secret | whsec_... | whsec_... per endpoint/instance | Server-only |
| Encryption key | random secret | random secret | Server-only |
Never mix pk_test_ with sk_live_, pk_live_ with sk_test_, or webhook secrets from another endpoint/instance.
.env.local/local secret storage for dev keys only.NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY for Next.js client exposure and CLERK_SECRET_KEY for server-only use..env files, logs with tokens, or tunnel URLs that imply private infrastructure.token-not-active-yet/token-expired errors. For container time resync recipes (WSL2 timedatectl, Docker Desktop restart, docker exec date -s), load the clerk-clock-skew-jwt skill.Preview deployments introduce dynamic hosts. Decide how those hosts map to Clerk settings.
Before going live:
authorizedParties for cross-subdomain safety.Clerk production keys use pk_live_ and sk_live_. DNS propagation can take time, so schedule domain validation before launch.
Production Clerk domains require DNS access. Clerk uses DNS records for session management and domain-verified emails. If using Cloudflare, certain Clerk validation records may need DNS-only mode so validation can complete.
When a Frontend API CNAME cannot be added, use Clerk's documented proxy option. Validate:
/__clerk/(.*) or the custom proxy path.Host, Origin, Referer, Authorization, User-Agent, X-Forwarded-Host, and X-Forwarded-Proto/CloudFront-Forwarded-Proto.For subdomains, setting a root domain can enable sessions across subdomains. Configure a subdomain allowlist and authorizedParties to reduce cross-subdomain risk.
Redirects are an auth security boundary. Validate:
Choose one request model per API surface:
await getToken().Authorization: Bearer <token>.Authorization header.Authorization.If the app uses Content Security Policy, update it for Clerk features in use:
Keep CSP as narrow as possible and verify in report-only mode before enforcing in production.
Use official SDKs/middleware where available. For unsupported framework combinations, follow Clerk's documented token verification rules and the same server-side trust boundary.
| Runtime | Recommended shape | Common failure |
|---|---|---|
| Node/Express | @clerk/express clerkMiddleware(), getAuth(req), requireAuth() | Middleware registered after routes |
| Node/Fastify | Clerk Fastify clerkPlugin(), request.auth, getAuth(request) | Assuming Express APIs exist in Fastify |
| Next.js | @clerk/nextjs auth(), currentUser(), auth.protect() | clerkMiddleware() installed but no protection logic |
| Python/FastAPI | Dependency verifies token and returns auth context | Decoding JWT without verification or missing CORS Authorization header |
| Python/Django/Flask | Middleware/decorator verifies token and attaches auth state | Trusting user ID from request body |
| Go | HTTP middleware verifies token and stores auth in context.Context | Ignoring issuer/audience/key rotation |
| Ruby/Rails | Rack/controller concern verifies token and sets current auth | Leaking server secrets to assets/frontend env |
| Java/Spring | Servlet filter/Spring Security provider populates SecurityContext | Treating any valid JWT as a Clerk token without issuer/audience checks |
| C#/.NET | JWT bearer/custom auth handler populates ClaimsPrincipal and policies | Missing token-type/org authorization policies |
| PHP/Laravel | HTTP middleware verifies token; policies/gates enforce resource access | Using client-submitted org/user IDs for authorization |
Manual verification must validate signature, issuer, audience/authorized party as applicable, expiration, not-before, token type, and key rotation behavior. Claims are untrusted until all checks pass.
For each protected resource, define:
has().Default-deny unknown roles, absent org context, wrong token type, pending sessions, stale memberships, and missing entitlements.
2xx only after durable accept/queue.When auth breaks after deployment:
Authorization: Bearer.Authorization and forwarded host/proto headers.404 is not being mistaken for missing route.Log route, environment, Clerk instance ID, user/org IDs only after verification, token type, status, and correlation ID. Redact tokens, cookies, session IDs, secret keys, and webhook signatures.
If a Clerk secret or token leaks:
If a production deploy breaks auth:
development
Use for Clerk sessions, tokens, webhooks, orgs, and security. PROACTIVELY activate for session tokens, JWT templates, getToken(), custom claims, pending sessions, multi-session UX, organizations, roles, permissions, system vs custom permissions, features/plans, MFA/passkeys/password policy/bot protection, Clerk webhooks, Svix signatures, verifyWebhook(), user/org sync, retries/replays, environment variables, custom domains, secret rotation, logs, and auth security reviews. Provides token semantics, webhook idempotency, authorization defaults, and hardening checklist.
tools
Use for Clerk in Next.js. PROACTIVELY activate for @clerk/nextjs setup, App Router auth()/currentUser(), clerkMiddleware(), proxy.ts/middleware.ts, createRouteMatcher(), protected pages/layouts/Route Handlers/Server Actions/API routes/tRPC, auth.protect() role/permission/token checks, ClerkProvider placement, server-only clerkClient, Link prefetch, redirects, 401/404 auth failures, custom domains, __clerk proxy paths, and deployment gotchas. Provides file patterns, server/client boundary rules, matcher templates, and production checks.
development
Use for Clerk frontend auth flows. PROACTIVELY activate for React, JavaScript, Vue, Nuxt, Astro, Expo, React Router, TanStack React Start, or SPA setup; ClerkProvider and publishable-key wiring; SignIn/SignUp/UserButton/UserProfile/OrganizationSwitcher; custom useUser/useAuth/useClerk/useSignIn/useSignUp/useSession/useOrganization flows; multi-session UX; cross-origin getToken() fetches; loading states, redirects, routing, CORS/cookies, or hydration bugs. Provides SDK selection, UI patterns, token-fetch templates, and frontend gotchas.
development
Use for Clerk JWT and session token clock-skew issues. PROACTIVELY activate for "token-not-active-yet", "JWT cannot be used prior to not before", token-expired, nbf/iat/exp claim failures, clockSkewInMs in verifyToken/authenticateRequest, local dev container/WSL2/Docker Desktop time drift, NTP misconfiguration, paused VM clock, serverless cold-start clock issues, custom JWT template verification leeway across Node/Python/Go/Ruby/Java/.NET/PHP, debugging iat vs server-time delta, and separating real expiry from clock skew. Provides nbf/iat/exp semantics, Clerk and library clock-tolerance defaults, container time fix recipes, multi-language leeway patterns, diagnostics, and gotchas.