vibe-stack
CLAUDE.md8 starsChanged 8 months agoMITView on GitHub
8. NEVER expose raw error messages, stack traces, or database errors to the client. Log server-side, return { error: "Internal server error" } to the client. </security_critical> 4. NEVER use Math.random(), Date.now(), or new Date() directly in Server Components for rendering. These cause hydration mismatches. Use them in useEffect or pass from the server as props. </nextjs15_breaking_changes>
In this repository31 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .cursor/rules/ai-collaboration.mdcCursor rule
- .cursor/rules/api-design.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
Show its rules and text
We split this CLAUDE.md into the rules it gives an agent
19 rules. About 0 are common, 3 are distinctive, and 16 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
16
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Very specific: line 28
NEVER use supabase.auth.getSession() in server-side code (Server Components, Server Actions, Route Handlers, middleware).
- Very specific: line 30
NEVER import from @supabase/auth-helpers-nextjs — it is DEPRECATED.
- Very specific: line 32
NEVER put auth enforcement logic in middleware.ts.
- Distinctive: line 34
NEVER build a custom credit card form.
- Very specific: line 36
NEVER handle Stripe webhook events without calling stripe.webhooks.constructEvent() first to verify the stripe-signature header.
- Very specific: line 38
NEVER upload files directly from client code using the Supabase anon key — it allows writing to any storage path.
- Very specific: line 42
NEVER expose raw error messages, stack traces, or database errors to the client.
- Very specific: line 61
After mutations (Server Actions, Route Handlers), ALWAYS call revalidatePath() or revalidateTag().
- Very specific: line 63
Use Server Components by default.
- Very specific: line 65
NEVER use Math.random(), Date.now(), or new Date() directly in Server Components for rendering.
- Very specific: line 71
EVERY Route Handler and Server Action MUST validate input with Zod before any business logic.
- Very specific: line 83
Always use cn() from @/lib/utils for conditional Tailwind classes (wraps clsx + tailwind-merge).
- Distinctive: line 89
Import order: React/Next -> external packages -> @/ aliases -> relative imports -> types.
- Very specific: line 95
Use createClient() from @/lib/supabase/server in Server Components and Server Actions.
- Very specific: line 96
Use createClient() from @/lib/supabase/client in Client Components.
- Very specific: line 97
Always handle errors: const { data, error } = await supabase.from('table').select() — check error before using data.
- Distinctive: line 105
Before writing any code, read the relevant source files to verify current state — do not rely on memory.
- Very specific: line 106
After generating code, run npx tsc --noEmit to verify types.
- Very specific: line 107
Run npm run lint before declaring a task complete.
≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
CLAUDE.md — Vibe Stack Architecture Rules
For use with Claude Code (Anthropic's agentic CLI)
These rules prevent the most common AI hallucinations in Next.js 15 + Supabase + Stripe projects.
Project Overview
This is a Next.js 15 + Supabase + Stripe application using the App Router, TypeScript strict mode, and Tailwind CSS. All server-side auth MUST use getUser(), never getSession().
Tech Stack
- Next.js 15 (App Router only — no Pages Router)
- React 19
- TypeScript (strict mode)
- Supabase (auth, database, storage)
- Stripe (payments via Checkout Sessions)
- Tailwind CSS + shadcn/ui
- Zod (validation at every boundary)
Critical Build Commands
npm run dev # Start dev server
npm run build # Production build (catches type errors)
npm run lint # ESLint
npx tsc --noEmit # Type check without emittingSECURITY RULES — NEVER VIOLATE
<security_critical>
- NEVER use
supabase.auth.getSession()in server-side code (Server Components, Server Actions, Route Handlers, middleware). It reads the JWT from cookies WITHOUT verifying it — a forged token passes silently. ALWAYS usesupabase.auth.getUser()which makes a verification call to the Supabase auth server. - NEVER import from
@supabase/auth-helpers-nextjs— it is DEPRECATED. Always use@supabase/ssrfor bothcreateBrowserClient(client) andcreateServerClient(server). - NEVER put auth enforcement logic in
middleware.ts. Middleware runs on Edge Runtime and cannot securely verify Supabase JWTs. Middleware should ONLY callupdateSession()to refresh tokens. Auth enforcement MUST happen in layouts/pages viagetUser(). - NEVER build a custom credit card form. ALWAYS redirect to Stripe Checkout. Custom forms create PCI compliance liability.
- NEVER handle Stripe webhook events without calling
stripe.webhooks.constructEvent()first to verify thestripe-signatureheader. Without this, anyone can POST fake events to your webhook endpoint. - NEVER upload files directly from client code using the Supabase anon key — it allows writing to any storage path. ALWAYS generate signed upload URLs server-side, scoped to
user.id. - Row Level Security (RLS) MUST be enabled on EVERY Supabase table. Without RLS, the anon key (public in every client bundle) can read ALL rows from any table.
- NEVER expose raw error messages, stack traces, or database errors to the client. Log server-side, return
{ error: "Internal server error" }to the client. </security_critical>
NEXT.JS 15 RULES
<nextjs15_breaking_changes>
paramsandsearchParamsare PROMISES in Next.js 15. You MUST await them:
// CORRECT
export default async function Page({ params }: { params: Promise<{ id: string }> }) {
const { id } = await params
}
// WRONG — compiles but crashes at runtime
export default function Page({ params }: { params: { id: string } }) {
const id = params.id // TypeError at runtime
}- After mutations (Server Actions, Route Handlers), ALWAYS call
revalidatePath()orrevalidateTag(). Next.js 15 aggressively caches — stale data is the default without explicit revalidation. - Use Server Components by default. Only add
'use client'when the component genuinely needs browser APIs (useState, useEffect, onClick handlers, window/document access). - NEVER use
Math.random(),Date.now(), ornew Date()directly in Server Components for rendering. These cause hydration mismatches. Use them inuseEffector pass from the server as props. </nextjs15_breaking_changes>
API & VALIDATION RULES
<api_validation>
- EVERY Route Handler and Server Action MUST validate input with Zod before any business logic. Raw
request.json()access without validation is a crash and injection risk. - Auth check ALWAYS happens BEFORE input validation. Order: authenticate -> validate -> execute.
- Return consistent error shapes:
{ error: string, details?: unknown }. Never expose internal error messages. </api_validation>
CODE PATTERNS
<code_patterns>
- TypeScript: NEVER use
any. Useunknown+ type narrowing or Zod inference. - Always use
cn()from@/lib/utilsfor conditional Tailwind classes (wraps clsx + tailwind-merge). - Server Actions must return
ActionResponse<T>—{ success: true, data: T } | { success: false, error: string }. - File naming: kebab-case for files, PascalCase for React components, camelCase for utilities.
- Import order: React/Next -> external packages -> @/ aliases -> relative imports -> types. </code_patterns>
SUPABASE PATTERNS
<supabase>
1. Use `createClient()` from `@/lib/supabase/server` in Server Components and Server Actions.
2. Use `createClient()` from `@/lib/supabase/client` in Client Components.
3. Always handle errors: `const { data, error } = await supabase.from('table').select()` — check `error` before using `data`.
4. Enable RLS on every table. Write policies that check `auth.uid()`.
5. For email auth, implement the PKCE flow with a callback route at `app/auth/confirm/route.ts`.
</supabase>WORKFLOW
<workflow>
1. Before writing any code, read the relevant source files to verify current state — do not rely on memory.
2. After generating code, run `npx tsc --noEmit` to verify types.
3. Run `npm run lint` before declaring a task complete.
4. For complex features, break into sub-tasks and verify each step independently.
</workflow>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.

