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

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

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 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

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

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

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 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

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

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

Enable RLS on every table

CRITICAL

Every table must have Row Level Security enabled. Tables without RLS are fully accessible via the anon key.

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

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 (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

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

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 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 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

Use moddatetime triggers for updated_at columns

MEDIUM

Use database triggers to auto-update updated_at instead of setting it in application code.

nextjssupabase
Next.js + Supabase Standards

Use loading.tsx for route-level loading states

MEDIUM

Add loading.tsx to route segments with slow data fetching. It provides instant visual feedback during navigation.

nextjssupabase
Next.js + Supabase Standards

Use error.tsx for route-level error boundaries

HIGH

Every route group should have an error.tsx to prevent crashes from propagating to the entire app.

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

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

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 hardcode API keys or secrets in source code

CRITICAL

Always use environment variables for API keys, database credentials, and other secrets.

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:
Previous123...10Next