Automated summary
This skill walks through building a first authenticated request with Clerk to confirm the integration works, using a protected page, an API route, and a client-side test component.
Strengths
- Provides complete, copy-pasteable TypeScript examples for Next.js App Router: protected page, API route, and client hooks
- Also covers an Express.js variant with clerkMiddleware and requireAuth
- Includes an error-handling table for common failures (null userId, expired session, 401, hydration error)
- Acts as a fast smoke test after installing and configuring environment variables
Limitations
- Assumes the Clerk SDK is already installed and ClerkProvider wraps the app
- Does not cover middleware configuration, redirect strategies, or advanced roles/permissions
- One code snippet contains a stray Python-style comment inside TypeScript
Reach for it right after installing and configuring Clerk, to prove end-to-end that an authenticated request succeeds.
Skip it if you need fine-grained authorization design, multi-tenant organizations, or frameworks other than Next.js and Express.
Security analysis
SafeThe skill only provides code examples for creating authenticated pages and API routes using Clerk. It does not instruct destructive actions, data exfiltration, or obfuscated commands. The allowed Bash tool is limited to npm commands and is not used in a risky way. The only network call is a client-side fetch to the user's own API endpoint.
No concerns found
How this analysis is madeExamples
Create a protected Next.js dashboard page and an /api/hello route with Clerk, then show me how to call the API with a token to verify auth works.My Clerk-protected API route keeps returning 401 Unauthorized — walk me through checking the auth() call and the Authorization header.Add a Clerk-protected endpoint to my Express app using clerkMiddleware and requireAuth, and show a quick way to test it.name: clerk-hello-world description: | Create your first authenticated request with Clerk. Use when making initial API calls, testing authentication, or verifying Clerk integration works correctly. Trigger with phrases like "clerk hello world", "first clerk request", "test clerk auth", "verify clerk setup". allowed-tools: Read, Write, Edit, Bash(npm:*), Grep version: 1.0.0 license: MIT author: Jeremy Longshore jeremy@intentsolutions.io compatible-with: claude-code, codex, openclaw
Clerk Hello World
Overview
Make your first authenticated request using Clerk to verify the integration works.
Prerequisites
- Clerk SDK installed (
clerk-install-authcompleted) - Environment variables configured
- ClerkProvider wrapping application
Instructions
Step 1: Create Protected Page
// app/dashboard/page.tsx
import { auth, currentUser } from '@clerk/nextjs/server'
export default async function DashboardPage() {
const { userId } = await auth()
const user = await currentUser()
if (!userId) {
return <div>Please sign in to access this page</div>
}
return (
<div>
<h1>Hello, {user?.firstName || 'User'}!</h1>
<p>Your user ID: {userId}</p>
<p>Email: {user?.emailAddresses[0]?.emailAddress}</p>
</div>
)
}
Step 2: Create Protected API Route
// app/api/hello/route.ts
import { auth } from '@clerk/nextjs/server'
export async function GET() {
const { userId } = await auth()
if (!userId) {
return Response.json({ error: 'Unauthorized' }, { status: 401 }) # HTTP 401 Unauthorized
}
return Response.json({
message: 'Hello from Clerk!',
userId,
timestamp: new Date().toISOString()
})
}
Step 3: Test Authentication Flow
// Client-side test component
'use client'
import { useUser, useAuth } from '@clerk/nextjs'
export function AuthTest() {
const { user, isLoaded, isSignedIn } = useUser()
const { getToken } = useAuth()
if (!isLoaded) return <div>Loading...</div>
if (!isSignedIn) return <div>Not signed in</div>
const testAPI = async () => {
const token = await getToken()
const res = await fetch('/api/hello', {
headers: { Authorization: `Bearer ${token}` }
})
console.log(await res.json())
}
return (
<div>
<p>Signed in as: {user.primaryEmailAddress?.emailAddress}</p>
<button onClick={testAPI}>Test API</button>
</div>
)
}
Output
- Protected page showing user information
- API route returning authenticated user data
- Successful request/response verification
Error Handling
| Error | Cause | Solution | |-------|-------|----------| | userId is null | User not authenticated | Redirect to sign-in or check middleware | | currentUser returns null | Session expired | Refresh page or re-authenticate | | 401 Unauthorized | Token missing or invalid | Check Authorization header | | Hydration Error | Server/client mismatch | Use 'use client' for client hooks |
Examples
Using with React Hooks
'use client'
import { useUser, useClerk } from '@clerk/nextjs'
export function UserProfile() {
const { user } = useUser()
const { signOut } = useClerk()
return (
<div>
<img src={user?.imageUrl} alt="Profile" />
<h2>{user?.fullName}</h2>
<button onClick={() => signOut()}>Sign Out</button>
</div>
)
}
Express.js Example
import { clerkMiddleware, requireAuth } from '@clerk/express'
app.use(clerkMiddleware())
app.get('/api/protected', requireAuth(), (req, res) => {
res.json({
message: 'Hello!',
userId: req.auth.userId
})
})
Resources
Next Steps
Proceed to clerk-local-dev-loop for local development workflow setup.
From the file to a first result
The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.
View the source and supporting filesThis download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.
1. Download the file
Download SKILL.mdFrom the root of a test project, save the file as .skill-downloads/clerk-hello-world-ms2s7cmh/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.
Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.
mkdir -p '.skill-downloads/clerk-hello-world-ms2s7cmh' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/clerk-hello-world-ms2s7cmh/download' --output '.skill-downloads/clerk-hello-world-ms2s7cmh/SKILL.md.part' && mv '.skill-downloads/clerk-hello-world-ms2s7cmh/SKILL.md.part' '.skill-downloads/clerk-hello-world-ms2s7cmh/SKILL.md'2. Check prerequisites
Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.
Tools declared by the author (check availability in your agent): Read, Write, Edit, Bash(npm:*), Grep
Original excerpt: Prerequisites
- Clerk SDK installed (
clerk-install-authcompleted) - Environment variables configured
- ClerkProvider wrapping application
The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.
3. Load the skill
After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.
Claude Code
test -f '.skill-downloads/clerk-hello-world-ms2s7cmh/SKILL.md' && test -s '.skill-downloads/clerk-hello-world-ms2s7cmh/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/clerk-hello-world' && cp -R '.skill-downloads/clerk-hello-world-ms2s7cmh' '.claude/skills/clerk-hello-world'Codex
test -f '.skill-downloads/clerk-hello-world-ms2s7cmh/SKILL.md' && test -s '.skill-downloads/clerk-hello-world-ms2s7cmh/SKILL.md' && mkdir -p '.agents/skills' && test ! -e '.agents/skills/clerk-hello-world' && cp -R '.skill-downloads/clerk-hello-world-ms2s7cmh' '.agents/skills/clerk-hello-world'OpenSkills
OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.
Official OpenSkills installationopenskills install './.skill-downloads/clerk-hello-world-ms2s7cmh'openskills read 'clerk-hello-world-ms2s7cmh'Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.
For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.
openskills syncManual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.
4. Try a first task
Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:
Read .skill-downloads/clerk-hello-world-ms2s7cmh/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.
DeFi AMM Security
Security
Security checklist for Solidity AMM contracts, liquidity pools, and swap flows. Covers reentrancy, donation attacks, oracle manipulation, slippage, and integer math.
Semgrep Rule Creator
Security
Creates custom Semgrep rules for detecting security vulnerabilities, bug patterns, and code patterns. Includes test-first methodology, taint mode support, and validation steps. Helps when building targeted static analysis detections.
Dev Toolbar Review Guide
Security
Safety rules for the dev toolbar, PostHog client, and feature flags. Use when reviewing changes to dev-tools and related files, covering environment guards, override cookies, and SSE stream safety.