CL

clerk-incident-runbook

A set of triage and recovery procedures for responding to Clerk authentication outages or security issues.

Install

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

Installs to .claude/skills/clerk-incident-runbook

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.

Manage incident response for Clerk authentication issues.
57 charsno explicit “when” trigger
Intermediate

Key capabilities

  • Triage Clerk-related incidents by identifying symptoms and severity
  • Check Clerk's status page and API connectivity
  • Activate an emergency authentication bypass for Clerk outages
  • Rotate compromised Clerk API keys
  • Revoke all active user sessions in case of mass logout

How it works

The skill provides a triage script to diagnose Clerk issues and offers procedures for emergency auth bypass, key rotation, session recovery, and webhook replay. It also includes a post-incident review template.

Inputs & outputs

You give it
Symptoms of a Clerk-related incident (e.g., all auth fails, unauthorized access)
You get back
An incident category, a diagnostic report, or a mitigation action (e.g., bypass activated, keys rotated)

When to use clerk-incident-runbook

  • Triage authentication service outages
  • Manage emergency auth bypass procedures
  • Troubleshoot middleware failure symptoms
  • Conduct post-incident review for auth issues

About this skill

Clerk Incident Runbook

Overview

Procedures for responding to Clerk-related incidents in production. Covers triage, emergency auth bypass, recovery scripts, and post-incident review.

Prerequisites

  • Access to Clerk Dashboard (dashboard.clerk.com)
  • Access to application logs and monitoring
  • Emergency contact list for on-call team
  • Rollback procedures documented

Instructions

Step 1: Triage — Identify Incident Category

CategorySymptomsSeverity
Clerk outagestatus.clerk.com shows incident, all auth failsCritical
Key compromiseUnauthorized access detectedCritical
Middleware failureAll routes return 500High
Session issuesUsers randomly logged outMedium
Webhook backlogUser sync falling behindLow

Quick diagnostic:

#!/bin/bash
# scripts/clerk-triage.sh
set -euo pipefail

echo "=== Clerk Incident Triage ==="
echo "Time: $(date -u +%Y-%m-%dT%H:%M:%SZ)"

# 1. Check Clerk status
echo -e "\n--- Clerk Status ---"
curl -s https://status.clerk.com/api/v2/status.json | python3 -c "
import json,sys
d=json.load(sys.stdin)
print(f\"Status: {d['status']['description']}\")" 2>/dev/null || echo "Cannot reach status API"

# 2. Check API connectivity
echo -e "\n--- API Connectivity ---"
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" -H "Authorization: Bearer ${CLERK_SECRET_KEY}" \
  https://api.clerk.com/v1/users?limit=1 2>/dev/null)
echo "API response: HTTP $HTTP_CODE"

# 3. Check app health
echo -e "\n--- App Health ---"
curl -s http://localhost:3000/api/clerk-health 2>/dev/null | python3 -m json.tool || echo "App not reachable"

Step 2: Emergency Auth Bypass (Clerk Outage Only)

// middleware.ts — emergency bypass mode
import { clerkMiddleware, createRouteMatcher } from '@clerk/nextjs/server'
import { NextResponse } from 'next/server'

const EMERGENCY_BYPASS = process.env.CLERK_EMERGENCY_BYPASS === 'true'

const isPublicRoute = createRouteMatcher(['/', '/sign-in(.*)', '/sign-up(.*)'])

export default clerkMiddleware(async (auth, req) => {
  // Emergency bypass: allow all requests when Clerk is down
  if (EMERGENCY_BYPASS) {
    console.warn('[EMERGENCY] Auth bypass active — all requests allowed')
    const response = NextResponse.next()
    response.headers.set('X-Auth-Bypass', 'true')
    return response
  }

  if (!isPublicRoute(req)) {
    await auth.protect()
  }
})

Activate bypass:

# Vercel: set env var and redeploy
vercel env add CLERK_EMERGENCY_BYPASS production  # Set to "true"
vercel deploy --prod

# After Clerk recovers: remove bypass
vercel env rm CLERK_EMERGENCY_BYPASS production
vercel deploy --prod

Step 3: Key Rotation (Compromised Secret Key)

#!/bin/bash
# scripts/rotate-clerk-keys.sh
set -euo pipefail

echo "=== Clerk Key Rotation ==="
echo "1. Go to dashboard.clerk.com > API Keys"
echo "2. Generate new Secret Key"
echo "3. Update all environments:"

# Update production
echo "Updating production..."
# vercel env rm CLERK_SECRET_KEY production
# vercel env add CLERK_SECRET_KEY production  # Paste new key
# vercel deploy --prod

echo "4. Verify all endpoints still work"
echo "5. Monitor for unauthorized access attempts"
echo "6. File incident report"

Step 4: Session Recovery (Mass Logout Fix)

// app/api/admin/refresh-sessions/route.ts
import { auth, clerkClient } from '@clerk/nextjs/server'

export async function POST() {
  const { has } = await auth()
  if (!has({ role: 'org:admin' })) {
    return Response.json({ error: 'Admin only' }, { status: 403 })
  }

  // Force-revoke all sessions (users will need to re-authenticate)
  const client = await clerkClient()
  const users = await client.users.getUserList({ limit: 500 })
  let revoked = 0

  for (const user of users.data) {
    const sessions = await client.sessions.getSessionList({ userId: user.id })
    for (const session of sessions.data) {
      if (session.status === 'active') {
        await client.sessions.revokeSession(session.id)
        revoked++
      }
    }
  }

  return Response.json({ revoked, message: `Revoked ${revoked} sessions` })
}

Step 5: Webhook Replay (Missed Events)

# Check for missed webhooks in Clerk Dashboard:
# Dashboard > Webhooks > Select endpoint > Message Logs
# Click "Retry" on failed messages

# Or replay from your audit log:
echo "Check database for missing user records:"
echo "SELECT clerk_id FROM users WHERE created_at > NOW() - INTERVAL '1 hour'"

Step 6: Post-Incident Review Template

## Incident Report

**Date:** YYYY-MM-DD HH:MM UTC
**Duration:** X hours Y minutes
**Severity:** Critical / High / Medium / Low
**Category:** Clerk Outage / Key Compromise / Config Error / Middleware Failure

### Timeline
- HH:MM — Incident detected (how: monitoring alert / user report / manual)
- HH:MM — Triage started, category identified
- HH:MM — Mitigation applied (emergency bypass / key rotation / rollback)
- HH:MM — Service restored
- HH:MM — Post-incident review completed

### Root Cause
[Description of what caused the incident]

### Impact
- Users affected: X
- Duration of auth downtime: Y minutes
- Data loss: None / Partial / Details

### Action Items
- [ ] Add monitoring for [specific check]
- [ ] Update runbook with [new procedure]
- [ ] Implement [preventive measure]

Output

  • Triage script identifying incident category and severity
  • Emergency auth bypass middleware (activate via env var)
  • Key rotation procedure for compromised credentials
  • Session revocation endpoint for mass-logout recovery
  • Post-incident review template

Error Handling

ScenarioResponse
Clerk API completely downActivate emergency bypass, monitor status.clerk.com
Secret key compromisedRotate keys immediately, revoke all sessions, audit logs
Middleware 500 errorsCheck middleware.ts syntax, verify Clerk SDK version
Webhook delivery failuresRetry from Dashboard, check endpoint accessibility
Users randomly logged outCheck session lifetime settings, verify domain config

Examples

Quick Status Check One-Liner

curl -s https://status.clerk.com/api/v2/status.json | python3 -c "import json,sys; print(json.load(sys.stdin)['status']['description'])"

Resources

Next Steps

After resolving incident, review clerk-observability for improved monitoring.

When not to use it

  • When the incident is not related to Clerk authentication or services
  • When the application does not use Clerk for authentication

Prerequisites

Access to Clerk Dashboard (dashboard.clerk.com)Access to application logs and monitoringEmergency contact list for on-call teamRollback procedures documented

Limitations

  • The skill requires access to the Clerk Dashboard
  • The skill requires access to application logs and monitoring
  • The skill requires documented rollback procedures

How it compares

This skill provides a structured runbook with specific scripts and procedures for handling Clerk authentication incidents, unlike a general incident response plan.

Compared to similar skills

clerk-incident-runbook side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
clerk-incident-runbook (this skill)127dCautionIntermediate
auth-patterns77moReviewIntermediate
customerio-security-basics127dReviewIntermediate
gamma-enterprise-rbac127dReviewAdvanced

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

auth-patterns

davepoon

This skill should be used when the user asks about "authentication in Next.js", "NextAuth", "Auth.js", "middleware auth", "protected routes", "session management", "JWT", "login flow", or needs guidance on implementing authentication and authorization in Next.js applications.

720

customerio-security-basics

jeremylongshore

Apply Customer.io security best practices. Use when implementing secure integrations, handling PII, or setting up proper access controls. Trigger with phrases like "customer.io security", "customer.io pii", "secure customer.io", "customer.io gdpr".

15

gamma-enterprise-rbac

jeremylongshore

Implement enterprise role-based access control for Gamma integrations. Use when configuring team permissions, multi-tenant access, or enterprise authorization patterns. Trigger with phrases like "gamma RBAC", "gamma permissions", "gamma access control", "gamma enterprise", "gamma roles".

12

jwt-auth

dadbodgeoff

Implement secure JWT authentication with refresh token rotation, secure storage, and automatic renewal. Use when building authentication for SPAs, mobile apps, or APIs that need stateless auth with refresh capabilities.

12

maintainx-security-basics

jeremylongshore

Configure MaintainX API security, credential management, and access control. Use when securing API keys, implementing access controls, or hardening your MaintainX integration. Trigger with phrases like "maintainx security", "maintainx api key security", "secure maintainx", "maintainx credentials", "maintainx access control".

11

clerk-data-handling

jeremylongshore

Handle user data, privacy, and GDPR compliance with Clerk. Use when implementing data export, user deletion, or privacy compliance features. Trigger with phrases like "clerk user data", "clerk GDPR", "clerk privacy", "clerk data export", "clerk delete user".

01

Search skills

Search the agent skills registry