vibe-stack / rules
Cursor rule8 starsChanged 8 months agoMITView on GitHub
API route handler design patterns
In this repository31 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .cursor/rules/ai-collaboration.mdcCursor rule
- .cursor/rules/api-validation.mdcCursor rule
- .cursor/rules/caching-revalidation.mdcCursor rule
- .cursor/rules/context-management.mdcCursor rule
- .cursor/rules/database-design.mdcCursor rule
- .cursor/rules/env-management.mdcCursor rule
- .cursor/rules/error-handling.mdcCursor rule
- .cursor/rules/file-naming.mdcCursor rule
- .cursor/rules/file-uploads.mdcCursor rule
- .cursor/rules/git-conventions.mdcCursor rule
- .cursor/rules/hydration-safety.mdcCursor rule
- .cursor/rules/middleware-auth.mdcCursor rule
- .cursor/rules/nextjs15-params.mdcCursor rule
- .cursor/rules/performance.mdcCursor rule
- .cursor/rules/project-context.mdcCursor rule
- .cursor/rules/react19-patterns.mdcCursor rule
- .cursor/rules/security.mdcCursor rule
- .cursor/rules/server-actions.mdcCursor rule
- .cursor/rules/server-vs-client-components.mdcCursor rule
- .cursor/rules/shadcn-patterns.mdcCursor rule
- .cursor/rules/stripe-payments.mdcCursor rule
- .cursor/rules/stripe-webhooks.mdcCursor rule
- .cursor/rules/supabase-auth-security.mdcCursor rule
- .cursor/rules/supabase-rls.mdcCursor rule
- .cursor/rules/supabase-ssr-only.mdcCursor rule
- .cursor/rules/testing.mdcCursor rule
- .cursor/rules/typescript-strict.mdcCursor rule
- .cursor/rules/verify-before-use.mdcCursor rule
- llms.txtllms.txt
The file
Files
---
description: API route handler design patterns
globs: ["**/app/api/**", "**/route.ts"]
---
# API Design Patterns
Standard response format for Route Handlers:
Success: `{ data: T, error: null }`
Error: `{ data: null, error: { code: string, message: string } }`
HTTP status codes:
- 200: Success (GET, PATCH)
- 201: Created (POST)
- 204: No content (DELETE)
- 400: Validation error
- 401: Unauthenticated
- 403: Unauthorized
- 404: Not found
- 500: Server error
Route handler template:
```typescript
import { NextResponse } from 'next/server'
import { createServerClient } from '@supabase/ssr'
export async function GET(request: Request, { params }: { params: Promise<{ id: string }> }) {
const { id } = await params
const supabase = createServerClient(...)
const { data: { user } } = await supabase.auth.getUser()
if (!user) {
return NextResponse.json(
{ data: null, error: { code: 'UNAUTHORIZED', message: 'Login required' } },
{ status: 401 }
)
}
// ... fetch data
return NextResponse.json({ data: { id, status: 'ok' }, error: null })
}
```
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

