clerk-local-dev-loop
Set up local development workflow with Clerk. Use when configuring development environment, testing auth locally, or setting up hot reload with Clerk. Trigger with phrases like "clerk local dev", "clerk development", "test clerk locally", "clerk dev environment".
Best use case
clerk-local-dev-loop is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Set up local development workflow with Clerk. Use when configuring development environment, testing auth locally, or setting up hot reload with Clerk. Trigger with phrases like "clerk local dev", "clerk development", "test clerk locally", "clerk dev environment".
Teams using clerk-local-dev-loop should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/clerk-local-dev-loop/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How clerk-local-dev-loop Compares
| Feature / Agent | clerk-local-dev-loop | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Set up local development workflow with Clerk. Use when configuring development environment, testing auth locally, or setting up hot reload with Clerk. Trigger with phrases like "clerk local dev", "clerk development", "test clerk locally", "clerk dev environment".
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Clerk Local Dev Loop
## Overview
Configure an efficient local development workflow with Clerk authentication, including test users, hot reload, and mock auth for unit tests.
## Prerequisites
- Clerk SDK installed (`clerk-install-auth` completed)
- Development instance created in Clerk Dashboard
- Node.js development environment
## Instructions
### Step 1: Configure Development Instance
Create a separate Clerk development instance to isolate test data from production.
```bash
# .env.local — use test keys (pk_test_ / sk_test_)
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_test_...
CLERK_SECRET_KEY=sk_test_...
# Optional: Enable Clerk debug logging
CLERK_DEBUG=true
```
Clerk development instances provide:
- No email verification required
- Test phone numbers accepted
- Relaxed rate limits
- OAuth with test credentials
### Step 2: Set Up Test Users
```typescript
// scripts/seed-test-users.ts
import { createClerkClient } from '@clerk/backend'
const clerk = createClerkClient({ secretKey: process.env.CLERK_SECRET_KEY! })
async function seedTestUsers() {
const users = [
{ emailAddress: ['admin@test.com'], password: 'test1234', firstName: 'Admin', lastName: 'User' },
{ emailAddress: ['member@test.com'], password: 'test1234', firstName: 'Member', lastName: 'User' },
]
for (const user of users) {
try {
await clerk.users.createUser(user)
console.log(`Created: ${user.emailAddress[0]}`)
} catch (err: any) {
if (err.status === 422) {
console.log(`Already exists: ${user.emailAddress[0]}`)
} else {
throw err
}
}
}
}
seedTestUsers()
```
Run with:
```bash
npx tsx scripts/seed-test-users.ts
```
### Step 3: Configure Hot Reload
```typescript
// next.config.ts — ensure Clerk works with hot reload
const nextConfig = {
// Clerk SDK is compatible with Turbopack
experimental: {
// turbo: {}, // Uncomment if using Turbopack
},
// Prevent Clerk SDK from being bundled incorrectly
serverExternalPackages: ['@clerk/backend'],
}
export default nextConfig
```
```bash
# Start dev server with HTTPS (required for some Clerk features)
npx next dev --experimental-https
```
### Step 4: Development Scripts
```json
// package.json scripts
{
"scripts": {
"dev": "next dev",
"dev:https": "next dev --experimental-https",
"dev:seed": "tsx scripts/seed-test-users.ts",
"dev:tunnel": "ngrok http 3000",
"dev:webhook": "ngrok http 3000 --log stdout"
}
}
```
### Step 5: Mock Authentication for Tests
```typescript
// test/helpers/clerk-mock.ts
import { vi } from 'vitest'
export function mockClerkAuth(overrides: { userId?: string; orgId?: string } = {}) {
const mockAuth = {
userId: overrides.userId || 'user_test_123',
orgId: overrides.orgId || null,
getToken: vi.fn().mockResolvedValue('mock_token'),
has: vi.fn().mockReturnValue(true),
}
vi.mock('@clerk/nextjs/server', () => ({
auth: vi.fn().mockResolvedValue(mockAuth),
currentUser: vi.fn().mockResolvedValue({
id: mockAuth.userId,
firstName: 'Test',
lastName: 'User',
emailAddresses: [{ emailAddress: 'test@test.com' }],
}),
clerkMiddleware: vi.fn(() => (req: any, res: any, next: any) => next()),
}))
return mockAuth
}
```
```typescript
// test/api/data.test.ts
import { describe, it, expect, beforeEach } from 'vitest'
import { mockClerkAuth } from '../helpers/clerk-mock'
describe('GET /api/data', () => {
beforeEach(() => {
mockClerkAuth({ userId: 'user_test_123' })
})
it('returns data for authenticated user', async () => {
const res = await fetch('/api/data')
expect(res.status).toBe(200)
})
})
```
## Output
- Development instance with test keys configured
- Test users seeded via script
- HTTPS dev server running for Clerk compatibility
- Vitest mock helpers for auth in unit tests
## Error Handling
| Error | Cause | Solution |
|-------|-------|----------|
| Dev/prod key mismatch | Using `pk_live_` in dev | Switch to `pk_test_` / `sk_test_` keys |
| SSL required | Clerk needs HTTPS locally | Run `next dev --experimental-https` |
| Cookies not set | Wrong domain config | Check Clerk Dashboard domain settings |
| Session not persisting | Browser storage issue | Clear cookies, check localhost domain |
## Examples
### Playwright Auth Fixture for E2E Tests
```typescript
// e2e/fixtures/auth.ts
import { test as base } from '@playwright/test'
export const test = base.extend({
authenticatedPage: async ({ page }, use) => {
await page.goto('/sign-in')
await page.fill('input[name="identifier"]', 'admin@test.com')
await page.click('button:has-text("Continue")')
await page.fill('input[name="password"]', 'test1234')
await page.click('button:has-text("Continue")')
await page.waitForURL('/dashboard')
await use(page)
},
})
```
## Resources
- [Clerk Development Mode](https://clerk.com/docs/deployments/overview)
- [Clerk Testing Guide](https://clerk.com/docs/testing/overview)
- [Next.js HTTPS Dev](https://nextjs.org/docs/app/api-reference/cli/next#https-for-local-development)
## Next Steps
Proceed to `clerk-sdk-patterns` for common SDK usage patterns.Related Skills
exa-local-dev-loop
Configure Exa local development with hot reload, testing, and mock responses. Use when setting up a development environment, writing tests against Exa, or establishing a fast iteration cycle. Trigger with phrases like "exa dev setup", "exa local development", "exa test setup", "develop with exa", "mock exa".
evernote-local-dev-loop
Set up efficient local development workflow for Evernote integrations. Use when configuring dev environment, setting up sandbox testing, or optimizing development iteration speed. Trigger with phrases like "evernote dev setup", "evernote local development", "evernote sandbox", "test evernote locally".
elevenlabs-local-dev-loop
Configure local ElevenLabs development with mocking, hot reload, and audio testing. Use when setting up a dev environment for TTS/voice projects, configuring test workflows, or building a fast iteration cycle with ElevenLabs audio. Trigger: "elevenlabs dev setup", "elevenlabs local development", "elevenlabs dev environment", "develop with elevenlabs", "test elevenlabs locally".
documenso-local-dev-loop
Set up local development environment and testing workflow for Documenso. Use when configuring dev environment, setting up test workflows, or establishing rapid iteration patterns with Documenso. Trigger with phrases like "documenso local dev", "documenso development", "test documenso locally", "documenso dev environment".
deepgram-local-dev-loop
Configure Deepgram local development workflow with testing and mocks. Use when setting up development environment, configuring test fixtures, or establishing rapid iteration patterns for Deepgram integration. Trigger: "deepgram local dev", "deepgram development setup", "deepgram test environment", "deepgram dev workflow", "deepgram mock".
databricks-local-dev-loop
Configure Databricks local development with Databricks Connect, Asset Bundles, and IDE. Use when setting up a local dev environment, configuring test workflows, or establishing a fast iteration cycle with Databricks. Trigger with phrases like "databricks dev setup", "databricks local", "databricks IDE", "develop with databricks", "databricks connect".
customerio-local-dev-loop
Configure Customer.io local development workflow. Use when setting up local testing, dev/staging isolation, or mocking Customer.io for unit tests. Trigger: "customer.io local dev", "test customer.io locally", "customer.io dev environment", "customer.io sandbox", "mock customer.io".
cursor-local-dev-loop
Optimize daily development workflow with Cursor IDE using Chat, Composer, Tab, and Git integration. Triggers on "cursor workflow", "cursor development loop", "cursor productivity", "cursor daily workflow", "cursor dev flow".
coreweave-local-dev-loop
Set up local development workflow for CoreWeave GPU deployments. Use when building containers locally, testing YAML manifests, or iterating on model serving configurations before deploying. Trigger with phrases like "coreweave dev setup", "coreweave local testing", "develop for coreweave", "coreweave container build".
cohere-local-dev-loop
Configure Cohere local development with mocking, testing, and hot reload. Use when setting up a development environment, configuring test workflows, or establishing a fast iteration cycle with Cohere API v2. Trigger with phrases like "cohere dev setup", "cohere local development", "cohere dev environment", "develop with cohere", "mock cohere".
coderabbit-local-dev-loop
Configure CodeRabbit CLI for local pre-commit code reviews and fast iteration. Use when setting up local development with CodeRabbit CLI reviews, integrating AI review into your commit workflow, or testing config changes. Trigger with phrases like "coderabbit dev setup", "coderabbit local development", "coderabbit CLI workflow", "coderabbit pre-commit review".
clickup-local-dev-loop
Set up local development for ClickUp API integrations with testing, mocking, and hot reload. Trigger: "clickup dev setup", "clickup local development", "clickup dev environment", "develop with clickup", "clickup testing setup", "mock clickup API".