Token导航 LogoToken导航

Agent Skill · 前端设计

clerk-auth(职员授权)

用于辅助安全审计、权限检查、凭据风险、认证流程和常见漏洞排查。它适合让 Agent 梳理敏感配置、检查依赖风险、分析鉴权逻辑或生成安全复核清单。使用时不能把工具输出直接当最终结论,涉及密钥、令牌、用户数据或生产系统时,应先确认最小权限、脱敏方式和操作边界。

clerk-auth 是前端设计类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为接触敏感数据;许可证为 MIT,第三方扫描有未通过项,按安装量在前端设计类的 10,216 个 Skill 里排第 5,606。

总安装 636周安装 26GitHub Stars 14下载 204核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
MIT

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:clerk-auth(职员授权)
来源仓库:https://github.com/jackspace/claudeskillz
仓库路径:skills/clerk-auth
安装命令:
npx skills add https://github.com/jackspace/claudeskillz --skill clerk-auth
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/jackspace/claudeskillz --skill clerk-auth

这个 Skill 是做什么的

前端设计类 Skill 关注页面结构、视觉规范和组件写法,输出通常是可运行的界面代码。

clerk-auth 用于辅助安全审计和权限检查,帮助梳理敏感配置和鉴权逻辑。适用于需要排查凭据风险、认证流程漏洞或生成安全复核清单的场景。通过 npx skills add 命令从指定仓库安装,需确认权限范围和操作边界。使用时不能将工具输出直接当作最终结论,涉及密钥或生产系统时应先确认最小权限。

可结合原始 README 和仓库内容进一步核验具体功能和使用方式。

来源仓库内路径:skills/clerk-auth

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/jackspace/claudeskillz --skill clerk-auth;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要接触敏感数据,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

clerk-auth 怎么安装?

在终端执行 npx skills add https://github.com/jackspace/claudeskillz --skill clerk-auth。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

clerk-auth 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

clerk-auth 需要什么权限?

权限级别是接触敏感数据。该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

clerk-auth 是免费的吗?

来源标注的许可证是 MIT。本站不代收任何费用,也不托管安装包;能否商用、要不要署名,以许可证原文为准。

clerk-auth 用的人多吗?

公开数据是累计安装 636 次,近一周安装 26 次,下载 204 次,GitHub 14 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

clerk-auth 安全吗?

第三方扫描有未通过项,风险较高。除非你确认过源码,否则不建议直接安装到常用环境。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 3 个目录同时收录,说明这个 Skill 流传比较广。
  • 许可证明确为 MIT,商用和分发边界好判断。

先想清楚的地方

  • 需要接触敏感数据,装到常用环境前要先评估影响面。
  • 第三方扫描存在提醒项或未通过项,需要人工逐条确认。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理前端设计类任务、又不想每次都手写提示词的人。

不太适合

  • 环境里有大量密钥、凭证,不方便给第三方 Skill 读取的人。
  • 需要厂商级技术支持和 SLA 的生产系统。

前端设计类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
frontend-design

前端设计 · Codex、Claude

8,823,360126,072只读MIT通过
vercel-composition-patterns

Vercel 组合模式 · Codex、Claude

3,858,81625,893需要联网MIT通过
vercel-react-native-skills

Vercel React native skills 前端 · Codex、Claude

2,468,66425,878只读MIT通过
adapt

adapt 搜索 · Codex、Claude

2,027,04023,125操作浏览器未明确通过
bolder

bolder 分析 · Codex、Claude

2,004,28823,130只读未明确通过
clerk-auth

职员授权 · 本页

63614接触敏感数据MIT未通过

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

Clerk Authentication

Status: Production Ready ✅ Last Updated: 2025-10-28 Dependencies: None Latest Versions: @clerk/nextjs@6.33.3, @clerk/backend@2.17.2, @clerk/clerk-react@5.51.0, @clerk/testing@1.4.4


Quick Start (10 Minutes)

Choose your framework:


React (Vite) Setup

1. Install Clerk


**Latest Version**: @clerk/clerk-react@5.51.0 (verified 2025-10-22)

### 2. Configure ClerkProvider

Update `src/main.tsx`:

// Get publishable key from environment const PUBLISHABLE_KEY = import.meta.env.VITE_CLERK_PUBLISHABLE_KEY

if (!PUBLISHABLE_KEY) {throw new Error('Missing Publishable Key')}

ReactDOM.createRoot(document.getElementById('root')!).render(<React.StrictMode> </React.StrictMode>,) ```

CRITICAL:

3. Add Environment Variables

Create .env.local:


**Security Note**: Only `VITE_` prefixed vars are exposed to client code.

### 4. Use Authentication Hooks

function App() {// Get user object (includes email, metadata, etc.) const {isLoaded, isSignedIn, user} = useUser()

// Get auth state and session methods const {userId, sessionId, getToken} = useAuth()

// Get Clerk instance for advanced operations const {openSignIn, signOut} = useClerk()

// Always check isLoaded before rendering auth-dependent UI if (!isLoaded) {return Loading...}

if (!isSignedIn) {return <button onClick={() => openSignIn()}>Sign In}

return (Welcome {user.firstName}! Email: {user.primaryEmailAddress?.emailAddress} <button onClick={() => signOut()}>Sign Out)} ```

Why This Matters:


Next.js App Router Setup

1. Install Clerk


**Latest Version**: @clerk/nextjs@6.33.3 (verified 2025-10-22)

- **New in v6**: Async auth() helper, Next.js 15 support, static rendering by default
- Source: [https://clerk.com/changelog/2024-10-22-clerk-nextjs-v6](https://clerk.com/changelog/2024-10-22-clerk-nextjs-v6)

### 2. Configure Environment Variables

Create `.env.local`:

Optional: Customize sign-in/up pages

NEXT_PUBLIC_CLERK_SIGN_IN_URL=/sign-in NEXT_PUBLIC_CLERK_SIGN_UP_URL=/sign-up NEXT_PUBLIC_CLERK_AFTER_SIGN_IN_URL=/dashboard NEXT_PUBLIC_CLERK_AFTER_SIGN_UP_URL=/onboarding ```

CRITICAL:

3. Add Middleware for Route Protection

Create middleware.ts in project root:


// Define which routes are public (everything else requires auth) const isPublicRoute = createRouteMatcher(['/', '/sign-in(.*)', '/sign-up(.*)', '/api/webhooks(.*)', // Clerk webhooks should be public])

export default clerkMiddleware(async (auth, request) => {// Protect all routes except public ones if (!isPublicRoute(request)) {await auth.protect()}})

export const config = {matcher: [// Skip Next.js internals and static files '/((?!_next|[^?]*\.(?:html?|css|js(?!on)|jpe?g|webp|png|gif|svg|ttf|woff2?|ico|csv|docx?|xlsx?|zip|webmanifest)).*)', // Always run for API routes '/(api|trpc)(.*)',],} ```

**CRITICAL**:

- `auth.protect()` is async in v6 (breaking change from v5)
- `createRouteMatcher()` accepts glob patterns
- Alternative: protect specific routes instead of inverting logic
- Source: [https://clerk.com/docs/reference/nextjs/clerk-middleware](https://clerk.com/docs/reference/nextjs/clerk-middleware)

### 4. Wrap App with ClerkProvider

Update `app/layout.tsx`:

export default function RootLayout({children,}: {children: React.ReactNode}) {return ({children})} ```

5. Use auth() in Server Components


export default async function DashboardPage() {// Get auth state (lightweight) const {userId, sessionId} = await auth()

// Get full user object (heavier, fewer calls) const user = await currentUser()

if (!userId) {return Unauthorized}

return (Dashboard User ID: {userId} Email: {user?.primaryEmailAddress?.emailAddress})} ```

**CRITICAL**:

- `auth()` is async in v6 (breaking change)
- Use `auth()` for lightweight checks
- Use `currentUser()` when you need full user object

---

## Cloudflare Workers Setup

### 1. Install Dependencies

Latest Versions:

  • @clerk/backend@2.17.2 (verified 2025-10-22)
  • hono@4.10.1

2. Configure Environment Variables

Create .dev.vars for local development:


**Production**: Use `wrangler secret put CLERK_SECRET_KEY`

### 3. Implement Token Verification

Create `src/index.ts`:

type Bindings = {CLERK_SECRET_KEY: string CLERK_PUBLISHABLE_KEY: string}

type Variables = {userId: string | null sessionClaims: any | null}

const app = new Hono<{Bindings: Bindings; Variables: Variables}>()

// Middleware: Verify Clerk token app.use('/api/*', async (c, next) => {const authHeader = c.req.header('Authorization')

if (!authHeader) {c.set('userId', null) c.set('sessionClaims', null) return next()}

const token = authHeader.replace('Bearer ', '')

try {const {data, error} = await verifyToken(token, {secretKey: c.env.CLERK_SECRET_KEY, // IMPORTANT: Set authorizedParties to prevent CSRF attacks authorizedParties: '[https://yourdomain.com'],})

if (error) {
  console.error('Token verification failed:', error)
  c.set('userId', null)
  c.set('sessionClaims', null)
} else {
  c.set('userId', data.sub)
  c.set('sessionClaims', data)
}

} catch (err) {console.error('Token verification error:', err) c.set('userId', null) c.set('sessionClaims', null)}

return next()})

// Protected route app.get('/api/protected', (c) => {const userId = c.get('userId')

if (!userId) {return c.json({error: 'Unauthorized'}, 401)}

return c.json({message: 'This is protected', userId, sessionClaims: c.get('sessionClaims'),})})

export default app ```

CRITICAL:


JWT Templates & Custom Claims

Clerk allows customizing JWT (JSON Web Token) structure using templates. This enables integration with third-party services, role-based access control, and multi-tenant applications.

Quick Start: Create a JWT Template

1. Navigate to Clerk Dashboard:

  • Go to Sessions page
  • Click Customize session token
  • Click Create template

2. Define Template:

{
  "user_id": "{{user.id}}",
  "email": "{{user.primary_email_address}}",
  "role": "{{user.public_metadata.role || 'user'}}"
}

3. Use Template in Code:

// Frontend (React/Next.js)
const { getToken } = useAuth()
const token = await getToken({ template: 'my-template' })

// Backend (Cloudflare Workers)
const sessionClaims = c.get('sessionClaims')
const role = sessionClaims?.role

Available Shortcodes

CategoryShortcodesExample
User ID & Name{{user.id}}, {{user.first_name}}, {{user.last_name}}, {{user.full_name}}"John Doe"
Contact{{user.primary_email_address}}, {{user.primary_phone_address}}"john@example.com"
Profile{{user.image_url}}, {{user.username}}, {{user.created_at}}"https://..."
Verification{{user.email_verified}}, {{user.phone_number_verified}}true
Metadata{{user.public_metadata}}, {{user.public_metadata.FIELD}}{"role": "admin"}
Organizationorg_id, org_slug, org_role (in sessionClaims)"org:admin"

Advanced Features

String Interpolation:

{
  "full_name": "{{user.last_name}} {{user.first_name}}",
  "greeting": "Hello, {{user.first_name}}!"
}

Conditional Fallbacks:

{
  "role": "{{user.public_metadata.role || 'user'}}",
  "age": "{{user.public_metadata.age || 18}}",
  "verified": "{{user.email_verified || user.phone_number_verified}}"
}

Nested Metadata with Dot Notation:

{
  "interests": "{{user.public_metadata.profile.interests}}",
  "department": "{{user.public_metadata.department}}"
}

Default Claims (Auto-Included)

Every JWT includes these claims automatically (cannot be overridden):

{
  "azp": "http://localhost:3000",              // Authorized party
  "exp": 1639398300,                            // Expiration time
  "iat": 1639398272,                            // Issued at
  "iss": "https://your-app.clerk.accounts.dev", // Issuer
  "jti": "10db7f531a90cb2faea4",               // JWT ID
  "nbf": 1639398220,                            // Not before
  "sub": "user_1deJLArSTiWiF1YdsEWysnhJLLY"    // User ID
}

Size Limitation: 1.2KB for Custom Claims

Problem: Browser cookies limited to 4KB. Clerk's default claims consume ~2.8KB, leaving 1.2KB for custom claims.

⚠️ Development Note: When testing custom claims in Vite dev mode, you may encounter "431 Request Header Fields Too Large" error. This is caused by Clerk's handshake token in the URL exceeding Vite's 8KB limit. See Issue #11 for solution.

Solution:

// ✅ GOOD: Minimal claims
{
  "user_id": "{{user.id}}",
  "email": "{{user.primary_email_address}}",
  "role": "{{user.public_metadata.role}}"
}

// ❌ BAD: Exceeds limit
{
  "bio": "{{user.public_metadata.bio}}",  // 6KB field
  "all_metadata": "{{user.public_metadata}}"  // Entire object
}

Best Practice: Store large data in database, include only identifiers/roles in JWT.

TypeScript Type Safety

Add global type declarations for auto-complete:

Create types/globals.d.ts:

export {}

declare global {
  interface CustomJwtSessionClaims {
    metadata: {
      role?: 'admin' | 'moderator' | 'user'
      onboardingComplete?: boolean
      organizationId?: string
    }
  }
}

Common Use Cases

Role-Based Access Control:

{
  "email": "{{user.primary_email_address}}",
  "role": "{{user.public_metadata.role || 'user'}}",
  "permissions": "{{user.public_metadata.permissions}}"
}

Multi-Tenant Applications:

{
  "user_id": "{{user.id}}",
  "org_id": "{{user.public_metadata.org_id}}",
  "org_role": "{{user.public_metadata.org_role}}"
}

Supabase Integration:

{
  "email": "{{user.primary_email_address}}",
  "app_metadata": {
    "provider": "clerk"
  },
  "user_metadata": {
    "full_name": "{{user.full_name}}"
  }
}

See Also

  • Complete Reference: See references/jwt-claims-guide.md for comprehensive documentation
  • Template Examples: See templates/jwt/ directory for working examples
  • TypeScript Types: See templates/typescript/custom-jwt-types.d.ts
  • Official Docs: https://clerk.com/docs/guides/sessions/jwt-templates

Testing

Clerk provides comprehensive testing tools for local development and CI/CD pipelines.

Quick Start: Test Credentials

Test Emails (no emails sent, fixed OTP):

john+clerk_test@example.com
jane+clerk_test@gmail.com

Test Phone Numbers (no SMS sent, fixed OTP):

+12015550100
+19735550133

Fixed OTP Code: 424242 (works for all test credentials)

Generate Session Tokens

For testing API endpoints, generate valid session tokens (60-second lifetime):

# Using the provided script
CLERK_SECRET_KEY=sk_test_... node scripts/generate-session-token.js

# Create new test user
CLERK_SECRET_KEY=sk_test_... node scripts/generate-session-token.js --create-user

# Auto-refresh token every 50 seconds
CLERK_SECRET_KEY=sk_test_... node scripts/generate-session-token.js --refresh

Manual Flow:

  1. Create user: POST /v1/users
  2. Create session: POST /v1/sessions
  3. Generate token: POST /v1/sessions/{session_id}/tokens
  4. Use in header: Authorization: Bearer <token>

E2E Testing with Playwright

Install @clerk/testing for automatic Testing Token management:

npm install -D @clerk/testing

Global Setup (global.setup.ts):

import { clerkSetup } from '@clerk/testing/playwright'
import { test as setup } from '@playwright/test'

setup('global setup', async ({}) => {
  await clerkSetup()
})

Test File (auth.spec.ts):

import { setupClerkTestingToken } from '@clerk/testing/playwright'
import { test } from '@playwright/test'

test('sign up', async ({ page }) => {
  await setupClerkTestingToken({ page })

  await page.goto('/sign-up')
  await page.fill('input[name="emailAddress"]', 'test+clerk_test@example.com')
  await page.fill('input[name="password"]', 'TestPassword123!')
  await page.click('button[type="submit"]')

  // Verify with fixed OTP
  await page.fill('input[name="code"]', '424242')
  await page.click('button[type="submit"]')

  await expect(page).toHaveURL('/dashboard')
})

Testing Tokens (Bot Detection Bypass)

Testing Tokens bypass bot detection in test suites.

Obtain Token:

curl -X POST https://api.clerk.com/v1/testing_tokens \
  -H "Authorization: Bearer sk_test_..."

Use in Frontend API Requests:

POST https://your-app.clerk.accounts.dev/v1/client/sign_ups?__clerk_testing_token=TOKEN

Note: @clerk/testing handles this automatically for Playwright/Cypress.

Production Limitations

Testing Tokens work in both development and production, but:

  • ❌ Code-based auth (SMS/Email OTP) not supported in production
  • ✅ Email + password authentication supported
  • ✅ Magic links supported

See Also


Known Issues Prevention

This skill prevents 11 documented issues:

Issue #1: Missing Clerk Secret Key

Error: "Missing Clerk Secret Key or API Key" Source: https://stackoverflow.com/questions/77620604 Prevention: Always set in .env.local or via wrangler secret put

Issue #2: API Key → Secret Key Migration

Error: "apiKey is deprecated, use secretKey" Source: https://clerk.com/docs/upgrade-guides/core-2/backend Prevention: Replace apiKey with secretKey in all calls

Issue #3: JWKS Cache Race Condition

Error: "No JWK available" Source: https://github.com/clerk/javascript/blob/main/packages/backend/CHANGELOG.md Prevention: Use @clerk/backend@2.17.2 or later (fixed)

Issue #4: Missing authorizedParties (CSRF)

Error: No error, but CSRF vulnerability Source: https://clerk.com/docs/reference/backend/verify-token Prevention: Always set authorizedParties: ['[https://yourdomain.com']](https://yourdomain.com'%5D%60)

Issue #5: Import Path Changes (Core 2)

Error: "Cannot find module" Source: https://clerk.com/docs/upgrade-guides/core-2/backend Prevention: Update import paths for Core 2

Issue #6: JWT Size Limit Exceeded

Error: Token exceeds size limit Source: https://clerk.com/docs/backend-requests/making/custom-session-token Prevention: Keep custom claims under 1.2KB

Issue #7: Deprecated API Version v1

Error: "API version v1 is deprecated" Source: https://clerk.com/docs/upgrade-guides/core-2/backend Prevention: Use latest SDK versions (API v2025-04-10)

Issue #8: ClerkProvider JSX Component Error

Error: "cannot be used as a JSX component" Source: https://stackoverflow.com/questions/79265537 Prevention: Ensure React 19 compatibility with @clerk/clerk-react@5.51.0+

Issue #9: Async auth() Helper Confusion

Error: "auth() is not a function" Source: https://clerk.com/changelog/2024-10-22-clerk-nextjs-v6 Prevention: Always await: const {userId} = await auth()

Issue #10: Environment Variable Misconfiguration

Error: "Missing Publishable Key" or secret leaked Prevention: Use correct prefixes (NEXT_PUBLIC_, VITE_), never commit secrets

Issue #11: 431 Request Header Fields Too Large (Vite Dev Mode)

Error: "431 Request Header Fields Too Large" when signing in Source: Common in Vite dev mode when testing custom JWT claims Cause: Clerk's __clerk_handshake token in URL exceeds Vite's 8KB header limit Prevention:

Add to package.json: ``json {"scripts": {"dev": "NODE_OPTIONS='--max-http-header-size=32768' vite"}} ``

Temporary Workaround: Clear browser cache, sign out, sign back in

Why: Clerk dev tokens are larger than production; custom JWT claims increase handshake token size

Note: This is different from Issue #6 (session token size). Issue #6 is about cookies (1.2KB), this is about URL parameters in dev mode (8KB → 32KB).


Critical Rules

Always Do

✅ Set authorizedParties when verifying tokens ✅ Use CLERK_SECRET_KEY environment variable ✅ Check isLoaded before rendering auth UI ✅ Use getToken() fresh for each request ✅ Await auth() in Next.js v6+ ✅ Use NEXT_PUBLIC_ prefix for client vars only ✅ Store secrets via wrangler secret put ✅ Implement middleware for route protection ✅ Use API version 2025-04-10 or later

Never Do

❌ Store CLERK_SECRET_KEY in client code ❌ Use deprecated apiKey parameter ❌ Store tokens in localStorage ❌ Skip authorizedParties check ❌ Exceed 1.2KB for custom JWT claims ❌ Forget to check isLoaded ❌ Expose secrets with NEXT_PUBLIC_ prefix ❌ Use API version v1


Official Documentation


Package Versions (Verified 2025-10-22)

平台分布

Claude Code

27.86%
按下载量换算57

windsurf

22.01%
按下载量换算45

OpenCode

16.93%
按下载量换算35

Codex

13.39%
按下载量换算27

Antigravity

7.48%
按下载量换算15

Gemini CLI

3.56%
按下载量换算7

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

未通过

权限和风险

接触敏感数据

该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在提醒或未通过项,安装前请自行复核。

继续浏览同类 Skills