Browse 225 rules, 42 knowledge articles, and 28 prompt templates across security, performance, architecture, and quality.
225 rules
Creating a new NextResponse without copying Supabase cookies breaks session management and causes random logouts.
Only the Supabase URL and anon key should have NEXT_PUBLIC_ prefix. All other Supabase credentials are server-only.
Use createClient() for authenticated pages (RLS enforced), createAdminClient() for server-side writes (service_role), and createReadOnlyClient() for public pages (anon key).
Per Supabase docs: do not run code between createServerClient and supabase.auth.getUser(). A simple mistake could cause random logouts.
For data that changes frequently (notifications, dashboards), use SWR or React Query instead of manual useEffect + fetch.
Public pages (explore, content detail) should use createReadOnlyClient() with the anon key, not the service_role.
Call revalidatePath() or revalidateTag() after insert/update/delete operations to refresh cached pages.
Supabase client calls are NOT automatically deduplicated like fetch(). Querying the same data in layout.tsx and page.tsx doubles database load.
The SUPABASE_SERVICE_ROLE_KEY must never be in a NEXT_PUBLIC_ env var or imported in "use client" files.
Use Promise.all for independent Supabase queries instead of sequential await chains.
Wrapping auth.uid() in (select ...) ensures it's evaluated once per query instead of once per row.
When a dynamic route param doesn't match any record, call notFound() from next/navigation to show the 404 page.
Name files and directories in kebab-case (lowercase with hyphens) to avoid cross-platform case sensitivity issues.
Always check the error field from Supabase queries. The client returns { data, error } and never throws.
Fetch data in async server components instead of client-side useEffect + fetch patterns.
Organize routes using parenthesized layout groups like (auth), (dashboard), (content), (marketing) for separate layouts and clear separation of concerns.
Add import "server-only" to any module that uses secrets, database connections, or server-only APIs.
Place server actions in separate *-actions.ts files rather than inline in page components.
Centralize shared logic (auth, database clients, formatters) in a lib/ directory to avoid duplication.
Use atomic design to structure components: atoms (Button, Input), molecules (SearchBar, FormField), organisms (Header, Sidebar).
Files with "use client" must never import server-only modules like database clients, API keys, or service role credentials.
Server components can query Supabase directly. Don't create API route middlemen just to proxy Supabase queries.
Keep page.tsx, layout.tsx, loading.tsx, and error.tsx together in the same route segment directory.
Use supabase gen types typescript to generate types from your schema, then pass them as a generic: createClient<Database>().
BeforeMerge scans your pull requests against these rules automatically. Get actionable feedback before code ships to production.