claude-code-framework/essential/skills/scaffolding/auth-middleware-setup/SKILL.md
Adds authentication middleware to protect routes and endpoints with JWT validation. Use when user says "add authentication", "protect route", "add auth", "secure endpoint", or mentions authentication/authorization.
npx skillsauth add tokenized2027/claude-initilization-v7 auth-middleware-setupInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
// middleware.ts
import { NextResponse } from 'next/server'
import type { NextRequest } from 'next/server'
import { verify } from 'jsonwebtoken'
const JWT_SECRET = process.env.JWT_SECRET || ''
export function middleware(request: NextRequest) {
const token = request.cookies.get('token')?.value
if (!token) {
return NextResponse.redirect(new URL('/login', request.url))
}
try {
verify(token, JWT_SECRET)
return NextResponse.next()
} catch (error) {
return NextResponse.redirect(new URL('/login', request.url))
}
}
export const config = {
matcher: ['/dashboard/:path*', '/api/protected/:path*'],
}
// lib/auth.ts
import { NextRequest, NextResponse } from 'next/server'
import { verify } from 'jsonwebtoken'
export function withAuth(handler: Function) {
return async (request: NextRequest) => {
const token = request.cookies.get('token')?.value
if (!token) {
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })
}
try {
const decoded = verify(token, process.env.JWT_SECRET!)
return handler(request, decoded)
} catch (error) {
return NextResponse.json({ error: 'Invalid token' }, { status: 401 })
}
}
}
development
Methodical debugging using reproducible steps, instrumentation, and root-cause analysis. Use when something is broken and you don't know why. Triggers on "bug", "broken", "not working", "error", "fails intermittently", "regression", "unexpected behavior".
development
Optimize prompts for Claude Code agents, API calls, and multi-agent orchestration. Use when writing system prompts, agent instructions, or refining LLM interactions. Triggers on "improve prompt", "write a prompt", "agent instructions", "system prompt", "prompt not working", "LLM output quality".
tools
Structured ideation and design review before any creative or constructive work. Use before building features, components, architecture, dashboards, or automation workflows. Triggers on "plan this", "design this", "brainstorm", "think through", "what should we build", "how should I approach".
testing
Generates test files for components and functions with setup, basic tests, and mocks. Use when user says "add tests", "create test", "test this component", or mentions testing.