[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M78YFGS3653EHPGJ66QBZXBD":3,"skill-same:01M78YFGS3653EHPGJ66QBZXBD":57},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":34,"commitSha":35,"skillDirectory":36,"forksCount":37,"repositoryHtmlUrl":38,"repositoryHomepageUrl":6,"ownerHtmlUrl":39,"ownerBlogUrl":40,"ownerDescription":41,"updatedAt":42,"install":43,"resources":56},"01M78YFGS3653EHPGJ66QBZXBD","clerk-sdk-patterns",null,"Common Clerk SDK patterns and best practices.\nUse when implementing authentication flows, accessing user data,\nor integrating Clerk SDK methods in your application.\nTrigger with phrases like \"clerk SDK\", \"clerk patterns\",\n\"clerk best practices\", \"clerk API usage\".","jukeyman\u002Fjukeyman-skills","jukeyman","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F142960420?v=4","01M78FR4Y3DHMMCBCC0GXXNB3F","RICK JEFFERSON","01M78FR4Z8RVQRAD31Y5J7V6EB",1,"MIT","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fsaas-packs--clerk-pack--clerk-sdk-patterns\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: clerk-sdk-patterns\ndescription: |\n  Common Clerk SDK patterns and best practices.\n  Use when implementing authentication flows, accessing user data,\n  or integrating Clerk SDK methods in your application.\n  Trigger with phrases like \"clerk SDK\", \"clerk patterns\",\n  \"clerk best practices\", \"clerk API usage\".\nallowed-tools: Read, Write, Edit, Grep\nversion: 1.0.0\nlicense: MIT\nauthor: Jeremy Longshore \u003Cjeremy@intentsolutions.io>\ncompatible-with: claude-code, codex, openclaw\ntags: [saas, clerk, api, authentication]\n---\n# Clerk SDK Patterns\n\n## Overview\nCommon patterns and best practices for using the Clerk SDK effectively across server components, client components, API routes, and middleware.\n\n## Prerequisites\n- Clerk SDK installed and configured\n- Basic understanding of React\u002FNext.js\n- ClerkProvider wrapping application\n\n## Instructions\n\n### Pattern 1: Server-Side Authentication\n```typescript\n\u002F\u002F Server Component — use auth() for lightweight checks\nimport { auth } from '@clerk\u002Fnextjs\u002Fserver'\n\nexport default async function ServerPage() {\n  const { userId, orgId, has } = await auth()\n\n  if (!userId) return \u003Cdiv>Not authenticated\u003C\u002Fdiv>\n  if (!has({ permission: 'org:posts:create' })) return \u003Cdiv>No permission\u003C\u002Fdiv>\n\n  return \u003Cdiv>Authorized content for {userId}\u003C\u002Fdiv>\n}\n```\n\n```typescript\n\u002F\u002F Use currentUser() when you need full user profile data\nimport { currentUser } from '@clerk\u002Fnextjs\u002Fserver'\n\nexport default async function ProfilePage() {\n  const user = await currentUser()\n  if (!user) return null\n\n  return (\n    \u003Cdiv>\n      \u003Ch1>{user.firstName} {user.lastName}\u003C\u002Fh1>\n      \u003Cp>{user.emailAddresses[0]?.emailAddress}\u003C\u002Fp>\n      \u003Cimg src={user.imageUrl} alt=\"Avatar\" \u002F>\n    \u003C\u002Fdiv>\n  )\n}\n```\n\n### Pattern 2: Client-Side Hooks\n```typescript\n'use client'\nimport { useUser, useAuth, useClerk, useSignIn } from '@clerk\u002Fnextjs'\n\nexport function ClientAuthExample() {\n  const { user, isLoaded, isSignedIn } = useUser()       \u002F\u002F Full user object\n  const { userId, getToken, signOut } = useAuth()          \u002F\u002F Auth state + token access\n  const { openSignIn, openUserProfile } = useClerk()       \u002F\u002F UI controls\n\n  if (!isLoaded) return \u003Cdiv>Loading...\u003C\u002Fdiv>\n  if (!isSignedIn) return \u003Cbutton onClick={() => openSignIn()}>Sign In\u003C\u002Fbutton>\n\n  const fetchWithAuth = async (url: string) => {\n    const token = await getToken()\n    return fetch(url, {\n      headers: { Authorization: `Bearer ${token}` },\n    })\n  }\n\n  return (\n    \u003Cdiv>\n      \u003Cp>Hello, {user.firstName}\u003C\u002Fp>\n      \u003Cbutton onClick={() => openUserProfile()}>Profile\u003C\u002Fbutton>\n      \u003Cbutton onClick={() => signOut()}>Sign Out\u003C\u002Fbutton>\n    \u003C\u002Fdiv>\n  )\n}\n```\n\n### Pattern 3: Protected Routes with Middleware\n```typescript\n\u002F\u002F middleware.ts\nimport { clerkMiddleware, createRouteMatcher } from '@clerk\u002Fnextjs\u002Fserver'\n\nconst isPublicRoute = createRouteMatcher([\n  '\u002F',\n  '\u002Fpricing',\n  '\u002Fsign-in(.*)',\n  '\u002Fsign-up(.*)',\n  '\u002Fapi\u002Fwebhooks(.*)',\n])\n\nexport default clerkMiddleware(async (auth, req) => {\n  if (!isPublicRoute(req)) {\n    await auth.protect()\n  }\n})\n```\n\n### Pattern 4: Organization-Aware Queries\n```typescript\n\u002F\u002F lib\u002Fdb-helpers.ts\nimport { auth } from '@clerk\u002Fnextjs\u002Fserver'\n\nexport async function getOrgData() {\n  const { userId, orgId } = await auth()\n\n  if (orgId) {\n    \u002F\u002F Org-scoped query: return data for the active organization\n    return db.items.findMany({ where: { organizationId: orgId } })\n  }\n\n  \u002F\u002F Personal account: return user's own data\n  return db.items.findMany({ where: { ownerId: userId } })\n}\n```\n\n### Pattern 5: Custom JWT Templates for External Services\n```typescript\n\u002F\u002F Generate a Supabase-compatible JWT\nimport { auth } from '@clerk\u002Fnextjs\u002Fserver'\nimport { createClient } from '@supabase\u002Fsupabase-js'\n\nexport async function getSupabaseClient() {\n  const { getToken } = await auth()\n  const supabaseToken = await getToken({ template: 'supabase' })\n\n  return createClient(\n    process.env.NEXT_PUBLIC_SUPABASE_URL!,\n    process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,\n    {\n      global: {\n        headers: { Authorization: `Bearer ${supabaseToken}` },\n      },\n    }\n  )\n}\n```\n\nConfigure the JWT template in Clerk Dashboard > JWT Templates with claims:\n```json\n{\n  \"sub\": \"{{user.id}}\",\n  \"email\": \"{{user.primary_email_address}}\",\n  \"role\": \"authenticated\"\n}\n```\n\n## Output\n- Server and client authentication patterns ready to use\n- Protected route middleware with public route exceptions\n- Organization-aware data queries\n- Custom JWT tokens for third-party integrations (Supabase, Hasura, etc.)\n\n## Error Handling\n| Error | Cause | Solution |\n|-------|-------|----------|\n| `auth()` returns null userId | Not in server context | Use only in Server Components or API routes |\n| `useUser()` not updating | Stale component | Check ClerkProvider wraps the component tree |\n| `getToken()` fails | JWT template not configured | Create template in Dashboard > JWT Templates |\n| `orgId` is null | No organization selected | Prompt user with `\u003COrganizationSwitcher \u002F>` |\n\n## Examples\n\n### Server Action with Auth Check\n```typescript\n'use server'\nimport { auth } from '@clerk\u002Fnextjs\u002Fserver'\n\nexport async function createPost(title: string, content: string) {\n  const { userId, orgId } = await auth()\n  if (!userId) throw new Error('Unauthorized')\n\n  return db.post.create({\n    data: { title, content, authorId: userId, orgId },\n  })\n}\n```\n\n## Resources\n- [Clerk SDK Reference](https:\u002F\u002Fclerk.com\u002Fdocs\u002Freferences\u002Fnextjs\u002Foverview)\n- [Auth Helper](https:\u002F\u002Fclerk.com\u002Fdocs\u002Freferences\u002Fnextjs\u002Fauth)\n- [JWT Templates](https:\u002F\u002Fclerk.com\u002Fdocs\u002Fbackend-requests\u002Fmaking\u002Fjwt-templates)\n\n## Next Steps\nProceed to `clerk-core-workflow-a` for user sign-up and sign-in flows.\n","# Clerk SDK Patterns\n\n## Overview\nCommon patterns and best practices for using the Clerk SDK effectively across server components, client components, API routes, and middleware.\n\n## Prerequisites\n- Clerk SDK installed and configured\n- Basic understanding of React\u002FNext.js\n- ClerkProvider wrapping application\n\n## Instructions\n\n### Pattern 1: Server-Side Authentication\n```typescript\n\u002F\u002F Server Component — use auth() for lightweight checks\nimport { auth } from '@clerk\u002Fnextjs\u002Fserver'\n\nexport default async function ServerPage() {\n  const { userId, orgId, has } = await auth()\n\n  if (!userId) return \u003Cdiv>Not authenticated\u003C\u002Fdiv>\n  if (!has({ permission: 'org:posts:create' })) return \u003Cdiv>No permission\u003C\u002Fdiv>\n\n  return \u003Cdiv>Authorized content for {userId}\u003C\u002Fdiv>\n}\n```\n\n```typescript\n\u002F\u002F Use currentUser() when you need full user profile data\nimport { currentUser } from '@clerk\u002Fnextjs\u002Fserver'\n\nexport default async function ProfilePage() {\n  const user = await currentUser()\n  if (!user) return null\n\n  return (\n    \u003Cdiv>\n      \u003Ch1>{user.firstName} {user.lastName}\u003C\u002Fh1>\n      \u003Cp>{user.emailAddresses[0]?.emailAddress}\u003C\u002Fp>\n      \u003Cimg src={user.imageUrl} alt=\"Avatar\" \u002F>\n    \u003C\u002Fdiv>\n  )\n}\n```\n\n### Pattern 2: Client-Side Hooks\n```typescript\n'use client'\nimport { useUser, useAuth, useClerk, useSignIn } from '@clerk\u002Fnextjs'\n\nexport function ClientAuthExample() {\n  const { user, isLoaded, isSignedIn } = useUser()       \u002F\u002F Full user object\n  const { userId, getToken, signOut } = useAuth()          \u002F\u002F Auth state + token access\n  const { openSignIn, openUserProfile } = useClerk()       \u002F\u002F UI controls\n\n  if (!isLoaded) return \u003Cdiv>Loading...\u003C\u002Fdiv>\n  if (!isSignedIn) return \u003Cbutton onClick={() => openSignIn()}>Sign In\u003C\u002Fbutton>\n\n  const fetchWithAuth = async (url: string) => {\n    const token = await getToken()\n    return fetch(url, {\n      headers: { Authorization: `Bearer ${token}` },\n    })\n  }\n\n  return (\n    \u003Cdiv>\n      \u003Cp>Hello, {user.firstName}\u003C\u002Fp>\n      \u003Cbutton onClick={() => openUserProfile()}>Profile\u003C\u002Fbutton>\n      \u003Cbutton onClick={() => signOut()}>Sign Out\u003C\u002Fbutton>\n    \u003C\u002Fdiv>\n  )\n}\n```\n\n### Pattern 3: Protected Routes with Middleware\n```typescript\n\u002F\u002F middleware.ts\nimport { clerkMiddleware, createRouteMatcher } from '@clerk\u002Fnextjs\u002Fserver'\n\nconst isPublicRoute = createRouteMatcher([\n  '\u002F',\n  '\u002Fpricing',\n  '\u002Fsign-in(.*)',\n  '\u002Fsign-up(.*)',\n  '\u002Fapi\u002Fwebhooks(.*)',\n])\n\nexport default clerkMiddleware(async (auth, req) => {\n  if (!isPublicRoute(req)) {\n    await auth.protect()\n  }\n})\n```\n\n### Pattern 4: Organization-Aware Queries\n```typescript\n\u002F\u002F lib\u002Fdb-helpers.ts\nimport { auth } from '@clerk\u002Fnextjs\u002Fserver'\n\nexport async function getOrgData() {\n  const { userId, orgId } = await auth()\n\n  if (orgId) {\n    \u002F\u002F Org-scoped query: return data for the active organization\n    return db.items.findMany({ where: { organizationId: orgId } })\n  }\n\n  \u002F\u002F Personal account: return user's own data\n  return db.items.findMany({ where: { ownerId: userId } })\n}\n```\n\n### Pattern 5: Custom JWT Templates for External Services\n```typescript\n\u002F\u002F Generate a Supabase-compatible JWT\nimport { auth } from '@clerk\u002Fnextjs\u002Fserver'\nimport { createClient } from '@supabase\u002Fsupabase-js'\n\nexport async function getSupabaseClient() {\n  const { getToken } = await auth()\n  const supabaseToken = await getToken({ template: 'supabase' })\n\n  return createClient(\n    process.env.NEXT_PUBLIC_SUPABASE_URL!,\n    process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,\n    {\n      global: {\n        headers: { Authorization: `Bearer ${supabaseToken}` },\n      },\n    }\n  )\n}\n```\n\nConfigure the JWT template in Clerk Dashboard > JWT Templates with claims:\n```json\n{\n  \"sub\": \"{{user.id}}\",\n  \"email\": \"{{user.primary_email_address}}\",\n  \"role\": \"authenticated\"\n}\n```\n\n## Output\n- Server and client authentication patterns ready to use\n- Protected route middleware with public route exceptions\n- Organization-aware data queries\n- Custom JWT tokens for third-party integrations (Supabase, Hasura, etc.)\n\n## Error Handling\n| Error | Cause | Solution |\n|-------|-------|----------|\n| `auth()` returns null userId | Not in server context | Use only in Server Components or API routes |\n| `useUser()` not updating | Stale component | Check ClerkProvider wraps the component tree |\n| `getToken()` fails | JWT template not configured | Create template in Dashboard > JWT Templates |\n| `orgId` is null | No organization selected | Prompt user with `\u003COrganizationSwitcher \u002F>` |\n\n## Examples\n\n### Server Action with Auth Check\n```typescript\n'use server'\nimport { auth } from '@clerk\u002Fnextjs\u002Fserver'\n\nexport async function createPost(title: string, content: string) {\n  const { userId, orgId } = await auth()\n  if (!userId) throw new Error('Unauthorized')\n\n  return db.post.create({\n    data: { title, content, authorId: userId, orgId },\n  })\n}\n```\n\n## Resources\n- [Clerk SDK Reference](https:\u002F\u002Fclerk.com\u002Fdocs\u002Freferences\u002Fnextjs\u002Foverview)\n- [Auth Helper](https:\u002F\u002Fclerk.com\u002Fdocs\u002Freferences\u002Fnextjs\u002Fauth)\n- [JWT Templates](https:\u002F\u002Fclerk.com\u002Fdocs\u002Fbackend-requests\u002Fmaking\u002Fjwt-templates)\n\n## Next Steps\nProceed to `clerk-core-workflow-a` for user sign-up and sign-in flows.\n",{"name":5,"tags":24,"author":29,"license":15,"version":30,"description":31,"allowed-tools":32,"compatible-with":33},[25,26,27,28],"saas","clerk","api","authentication","Jeremy Longshore \u003Cjeremy@intentsolutions.io>","1.0.0","Common Clerk SDK patterns and best practices.\nUse when implementing authentication flows, accessing user data,\nor integrating Clerk SDK methods in your application.\nTrigger with phrases like \"clerk SDK\", \"clerk patterns\",\n\"clerk best practices\", \"clerk API usage\".\n","Read, Write, Edit, Grep","claude-code, codex, openclaw","main","99825ad3f3bcc6597ddcc7294a14e6e922f2b67b","skills\u002Fsaas-packs--clerk-pack--clerk-sdk-patterns",0,"https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills","https:\u002F\u002Fgithub.com\u002Fjukeyman","https:\u002F\u002FRJBUSINESSSOLUTIONS.ORG","Credit and Finance Expert | Developer\r\n\r\nI'm Rick Jefferson, a seasoned credit and finance expert with over a decade of experience in financial literacy,","2026-07-13 07:03:29",{"source":8,"skillName":5,"commands":44,"prompt":54,"zipAvailable":55},[45,48,51],{"tool":46,"command":47},"npx","npx skills add jukeyman\u002Fjukeyman-skills --skill clerk-sdk-patterns",{"tool":49,"command":50},"bunx","bunx skills add jukeyman\u002Fjukeyman-skills --skill clerk-sdk-patterns",{"tool":52,"command":53},"pnpm","pnpm dlx skills add jukeyman\u002Fjukeyman-skills --skill clerk-sdk-patterns","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fsaas-packs--clerk-pack--clerk-sdk-patterns\u002FSKILL.md",true,[],[58,65,72,79,86,94],{"skillNo":59,"name":60,"nameZh":6,"description":61,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":62,"categories":63,"keywords":64,"publishedAt":19},"01M79ANS2SM329NEP5ZCX106RR","zustand-store-creator","Create zustand store creator operations. Auto-activating skill for Frontend Development.\nTriggers on: zustand store creator, zustand store creator\nPart of the Frontend Development skill category. Use when working with zustand store creator functionality. Trigger with phrases like \"zustand store creator\", \"zustand creator\", \"zustand\".","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fzustand-store-creator\u002FSKILL.md",[],[],{"skillNo":66,"name":67,"nameZh":6,"description":68,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":69,"categories":70,"keywords":71,"publishedAt":19},"01M79AMZKP4YDEZ7EHG1Y7PP74","zero-trust-config-helper","Configure with zero trust config helper operations. Auto-activating skill for Security Advanced.\nTriggers on: zero trust config helper, zero trust config helper\nPart of the Security Advanced skill category. Use when configuring systems or services. Trigger with phrases like \"zero trust config helper\", \"zero helper\", \"zero\".","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fzero-trust-config-helper\u002FSKILL.md",[],[],{"skillNo":73,"name":74,"nameZh":6,"description":75,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":76,"categories":77,"keywords":78,"publishedAt":19},"01M79AMJSBCEJQNBTYNAHYN5HM","zapier-integration-helper","Assist with zapier integration helper operations. Auto-activating skill for Business Automation.\nTriggers on: zapier integration helper, zapier integration helper\nPart of the Business Automation skill category. Use when working with APIs or building integrations. Trigger with phrases like \"zapier integration helper\", \"zapier helper\", \"zapier\".","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fzapier-integration-helper\u002FSKILL.md",[],[],{"skillNo":80,"name":81,"nameZh":6,"description":82,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":83,"categories":84,"keywords":85,"publishedAt":19},"01M79AHJZGVMARS13VFQYRR1MP","yaml-config-validator","Validate yaml config validator operations. Auto-activating skill for DevOps Basics.\nTriggers on: yaml config validator, yaml config validator\nPart of the DevOps Basics skill category. Use when configuring systems or services. Trigger with phrases like \"yaml config validator\", \"yaml validator\", \"yaml\".","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fyaml-config-validator\u002FSKILL.md",[],[],{"skillNo":87,"name":88,"nameZh":6,"description":89,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":90,"sourceHtmlUrl":91,"categories":92,"keywords":93,"publishedAt":19},"01M79AHGDZRN0020RDQSQDPAM8","xvary-stock-research","Thesis-driven equity analysis from public SEC EDGAR and market data; \u002Fanalyze, \u002Fscore, \u002Fcompare workflows with bundled Python tools (Claude Code, Cursor, Codex).","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fxvary-stock-research\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fxvary-stock-research\u002FSKILL.md",[],[],{"skillNo":95,"name":96,"nameZh":6,"description":97,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":98,"categories":99,"keywords":100,"publishedAt":19},"01M79AHCYJ9FV9RMHQ24HDRN33","xss-vulnerability-scanner","Scan xss vulnerability scanner operations. Auto-activating skill for Security Fundamentals.\nTriggers on: xss vulnerability scanner, xss vulnerability scanner\nPart of the Security Fundamentals skill category. Use when working with xss vulnerability scanner functionality. Trigger with phrases like \"xss vulnerability scanner\", \"xss scanner\", \"xss\".","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fxss-vulnerability-scanner\u002FSKILL.md",[],[]]