# clerk-nextjs-skills

Walks your agent through Clerk auth in Next.js 16 App Router: proxy.ts, env vars, route protection and an MCP server.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 436 installs · ★ 23
- Author: gocallum
- License: not stated · policy=link-only · description only; the file stays with the author
- Source: https://github.com/gocallum/nextjs16-agent-skills/tree/HEAD/skills/clerk-nextjs-skills/SKILL.md
- Updated: 2026-01-21
- HTML: https://affpapa.org/en/nevibecode/skills/clerk-nextjs-skills

## What it does

The skill lays out the install path for Clerk in a Next.js 16 project. It covers adding `@clerk/nextjs` with pnpm, creating `proxy.ts` at the root or in `/src`, filling `.env.local` with the Clerk keys, and wrapping the app in `ClerkProvider` inside `app/layout.tsx`.

A separate section handles the move from Next.js 15. You rename `middleware.ts` to `proxy.ts`, keep the code as is, since `clerkMiddleware()` behaves the same either way. If routes stop being protected, the skill points at the file location and suggests clearing the cache with `rm -rf .next && pnpm dev`.

There is also a walkthrough for an MCP server built on `@vercel/mcp-adapter` and `@clerk/mcp-tools`, with a route at `app/[transport]/route.ts`. One thing to watch: `clerkMiddleware()` leaves every route public by default, so you add `auth.protect()` yourself. You will need a publishable key and a secret key from the Clerk dashboard.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add gocallum/nextjs16-agent-skills --skill clerk-nextjs-skills -a claude-code
```

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

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add gocallum/nextjs16-agent-skills --skill clerk-nextjs-skills -a codex
```

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

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add gocallum/nextjs16-agent-skills --skill clerk-nextjs-skills -a cursor
```

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

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install gocallum/nextjs16-agent-skills clerk-nextjs-skills
```

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

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add gocallum/nextjs16-agent-skills --skill clerk-nextjs-skills -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/gocallum/nextjs16-agent-skills --path skills/clerk-nextjs-skills
```

### Windsurf (Devin Desktop)

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

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add gocallum/nextjs16-agent-skills --skill clerk-nextjs-skills -a opencode
```

### 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/gocallum/nextjs16-agent-skills/tree/HEAD/skills/clerk-nextjs-skills/SKILL.md

## When to use it
- set up Clerk auth in a fresh Next.js 16 project
- rename `middleware.ts` to `proxy.ts` without touching the code
- lock down routes with `auth.protect()`
- catch missing Clerk env vars before runtime
- build an MCP server that verifies Clerk tokens

## Example prompts
- Set up Clerk auth in my Next.js 16 App Router project
- Help me migrate `middleware.ts` to `proxy.ts`
- Protect this route with `auth.protect()` and show the signed-in user

## Similar
- [clerk-nextjs-patterns](https://affpapa.org/en/nevibecode/skills/clerk-nextjs-patterns.md) — skill · 53400 installs
- [clerk-setup](https://affpapa.org/en/nevibecode/skills/clerk-setup.md) — skill · 56600 installs
- [clerk-authentication](https://affpapa.org/en/nevibecode/skills/clerk-authentication.md) — skill · 683 installs
- [clerk](https://affpapa.org/en/nevibecode/rules/clerk.md) — rule · ★ 3579
- [nextjs-supabase-auth](https://affpapa.org/en/nevibecode/skills/sickn33-nextjs-supabase-auth.md) — skill · 6600 installs
- [auth](https://affpapa.org/en/nevibecode/skills/auth.md) — skill · 8 installs

From the same set: [gocallum/nextjs16-agent-skills](https://affpapa.org/en/nevibecode/by/gocallum/nextjs16-agent-skills.md) — 3 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
