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
3Sign In
FeaturesExplore
RulesSkillsKnowledgePrompts
PricingBlogContributorsInstall Guide
Sign In

Explore

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

Sort:
Previous1...678...15Next

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

354 rules

Never use any — use unknown for truly unknown types

HIGH

The any type disables all type checking. Use unknown and narrow the type, or use a specific type.

QualitynextjssupabaseNext.js + Supabase Standards

Never use the admin client for reads in server actions

HIGH

createAdminClient() bypasses RLS. Use it only for writes that need service_role privileges. For reads, use createClient().

Securitynextjssupabase

Validate all server action inputs at the boundary

HIGH

Server actions are public HTTP endpoints. Validate all inputs with Zod or similar before any database operation.

Securitynextjssupabase

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.

Securitynextjssupabase

Scope all mutations to the authenticated organization

CRITICAL

Every insert/update/delete must include organization_id from requireAuth(). RLS is defense-in-depth, not the only defense.

Securitynextjssupabase

Use next/image for all images

HIGH

Use the Image component from next/image instead of raw HTML img tags. It auto-optimizes format, size, and loading.

Performancenextjssupabase

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.

Securitynextjssupabase

Use requireAuth() as the first call in every authenticated server action

HIGH

Every server action that modifies data must call requireAuth() first to validate the user session and get orgId.

Securitynextjssupabase

Organize components into atoms, molecules, organisms

MEDIUM

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

Qualitynextjssupabase

Use a lib/ directory for shared utilities

LOW

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

Architecturenextjs

Return the supabaseResponse object unchanged from middleware

HIGH

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

Qualitynextjssupabase

Never hardcode API keys or secrets in source code

CRITICAL

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

Securitynextjssupabase

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.

Securitynextjssupabase

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.

Performancenextjssupabase

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.

Qualitynextjssupabase

Keep server actions in dedicated files

HIGH

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

Architecturenextjssupabase

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.

Qualitynextjssupabase

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

Securitynextjssupabase

Test RLS policies explicitly

HIGH

Write tests that verify: User A cannot read User B's data. Anon users cannot read private data. RLS bugs are data breaches.

Securitynextjssupabase

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.

Architecturenextjs

Use revalidatePath after server action mutations

HIGH

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

Qualitynextjssupabase

Handle Supabase query errors explicitly

HIGH

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

Qualitynextjssupabase

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.

Performancenextjssupabase

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.

Architecturenextjs
Next.js + Supabase Standards
Next.js + Supabase Standards
Next.js + Supabase Standards
Next.js + Supabase Standards
Next.js + Supabase Standards
Next.js + Supabase Standards
Next.js + Supabase Standards
Next.js + Supabase Standards
supabase
Next.js + Supabase Standards
Next.js + Supabase Standards
Next.js + Supabase Standards
Next.js + Supabase Standards
Next.js + Supabase Standards
Next.js + Supabase Standards
Next.js + Supabase Standards
Next.js + Supabase Standards
Next.js + Supabase Standards
Next.js + Supabase Standards
supabase
Next.js + Supabase Standards
Next.js + Supabase Standards
Next.js + Supabase Standards
Next.js + Supabase Standards
supabase
Next.js + Supabase Standards