Agent skill · software engineering · jeremylongshore
clerk-sdk-patterns
Common Clerk SDK patterns and best practices.
Why this skill is useful
Provides specific patterns and best practices for integrating Clerk SDK in applications, which the AI may not generate reliably on its own.
What it needs
Requires clerk installed locally. About 3k tokens when loaded. Last updated 2026-08-07. 2,604 stars on the source repository.
What this skill does
Clerk SDK Patterns Overview Common patterns and best practices for using the Clerk SDK effectively across server components, client components, API routes, and middleware. Prerequisites Clerk SDK installed and configured Basic understanding of React/Next.js ClerkProvider wrapping application Instructions Pattern 1: Server-Side Authentication Pattern 2: Client-Side Hooks Pattern 3: Protected Routes with Middleware Pattern 4: Organization-Aware Queries Pattern 5: Custom JWT Templates for External Services Configure the JWT template in Clerk Dashboard > JWT Templates with claims: Output Server and client authentication patterns ready to use Protected route middleware with public route exceptions Organization-aware data queries Custom JWT tokens for third-party integrations (Supabase, Hasura, etc.) Error Handling Error Cause Solution ------- ------- ---------- auth() returns null userId Not in server context Use only in Server Components or API routes useUser() not updating Stale component Check ClerkProvider wraps the component tree getToken() fails JWT template not configured Create template in Dashboard > JWT Templates orgId is null No organization selected Prompt user with <OrganizationSwitcher /> Examples Server Action with Auth Check Resources Clerk SDK Reference Auth Helper JWT Templates Next Steps Proceed to clerk-core-workflow-a for user sign-up and sign-in flows.
How to use it
Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:
@skills jeremylongshore/clerk-sdk-patterns