CL

clerk-ci-integration

Configures automated testing and CI pipelines for projects using Clerk authentication.

Install

mkdir -p .claude/skills/clerk-ci-integration && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/8047" && unzip -o skill.zip -d .claude/skills/clerk-ci-integration && rm skill.zip

Installs to .claude/skills/clerk-ci-integration

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

Configure Clerk CI/CD integration with GitHub Actions and testing.
66 charsno explicit “when” trigger
Advanced

Key capabilities

  • Configure GitHub Actions workflows
  • Manage CI secrets for Clerk
  • Set up Playwright E2E tests
  • Seed test users for CI
  • Mock Clerk authentication in unit tests

How it works

It integrates Clerk authentication into CI pipelines by using test-specific API keys and seeding test users to enable automated E2E testing.

Inputs & outputs

You give it
Clerk test credentials
You get back
Automated CI test results

When to use clerk-ci-integration

  • Setting up CI pipelines
  • Automating Clerk auth testing
  • Configuring E2E test environments

About this skill

Clerk CI Integration

Overview

Set up CI/CD pipelines with Clerk authentication testing. Covers GitHub Actions workflows, Playwright E2E tests with Clerk auth, test user management, and CI secrets configuration.

Prerequisites

  • GitHub repository with Actions enabled
  • Clerk test API keys (pk_test_ / sk_test_)
  • npm/pnpm project configured

Instructions

Step 1: GitHub Actions Workflow

# .github/workflows/test.yml
name: Test with Clerk Auth
on:
  pull_request:
    branches: [main]
  push:
    branches: [main]

jobs:
  test:
    runs-on: ubuntu-latest
    env:
      NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY: ${{ secrets.CLERK_PK_TEST }}
      CLERK_SECRET_KEY: ${{ secrets.CLERK_SK_TEST }}
      CLERK_WEBHOOK_SECRET: ${{ secrets.CLERK_WEBHOOK_SECRET_TEST }}

    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 20
          cache: npm

      - run: npm ci
      - run: npm run build
      - run: npm test

      - name: Install Playwright
        run: npx playwright install --with-deps chromium

      - name: Run E2E tests
        run: npx playwright test
        env:
          CLERK_TEST_USER_EMAIL: ${{ secrets.CLERK_TEST_USER_EMAIL }}
          CLERK_TEST_USER_PASSWORD: ${{ secrets.CLERK_TEST_USER_PASSWORD }}

Step 2: Configure GitHub Secrets

Add these secrets in GitHub repo > Settings > Secrets:

SecretValue
CLERK_PK_TESTpk_test_... from dev instance
CLERK_SK_TESTsk_test_... from dev instance
CLERK_WEBHOOK_SECRET_TESTwhsec_... from dev webhooks
CLERK_TEST_USER_EMAIL[email protected]
CLERK_TEST_USER_PASSWORDStrong test password

Step 3: Playwright Auth Setup

// e2e/auth.setup.ts
import { test as setup, expect } from '@playwright/test'
import path from 'path'

const authFile = path.join(__dirname, '.auth/user.json')

setup('authenticate', async ({ page }) => {
  await page.goto('/sign-in')

  // Fill Clerk sign-in form
  await page.fill('input[name="identifier"]', process.env.CLERK_TEST_USER_EMAIL!)
  await page.click('button:has-text("Continue")')
  await page.fill('input[name="password"]', process.env.CLERK_TEST_USER_PASSWORD!)
  await page.click('button:has-text("Continue")')

  // Wait for redirect to authenticated page
  await page.waitForURL('/dashboard')
  await expect(page.locator('text=Dashboard')).toBeVisible()

  // Save auth state for reuse across tests
  await page.context().storageState({ path: authFile })
})

Step 4: Playwright Config with Auth State

// playwright.config.ts
import { defineConfig } from '@playwright/test'

export default defineConfig({
  testDir: './e2e',
  projects: [
    { name: 'setup', testMatch: 'auth.setup.ts' },
    {
      name: 'authenticated',
      testMatch: '*.spec.ts',
      dependencies: ['setup'],
      use: {
        storageState: 'e2e/.auth/user.json',
      },
    },
  ],
  webServer: {
    command: 'npm run dev',
    port: 3000,
    reuseExistingServer: !process.env.CI,
  },
})

Step 5: E2E Test Examples

// e2e/dashboard.spec.ts
import { test, expect } from '@playwright/test'

test('authenticated user sees dashboard', async ({ page }) => {
  await page.goto('/dashboard')
  await expect(page.locator('h1')).toContainText('Dashboard')
  await expect(page.locator('[data-clerk-user-button]')).toBeVisible()
})

test('unauthenticated user is redirected to sign-in', async ({ browser }) => {
  // Create fresh context without saved auth state
  const context = await browser.newContext()
  const page = await context.newPage()

  await page.goto('/dashboard')
  await expect(page).toHaveURL(/sign-in/)

  await context.close()
})

test('protected API returns data', async ({ page }) => {
  const response = await page.request.get('/api/data')
  expect(response.status()).toBe(200)
  const data = await response.json()
  expect(data.userId).toBeTruthy()
})

Step 6: Test User Seed Script for CI

// scripts/seed-ci-user.ts
import { createClerkClient } from '@clerk/backend'

const clerk = createClerkClient({ secretKey: process.env.CLERK_SECRET_KEY! })

async function ensureTestUser() {
  const email = process.env.CLERK_TEST_USER_EMAIL!
  const password = process.env.CLERK_TEST_USER_PASSWORD!

  const existing = await clerk.users.getUserList({ emailAddress: [email] })
  if (existing.totalCount > 0) {
    console.log('Test user already exists')
    return
  }

  await clerk.users.createUser({
    emailAddress: [email],
    password,
    firstName: 'CI',
    lastName: 'TestUser',
  })
  console.log('Test user created')
}

ensureTestUser()

Output

  • GitHub Actions workflow with Clerk env vars from secrets
  • Playwright auth setup saving session state for reuse
  • E2E tests covering authenticated and unauthenticated flows
  • Test user seed script for CI environments
  • Protected API endpoint test

Error Handling

ErrorCauseSolution
Secret not found in CIMissing GitHub secretAdd in repo Settings > Secrets and variables > Actions
Test user sign-in failsUser not created or wrong passwordRun seed script, verify credentials
Timeout on sign-in pageClerk SDK not loaded in CI buildEnsure NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY is set
E2E auth state staleCached session expiredDelete .auth/ directory, re-run setup

Examples

Vitest Unit Test with Mocked Clerk

// __tests__/api.test.ts
import { describe, it, expect, vi } from 'vitest'

vi.mock('@clerk/nextjs/server', () => ({
  auth: vi.fn().mockResolvedValue({ userId: 'user_test_123', has: () => true }),
}))

describe('Protected API', () => {
  it('returns data for authenticated user', async () => {
    const { GET } = await import('@/app/api/data/route')
    const response = await GET()
    expect(response.status).toBe(200)
  })
})

Resources

Next Steps

Proceed to clerk-deploy-integration for deployment platform setup.

Prerequisites

GitHub repository with Actions enabledClerk test API keysnpm/pnpm project

Limitations

  • Requires Clerk test instance configuration
  • Dependent on GitHub Actions environment

How it compares

This method automates authentication state management for tests instead of requiring manual sign-in steps during CI runs.

Compared to similar skills

clerk-ci-integration side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
clerk-ci-integration (this skill)027dReviewAdvanced
perf-lighthouse135moReviewIntermediate
smoke-test64moReviewBeginner
1k-dev-commands229dReviewBeginner

Try saying

Example prompts that trigger this skill in your AI assistant.

More by jeremylongshore

View all by jeremylongshore

analyzing-logs

jeremylongshore

Analyze application logs to detect performance issues, identify error patterns, and improve stability by extracting key insights.

14123

ollama-setup

jeremylongshore

Configure auto-configure Ollama when user needs local LLM deployment, free AI alternatives, or wants to eliminate hosted API costs. Trigger phrases: "install ollama", "local AI", "free LLM", "self-hosted AI", "replace OpenAI", "no API costs". Use when appropriate context detected. Trigger with relevant phrases based on skill purpose.

1167

backtesting-trading-strategies

jeremylongshore

Backtest crypto and traditional trading strategies against historical data. Calculates performance metrics (Sharpe, Sortino, max drawdown), generates equity curves, and optimizes strategy parameters. Use when user wants to test a trading strategy, validate signals, or compare approaches. Trigger with phrases like "backtest strategy", "test trading strategy", "historical performance", "simulate trades", "optimize parameters", or "validate signals".

1071

generating-database-seed-data

jeremylongshore

Process this skill enables AI assistant to generate realistic test data and database seed scripts for development and testing environments. it uses faker libraries to create realistic data, maintains relational integrity, and allows configurable data volumes. u... Use when working with databases or data models. Trigger with phrases like 'database', 'query', or 'schema'.

1033

cursor-codebase-indexing

jeremylongshore

Execute set up and optimize Cursor codebase indexing. Triggers on "cursor index setup", "codebase indexing", "index codebase", "cursor semantic search". Use when working with cursor codebase indexing functionality. Trigger with phrases like "cursor codebase indexing", "cursor indexing", "cursor".

885

testing-mobile-apps

jeremylongshore

Execute mobile app testing on iOS and Android devices/simulators. Use when performing specialized testing. Trigger with phrases like "test mobile app", "run iOS tests", or "validate Android functionality".

810

You might also like

perf-lighthouse

tech-leads-club

Run Lighthouse audits locally via CLI or Node API, parse and interpret reports, set performance budgets. Use when measuring site performance, understanding Lighthouse scores, setting up budgets, or integrating audits into CI. Triggers on: lighthouse, run lighthouse, lighthouse score, performance audit, performance budget.

1361

smoke-test

mastra-ai

Create a Mastra project using create-mastra and smoke test the studio in Chrome

616

1k-dev-commands

OneKeyHQ

Development commands — yarn scripts for dev servers, building, linting, testing, and troubleshooting.

24

instantly-ci-integration

jeremylongshore

Configure Instantly CI/CD integration with GitHub Actions and testing. Use when setting up automated testing, configuring CI pipelines, or integrating Instantly tests into your build process. Trigger with phrases like "instantly CI", "instantly GitHub Actions", "instantly automated tests", "CI instantly".

14

groq-ci-integration

jeremylongshore

Configure Groq CI/CD integration with GitHub Actions and testing. Use when setting up automated testing, configuring CI pipelines, or integrating Groq tests into your build process. Trigger with phrases like "groq CI", "groq GitHub Actions", "groq automated tests", "CI groq".

13

obsidian-ci-integration

jeremylongshore

Set up GitHub Actions CI/CD for Obsidian plugin development. Use when automating builds, tests, and releases for your plugin, or setting up continuous integration for Obsidian projects. Trigger with phrases like "obsidian CI", "obsidian github actions", "obsidian automated build", "obsidian CI/CD".

03

Search skills

Search the agent skills registry