nextjs-middleware-generator
Installation
SKILL.md
Next.js Middleware Generator
Before generating any output, read config/defaults.md and adapt all patterns, imports, and code examples to the user's configured stack.
Generation Process
- Determine middleware requirements (auth, CORS, rate limiting, i18n, redirects)
- Generate
middleware.tsat the project root - Configure route matchers
- Add helper functions as needed
Base Middleware Structure
Create middleware.ts at the project root. Next.js only supports a single middleware file:
import { NextRequest, NextResponse } from 'next/server';