# clerk-auth

Provides patterns to set up Clerk authentication, configure route protection middleware, and handle server components in Next.js App Router.

- skill · `type=skill` · Claude Code · 62 installs
- Author: davila7
- License: not stated · policy=link-only · description only; the file stays with the author
- Source: https://github.com/davila7/claude-code-templates/tree/HEAD/cli-tool/components/skills/development/clerk-auth
- Updated: 2026-10-24
- HTML: https://affpapa.org/en/nevibecode/skills/clerk-auth

## What it does

This skill guides Claude Code through integrating Clerk into Next.js 14 and 15 applications using the App Router. It defines setups for `ClerkProvider`, environment variables, and pre-built UI components such as `<SignIn />`, `<SignUp />`, and `<UserButton />`.

Route protection relies entirely on a single `middleware.ts` placed at the project root. The patterns apply `clerkMiddleware` alongside `createRouteMatcher` to handle protected page groups explicitly through `auth.protect()`.

Server-side helpers like `auth()` and `currentUser()` fail if `clerkMiddleware` is missing. The skill enforces configuring this middleware first before fetching `userId`, claims, or user profile records inside Server Components.

## Install

### Claude Code (native platform)

1. **claude-code-templates**
```bash
npx claude-code-templates@latest --skill development/clerk-auth
```

2. **Skills CLI (Vercel)**
```bash
npx skills add davila7/claude-code-templates --skill clerk-auth -a claude-code
```

3. **Manually: put the files in place**
- File: `~/.claude/skills/clerk-auth/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/clerk-auth/

### Codex

**Manually: put the files in place**
- File: `.agents/skills/clerk-auth/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

**Manually: put the files in place**
- File: `.cursor/skills/clerk-auth/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install davila7/claude-code-templates clerk-auth
```

2. **Manually: put the files in place**
- File: `.github/skills/clerk-auth/SKILL.md`

### Gemini CLI

**Platform CLI**
```bash
gemini skills install https://github.com/davila7/claude-code-templates --path cli-tool/components/skills/development/clerk-auth
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/clerk-auth/SKILL.md` — The legacy .windsurf/skills/ path still works

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/davila7/claude-code-templates/tree/HEAD/cli-tool/components/skills/development/clerk-auth

## When to use it
- integrate Clerk authentication into Next.js 14 or 15 App Router
- restrict private routes using `clerkMiddleware` and `createRouteMatcher`
- read user identity and session data in Server Components
- insert pre-built sign-in, sign-up, and user profile buttons

## Example prompts
- Set up Clerk authentication for our Next.js App Router app
- Configure `middleware.ts` to protect dashboard routes with `createRouteMatcher`
- Fetch the current user ID in a Server Component using `auth()`

## Similar
- [git-guardrails-claude-code](https://affpapa.org/en/nevibecode/skills/git-guardrails-claude-code.md) — skill · 499069 installs
- [ponytail-review](https://affpapa.org/en/nevibecode/skills/ponytail-review.md) — skill · 57000 installs
- [ponytail-audit](https://affpapa.org/en/nevibecode/skills/ponytail-audit.md) — skill · 45400 installs
- [security-audit](https://affpapa.org/en/nevibecode/skills/cloudflare-security-audit.md) — skill · 54800 installs
- [security-and-hardening](https://affpapa.org/en/nevibecode/skills/security-and-hardening.md) — skill · 70200 installs
- [supabase](https://affpapa.org/en/nevibecode/skills/supabase.md) — skill · 8 installs

From the same set: [davila7/claude-code-templates](https://affpapa.org/en/nevibecode/by/davila7/claude-code-templates.md) — 804 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
