BeforeMerge

AI-native code review knowledge base. Structured rules that catch what linters miss.

Product

  • Features
  • Explore
  • Pricing
  • Docs
  • GitHub

Company

  • About
  • Blog
  • Contributors
  • Contributing

Legal

  • Privacy Policy
  • Terms of Service
  • MIT License

© 2026 BeforeMerge. Built by Peter Krzyzek

BeforeMerge
Features
Explore
PricingBlogContributorsInstall Guide
2Sign In
FeaturesExplore
RulesSkillsKnowledgePrompts
PricingBlogContributorsInstall Guide
Sign In

Explore

Browse 225 rules, 42 knowledge articles, and 28 prompt templates across security, performance, architecture, and quality.

225 rules

Return the supabaseResponse object unchanged from middleware

HIGH

Creating a new NextResponse without copying Supabase cookies breaks session management and causes random logouts.

nextjssupabase
Next.js + Supabase Standards

Store sensitive env vars without NEXT_PUBLIC_ prefix

CRITICAL

Only the Supabase URL and anon key should have NEXT_PUBLIC_ prefix. All other Supabase credentials are server-only.

nextjssupabase
Next.js + Supabase Standards

Use three distinct Supabase client types

CRITICAL

Use createClient() for authenticated pages (RLS enforced), createAdminClient() for server-side writes (service_role), and createReadOnlyClient() for public pages (anon key).

nextjssupabase
Next.js + Supabase Standards

Call auth.getUser() immediately after creating the server client in middleware

CRITICAL

Per Supabase docs: do not run code between createServerClient and supabase.auth.getUser(). A simple mistake could cause random logouts.

nextjssupabase
Next.js + Supabase Standards

Use SWR or React Query for client-side real-time data

MEDIUM

For data that changes frequently (notifications, dashboards), use SWR or React Query instead of manual useEffect + fetch.

nextjssupabase
Next.js + Supabase Standards

Use the anon key for public-facing pages

HIGH

Public pages (explore, content detail) should use createReadOnlyClient() with the anon key, not the service_role.

nextjssupabase
Next.js + Supabase Standards

Use revalidatePath after server action mutations

HIGH

Call revalidatePath() or revalidateTag() after insert/update/delete operations to refresh cached pages.

nextjssupabase
Next.js + Supabase Standards

Never fetch the same data in both layout and page

MEDIUM

Supabase client calls are NOT automatically deduplicated like fetch(). Querying the same data in layout.tsx and page.tsx doubles database load.

nextjssupabase
Next.js + Supabase Standards

Never expose the service_role key to the client

CRITICAL

The SUPABASE_SERVICE_ROLE_KEY must never be in a NEXT_PUBLIC_ env var or imported in "use client" files.

nextjssupabase
Next.js + Supabase Standards

Parallelize independent data fetches with Promise.all

HIGH

Use Promise.all for independent Supabase queries instead of sequential await chains.

nextjssupabase
Next.js + Supabase Standards

Use (select auth.uid()) instead of auth.uid() in policies

MEDIUM

Wrapping auth.uid() in (select ...) ensures it's evaluated once per query instead of once per row.

nextjssupabase
Next.js + Supabase Standards

Use notFound() for invalid dynamic route params

MEDIUM

When a dynamic route param doesn't match any record, call notFound() from next/navigation to show the 404 page.

nextjssupabase
Next.js + Supabase Standards

Use kebab-case for file and directory names

MEDIUM

Name files and directories in kebab-case (lowercase with hyphens) to avoid cross-platform case sensitivity issues.

nextjssupabase
Next.js + Supabase Standards

Handle Supabase query errors explicitly

HIGH

Always check the error field from Supabase queries. The client returns { data, error } and never throws.

nextjssupabase
Next.js + Supabase Standards

Use server components for data fetching by default

HIGH

Fetch data in async server components instead of client-side useEffect + fetch patterns.

nextjssupabase
Next.js + Supabase Standards

Use route groups to organize app sections

HIGH

Organize routes using parenthesized layout groups like (auth), (dashboard), (content), (marketing) for separate layouts and clear separation of concerns.

nextjssupabase
Next.js + Supabase Standards

Mark server modules with import "server-only"

HIGH

Add import "server-only" to any module that uses secrets, database connections, or server-only APIs.

nextjssupabase
Next.js + Supabase Standards

Keep server actions in dedicated files

HIGH

Place server actions in separate *-actions.ts files rather than inline in page components.

nextjssupabase
Next.js + Supabase Standards

Use a lib/ directory for shared utilities

LOW

Centralize shared logic (auth, database clients, formatters) in a lib/ directory to avoid duplication.

nextjssupabase
Next.js + Supabase Standards

Organize components into atoms, molecules, organisms

MEDIUM

Use atomic design to structure components: atoms (Button, Input), molecules (SearchBar, FormField), organisms (Header, Sidebar).

nextjssupabase
Next.js + Supabase Standards

Never import server-only code in client components

CRITICAL

Files with "use client" must never import server-only modules like database clients, API keys, or service role credentials.

nextjssupabase
Next.js + Supabase Standards

Query Supabase directly in server components — skip API routes

HIGH

Server components can query Supabase directly. Don't create API route middlemen just to proxy Supabase queries.

nextjssupabase
Next.js + Supabase Standards

Colocate page files with their route segment

MEDIUM

Keep page.tsx, layout.tsx, loading.tsx, and error.tsx together in the same route segment directory.

nextjssupabase
Next.js + Supabase Standards

Type your Supabase client with generated database types

MEDIUM

Use supabase gen types typescript to generate types from your schema, then pass them as a generic: createClient<Database>().

nextjssupabase
Next.js + Supabase Standards

Automate these checks on every PR

BeforeMerge scans your pull requests against these rules automatically. Get actionable feedback before code ships to production.

Join WaitlistLearn More
Sort:
Previous12...10Next